From 12bf4fd843be26f89b5fe3415aeec3055c54d786 Mon Sep 17 00:00:00 2001 From: Zoryn Aaron Date: Sun, 27 Mar 2016 01:09:09 -0400 Subject: someone needs to generate xml doc info im not fuck that shit --- StardewModdingAPI/App.config | 17 +- StardewModdingAPI/Command.cs | 63 +-- StardewModdingAPI/Config.cs | 55 +-- StardewModdingAPI/Constants.cs | 35 +- StardewModdingAPI/Entities/SCharacter.cs | 4 +- StardewModdingAPI/Entities/SFarm.cs | 4 +- StardewModdingAPI/Entities/SFarmAnimal.cs | 4 +- StardewModdingAPI/Entities/SNpc.cs | 4 +- StardewModdingAPI/Entities/SPlayer.cs | 50 +- StardewModdingAPI/Events/Controls.cs | 2 +- StardewModdingAPI/Events/EventArgs.cs | 47 +- StardewModdingAPI/Events/Game.cs | 29 +- StardewModdingAPI/Events/Graphics.cs | 4 +- StardewModdingAPI/Events/Location.cs | 4 +- StardewModdingAPI/Events/Menu.cs | 2 +- StardewModdingAPI/Events/Mine.cs | 2 +- StardewModdingAPI/Events/Player.cs | 2 +- StardewModdingAPI/Events/Time.cs | 10 +- StardewModdingAPI/Extensions.cs | 28 +- StardewModdingAPI/Inheritance/ItemStackChange.cs | 2 +- StardewModdingAPI/Inheritance/Menus/SBobberBar.cs | 29 +- StardewModdingAPI/Inheritance/Menus/SGameMenu.cs | 14 +- .../Inheritance/Menus/SInventoryPage.cs | 12 +- .../Inheritance/Minigames/SMinigameBase.cs | 4 +- StardewModdingAPI/Inheritance/SBareObject.cs | 11 +- StardewModdingAPI/Inheritance/SGame.cs | 397 +++++++++++---- StardewModdingAPI/Inheritance/SObject.cs | 538 +++++++++++---------- StardewModdingAPI/JsonResolver.cs | 61 ++- StardewModdingAPI/Logger.cs | 86 ++-- StardewModdingAPI/Manifest.cs | 16 +- StardewModdingAPI/Mod.cs | 24 +- StardewModdingAPI/ModItem.cs | 10 +- StardewModdingAPI/Program.cs | 149 +++--- StardewModdingAPI/Properties/AssemblyInfo.cs | 6 +- StardewModdingAPI/Version.cs | 9 +- StardewModdingAPI/packages.config | 1 + TrainerMod/FodyWeavers.xml | 3 +- TrainerMod/Properties/AssemblyInfo.cs | 7 +- TrainerMod/TrainerMod.cs | 251 +++++----- TrainerMod/packages.config | 1 + 40 files changed, 1095 insertions(+), 902 deletions(-) diff --git a/StardewModdingAPI/App.config b/StardewModdingAPI/App.config index 697c237b..dc6eaae3 100644 --- a/StardewModdingAPI/App.config +++ b/StardewModdingAPI/App.config @@ -1,9 +1,10 @@ - + + - - - - - - - + + + + + + + \ No newline at end of file diff --git a/StardewModdingAPI/Command.cs b/StardewModdingAPI/Command.cs index 7cf2b67b..8bc2c0c3 100644 --- a/StardewModdingAPI/Command.cs +++ b/StardewModdingAPI/Command.cs @@ -7,27 +7,43 @@ namespace StardewModdingAPI public class Command { internal static List RegisteredCommands = new List(); + public string[] CalledArgs; + public string[] CommandArgs; + public string CommandDesc; + + public string CommandName; + + /// + /// Creates a Command from a Name, Description, and Arguments + /// + /// Name + /// Description + /// Arguments + public Command(string cname, string cdesc, string[] args = null) + { + CommandName = cname; + CommandDesc = cdesc; + if (args == null) + args = new string[0]; + CommandArgs = args; + } - public String CommandName; - public String CommandDesc; - public String[] CommandArgs; - public String[] CalledArgs; public event EventHandler CommandFired; /// - /// Calls the specified command. (It runs the command) + /// Calls the specified command. (It runs the command) /// /// The command to run public static void CallCommand(string input) { input = input.TrimEnd(' '); - string[] args = new string[0]; + var args = new string[0]; Command fnd; if (input.Contains(" ")) { args = input.Split(new[] {" "}, 2, StringSplitOptions.RemoveEmptyEntries); fnd = FindCommand(args[0]); - args = args[1].Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries); + args = args[1].Split(new[] {" "}, StringSplitOptions.RemoveEmptyEntries); } else { @@ -41,12 +57,12 @@ namespace StardewModdingAPI } else { - Log.Error("Unknown Command"); + Log.AsyncR("Unknown Command"); } } /// - /// Registers a command to the list of commands properly + /// Registers a command to the list of commands properly /// /// Name of the command to register /// Description @@ -54,21 +70,21 @@ namespace StardewModdingAPI /// public static Command RegisterCommand(string command, string cdesc, string[] args = null) { - Command c = new Command(command, cdesc, args); + var c = new Command(command, cdesc, args); if (RegisteredCommands.Contains(c)) { - Log.Error("Command already registered! [{0}]", c.CommandName); + Log.AsyncR($"Command already registered! [{c.CommandName}]"); return RegisteredCommands.Find(x => x.Equals(c)); } RegisteredCommands.Add(c); - Log.Verbose("Registered command: " + command); + Log.AsyncY("Registered command: " + command); return c; } /// - /// Looks up a command in the list of registered commands. Returns null if it doesn't exist (I think) + /// Looks up a command in the list of registered commands. Returns null if it doesn't exist (I think) /// /// Name of command to find /// @@ -78,31 +94,16 @@ namespace StardewModdingAPI } /// - /// Creates a Command from a Name, Description, and Arguments - /// - /// Name - /// Description - /// Arguments - public Command(String cname, String cdesc, String[] args = null) - { - CommandName = cname; - CommandDesc = cdesc; - if (args == null) - args = new string[0]; - CommandArgs = args; - } - - /// - /// Runs a command. Fires it. Calls it. Any of those. + /// Runs a command. Fires it. Calls it. Any of those. /// public void Fire() { if (CommandFired == null) { - Log.Error("Command failed to fire because it's fire event is null: " + CommandName); + Log.AsyncR("Command failed to fire because it's fire event is null: " + CommandName); return; } CommandFired.Invoke(this, new EventArgsCommand(this)); } } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Config.cs b/StardewModdingAPI/Config.cs index d5517535..035d28d7 100644 --- a/StardewModdingAPI/Config.cs +++ b/StardewModdingAPI/Config.cs @@ -5,7 +5,6 @@ using System; using System.IO; using System.Linq; -using System.Reflection; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -22,15 +21,7 @@ namespace StardewModdingAPI public virtual Config Instance() where T : Config => Activator.CreateInstance(); /// - /// Should never be used for anything. - /// - public Config() - { - - } - - /// - /// Loads the config from the json blob on disk, updating and re-writing to the disk if needed. + /// Loads the config from the json blob on disk, updating and re-writing to the disk if needed. /// /// /// @@ -38,7 +29,7 @@ namespace StardewModdingAPI { if (string.IsNullOrEmpty(ConfigLocation)) { - Log.Error("A config tried to load without specifying a location on the disk."); + Log.AsyncR("A config tried to load without specifying a location on the disk."); return null; } @@ -47,7 +38,7 @@ namespace StardewModdingAPI if (!File.Exists(ConfigLocation)) { //no config exists, generate default values - var c = this.GenerateDefaultConfig(); + var c = GenerateDefaultConfig(); c.ConfigLocation = ConfigLocation; ret = c; } @@ -56,7 +47,7 @@ namespace StardewModdingAPI try { //try to load the config from a json blob on disk - T c = JsonConvert.DeserializeObject(File.ReadAllText(ConfigLocation), new JsonSerializerSettings() {ContractResolver = new JsonResolver()}); + var c = JsonConvert.DeserializeObject(File.ReadAllText(ConfigLocation), new JsonSerializerSettings {ContractResolver = new JsonResolver()}); c.ConfigLocation = ConfigLocation; @@ -67,7 +58,7 @@ namespace StardewModdingAPI } catch (Exception ex) { - Log.Error("Invalid JSON ({0}): {1} \n{2}", GetType().Name, ConfigLocation, ex); + Log.AsyncR($"Invalid JSON ({GetType().Name}): {ConfigLocation} \n{ex}"); return GenerateDefaultConfig(); } } @@ -77,7 +68,7 @@ namespace StardewModdingAPI } /// - /// MUST be implemented in inheriting class! + /// MUST be implemented in inheriting class! /// public virtual T GenerateDefaultConfig() where T : Config { @@ -85,7 +76,7 @@ namespace StardewModdingAPI } /// - /// Merges a default-value config with the user-config on disk. + /// Merges a default-value config with the user-config on disk. /// /// /// @@ -94,16 +85,16 @@ namespace StardewModdingAPI try { //default config - var b = JObject.FromObject(Instance().GenerateDefaultConfig(), new JsonSerializer() {ContractResolver = new JsonResolver()}); + var b = JObject.FromObject(Instance().GenerateDefaultConfig(), new JsonSerializer {ContractResolver = new JsonResolver()}); //user config - var u = JObject.FromObject(this, new JsonSerializer() {ContractResolver = new JsonResolver()}); + var u = JObject.FromObject(this, new JsonSerializer {ContractResolver = new JsonResolver()}); //overwrite default values with user values b.Merge(u, new JsonMergeSettings {MergeArrayHandling = MergeArrayHandling.Replace}); //cast json object to config - T c = b.ToObject(); + var c = b.ToObject(); //re-write the location on disk to the object c.ConfigLocation = ConfigLocation; @@ -112,7 +103,7 @@ namespace StardewModdingAPI } catch (Exception ex) { - Log.Error("An error occured when updating a config: " + ex); + Log.AsyncR("An error occured when updating a config: " + ex); return this as T; } } @@ -121,10 +112,10 @@ namespace StardewModdingAPI public static class ConfigExtensions { /// - /// Initializes an instance of any class that inherits from Config. - /// This method performs the loading, saving, and merging of the config on the disk and in memory at a default state. - /// This method should not be used to re-load or to re-save a config. - /// NOTE: You MUST set your config EQUAL to the return of this method! + /// Initializes an instance of any class that inherits from Config. + /// This method performs the loading, saving, and merging of the config on the disk and in memory at a default state. + /// This method should not be used to re-load or to re-save a config. + /// NOTE: You MUST set your config EQUAL to the return of this method! /// /// /// @@ -136,35 +127,35 @@ namespace StardewModdingAPI { baseConfig = Activator.CreateInstance(); /* - Log.Error("A config tried to initialize whilst being null."); + Log.AsyncR("A config tried to initialize whilst being null."); return null; */ } if (string.IsNullOrEmpty(configLocation)) { - Log.Error("A config tried to initialize without specifying a location on the disk."); + Log.AsyncR("A config tried to initialize without specifying a location on the disk."); return null; } baseConfig.ConfigLocation = configLocation; - T c = baseConfig.LoadConfig(); + var c = baseConfig.LoadConfig(); return c; } /// - /// Writes a config to a json blob on the disk specified in the config's properties. + /// Writes a config to a json blob on the disk specified in the config's properties. /// public static void WriteConfig(this T baseConfig) where T : Config { if (string.IsNullOrEmpty(baseConfig?.ConfigLocation) || string.IsNullOrEmpty(baseConfig.ConfigDir)) { - Log.Error("A config attempted to save when it itself or it's location were null."); + Log.AsyncR("A config attempted to save when it itself or it's location were null."); return; } - string s = JsonConvert.SerializeObject(baseConfig, typeof (T), Formatting.Indented, new JsonSerializerSettings() {ContractResolver = new JsonResolver()}); + var s = JsonConvert.SerializeObject(baseConfig, typeof (T), Formatting.Indented, new JsonSerializerSettings {ContractResolver = new JsonResolver()}); if (!Directory.Exists(baseConfig.ConfigDir)) Directory.CreateDirectory(baseConfig.ConfigDir); @@ -174,8 +165,8 @@ namespace StardewModdingAPI } /// - /// Re-reads the json blob on the disk and merges its values with a default config - /// NOTE: You MUST set your config EQUAL to the return of this method! + /// Re-reads the json blob on the disk and merges its values with a default config + /// NOTE: You MUST set your config EQUAL to the return of this method! /// public static T ReloadConfig(this T baseConfig) where T : Config { diff --git a/StardewModdingAPI/Constants.cs b/StardewModdingAPI/Constants.cs index 109f22f8..ddd46115 100644 --- a/StardewModdingAPI/Constants.cs +++ b/StardewModdingAPI/Constants.cs @@ -6,13 +6,20 @@ using StardewValley; namespace StardewModdingAPI { /// - /// Static class containing readonly values. + /// Static class containing readonly values. /// public static class Constants { + public static readonly Version Version = new Version(0, 39, 3, "Alpha"); + /// - /// Stardew Valley's roaming app data location. - /// %AppData%//StardewValley + /// Not quite "constant", but it makes more sense for it to be here, at least for now + /// + public static int ModsLoaded = 0; + + /// + /// Stardew Valley's roaming app data location. + /// %AppData%//StardewValley /// public static string DataPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley"); @@ -29,33 +36,27 @@ namespace StardewModdingAPI public static bool PlayerNull => !Game1.hasLoadedGame || Game1.player == null || string.IsNullOrEmpty(Game1.player.name); /// - /// Execution path to execute the code. + /// Execution path to execute the code. /// public static string ExecutionPath => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); /// - /// Title for the API console + /// Title for the API console /// public static string ConsoleTitle => $"Stardew Modding API Console - Version {Version.VersionString} - Mods Loaded: {ModsLoaded}"; /// - /// Path for log files to be output to. - /// %LocalAppData%//StardewValley//ErrorLogs + /// Path for log files to be output to. + /// %LocalAppData%//StardewValley//ErrorLogs /// public static string LogDir => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "ErrorLogs"); - public static string LogPath => Path.Combine(LogDir, "MODDED_ProgramLog.Log_LATEST.txt"); - public static readonly Version Version = new Version(0, 39, 3, "Alpha"); - - /// - /// Not quite "constant", but it makes more sense for it to be here, at least for now - /// - public static int ModsLoaded = 0; + public static string LogPath => Path.Combine(LogDir, "MODDED_ProgramLog.Log_LATEST.txt"); /// - /// Whether or not to enable the Render Target drawing code offered by ClxS - /// Do not mark as 'const' or else 'if' checks will complain that the expression is always true in ReSharper + /// Whether or not to enable the Render Target drawing code offered by ClxS + /// Do not mark as 'const' or else 'if' checks will complain that the expression is always true in ReSharper /// public static bool EnableDrawingIntoRenderTarget => true; } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Entities/SCharacter.cs b/StardewModdingAPI/Entities/SCharacter.cs index 39e4f9c8..2d941d55 100644 --- a/StardewModdingAPI/Entities/SCharacter.cs +++ b/StardewModdingAPI/Entities/SCharacter.cs @@ -1,6 +1,6 @@ namespace StardewModdingAPI.Entities { - class SCharacter + internal class SCharacter { } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Entities/SFarm.cs b/StardewModdingAPI/Entities/SFarm.cs index 4895df7e..c6c64681 100644 --- a/StardewModdingAPI/Entities/SFarm.cs +++ b/StardewModdingAPI/Entities/SFarm.cs @@ -1,6 +1,6 @@ namespace StardewModdingAPI.Entities { - class SFarm + internal class SFarm { } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Entities/SFarmAnimal.cs b/StardewModdingAPI/Entities/SFarmAnimal.cs index 8bd99e1c..fb8ee267 100644 --- a/StardewModdingAPI/Entities/SFarmAnimal.cs +++ b/StardewModdingAPI/Entities/SFarmAnimal.cs @@ -1,6 +1,6 @@ namespace StardewModdingAPI.Entities { - class SFarmAnimal + internal class SFarmAnimal { } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Entities/SNpc.cs b/StardewModdingAPI/Entities/SNpc.cs index 612c9c89..727dcff7 100644 --- a/StardewModdingAPI/Entities/SNpc.cs +++ b/StardewModdingAPI/Entities/SNpc.cs @@ -1,6 +1,6 @@ namespace StardewModdingAPI.Entities { - class SNpc + internal class SNpc { } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Entities/SPlayer.cs b/StardewModdingAPI/Entities/SPlayer.cs index c74ba461..d464cded 100644 --- a/StardewModdingAPI/Entities/SPlayer.cs +++ b/StardewModdingAPI/Entities/SPlayer.cs @@ -1,33 +1,33 @@ -using System.Collections.Generic; -using StardewModdingAPI.Inheritance; +using System; +using System.Collections.Generic; using StardewValley; namespace StardewModdingAPI.Entities { - public static class SPlayer + /// + /// Static class for intergrating with the player + /// + public class SPlayer { - public static List AllFarmers - { - get - { - return SGame.getAllFarmers(); - } - } + /// + /// Calls 'getAllFarmers' in Game1 + /// + public static List AllFarmers => Game1.getAllFarmers(); - public static Farmer CurrentFarmer - { - get - { - return SGame.player; - } - } + /// + /// Do not use. + /// + [Obsolete("Use 'Player' instead.")] + public static Farmer CurrentFarmer => Game1.player; - public static GameLocation CurrentFarmerLocation - { - get - { - return SGame.player.currentLocation; - } - } + /// + /// Gets the current player from Game1 + /// + public static Farmer Player => Game1.player; + + /// + /// Gets the player's current location from Game1 + /// + public static GameLocation CurrentFarmerLocation => Player.currentLocation; } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Events/Controls.cs b/StardewModdingAPI/Events/Controls.cs index 5c604492..87319f37 100644 --- a/StardewModdingAPI/Events/Controls.cs +++ b/StardewModdingAPI/Events/Controls.cs @@ -55,4 +55,4 @@ namespace StardewModdingAPI.Events ControllerTriggerReleased.Invoke(null, new EventArgsControllerTriggerReleased(playerIndex, buttons, value)); } } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Events/EventArgs.cs b/StardewModdingAPI/Events/EventArgs.cs index 59fa1bbd..91151e86 100644 --- a/StardewModdingAPI/Events/EventArgs.cs +++ b/StardewModdingAPI/Events/EventArgs.cs @@ -17,6 +17,7 @@ namespace StardewModdingAPI.Events NewState = newState; NewState = newState; } + public KeyboardState NewState { get; private set; } public KeyboardState PriorState { get; private set; } } @@ -27,6 +28,7 @@ namespace StardewModdingAPI.Events { KeyPressed = keyPressed; } + public Keys KeyPressed { get; private set; } } @@ -37,6 +39,7 @@ namespace StardewModdingAPI.Events PlayerIndex = playerIndex; ButtonPressed = buttonPressed; } + public PlayerIndex PlayerIndex { get; private set; } public Buttons ButtonPressed { get; private set; } } @@ -48,6 +51,7 @@ namespace StardewModdingAPI.Events PlayerIndex = playerIndex; ButtonReleased = buttonReleased; } + public PlayerIndex PlayerIndex { get; private set; } public Buttons ButtonReleased { get; private set; } } @@ -60,6 +64,7 @@ namespace StardewModdingAPI.Events ButtonPressed = buttonPressed; Value = value; } + public PlayerIndex PlayerIndex { get; private set; } public Buttons ButtonPressed { get; private set; } public float Value { get; private set; } @@ -73,18 +78,20 @@ namespace StardewModdingAPI.Events ButtonReleased = buttonReleased; Value = value; } + public PlayerIndex PlayerIndex { get; private set; } public Buttons ButtonReleased { get; private set; } public float Value { get; private set; } } public class EventArgsMouseStateChanged : EventArgs - { + { public EventArgsMouseStateChanged(MouseState priorState, MouseState newState) { NewState = newState; NewState = newState; } + public MouseState NewState { get; private set; } public MouseState PriorState { get; private set; } } @@ -96,6 +103,7 @@ namespace StardewModdingAPI.Events NewMenu = newMenu; PriorMenu = priorMenu; } + public IClickableMenu NewMenu { get; private set; } public IClickableMenu PriorMenu { get; private set; } } @@ -106,8 +114,10 @@ namespace StardewModdingAPI.Events { NewLocations = newLocations; } + public List NewLocations { get; private set; } } + public class EventArgsMineLevelChanged : EventArgs { public EventArgsMineLevelChanged(int previousMineLevel, int currentMineLevel) @@ -115,6 +125,7 @@ namespace StardewModdingAPI.Events PreviousMineLevel = previousMineLevel; CurrentMineLevel = currentMineLevel; } + public int PreviousMineLevel { get; private set; } public int CurrentMineLevel { get; private set; } } @@ -125,6 +136,7 @@ namespace StardewModdingAPI.Events { NewObjects = newObjects; } + public SerializableDictionary NewObjects { get; private set; } } @@ -135,6 +147,7 @@ namespace StardewModdingAPI.Events NewLocation = newLocation; PriorLocation = priorLocation; } + public GameLocation NewLocation { get; private set; } public GameLocation PriorLocation { get; private set; } } @@ -146,8 +159,9 @@ namespace StardewModdingAPI.Events NewFarmer = NewFarmer; PriorFarmer = PriorFarmer; } - public Farmer NewFarmer { get; private set; } - public Farmer PriorFarmer { get; private set; } + + public Farmer NewFarmer { get; } + public Farmer PriorFarmer { get; } } public class EventArgsInventoryChanged : EventArgs @@ -159,6 +173,7 @@ namespace StardewModdingAPI.Events Removed = changedItems.Where(n => n.ChangeType == ChangeType.Removed).ToList(); QuantityChanged = changedItems.Where(n => n.ChangeType == ChangeType.StackChange).ToList(); } + public List Inventory { get; private set; } public List Added { get; private set; } public List Removed { get; private set; } @@ -169,42 +184,46 @@ namespace StardewModdingAPI.Events { public enum LevelType { - Combat, + Combat, Farming, Fishing, Foraging, Mining, Luck } - public EventArgsLevelUp(LevelType type, Int32 newLevel) + + public EventArgsLevelUp(LevelType type, int newLevel) { Type = type; NewLevel = newLevel; } + public LevelType Type { get; private set; } - public Int32 NewLevel { get; private set; } + public int NewLevel { get; private set; } } public class EventArgsIntChanged : EventArgs { - public EventArgsIntChanged(Int32 priorInt, Int32 newInt) + public EventArgsIntChanged(int priorInt, int newInt) { NewInt = NewInt; PriorInt = PriorInt; } - public Int32 NewInt { get; private set; } - public Int32 PriorInt { get; private set; } + + public int NewInt { get; } + public int PriorInt { get; } } public class EventArgsStringChanged : EventArgs { - public EventArgsStringChanged(String priorString, String newString) + public EventArgsStringChanged(string priorString, string newString) { NewString = newString; PriorString = priorString; } - public String NewString { get; private set; } - public String PriorString { get; private set; } + + public string NewString { get; private set; } + public string PriorString { get; private set; } } public class EventArgsLoadedGameChanged : EventArgs @@ -224,7 +243,7 @@ namespace StardewModdingAPI.Events { Command = command; } + public Command Command { get; private set; } } -} - +} \ No newline at end of file diff --git a/StardewModdingAPI/Events/Game.cs b/StardewModdingAPI/Events/Game.cs index 85022391..c8052962 100644 --- a/StardewModdingAPI/Events/Game.cs +++ b/StardewModdingAPI/Events/Game.cs @@ -8,32 +8,39 @@ namespace StardewModdingAPI.Events public static event EventHandler Initialize = delegate { }; public static event EventHandler LoadContent = delegate { }; public static event EventHandler FirstUpdateTick = delegate { }; + /// - /// Fires every update (1/60 of a second) + /// Fires every update (1/60 of a second) /// public static event EventHandler UpdateTick = delegate { }; + /// - /// Fires every other update (1/30 of a second) + /// Fires every other update (1/30 of a second) /// public static event EventHandler SecondUpdateTick = delegate { }; + /// - /// Fires every fourth update (1/15 of a second) + /// Fires every fourth update (1/15 of a second) /// public static event EventHandler FourthUpdateTick = delegate { }; + /// - /// Fires every eighth update (roughly 1/8 of a second) + /// Fires every eighth update (roughly 1/8 of a second) /// public static event EventHandler EighthUpdateTick = delegate { }; + /// - /// Fires every fifthteenth update (1/4 of a second) + /// Fires every fifthteenth update (1/4 of a second) /// public static event EventHandler QuarterSecondTick = delegate { }; + /// - /// Fires every thirtieth update (1/2 of a second) + /// Fires every thirtieth update (1/2 of a second) /// public static event EventHandler HalfSecondTick = delegate { }; + /// - /// Fires every sixtieth update (a second) + /// Fires every sixtieth update (a second) /// public static event EventHandler OneSecondTick = delegate { }; @@ -50,7 +57,7 @@ namespace StardewModdingAPI.Events } catch (Exception ex) { - Log.Error("An exception occured in XNA Initialize: " + ex); + Log.AsyncR("An exception occured in XNA Initialize: " + ex); } } @@ -62,7 +69,7 @@ namespace StardewModdingAPI.Events } catch (Exception ex) { - Log.Error("An exception occured in XNA LoadContent: " + ex); + Log.AsyncR("An exception occured in XNA LoadContent: " + ex); } } @@ -74,7 +81,7 @@ namespace StardewModdingAPI.Events } catch (Exception ex) { - Log.Error("An exception occured in XNA UpdateTick: " + ex); + Log.AsyncR("An exception occured in XNA UpdateTick: " + ex); } } @@ -113,4 +120,4 @@ namespace StardewModdingAPI.Events FirstUpdateTick.Invoke(null, EventArgs.Empty); } } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Events/Graphics.cs b/StardewModdingAPI/Events/Graphics.cs index db963924..a2e7fc40 100644 --- a/StardewModdingAPI/Events/Graphics.cs +++ b/StardewModdingAPI/Events/Graphics.cs @@ -16,7 +16,7 @@ namespace StardewModdingAPI.Events } catch (Exception ex) { - Log.Error("An exception occured in a Mod's DrawTick: " + ex); + Log.AsyncR("An exception occured in a Mod's DrawTick: " + ex); } } @@ -30,4 +30,4 @@ namespace StardewModdingAPI.Events Resize.Invoke(sender, e); } } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Events/Location.cs b/StardewModdingAPI/Events/Location.cs index 63b0f602..d5b6cdec 100644 --- a/StardewModdingAPI/Events/Location.cs +++ b/StardewModdingAPI/Events/Location.cs @@ -21,10 +21,10 @@ namespace StardewModdingAPI.Events { CurrentLocationChanged.Invoke(null, new EventArgsCurrentLocationChanged(priorLocation, newLocation)); } - + internal static void InvokeOnNewLocationObject(SerializableDictionary newObjects) { LocationObjectsChanged.Invoke(null, new EventArgsLocationObjectsChanged(newObjects)); } } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Events/Menu.cs b/StardewModdingAPI/Events/Menu.cs index d3f3e008..8acfc863 100644 --- a/StardewModdingAPI/Events/Menu.cs +++ b/StardewModdingAPI/Events/Menu.cs @@ -12,4 +12,4 @@ namespace StardewModdingAPI.Events MenuChanged.Invoke(null, new EventArgsClickableMenuChanged(priorMenu, newMenu)); } } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Events/Mine.cs b/StardewModdingAPI/Events/Mine.cs index f48e9574..2f89c91d 100644 --- a/StardewModdingAPI/Events/Mine.cs +++ b/StardewModdingAPI/Events/Mine.cs @@ -11,4 +11,4 @@ namespace StardewModdingAPI.Events MineLevelChanged.Invoke(null, new EventArgsMineLevelChanged(previousMinelevel, currentMineLevel)); } } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Events/Player.cs b/StardewModdingAPI/Events/Player.cs index ca05c05b..a658259e 100644 --- a/StardewModdingAPI/Events/Player.cs +++ b/StardewModdingAPI/Events/Player.cs @@ -32,4 +32,4 @@ namespace StardewModdingAPI.Events LoadedGame.Invoke(null, loaded); } } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Events/Time.cs b/StardewModdingAPI/Events/Time.cs index a3fcee19..56b23dc3 100644 --- a/StardewModdingAPI/Events/Time.cs +++ b/StardewModdingAPI/Events/Time.cs @@ -9,24 +9,24 @@ namespace StardewModdingAPI.Events public static event EventHandler YearOfGameChanged = delegate { }; public static event EventHandler SeasonOfYearChanged = delegate { }; - public static void InvokeTimeOfDayChanged(Int32 priorInt, Int32 newInt) + public static void InvokeTimeOfDayChanged(int priorInt, int newInt) { TimeOfDayChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt)); } - public static void InvokeDayOfMonthChanged(Int32 priorInt, Int32 newInt) + public static void InvokeDayOfMonthChanged(int priorInt, int newInt) { DayOfMonthChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt)); } - public static void InvokeYearOfGameChanged(Int32 priorInt, Int32 newInt) + public static void InvokeYearOfGameChanged(int priorInt, int newInt) { YearOfGameChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt)); } - public static void InvokeSeasonOfYearChanged(String priorString, String newString) + public static void InvokeSeasonOfYearChanged(string priorString, string newString) { SeasonOfYearChanged.Invoke(null, new EventArgsStringChanged(priorString, newString)); } } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Extensions.cs b/StardewModdingAPI/Extensions.cs index 58430a6e..fcf7eda2 100644 --- a/StardewModdingAPI/Extensions.cs +++ b/StardewModdingAPI/Extensions.cs @@ -25,16 +25,16 @@ namespace StardewModdingAPI [Obsolete("The usage of ToSingular has changed. Please update your call to use ToSingular")] public static string ToSingular(this IEnumerable ienum, string split = ", ") { - Log.Error("The usage of ToSingular has changed. Please update your call to use ToSingular"); + Log.AsyncR("The usage of ToSingular has changed. Please update your call to use ToSingular"); return ""; } - public static string ToSingular(this IEnumerable ienum, string split = ", ")// where T : class + public static string ToSingular(this IEnumerable ienum, string split = ", ") // where T : class { //Apparently Keys[] won't split normally :l - if (typeof(T) == typeof(Keys)) + if (typeof (T) == typeof (Keys)) { - return string.Join(split, ienum.ToArray()); + return string.Join(split, ienum.ToArray()); } return string.Join(split, ienum); } @@ -47,28 +47,28 @@ namespace StardewModdingAPI public static bool IsInt32(this object o) { int i; - return Int32.TryParse(o.ToString(), out i); + return int.TryParse(o.ToString(), out i); } - public static Int32 AsInt32(this object o) + public static int AsInt32(this object o) { - return Int32.Parse(o.ToString()); + return int.Parse(o.ToString()); } public static bool IsBool(this object o) { bool b; - return Boolean.TryParse(o.ToString(), out b); + return bool.TryParse(o.ToString(), out b); } public static bool AsBool(this object o) { - return Boolean.Parse(o.ToString()); + return bool.Parse(o.ToString()); } - + public static int GetHash(this IEnumerable enumerable) { - int hash = 0; + var hash = 0; foreach (var v in enumerable) { hash ^= v.GetHashCode(); @@ -107,7 +107,7 @@ namespace StardewModdingAPI return o.GetType().GetBaseFieldInfo(name).GetValue(o) as T; }*/ - /* + /* public static object GetBaseFieldValue(this object o, string name) { return o.GetType().GetBaseFieldInfo(name).GetValue(o); @@ -121,8 +121,8 @@ namespace StardewModdingAPI public static string RemoveNumerics(this string st) { - string s = st; - foreach (char c in s) + var s = st; + foreach (var c in s) { if (!char.IsLetterOrDigit(c)) { diff --git a/StardewModdingAPI/Inheritance/ItemStackChange.cs b/StardewModdingAPI/Inheritance/ItemStackChange.cs index cfadea04..88fc002e 100644 --- a/StardewModdingAPI/Inheritance/ItemStackChange.cs +++ b/StardewModdingAPI/Inheritance/ItemStackChange.cs @@ -15,4 +15,4 @@ namespace StardewModdingAPI.Inheritance public int StackChange { get; set; } public ChangeType ChangeType { get; set; } } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Inheritance/Menus/SBobberBar.cs b/StardewModdingAPI/Inheritance/Menus/SBobberBar.cs index ecfc0c38..ddac33c6 100644 --- a/StardewModdingAPI/Inheritance/Menus/SBobberBar.cs +++ b/StardewModdingAPI/Inheritance/Menus/SBobberBar.cs @@ -7,20 +7,28 @@ namespace StardewModdingAPI.Inheritance.Menus { public class SBobberBar : BobberBar { + /// + /// DO NOT CONSTRUCT THIS CLASS + /// To retrieve an instance of SBobberBar, use SBobberBar.ConstructFromBaseClass() + /// + public SBobberBar(int whichFish, float fishSize, bool treasure, int bobber) : base(whichFish, fishSize, treasure, bobber) + { + } + public BobberBar BaseBobberBar { get; private set; } /// - /// The green rectangle bar that moves up and down + /// The green rectangle bar that moves up and down /// public float bobberPosition { get { return (float) GetBaseFieldInfo("bobberPosition").GetValue(BaseBobberBar); } set { GetBaseFieldInfo("bobberPosition").SetValue(BaseBobberBar, value); } } - + /// - /// The green bar on the right. How close to catching the fish you are - /// Range: 0 - 1 | 1 = catch, 0 = fail + /// The green bar on the right. How close to catching the fish you are + /// Range: 0 - 1 | 1 = catch, 0 = fail /// public float distanceFromCatching { @@ -137,7 +145,7 @@ namespace StardewModdingAPI.Inheritance.Menus } /// - /// Whether or not a treasure chest appears + /// Whether or not a treasure chest appears /// public bool treasure { @@ -266,20 +274,11 @@ namespace StardewModdingAPI.Inheritance.Menus public static SBobberBar ConstructFromBaseClass(BobberBar baseClass) { - SBobberBar b = new SBobberBar(0, 0, false, 0); + var b = new SBobberBar(0, 0, false, 0); b.BaseBobberBar = baseClass; return b; } - /// - /// DO NOT CONSTRUCT THIS CLASS - /// To retrieve an instance of SBobberBar, use SBobberBar.ConstructFromBaseClass() - /// - public SBobberBar(int whichFish, float fishSize, bool treasure, int bobber) : base(whichFish, fishSize, treasure, bobber) - { - - } - public static FieldInfo[] GetPrivateFields() { return typeof (BobberBar).GetFields(BindingFlags.Instance | BindingFlags.NonPublic); diff --git a/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs b/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs index 43ea30d7..f45758f7 100644 --- a/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs +++ b/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs @@ -10,19 +10,19 @@ namespace StardewModdingAPI.Inheritance.Menus public List tabs { - get { return (List)GetBaseFieldInfo("tabs").GetValue(BaseGameMenu); } + get { return (List) GetBaseFieldInfo("tabs").GetValue(BaseGameMenu); } set { GetBaseFieldInfo("tabs").SetValue(BaseGameMenu, value); } } public List pages { - get { return (List)GetBaseFieldInfo("pages").GetValue(BaseGameMenu); } + get { return (List) GetBaseFieldInfo("pages").GetValue(BaseGameMenu); } set { GetBaseFieldInfo("pages").SetValue(BaseGameMenu, value); } } public static SGameMenu ConstructFromBaseClass(GameMenu baseClass) { - SGameMenu s = new SGameMenu(); + var s = new SGameMenu(); s.BaseGameMenu = baseClass; return s; } @@ -31,19 +31,19 @@ namespace StardewModdingAPI.Inheritance.Menus { if (pages[currentTab] is InventoryPage) { - Log.Verbose("INV SCREEN"); + Log.AsyncY("INV SCREEN"); } base.receiveRightClick(x, y, playSound); } public static FieldInfo[] GetPrivateFields() { - return typeof(GameMenu).GetFields(BindingFlags.Instance | BindingFlags.NonPublic); + return typeof (GameMenu).GetFields(BindingFlags.Instance | BindingFlags.NonPublic); } public static FieldInfo GetBaseFieldInfo(string name) { - return typeof(GameMenu).GetField(name, BindingFlags.Instance | BindingFlags.NonPublic); + return typeof (GameMenu).GetField(name, BindingFlags.Instance | BindingFlags.NonPublic); } } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs b/StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs index d798fc95..a51b2d71 100644 --- a/StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs +++ b/StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs @@ -4,17 +4,17 @@ namespace StardewModdingAPI.Inheritance.Menus { public class SInventoryPage : InventoryPage { + public SInventoryPage(int x, int y, int width, int height) : base(x, y, width, height) + { + } + public InventoryPage BaseInventoryPage { get; private set; } public static SInventoryPage ConstructFromBaseClass(InventoryPage baseClass) { - SInventoryPage s = new SInventoryPage(0,0,0,0); + var s = new SInventoryPage(0, 0, 0, 0); s.BaseInventoryPage = baseClass; return s; } - - public SInventoryPage(int x, int y, int width, int height) : base(x, y, width, height) - { - } } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Inheritance/Minigames/SMinigameBase.cs b/StardewModdingAPI/Inheritance/Minigames/SMinigameBase.cs index 08a5e861..f30021de 100644 --- a/StardewModdingAPI/Inheritance/Minigames/SMinigameBase.cs +++ b/StardewModdingAPI/Inheritance/Minigames/SMinigameBase.cs @@ -5,7 +5,7 @@ using StardewValley.Minigames; namespace StardewModdingAPI.Inheritance.Minigames { - abstract class SMinigameBase : IMinigame + internal abstract class SMinigameBase : IMinigame { public abstract bool tick(GameTime time); @@ -31,4 +31,4 @@ namespace StardewModdingAPI.Inheritance.Minigames public abstract void receiveEventPoke(int data); } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Inheritance/SBareObject.cs b/StardewModdingAPI/Inheritance/SBareObject.cs index 905dac0d..5bef7b3e 100644 --- a/StardewModdingAPI/Inheritance/SBareObject.cs +++ b/StardewModdingAPI/Inheritance/SBareObject.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.AccessControl; -using System.Text; -using System.Threading.Tasks; - -namespace StardewModdingAPI.Inheritance +namespace StardewModdingAPI.Inheritance { public struct SBareObject { @@ -24,4 +17,4 @@ namespace StardewModdingAPI.Inheritance quality = qua; } } -} +} \ No newline at end of file diff --git a/StardewModdingAPI/Inheritance/SGame.cs b/StardewModdingAPI/Inheritance/SGame.cs index ce2488d5..f1887253 100644 --- a/StardewModdingAPI/Inheritance/SGame.cs +++ b/StardewModdingAPI/Inheritance/SGame.cs @@ -11,60 +11,264 @@ using StardewValley.Menus; namespace StardewModdingAPI.Inheritance { + /// + /// The 'SGame' class. + /// This summary, and many others, only exists because XML doc tags. + /// public class SGame : Game1 { - public static Dictionary ModItems { get; private set; } - public const Int32 LowestModItemID = 1000; + /// + /// Useless right now. + /// + public const int LowestModItemID = 1000; - public static FieldInfo[] StaticFields { get { return GetStaticFields(); } } + private bool FireLoadedGameEvent; + + /// + /// Gets a jagged array of all buttons pressed on the gamepad the prior frame. + /// + public Buttons[][] PreviouslyPressedButtons; - public static FieldInfo[] GetStaticFields() + internal SGame() { - return typeof(Game1).GetFields(); + Instance = this; + FirstUpdate = true; } + /// + /// Useless at this time. + /// + [Obsolete] + public static Dictionary ModItems { get; private set; } + + /// + /// The current KeyboardState + /// public KeyboardState KStateNow { get; private set; } + /// + /// The prior KeyboardState + /// public KeyboardState KStatePrior { get; private set; } + /// + /// The current MouseState + /// public MouseState MStateNow { get; private set; } + + /// + /// The prior MouseState + /// public MouseState MStatePrior { get; private set; } + /// + /// All keys pressed on the current frame + /// public Keys[] CurrentlyPressedKeys => KStateNow.GetPressedKeys(); + + /// + /// All keys pressed on the prior frame + /// public Keys[] PreviouslyPressedKeys => KStatePrior.GetPressedKeys(); + /// + /// All keys pressed on this frame except for the ones pressed on the prior frame + /// public Keys[] FramePressedKeys => CurrentlyPressedKeys.Except(PreviouslyPressedKeys).ToArray(); + /// + /// All keys pressed on the prior frame except for the ones pressed on the current frame + /// public Keys[] FrameReleasedKeys => PreviouslyPressedKeys.Except(CurrentlyPressedKeys).ToArray(); - public Buttons[][] PreviouslyPressedButtons; + /// + /// Whether or not a save was tagged as 'Loaded' the prior frame. + /// + public bool PreviouslyLoadedGame { get; private set; } + + /// + /// The list of GameLocations on the prior frame + /// + public int PreviousGameLocations { get; private set; } + + /// + /// The list of GameObjects on the prior frame + /// + public int PreviousLocationObjects { get; private set; } + /// + /// The list of Items in the player's inventory on the prior frame + /// + public Dictionary PreviousItems { get; private set; } + + /// + /// The player's Combat level on the prior frame + /// + public int PreviousCombatLevel { get; private set; } + /// + /// The player's Farming level on the prior frame + /// + public int PreviousFarmingLevel { get; private set; } + /// + /// The player's Fishing level on the prior frame + /// + public int PreviousFishingLevel { get; private set; } + /// + /// The player's Foraging level on the prior frame + /// + public int PreviousForagingLevel { get; private set; } + /// + /// The player's Mining level on the prior frame + /// + public int PreviousMiningLevel { get; private set; } + /// + /// The player's Luck level on the prior frame + /// + public int PreviousLuckLevel { get; private set; } + + //Kill me now comments are so boring + + /// + /// The player's previous game location + /// + public GameLocation PreviousGameLocation { get; private set; } + + /// + /// The previous ActiveGameMenu in Game1 + /// + public IClickableMenu PreviousActiveMenu { get; private set; } + + /// + /// The previous mine level + /// + public int PreviousMineLevel { get; private set; } + + /// + /// The previous TimeOfDay (Int32 between 600 and 2400?) + /// + public int PreviousTimeOfDay { get; private set; } + + /// + /// The previous DayOfMonth (Int32 between 1 and 28?) + /// + public int PreviousDayOfMonth { get; private set; } + + /// + /// The previous Season (String as follows: "winter", "spring", "summer", "fall") + /// + public string PreviousSeasonOfYear { get; private set; } + + /// + /// The previous Year + /// + public int PreviousYearOfGame { get; private set; } + + /// + /// The previous 'Farmer' (Player) + /// + public Farmer PreviousFarmer { get; private set; } + + /// + /// The current index of the update tick. Recycles every 60th tick to 0. (Int32 between 0 and 59) + /// + public int CurrentUpdateTick { get; private set; } + + /// + /// Whether or not this update frame is the very first of the entire game + /// + public bool FirstUpdate { get; private set; } + + /// + /// The current RenderTarget in Game1 (Private field, uses reflection) + /// + public RenderTarget2D Screen + { + get { return typeof (Game1).GetBaseFieldValue(Program.gamePtr, "screen"); } + set { typeof (Game1).SetBaseFieldValue(this, "screen", value); } + } + + /// + /// Static accessor for an Instance of the class SGame + /// + public static SGame Instance { get; private set; } + + /// + /// The game's FPS. Re-determined every Draw update. + /// + public static float FramesPerSecond { get; private set; } + + /// + /// Whether or not we're in a pseudo 'debug' mode. Mostly for displaying information like FPS. + /// + public static bool Debug { get; private set; } + + /// + /// The current player (equal to Farmer.Player) + /// + [Obsolete("Use Farmer.Player instead")] + public Farmer CurrentFarmer => player; + + /// + /// Gets ALL static fields that belong to 'Game1' + /// + public static FieldInfo[] GetStaticFields => typeof (Game1).GetFields(); + + /// + /// Whether or not a button was just pressed on the controller + /// + /// + /// + /// + /// private bool WasButtonJustPressed(Buttons button, ButtonState buttonState, PlayerIndex stateIndex) { - return buttonState == ButtonState.Pressed && !PreviouslyPressedButtons[(int)stateIndex].Contains(button); + return buttonState == ButtonState.Pressed && !PreviouslyPressedButtons[(int) stateIndex].Contains(button); } + /// + /// Whether or not a button was just released on the controller + /// + /// + /// + /// + /// private bool WasButtonJustReleased(Buttons button, ButtonState buttonState, PlayerIndex stateIndex) { - return buttonState == ButtonState.Released && PreviouslyPressedButtons[(int)stateIndex].Contains(button); + return buttonState == ButtonState.Released && PreviouslyPressedButtons[(int) stateIndex].Contains(button); } + /// + /// Whether or not an analog button was just pressed on the controller + /// + /// + /// + /// + /// private bool WasButtonJustPressed(Buttons button, float value, PlayerIndex stateIndex) { return WasButtonJustPressed(button, value > 0.2f ? ButtonState.Pressed : ButtonState.Released, stateIndex); } - + + /// + /// Whether or not an analog button was just released on the controller + /// + /// + /// + /// + /// private bool WasButtonJustReleased(Buttons button, float value, PlayerIndex stateIndex) { return WasButtonJustReleased(button, value > 0.2f ? ButtonState.Pressed : ButtonState.Released, stateIndex); } - public bool PreviouslyLoadedGame { get; private set; } - private bool FireLoadedGameEvent; - + /// + /// Gets an array of all Buttons pressed on a joystick + /// + /// + /// public Buttons[] GetButtonsDown(PlayerIndex index) { - GamePadState state = GamePad.GetState(index); - List buttons = new List(); + var state = GamePad.GetState(index); + var buttons = new List(); if (state.IsConnected) { if (state.Buttons.A == ButtonState.Pressed) buttons.Add(Buttons.A); @@ -88,15 +292,20 @@ namespace StardewModdingAPI.Inheritance return buttons.ToArray(); } + /// + /// Gets all buttons that were pressed on the current frame of a joystick + /// + /// + /// public Buttons[] GetFramePressedButtons(PlayerIndex index) - { - GamePadState state = GamePad.GetState(index); - List buttons = new List(); + { + var state = GamePad.GetState(index); + var buttons = new List(); if (state.IsConnected) { - if (WasButtonJustPressed(Buttons.A, state.Buttons.A, index)) buttons.Add(Buttons.A); - if (WasButtonJustPressed(Buttons.B, state.Buttons.B, index)) buttons.Add(Buttons.B); - if (WasButtonJustPressed(Buttons.Back, state.Buttons.Back, index)) buttons.Add(Buttons.Back); + if (WasButtonJustPressed(Buttons.A, state.Buttons.A, index)) buttons.Add(Buttons.A); + if (WasButtonJustPressed(Buttons.B, state.Buttons.B, index)) buttons.Add(Buttons.B); + if (WasButtonJustPressed(Buttons.Back, state.Buttons.Back, index)) buttons.Add(Buttons.Back); if (WasButtonJustPressed(Buttons.BigButton, state.Buttons.BigButton, index)) buttons.Add(Buttons.BigButton); if (WasButtonJustPressed(Buttons.LeftShoulder, state.Buttons.LeftShoulder, index)) buttons.Add(Buttons.LeftShoulder); if (WasButtonJustPressed(Buttons.LeftStick, state.Buttons.LeftStick, index)) buttons.Add(Buttons.LeftStick); @@ -112,13 +321,18 @@ namespace StardewModdingAPI.Inheritance if (WasButtonJustPressed(Buttons.LeftTrigger, state.Triggers.Left, index)) buttons.Add(Buttons.LeftTrigger); if (WasButtonJustPressed(Buttons.RightTrigger, state.Triggers.Right, index)) buttons.Add(Buttons.RightTrigger); } - return buttons.ToArray(); + return buttons.ToArray(); } + /// + /// Gets all buttons that were released on the current frame of a joystick + /// + /// + /// public Buttons[] GetFrameReleasedButtons(PlayerIndex index) { - GamePadState state = GamePad.GetState(index); - List buttons = new List(); + var state = GamePad.GetState(index); + var buttons = new List(); if (state.IsConnected) { if (WasButtonJustReleased(Buttons.A, state.Buttons.A, index)) buttons.Add(Buttons.A); @@ -142,70 +356,34 @@ namespace StardewModdingAPI.Inheritance return buttons.ToArray(); } - public int PreviousGameLocations { get; private set; } - public int PreviousLocationObjects { get; private set; } - public Dictionary PreviousItems { get; private set; } - - public int PreviousCombatLevel { get; private set; } - public int PreviousFarmingLevel { get; private set; } - public int PreviousFishingLevel { get; private set; } - public int PreviousForagingLevel { get; private set; } - public int PreviousMiningLevel { get; private set; } - public int PreviousLuckLevel { get; private set; } - - public GameLocation PreviousGameLocation { get; private set; } - public IClickableMenu PreviousActiveMenu { get; private set; } - - public int PreviousMineLevel { 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 Int32 CurrentUpdateTick { get; private set; } - public bool FirstUpdate { get; private set; } - - public RenderTarget2D Screen - { - get { return typeof (Game1).GetBaseFieldValue(Program.gamePtr, "screen"); } - set { typeof (Game1).SetBaseFieldValue(this, "screen", value); } - } - - private static SGame instance; - public static SGame Instance => instance; - - public static float FramesPerSecond { get; private set; } - public static bool Debug { get; private set; } - - public Farmer CurrentFarmer => player; - - public SGame() - { - instance = this; - FirstUpdate = true; - } - + /// + /// XNA Init Method + /// protected override void Initialize() { - Log.Verbose("XNA Initialize"); -