Skip to content

Commit

Permalink
Ai main game day change fix (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
thojmr committed Mar 3, 2021
1 parent 0979f73 commit 424cbc3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/AIAPI/MainGame/GameAPI.Hooks.cs
Expand Up @@ -13,8 +13,8 @@ public static partial class GameAPI
{
private class Hooks
{
public static int lastCurrentDay = 1;//Always starts at 1
public static bool isNewGame = false;
public static int day = 0;

public static void SetupHooks()
{
Expand Down Expand Up @@ -66,21 +66,16 @@ public static void HScene_EndProc(HScene __instance)
[HarmonyPostfix]
[HarmonyPatch(typeof(EnvironmentSimulator), nameof(EnvironmentSimulator.SetTimeZone), typeof(AIProject.TimeZone))]
public static void EnvironmentChangeTypeHook(AIProject.TimeZone zone)
{
{
if (zone == AIProject.TimeZone.Morning)
{
OnDayChange(day);
day++;
}

OnPeriodChange(zone);//morning, day, evening
}

[HarmonyPostfix]
[HarmonyPatch(typeof(EnviroSky), "SetGameTime")]
public static void EnvironmentChangeDayHook(EnviroSky __instance)
{
var currentDay = (int)__instance.currentDay;
if (lastCurrentDay < currentDay)
{
lastCurrentDay = currentDay;
OnDayChange(currentDay);
}
}
}
}
}
15 changes: 15 additions & 0 deletions src/AIAPI/MainGame/GameExtensions.cs
Expand Up @@ -102,6 +102,21 @@ public static IEnumerable<ChaFileControl> GetRelatedChaFiles(this AgentData agen
return results;
}

/// <summary>
/// Get ChaFiles that are related to this AgentActor (heroine). Warning: It might not return some copies.
/// </summary>
public static IEnumerable<ChaFileControl> GetRelatedChaFiles(this AgentActor agentActor)
{
if (agentActor == null) throw new ArgumentNullException(nameof(agentActor));

var results = new HashSet<ChaFileControl>();

if (agentActor?.ChaControl?.chaFile != null)
results.Add(agentActor.ChaControl.chaFile);

return results;
}

/// <summary>
/// Get the persisting player object that describes this character.
/// Returns null if the player could not be found. Works only in the main game.
Expand Down

0 comments on commit 424cbc3

Please sign in to comment.