Updated night owl and fixed a SSR bug.

This commit is contained in:
JoshuaNavarro 2019-12-01 18:37:36 -08:00
parent dca4d497bb
commit 28adb69bbc
8 changed files with 115 additions and 25 deletions

View File

@ -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
{
/// <summary>
/// Adds an event that triggers after the player has been warped to their pre-collapse position.
/// </summary>
/// <param name="ID">The id of the event.</param>
/// <param name="Action">The code that triggers.</param>
public void addPostWarpEvent(string ID,Func<bool> Action)
{
NightOwl.PostWarpCharacter.Add(ID, Action);
}
/// <summary>
/// Removes an event that triggers when the player has been warped to their pre-collapse position.
/// </summary>
/// <param name="ID"></param>
public void removePostWarpEvent(string ID)
{
if (NightOwl.PostWarpCharacter.ContainsKey(ID))
{
NightOwl.PostWarpCharacter.Remove(ID);
}
}
/// <summary>
/// Adds an event that triggers when the player has stayed up all night until 6:00 A.M.
/// </summary>
/// <param name="ID">The id of the event.</param>
/// <param name="Action">The code that triggers.</param>
public void addPlayerUpLateEvent(string ID, Func<bool> Action)
{
NightOwl.OnPlayerStayingUpLate.Add(ID, Action);
}
/// <summary>
/// Removes an event that triggers when the player has stayed up all night.
/// </summary>
/// <param name="ID"></param>
public void removePlayerUpLateEvent(string ID)
{
if (NightOwl.OnPlayerStayingUpLate.ContainsKey(ID))
{
NightOwl.OnPlayerStayingUpLate.Remove(ID);
}
}
}
}

View File

@ -20,6 +20,19 @@ namespace Omegasis.NightOwl
/// <summary>The mod entry point.</summary>
public class NightOwl : Mod
{
/*********
** Static Fields
*********/
/// <summary>
/// Events that are handled after the player has warped after they have stayed up late.
/// </summary>
public static Dictionary<string, Func<bool>> PostWarpCharacter = new Dictionary<string, Func<bool>>();
/// <summary>
/// Events that are handled when the player has stayed up late and are going to collapse.
/// </summary>
public static Dictionary<string, Func<bool>> OnPlayerStayingUpLate = new Dictionary<string, Func<bool>>();
/*********
** Fields
*********/
@ -71,12 +84,13 @@ namespace Omegasis.NightOwl
/// <summary>Determines whehther or not to rewarp the player's horse to them.</summary>
private bool shouldWarpHorse;
/// <summary>Event in the night taht simulates the earthquake event that should happen.</summary>
/// <summary>Event in the night that simulates the earthquake event that should happen.</summary>
StardewValley.Events.SoundInTheNightEvent eve;
private List<NetByte> 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;
}
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
@ -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();
}
}

View File

@ -78,6 +78,7 @@
</Compile>
<Compile Include="Framework\ModConfig.cs" />
<Compile Include="Framework\NightFishing.cs" />
<Compile Include="Framework\NightOwlAPI.cs" />
<Compile Include="NightOwl.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

View File

@ -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" ]
}

View File

@ -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

View File

@ -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);

View File

@ -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" }

View File

@ -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",