Skip to content
This repository has been archived by the owner on Jan 27, 2025. It is now read-only.

Commit

Permalink
Hotfix to fix cutscenes not acknowledging custom host delays
Browse files Browse the repository at this point in the history
  • Loading branch information
AutumnRivers committed May 31, 2024
1 parent 1763e0c commit c4b4e8f
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Cutscenes/Actions/CutsceneActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ public TriggerInstruction(StuxnetCutsceneInstruction instruction)

public override void Trigger(object os_obj)
{
if (!StuxnetCore.cutsceneIsActive || StuxnetCore.activeCutsceneID == "NONE")
{
Console.WriteLine(StuxnetCore.logPrefix + "WARN:Tried to run a cutscene action, but there isn't an active cutscene.");
return;
}

inst.Execute();
}
}
Expand Down
28 changes: 28 additions & 0 deletions Cutscenes/Actions/StopCutscene.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Hacknet;

using Pathfinder.Action;
using Pathfinder.Util;

using Stuxnet_HN.Cutscenes.Patches;

namespace Stuxnet_HN.Cutscenes.Actions
{
public class StopCutscene : PathfinderAction
{
public override void Trigger(object os_obj)
{
if (StuxnetCore.activeCutsceneID == "NONE") return;

StuxnetCutsceneInstruction resetInst = StuxnetCutsceneInstruction.CreateResetInstruction();
resetInst.Cutscene = CutsceneExecutor.ActiveCutscene;
PathfinderAction resetAction = new TriggerInstruction(resetInst);
resetAction.Trigger(os_obj);
}
}
}
2 changes: 1 addition & 1 deletion Cutscenes/Patches/CutsceneExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class CutsceneExecutor
internal static bool hasSetDelays = false;
internal static float totalDelay = 0f;

private static StuxnetCutscene ActiveCutscene => StuxnetCore.cutscenes[StuxnetCore.activeCutsceneID];
internal static StuxnetCutscene ActiveCutscene => StuxnetCore.cutscenes[StuxnetCore.activeCutsceneID];

[HarmonyPostfix]
[HarmonyPatch(typeof(PostProcessor),nameof(PostProcessor.end))]
Expand Down
5 changes: 5 additions & 0 deletions Cutscenes/StuxnetCutsceneRegister.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public static StuxnetCutscene ReadFromXml(XmlReader xml, string filepath = null)
if(xml.Name == "StuxnetCutscene" && xml.IsStartElement())
{
cutscene.id = xml.ReadRequiredAttribute("id");

if(xml.MoveToAttribute("delayHost"))
{
cutscene.delayHostID = xml.ReadContentAsString();
}
}

xml.Read();
Expand Down
3 changes: 2 additions & 1 deletion StuxnetCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class StuxnetCore : HacknetPlugin
{
public const string ModGUID = "autumnrivers.stuxnet";
public const string ModName = "Stuxnet";
public const string ModVer = "1.3.0";
public const string ModVer = "1.3.1";

private readonly bool defaultSave = ExtensionLoader.ActiveExtensionInfo.AllowSave;

Expand Down Expand Up @@ -197,6 +197,7 @@ public override bool Load()
// Cutscene Actions
ActionManager.RegisterAction<Cutscenes.Actions.RegisterCutscene>("RegisterStuxnetCutscene");
ActionManager.RegisterAction<Cutscenes.Actions.TriggerCutscene>("TriggerStuxnetCutscene");
ActionManager.RegisterAction<Cutscenes.Actions.StopCutscene>("StopActiveCutscene");

// Misc. Actions
ActionManager.RegisterAction<ForceConnect>("ForceConnectPlayer");
Expand Down
1 change: 1 addition & 0 deletions Stuxnet_HN.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
<Compile Include="Conditions\OnCutsceneEnd.cs" />
<Compile Include="Conditions\OnSequencerKill.cs" />
<Compile Include="Cutscenes\Actions\CutsceneActions.cs" />
<Compile Include="Cutscenes\Actions\StopCutscene.cs" />
<Compile Include="Cutscenes\Patches\CutsceneExecutor.cs" />
<Compile Include="Cutscenes\StuxnetCutsceneRegister.cs" />
<Compile Include="Cutscenes\StuxnetCutscenes.cs" />
Expand Down

0 comments on commit c4b4e8f

Please sign in to comment.