-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.cs
71 lines (56 loc) · 1.93 KB
/
Plugin.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using HutongGames.PlayMaker;
using ProjectStar.Data;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace CatQuest3SpiritHide;
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
public class Plugin : BaseUnityPlugin
{
internal static new ManualLogSource Logger;
public static GameObject spirit;
private void Awake()
{
// Plugin startup logic
Logger = base.Logger;
new Harmony(MyPluginInfo.PLUGIN_GUID).PatchAll();
Logger.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");
}
}
[HarmonyPatch(typeof(PlayerSpiritBehaviour))]
class ProloguePatch {
[HarmonyPatch(nameof(PlayerSpiritBehaviour.Start))]
[HarmonyPostfix]
static void StartPostfix(PlayerSpiritBehaviour __instance) {
Plugin.spirit = __instance.transform.GetChild(0).gameObject;
Plugin.spirit.SetActive(false);
}
}
[HarmonyPatch(typeof(FsmStateAction))]
class FsmStateActionPatch {
static bool IsSpiritDialogue(FsmStateAction action) {
return action is BaseDialogueAction dialogueAction
&& dialogueAction.positionType == SpeakerPositionType.Spirit;
}
[HarmonyPatch(nameof(FsmStateAction.OnEnter))]
[HarmonyPostfix]
static void OnEnterPatch(FsmStateAction __instance) {
if (IsSpiritDialogue(__instance))
Plugin.spirit.SetActive(true);
}
[HarmonyPatch(nameof(FsmStateAction.OnExit))]
[HarmonyPostfix]
public static void OnExitPatch(FsmStateAction __instance) {
if (IsSpiritDialogue(__instance))
Plugin.spirit.SetActive(false);
}
}
[HarmonyPatch(typeof(AddDialogueFocus))]
class AddDialogueFocusPatch {
[HarmonyPatch(nameof(AddDialogueFocus.OnExit))]
[HarmonyPostfix]
public static void OnExitPatch(FsmStateAction __instance) => FsmStateActionPatch.OnExitPatch(__instance);
}