From 28adb69bbc1ad475ec2c8c7840481c791f93782e Mon Sep 17 00:00:00 2001 From: JoshuaNavarro Date: Sun, 1 Dec 2019 18:37:36 -0800 Subject: [PATCH] Updated night owl and fixed a SSR bug. --- GeneralMods/NightOwl/Framework/NightOwlAPI.cs | 59 +++++++++++++++++++ GeneralMods/NightOwl/NightOwl.cs | 45 ++++++++++++-- GeneralMods/NightOwl/NightOwl.csproj | 1 + GeneralMods/NightOwl/manifest.json | 4 +- GeneralMods/StardewMods.sln | 14 ----- .../Framework/V2/MusicManagerV2.cs | 11 +++- .../StardewSymphonyRemastered/manifest.json | 4 +- GeneralMods/StardustCore/manifest.json | 2 +- 8 files changed, 115 insertions(+), 25 deletions(-) create mode 100644 GeneralMods/NightOwl/Framework/NightOwlAPI.cs diff --git a/GeneralMods/NightOwl/Framework/NightOwlAPI.cs b/GeneralMods/NightOwl/Framework/NightOwlAPI.cs new file mode 100644 index 00000000..51100ebe --- /dev/null +++ b/GeneralMods/NightOwl/Framework/NightOwlAPI.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Omegasis.NightOwl.Framework +{ + public class NightOwlAPI + { + + /// + /// Adds an event that triggers after the player has been warped to their pre-collapse position. + /// + /// The id of the event. + /// The code that triggers. + public void addPostWarpEvent(string ID,Func Action) + { + NightOwl.PostWarpCharacter.Add(ID, Action); + } + + + /// + /// Removes an event that triggers when the player has been warped to their pre-collapse position. + /// + /// + public void removePostWarpEvent(string ID) + { + if (NightOwl.PostWarpCharacter.ContainsKey(ID)) + { + NightOwl.PostWarpCharacter.Remove(ID); + } + } + + /// + /// Adds an event that triggers when the player has stayed up all night until 6:00 A.M. + /// + /// The id of the event. + /// The code that triggers. + public void addPlayerUpLateEvent(string ID, Func Action) + { + NightOwl.OnPlayerStayingUpLate.Add(ID, Action); + } + + /// + /// Removes an event that triggers when the player has stayed up all night. + /// + /// + public void removePlayerUpLateEvent(string ID) + { + if (NightOwl.OnPlayerStayingUpLate.ContainsKey(ID)) + { + NightOwl.OnPlayerStayingUpLate.Remove(ID); + } + } + + + } +} diff --git a/GeneralMods/NightOwl/NightOwl.cs b/GeneralMods/NightOwl/NightOwl.cs index 86aeaa71..2f933810 100644 --- a/GeneralMods/NightOwl/NightOwl.cs +++ b/GeneralMods/NightOwl/NightOwl.cs @@ -20,6 +20,19 @@ namespace Omegasis.NightOwl /// The mod entry point. public class NightOwl : Mod { + + /********* + ** Static Fields + *********/ + /// + /// Events that are handled after the player has warped after they have stayed up late. + /// + public static Dictionary> PostWarpCharacter = new Dictionary>(); + /// + /// Events that are handled when the player has stayed up late and are going to collapse. + /// + public static Dictionary> OnPlayerStayingUpLate = new Dictionary>(); + /********* ** Fields *********/ @@ -71,12 +84,13 @@ namespace Omegasis.NightOwl /// Determines whehther or not to rewarp the player's horse to them. private bool shouldWarpHorse; - /// Event in the night taht simulates the earthquake event that should happen. + /// Event in the night that simulates the earthquake event that should happen. StardewValley.Events.SoundInTheNightEvent eve; private List oldAnimalHappiness; + /********* ** Public methods *********/ @@ -98,6 +112,10 @@ namespace Omegasis.NightOwl this.shouldWarpHorse = false; } + public override object GetApi() + { + return new NightOwlAPI(); + } /********* ** Private methods @@ -117,7 +135,13 @@ namespace Omegasis.NightOwl if (Context.IsWorldReady && this.JustStartedNewDay && this.Config.KeepPositionAfterCollapse) { if (this.PreCollapseMap != null) + { Game1.warpFarmer(this.PreCollapseMap, this.PreCollapseTile.X, this.PreCollapseTile.Y, false); + foreach (var v in PostWarpCharacter) + { + v.Value.Invoke(); + } + } this.PreCollapseMap = null; this.JustStartedNewDay = false; @@ -148,7 +172,7 @@ namespace Omegasis.NightOwl } if (this.Config.KeepMoneyAfterCollapse) - Game1.player.money += collapseFee; + Game1.player.Money += collapseFee; } /// Raised after the player loads a save slot and the world is initialised. @@ -183,7 +207,13 @@ namespace Omegasis.NightOwl if (this.Config.KeepPositionAfterCollapse) { if (!Game1.weddingToday) + { Game1.warpFarmer(this.PreCollapseMap, this.PreCollapseTile.X, this.PreCollapseTile.Y, false); + foreach(var v in PostWarpCharacter) + { + v.Value.Invoke(); + } + } } if (this.horse != null && this.shouldWarpHorse) @@ -196,7 +226,7 @@ namespace Omegasis.NightOwl if (this.isBathing) Game1.player.swimming.Value = true; - //Reflction to ensure that the railroad becomes properly unblocked. + //Reflection to ensure that the railroad becomes properly unblocked. if (Game1.dayOfMonth == 1 && Game1.currentSeason == "summer" && Game1.year == 1) { Mountain mountain = (Mountain)Game1.getLocationFromName("Mountain"); @@ -304,7 +334,7 @@ namespace Omegasis.NightOwl this.PreCollapseMap = Game1.player.currentLocation.Name; this.PreCollapseStamina = Game1.player.stamina; this.PreCollapseHealth = Game1.player.health; - this.PreCollapseMoney = Game1.player.money; + this.PreCollapseMoney = Game1.player.Money; this.isInSwimSuit = Game1.player.bathingClothes.Value; this.isBathing = Game1.player.swimming.Value; @@ -314,7 +344,7 @@ namespace Omegasis.NightOwl if (Game1.activeClickableMenu != null) Game1.activeClickableMenu.exitThisMenu(true); //Exit menus. - Game1.timeOfDay += 2400; //Recalculate for the sake of technically being up a whole day. + //Game1.timeOfDay += 2400; //Recalculate for the sake of technically being up a whole day. Why did I put this here? //Reset animal happiness since it drains over night. for (int i = 0; i < this.oldAnimalHappiness.Count; i++) @@ -322,6 +352,11 @@ namespace Omegasis.NightOwl Game1.getFarm().getAllFarmAnimals()[i].happiness.Value = this.oldAnimalHappiness[i].Value; } + foreach(var v in OnPlayerStayingUpLate) + { + v.Value.Invoke(); + } + Game1.player.startToPassOut(); } } diff --git a/GeneralMods/NightOwl/NightOwl.csproj b/GeneralMods/NightOwl/NightOwl.csproj index 05d47fe6..6a78faa1 100644 --- a/GeneralMods/NightOwl/NightOwl.csproj +++ b/GeneralMods/NightOwl/NightOwl.csproj @@ -78,6 +78,7 @@ + diff --git a/GeneralMods/NightOwl/manifest.json b/GeneralMods/NightOwl/manifest.json index acff5fad..6257c1e6 100644 --- a/GeneralMods/NightOwl/manifest.json +++ b/GeneralMods/NightOwl/manifest.json @@ -1,10 +1,10 @@ { "Name": "Night Owl", "Author": "Alpha_Omegasis", - "Version": "1.9.0", + "Version": "1.10.0", "Description": "Lets you stay up all night.", "UniqueID": "Omegasis.NightOwl", "EntryDll": "NightOwl.dll", - "MinimumApiVersion": "2.10.1", + "MinimumApiVersion": "3.0.0", "UpdateKeys": [ "Nexus:433" ] } diff --git a/GeneralMods/StardewMods.sln b/GeneralMods/StardewMods.sln index c6cd0630..7fc00954 100644 --- a/GeneralMods/StardewMods.sln +++ b/GeneralMods/StardewMods.sln @@ -74,8 +74,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Revitalize", "Revitalize\Re {0756D36A-95C8-480D-8EA6-4584C03010C6} = {0756D36A-95C8-480D-8EA6-4584C03010C6} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapExampleRF1", "MapExampleRF1\MapExampleRF1.csproj", "{696CDAA9-295F-49F0-97F9-334F626EA137}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -350,18 +348,6 @@ Global {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.x86|Any CPU.Build.0 = Release|Any CPU {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.x86|x86.ActiveCfg = Release|Any CPU {44EF6CEC-FBF1-4B45-8135-81D4EBE84DDD}.x86|x86.Build.0 = Release|Any CPU - {696CDAA9-295F-49F0-97F9-334F626EA137}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {696CDAA9-295F-49F0-97F9-334F626EA137}.Debug|Any CPU.Build.0 = Debug|Any CPU - {696CDAA9-295F-49F0-97F9-334F626EA137}.Debug|x86.ActiveCfg = Debug|Any CPU - {696CDAA9-295F-49F0-97F9-334F626EA137}.Debug|x86.Build.0 = Debug|Any CPU - {696CDAA9-295F-49F0-97F9-334F626EA137}.Release|Any CPU.ActiveCfg = Release|Any CPU - {696CDAA9-295F-49F0-97F9-334F626EA137}.Release|Any CPU.Build.0 = Release|Any CPU - {696CDAA9-295F-49F0-97F9-334F626EA137}.Release|x86.ActiveCfg = Release|Any CPU - {696CDAA9-295F-49F0-97F9-334F626EA137}.Release|x86.Build.0 = Release|Any CPU - {696CDAA9-295F-49F0-97F9-334F626EA137}.x86|Any CPU.ActiveCfg = Release|Any CPU - {696CDAA9-295F-49F0-97F9-334F626EA137}.x86|Any CPU.Build.0 = Release|Any CPU - {696CDAA9-295F-49F0-97F9-334F626EA137}.x86|x86.ActiveCfg = Release|Any CPU - {696CDAA9-295F-49F0-97F9-334F626EA137}.x86|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/V2/MusicManagerV2.cs b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/V2/MusicManagerV2.cs index 78ef0fea..c734215d 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/V2/MusicManagerV2.cs +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/Framework/V2/MusicManagerV2.cs @@ -173,10 +173,19 @@ namespace StardewSymphonyRemastered.Framework.V2 return false; } } - if (warpCheck == true && StardewSymphony.Config.LocationsToIgnoreWarpMusicChange.ContainsKey(Game1.player.currentLocation.Name)) + if (warpCheck == true) { + if (StardewSymphony.Config.LocationsToIgnoreWarpMusicChange.ContainsKey(Game1.player.currentLocation.Name)) + { + if (StardewSymphony.Config.LocationsToIgnoreWarpMusicChange[Game1.player.currentLocation.Name] == true) + { + return false; + } + } return false; } + + //Prevent generic song changes when running about. SongConditionals conditional = new SongConditionals(songListKey); diff --git a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json index fdc55b07..ac161b15 100644 --- a/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json +++ b/GeneralMods/StardewSymphonyRemastered/StardewSymphonyRemastered/manifest.json @@ -1,11 +1,11 @@ { "Name": "Stardew Symphony Remastered", "Author": "Alpha_Omegasis", - "Version": "3.1.0", + "Version": "3.1.1", "Description": "Adding more music to the game one beep at a time. Now with streaming!", "UniqueID": "Omegasis.StardewSymphonyRemastered", "EntryDll": "StardewSymphonyRemastered.dll", - "MinimumApiVersion": "2.10.1", + "MinimumApiVersion": "3.0.0", "UpdateKeys": [ "Nexus:425" ], "Dependencies": [ { "UniqueID": "Omegasis.StardustCore" } diff --git a/GeneralMods/StardustCore/manifest.json b/GeneralMods/StardustCore/manifest.json index 520808d0..864047c2 100644 --- a/GeneralMods/StardustCore/manifest.json +++ b/GeneralMods/StardustCore/manifest.json @@ -1,7 +1,7 @@ { "Name": "StardustCore", "Author": "Alpha_Omegasis", - "Version": "2.2.2", + "Version": "2.3.0", "Description": "A core mod that allows for other mods of mine to be run.", "UniqueID": "Omegasis.StardustCore", "EntryDll": "StardustCore.dll",