Skip to content

Commit

Permalink
feat: add kingsoul
Browse files Browse the repository at this point in the history
  • Loading branch information
royitaqi committed Feb 1, 2023
1 parent e2c5433 commit bf89fb2
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
12 changes: 10 additions & 2 deletions Pet/ModClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,18 @@ public override void Initialize(Dictionary<string, Dictionary<string, GameObject
KeyboardOverride.Load();

// objects
_shade = new Shade();
_lantern = new Lantern();
_shade = new();
_lantern = new();
_kingsoul = new();

// hooks
GameUtils.Load();
GameUtils.GameLoaded += _shade.Load;
GameUtils.GameLoaded += _lantern.Load;
GameUtils.GameLoaded += _kingsoul.Load;
GameUtils.OnGameQuit += _shade.Unload;
GameUtils.OnGameQuit += _lantern.Unload;
GameUtils.OnGameQuit += _kingsoul.Load;
GameUtils.CatchUpEvents();

#if (DEBUG)
Expand Down Expand Up @@ -113,14 +116,18 @@ public void Unload()
GameUtils.Unload();
GameUtils.GameLoaded -= _shade.Load;
GameUtils.GameLoaded -= _lantern.Load;
GameUtils.GameLoaded -= _kingsoul.Load;
GameUtils.OnGameQuit -= _shade.Unload;
GameUtils.OnGameQuit -= _lantern.Unload;
GameUtils.OnGameQuit -= _kingsoul.Load;

// objects
_shade.Unload();
_shade = null;
_lantern.Unload();
_lantern = null;
_kingsoul.Unload();
_kingsoul = null;

// input overrides
KeyboardOverride.Unload();
Expand All @@ -135,6 +142,7 @@ public void Unload()

private Shade _shade;
private Lantern _lantern;
private Kingsoul _kingsoul;

///
/// IGlobalSettings<GlobalData>
Expand Down
46 changes: 46 additions & 0 deletions Pet/Modules/Kingsoul.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
using Pet.Utils;
using SFCore.Utils;
using static HutongGames.PlayMaker.FsmEventTarget;

namespace Pet.Modules;

internal class Kingsoul
{
internal bool IsLoaded { get; set; }

internal void Load()
{
this.LogMod("Load()");
IsLoaded = true;

// set up as if hero has lantern
KingsoulCharmFsm.GetState("Check").Insert(new FsmUtils.InsertParam
{
Action = new SendEvent
{
eventTarget = Self,
sendEvent = FsmEvent.GetFsmEvent("ACTIVE"),
delay = 0f,
},
Named = "Pet Has Kingsoul",
Before = typeof(PlayerDataBoolTest),
});
KingsoulCharmFsm.SetState("Check");
}

internal void Unload()
{
if (!IsLoaded) return;

this.LogMod("Unload()");
IsLoaded = false;

// recover setup
KingsoulCharmFsm.GetState("Check").RemoveActionByName("Pet Has Kingsoul");
KingsoulCharmFsm.SetState("Check");
}

private PlayMakerFSM KingsoulCharmFsm => HeroController.instance.gameObject.Find("Charm Effects").GetComponent<PlayMakerFSM>(fsm => fsm.FsmName == "White Charm");
}
2 changes: 1 addition & 1 deletion Pet/Pet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<FileVersion></FileVersion>
<OutputPath>bin\$(Configuration)\</OutputPath>
<LangVersion>latest</LangVersion>
<Version>0.1.0</Version>
<Version>0.1.1</Version>
</PropertyGroup>

<Target Name="ClearModAndExportDir" AfterTargets="PostBuildEvent">
Expand Down

0 comments on commit bf89fb2

Please sign in to comment.