more events
This commit is contained in:
parent
5a33d4c7f2
commit
47fecbd81e
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -42,6 +42,14 @@ namespace StardewModdingAPI
|
||||||
public delegate void FarmerChangedD(Farmer newFarmer);
|
public delegate void FarmerChangedD(Farmer newFarmer);
|
||||||
public static event FarmerChangedD FarmerChanged = delegate { };
|
public static event FarmerChangedD FarmerChanged = delegate { };
|
||||||
|
|
||||||
|
public delegate void IntChanged(Int32 newInt);
|
||||||
|
public static event IntChanged TimeOfDayChanged = delegate { };
|
||||||
|
public static event IntChanged DayOfMonthChanged = delegate { };
|
||||||
|
public static event IntChanged YearOfGameChanged = delegate { };
|
||||||
|
|
||||||
|
public delegate void StringChanged(String newString);
|
||||||
|
public static event StringChanged SeasonOfYearChanged = delegate { };
|
||||||
|
|
||||||
public static void InvokeGameLoaded()
|
public static void InvokeGameLoaded()
|
||||||
{
|
{
|
||||||
GameLoaded.Invoke();
|
GameLoaded.Invoke();
|
||||||
|
@ -134,5 +142,25 @@ namespace StardewModdingAPI
|
||||||
{
|
{
|
||||||
FarmerChanged.Invoke(newFarmer);
|
FarmerChanged.Invoke(newFarmer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void InvokeTimeOfDayChanged(Int32 newInt)
|
||||||
|
{
|
||||||
|
TimeOfDayChanged.Invoke(newInt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void InvokeDayOfMonthChanged(Int32 newInt)
|
||||||
|
{
|
||||||
|
DayOfMonthChanged.Invoke(newInt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void InvokeYearOfGameChanged(Int32 newInt)
|
||||||
|
{
|
||||||
|
YearOfGameChanged.Invoke(newInt);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void InvokeSeasonOfYearChanged(String newString)
|
||||||
|
{
|
||||||
|
SeasonOfYearChanged.Invoke(newString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,12 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Runtime.Serialization.Formatters.Binary;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
using StardewValley.Menus;
|
using StardewValley.Menus;
|
||||||
using StardewValley.Minigames;
|
|
||||||
|
|
||||||
namespace StardewModdingAPI.Inheritance
|
namespace StardewModdingAPI.Inheritance
|
||||||
{
|
{
|
||||||
|
@ -49,6 +42,11 @@ namespace StardewModdingAPI.Inheritance
|
||||||
public GameLocation PreviousGameLocation { get; private set; }
|
public GameLocation PreviousGameLocation { get; private set; }
|
||||||
public IClickableMenu PreviousActiveMenu { get; private set; }
|
public IClickableMenu PreviousActiveMenu { get; private set; }
|
||||||
|
|
||||||
|
public Int32 PreviousTimeOfDay { get; private set; }
|
||||||
|
public Int32 PreviousDayOfMonth { get; private set; }
|
||||||
|
public String PreviousSeasonOfYear { get; private set; }
|
||||||
|
public Int32 PreviousYearOfGame { get; private set; }
|
||||||
|
|
||||||
public Farmer PreviousFarmer { get; private set; }
|
public Farmer PreviousFarmer { get; private set; }
|
||||||
|
|
||||||
protected override void Initialize()
|
protected override void Initialize()
|
||||||
|
@ -69,53 +67,18 @@ namespace StardewModdingAPI.Inheritance
|
||||||
|
|
||||||
protected override void Update(GameTime gameTime)
|
protected override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
KStateNow = Keyboard.GetState();
|
UpdateEventCalls();
|
||||||
CurrentlyPressedKeys = KStateNow.GetPressedKeys();
|
|
||||||
MStateNow = Mouse.GetState();
|
|
||||||
|
|
||||||
foreach (Keys k in FramePressedKeys)
|
try
|
||||||
Events.InvokeKeyPressed(k);
|
|
||||||
|
|
||||||
if (KStateNow != KStatePrior)
|
|
||||||
{
|
{
|
||||||
Events.InvokeKeyboardChanged(KStateNow);
|
base.Update(gameTime);
|
||||||
KStatePrior = KStateNow;
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Program.LogError("An error occured in the base update loop: " + ex);
|
||||||
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MStateNow != MStatePrior)
|
|
||||||
{
|
|
||||||
Events.InvokeMouseChanged(MStateNow);
|
|
||||||
MStatePrior = MStateNow;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Game1.activeClickableMenu != null && Game1.activeClickableMenu != PreviousActiveMenu)
|
|
||||||
{
|
|
||||||
Events.InvokeMenuChanged(Game1.activeClickableMenu);
|
|
||||||
PreviousActiveMenu = Game1.activeClickableMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Game1.locations.GetHash() != PreviousGameLocations)
|
|
||||||
{
|
|
||||||
Events.InvokeLocationsChanged(Game1.locations);
|
|
||||||
PreviousGameLocations = Game1.locations.GetHash();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Game1.currentLocation != PreviousGameLocation)
|
|
||||||
{
|
|
||||||
Events.InvokeCurrentLocationChanged(Game1.currentLocation);
|
|
||||||
PreviousGameLocation = Game1.currentLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Game1.player != null && Game1.player != PreviousFarmer)
|
|
||||||
{
|
|
||||||
Events.InvokeFarmerChanged(Game1.player);
|
|
||||||
PreviousFarmer = Game1.player;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CurrentLocation != null)
|
|
||||||
CurrentLocation.update(gameTime);
|
|
||||||
|
|
||||||
base.Update(gameTime);
|
|
||||||
Events.InvokeUpdateTick();
|
Events.InvokeUpdateTick();
|
||||||
|
|
||||||
PreviouslyPressedKeys = CurrentlyPressedKeys;
|
PreviouslyPressedKeys = CurrentlyPressedKeys;
|
||||||
|
@ -126,15 +89,15 @@ namespace StardewModdingAPI.Inheritance
|
||||||
base.Draw(gameTime);
|
base.Draw(gameTime);
|
||||||
Events.InvokeDrawTick();
|
Events.InvokeDrawTick();
|
||||||
|
|
||||||
if (Program.debug)
|
if (false)
|
||||||
{
|
{
|
||||||
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
|
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
|
||||||
|
|
||||||
if (CurrentLocation != null)
|
if (CurrentLocation != null)
|
||||||
CurrentLocation.draw(Game1.spriteBatch);
|
CurrentLocation.draw(spriteBatch);
|
||||||
|
|
||||||
if (player != null && player.position != null)
|
if (player != null && player.position != null)
|
||||||
spriteBatch.DrawString(Game1.dialogueFont, Game1.player.position.ToString(), new Vector2(0, 180), Color.Orange);
|
spriteBatch.DrawString(dialogueFont, player.position.ToString(), new Vector2(0, 180), Color.Orange);
|
||||||
|
|
||||||
spriteBatch.End();
|
spriteBatch.End();
|
||||||
}
|
}
|
||||||
|
@ -164,24 +127,15 @@ namespace StardewModdingAPI.Inheritance
|
||||||
{
|
{
|
||||||
return ModItems.ElementAt(id).Value.Clone();
|
return ModItems.ElementAt(id).Value.Clone();
|
||||||
}
|
}
|
||||||
else
|
Program.LogError("ModItem Dictionary does not contain index: " + id);
|
||||||
{
|
return null;
|
||||||
Program.LogError("ModItem Dictionary does not contain index: " + id);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
if (ModItems.ContainsKey(id))
|
||||||
{
|
{
|
||||||
if (ModItems.ContainsKey(id))
|
return ModItems[id].Clone();
|
||||||
{
|
|
||||||
return ModItems[id].Clone();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Program.LogError("ModItem Dictionary does not contain ID: " + id);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Program.LogError("ModItem Dictionary does not contain ID: " + id);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SGameLocation GetLocationFromName(String name)
|
public static SGameLocation GetLocationFromName(String name)
|
||||||
|
@ -197,30 +151,95 @@ namespace StardewModdingAPI.Inheritance
|
||||||
{
|
{
|
||||||
if (GetLocationFromName(name) != null)
|
if (GetLocationFromName(name) != null)
|
||||||
return GetLocationFromName(name);
|
return GetLocationFromName(name);
|
||||||
else
|
GameLocation gl = locations.FirstOrDefault(x => x.name == name);
|
||||||
|
if (gl != null)
|
||||||
{
|
{
|
||||||
GameLocation gl = Game1.locations.FirstOrDefault(x => x.name == name);
|
Program.LogDebug("A custom location was created for the new name: " + name);
|
||||||
if (gl != null)
|
SGameLocation s = SGameLocation.ConstructFromBaseClass(gl);
|
||||||
{
|
ModLocations.Add(s);
|
||||||
Program.LogDebug("A custom location was created for the new name: " + name);
|
return s;
|
||||||
SGameLocation s = SGameLocation.ConstructFromBaseClass(gl);
|
}
|
||||||
ModLocations.Add(s);
|
if (currentLocation != null && currentLocation.name == name)
|
||||||
return s;
|
{
|
||||||
}
|
gl = currentLocation;
|
||||||
else
|
Program.LogDebug("A custom location was created from the current location for the new name: " + name);
|
||||||
{
|
SGameLocation s = SGameLocation.ConstructFromBaseClass(gl);
|
||||||
if (Game1.currentLocation != null && Game1.currentLocation.name == name)
|
ModLocations.Add(s);
|
||||||
{
|
return s;
|
||||||
gl = Game1.currentLocation;
|
}
|
||||||
Program.LogDebug("A custom location was created from the current location for the new name: " + name);
|
|
||||||
SGameLocation s = SGameLocation.ConstructFromBaseClass(gl);
|
|
||||||
ModLocations.Add(s);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
Program.LogDebug("A custom location could not be created for: " + name);
|
Program.LogDebug("A custom location could not be created for: " + name);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void UpdateEventCalls()
|
||||||
|
{
|
||||||
|
KStateNow = Keyboard.GetState();
|
||||||
|
CurrentlyPressedKeys = KStateNow.GetPressedKeys();
|
||||||
|
MStateNow = Mouse.GetState();
|
||||||
|
|
||||||
|
foreach (Keys k in FramePressedKeys)
|
||||||
|
Events.InvokeKeyPressed(k);
|
||||||
|
|
||||||
|
if (KStateNow != KStatePrior)
|
||||||
|
{
|
||||||
|
Events.InvokeKeyboardChanged(KStateNow);
|
||||||
|
KStatePrior = KStateNow;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MStateNow != MStatePrior)
|
||||||
|
{
|
||||||
|
Events.InvokeMouseChanged(MStateNow);
|
||||||
|
MStatePrior = MStateNow;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (activeClickableMenu != null && activeClickableMenu != PreviousActiveMenu)
|
||||||
|
{
|
||||||
|
Events.InvokeMenuChanged(activeClickableMenu);
|
||||||
|
PreviousActiveMenu = activeClickableMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (locations.GetHash() != PreviousGameLocations)
|
||||||
|
{
|
||||||
|
Events.InvokeLocationsChanged(locations);
|
||||||
|
PreviousGameLocations = locations.GetHash();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentLocation != PreviousGameLocation)
|
||||||
|
{
|
||||||
|
Events.InvokeCurrentLocationChanged(currentLocation);
|
||||||
|
PreviousGameLocation = currentLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player != null && player != PreviousFarmer)
|
||||||
|
{
|
||||||
|
Events.InvokeFarmerChanged(player);
|
||||||
|
PreviousFarmer = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timeOfDay != PreviousTimeOfDay)
|
||||||
|
{
|
||||||
|
Events.InvokeTimeOfDayChanged(timeOfDay);
|
||||||
|
PreviousTimeOfDay = timeOfDay;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dayOfMonth != PreviousDayOfMonth)
|
||||||
|
{
|
||||||
|
Events.InvokeDayOfMonthChanged(dayOfMonth);
|
||||||
|
PreviousDayOfMonth = dayOfMonth;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentSeason != PreviousSeasonOfYear)
|
||||||
|
{
|
||||||
|
Events.InvokeSeasonOfYearChanged(currentSeason);
|
||||||
|
PreviousSeasonOfYear = currentSeason;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (year != PreviousYearOfGame)
|
||||||
|
{
|
||||||
|
Events.InvokeYearOfGameChanged(year);
|
||||||
|
PreviousYearOfGame = year;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ using StardewValley.BellsAndWhistles;
|
||||||
|
|
||||||
namespace StardewModdingAPI.Inheritance
|
namespace StardewModdingAPI.Inheritance
|
||||||
{
|
{
|
||||||
|
[Obsolete]
|
||||||
public class SGameLocation : GameLocation
|
public class SGameLocation : GameLocation
|
||||||
{
|
{
|
||||||
public GameLocation BaseGameLocation { get; private set; }
|
public GameLocation BaseGameLocation { get; private set; }
|
||||||
|
|
|
@ -12,7 +12,10 @@ namespace StardewModdingAPI.Inheritance
|
||||||
{
|
{
|
||||||
public class SObject : StardewValley.Object
|
public class SObject : StardewValley.Object
|
||||||
{
|
{
|
||||||
public override String Name { get; set; }
|
public override String Name {
|
||||||
|
get { return name; }
|
||||||
|
set { name = value; }
|
||||||
|
}
|
||||||
public String Description { get; set; }
|
public String Description { get; set; }
|
||||||
public Texture2D Texture { get; set; }
|
public Texture2D Texture { get; set; }
|
||||||
public String CategoryName { get; set; }
|
public String CategoryName { get; set; }
|
||||||
|
@ -29,9 +32,18 @@ namespace StardewModdingAPI.Inheritance
|
||||||
|
|
||||||
public Boolean FlaggedForPickup { get; set; }
|
public Boolean FlaggedForPickup { get; set; }
|
||||||
|
|
||||||
|
public Vector2 CurrentMouse { get; protected set; }
|
||||||
|
public Vector2 PlacedAt { get; protected set; }
|
||||||
|
|
||||||
|
public override int Stack
|
||||||
|
{
|
||||||
|
get { return stack; }
|
||||||
|
set { stack = value; }
|
||||||
|
}
|
||||||
|
|
||||||
public SObject()
|
public SObject()
|
||||||
{
|
{
|
||||||
Name = "Modded Item Name";
|
name = "Modded Item Name";
|
||||||
Description = "Modded Item Description";
|
Description = "Modded Item Description";
|
||||||
CategoryName = "Modded Item Category";
|
CategoryName = "Modded Item Category";
|
||||||
Category = 4163;
|
Category = 4163;
|
||||||
|
@ -39,6 +51,9 @@ namespace StardewModdingAPI.Inheritance
|
||||||
IsPassable = false;
|
IsPassable = false;
|
||||||
IsPlaceable = false;
|
IsPlaceable = false;
|
||||||
boundingBox = new Rectangle(0, 0, 64, 64);
|
boundingBox = new Rectangle(0, 0, 64, 64);
|
||||||
|
MaxStackSize = 999;
|
||||||
|
|
||||||
|
type = "interactive";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string getDescription()
|
public override string getDescription()
|
||||||
|
@ -49,22 +64,20 @@ namespace StardewModdingAPI.Inheritance
|
||||||
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1)
|
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1)
|
||||||
{
|
{
|
||||||
if (Texture != null)
|
if (Texture != null)
|
||||||
{
|
{
|
||||||
int targSize = Game1.tileSize;
|
int targSize = Game1.tileSize;
|
||||||
int midX = (int) ((x) + 32);
|
int midX = (int) ((x) + 32);
|
||||||
int midY = (int) ((y) + 32);
|
int midY = (int) ((y) + 32);
|
||||||
|
|
||||||
int targX = midX - targSize / 2;
|
Vector2 local = Game1.GlobalToLocal(Game1.viewport, new Vector2(x,y));
|
||||||
int targY = midY - targSize / 2;
|
Rectangle targ = new Rectangle((int)local.X, (int)local.Y, targSize, targSize);
|
||||||
|
spriteBatch.Draw(Texture, targ, null, new Color(255, 255, 255, 255f * alpha));
|
||||||
Rectangle targ = new Rectangle(targX, targY, targSize, targSize);
|
}
|
||||||
spriteBatch.Draw(Texture, targ, null, new Color(255, 255, 255, 255f * alpha), 0, Vector2.Zero, SpriteEffects.None, 0.999f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1)
|
public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1)
|
||||||
{
|
{
|
||||||
Program.LogInfo("DRAW ME2");
|
Program.LogInfo("THIS DRAW FUNCTION IS NOT IMPLEMENTED I WANT TO KNOW WHERE IT IS CALLED");
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -191,39 +204,51 @@ namespace StardewModdingAPI.Inheritance
|
||||||
return this.Clone();
|
return this.Clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void actionWhenBeingHeld(Farmer who)
|
||||||
|
{
|
||||||
|
Point p = Game1.getMousePosition();
|
||||||
|
CurrentMouse = new Vector2(p.X, p.Y);
|
||||||
|
base.actionWhenBeingHeld(who);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool canBePlacedHere(GameLocation l, Vector2 tile)
|
||||||
|
{
|
||||||
|
if (!l.objects.ContainsKey(tile))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null)
|
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null)
|
||||||
{
|
{
|
||||||
|
x = (x / Game1.tileSize) * Game1.tileSize;
|
||||||
|
y = (y / Game1.tileSize) * Game1.tileSize;
|
||||||
|
|
||||||
Vector2 key = new Vector2(x, y);
|
Vector2 key = new Vector2(x, y);
|
||||||
if (!location.objects.ContainsKey(key))
|
|
||||||
location.objects.Add(key, this);
|
|
||||||
return false;
|
|
||||||
|
|
||||||
SGameLocation s = SGame.GetLocationFromName(location.name);
|
if (!canBePlacedHere(location, key))
|
||||||
|
|
||||||
if (s.GetHashCode() != SGame.CurrentLocation.GetHashCode())
|
|
||||||
{
|
|
||||||
Program.LogError("HASH DIFFERENCE: " + s.GetHashCode() + " | " + SGame.ModLocations[SGame.ModLocations.IndexOf(SGame.ModLocations.First(z => z.name == location.name))].GetHashCode() + " | " + SGame.CurrentLocation.GetHashCode());
|
|
||||||
Console.ReadKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.Title = (this.GetHashCode() + " PLACEMENT");
|
|
||||||
|
|
||||||
if (s != null)
|
|
||||||
{
|
|
||||||
Vector2 index1 = new Vector2(x - (Game1.tileSize / 2), y - (Game1.tileSize / 2));
|
|
||||||
if (!s.ModObjects.ContainsKey(index1))
|
|
||||||
{
|
|
||||||
s.ModObjects.Add(index1, this);
|
|
||||||
Game1.player.position = index1;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Program.LogError("No SGameLocation could be found for the supplied GameLocation!");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
return false;
|
SObject s = Clone();
|
||||||
|
|
||||||
|
s.PlacedAt = key;
|
||||||
|
s.boundingBox = new Rectangle(x / Game1.tileSize * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height);
|
||||||
|
|
||||||
|
location.objects.Add(key, s);
|
||||||
|
Program.LogInfo("{0} - {1}", this.GetHashCode(), s.GetHashCode());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void actionOnPlayerEntry()
|
||||||
|
{
|
||||||
|
//base.actionOnPlayerEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location)
|
||||||
|
{
|
||||||
|
if (canBePlacedHere(location, CurrentMouse))
|
||||||
|
base.drawPlacementBounds(spriteBatch, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -49,12 +49,14 @@ namespace StardewModdingAPI
|
||||||
public static Thread gameThread;
|
public static Thread gameThread;
|
||||||
public static Thread consoleInputThread;
|
public static Thread consoleInputThread;
|
||||||
|
|
||||||
public const string Version = "0.34 Alpha";
|
public const string Version = "0.35 Alpha";
|
||||||
public const bool debug = false;
|
public const bool debug = false;
|
||||||
public static bool disableLogging { get; private set; }
|
public static bool disableLogging { get; private set; }
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Console.Title = "Stardew Modding API Console";
|
Console.Title = "Stardew Modding API Console";
|
||||||
|
@ -63,8 +65,6 @@ namespace StardewModdingAPI
|
||||||
if (debug)
|
if (debug)
|
||||||
Console.Title += " - DEBUG IS NOT FALSE, AUTHOUR FORGOT TO INCREMENT VERSION VARS";
|
Console.Title += " - DEBUG IS NOT FALSE, AUTHOUR FORGOT TO INCREMENT VERSION VARS";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//TODO: Have an app.config and put the paths inside it so users can define locations to load mods from
|
//TODO: Have an app.config and put the paths inside it so users can define locations to load mods from
|
||||||
ExecutionPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
ExecutionPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||||
ModPaths.Add(Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley")), "Mods"));
|
ModPaths.Add(Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley")), "Mods"));
|
||||||
|
@ -178,8 +178,8 @@ namespace StardewModdingAPI
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
//Experimental
|
//Experimental
|
||||||
Events.LocationsChanged += Events_LocationsChanged;
|
//Events.LocationsChanged += Events_LocationsChanged;
|
||||||
Events.CurrentLocationChanged += Events_CurrentLocationChanged;
|
//Events.CurrentLocationChanged += Events_CurrentLocationChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Do tweaks using winforms invoke because I'm lazy
|
//Do tweaks using winforms invoke because I'm lazy
|
||||||
|
@ -349,6 +349,9 @@ namespace StardewModdingAPI
|
||||||
so2.IsPlaceable = true;
|
so2.IsPlaceable = true;
|
||||||
LogColour(ConsoleColor.Cyan, "REGISTERED WITH ID OF: " + SGame.RegisterModItem(so2));
|
LogColour(ConsoleColor.Cyan, "REGISTERED WITH ID OF: " + SGame.RegisterModItem(so2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
Command.CallCommand("load");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Events_KeyPressed(Keys key)
|
static void Events_KeyPressed(Keys key)
|
||||||
|
@ -404,10 +407,6 @@ namespace StardewModdingAPI
|
||||||
File.WriteAllText(Program.LogPath + "\\MODDED_ErrorLog_" + Extensions.Random.Next(100000000, 999999999) + ".txt", e.Exception.ToString());
|
File.WriteAllText(Program.LogPath + "\\MODDED_ErrorLog_" + Extensions.Random.Next(100000000, 999999999) + ".txt", e.Exception.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void help_CommandFired(Command cmd)
|
static void help_CommandFired(Command cmd)
|
||||||
{
|
{
|
||||||
if (cmd.CalledArgs.Length > 0)
|
if (cmd.CalledArgs.Length > 0)
|
||||||
|
@ -427,11 +426,6 @@ namespace StardewModdingAPI
|
||||||
LogInfo("Commands: " + Command.RegisteredCommands.Select(x => x.CommandName).ToSingular());
|
LogInfo("Commands: " + Command.RegisteredCommands.Select(x => x.CommandName).ToSingular());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region Logging
|
#region Logging
|
||||||
|
|
||||||
public static void Log(object o, params object[] format)
|
public static void Log(object o, params object[] format)
|
||||||
|
|
|
@ -46,6 +46,9 @@ namespace TrainerMod
|
||||||
|
|
||||||
static void Events_UpdateTick()
|
static void Events_UpdateTick()
|
||||||
{
|
{
|
||||||
|
if (Game1.player == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (infHealth)
|
if (infHealth)
|
||||||
{
|
{
|
||||||
Game1.player.health = Game1.player.maxHealth;
|
Game1.player.health = Game1.player.maxHealth;
|
||||||
|
@ -756,6 +759,8 @@ namespace TrainerMod
|
||||||
|
|
||||||
static void RegisterNewItem(Command cmd)
|
static void RegisterNewItem(Command cmd)
|
||||||
{
|
{
|
||||||
|
if (!Program.debug)
|
||||||
|
return;
|
||||||
SObject s = SGame.PullModItemFromDict(0, true);
|
SObject s = SGame.PullModItemFromDict(0, true);
|
||||||
s.Stack = 999;
|
s.Stack = 999;
|
||||||
Game1.player.addItemToInventory(s);
|
Game1.player.addItemToInventory(s);
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue