diff options
Diffstat (limited to 'StardewModdingAPI/Inheritance/SGame.cs')
-rw-r--r-- | StardewModdingAPI/Inheritance/SGame.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/StardewModdingAPI/Inheritance/SGame.cs b/StardewModdingAPI/Inheritance/SGame.cs index fdc6f3f7..fbea47bd 100644 --- a/StardewModdingAPI/Inheritance/SGame.cs +++ b/StardewModdingAPI/Inheritance/SGame.cs @@ -49,6 +49,8 @@ namespace StardewModdingAPI.Inheritance public GameLocation PreviousGameLocation { get; private set; } public IClickableMenu PreviousActiveMenu { get; private set; } + public Farmer PreviousFarmer { get; private set; } + protected override void Initialize() { Program.Log("XNA Initialize"); @@ -104,6 +106,12 @@ namespace StardewModdingAPI.Inheritance PreviousGameLocation = Game1.currentLocation; } + if (Game1.player != null && Game1.player != PreviousFarmer) + { + Events.InvokeFarmerChanged(Game1.player); + PreviousFarmer = Game1.player; + } + if (CurrentLocation != null) CurrentLocation.update(gameTime); @@ -184,5 +192,36 @@ namespace StardewModdingAPI.Inheritance } return null; } + + public static SGameLocation LoadOrCreateSGameLocationFromName(String name) + { + if (GetLocationFromName(name) != null) + return GetLocationFromName(name); + else + { + GameLocation gl = Game1.locations.FirstOrDefault(x => x.name == name); + if (gl != null) + { + Program.LogDebug("A custom location was created for the new name: " + name); + SGameLocation s = SGameLocation.ConstructFromBaseClass(gl); + ModLocations.Add(s); + return s; + } + else + { + if (Game1.currentLocation != null && Game1.currentLocation.name == name) + { + 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); + return null; + } + } + } } }
\ No newline at end of file |