Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of FifthChorus v1.0.2
FifthChorus.dll
Decompiled 6 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FifthChorus.Patches; using FifthChorus.Patches.FSM; using FifthChorus.Systems; using FifthChorus.UI; using FifthChorus.Util; using GenericVariableExtension; using HarmonyLib; using HutongGames.PlayMaker; using HutongGames.PlayMaker.Actions; using SilksongTestMod.Actions; using TeamCherry.Localization; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("FifthChorus")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FifthChorus")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("befdf537-2cce-4d11-a71e-a663a05970c7")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace FifthChorus { [BepInPlugin("com.prodigg.fifthchorus", "Fifth Chorus", "1.0.0")] public class Plugin : BaseUnityPlugin { private const string HARMONY_ID = "com.prodigg.fifthchorus"; internal static ManualLogSource Log; private static Harmony _rootHarmony; internal static ConfigEntry<KeyboardShortcut> PracticeMenuKey; private void Awake() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ModLog.Init(((BaseUnityPlugin)this).Logger); ModLog.Info<Plugin>("Fifth Chorus mod initializing..."); PracticeMenuKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Controls", "Open Fifth Chorus Menu", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Open/close the Fifth Chorus Menu."); GameObject val = new GameObject("FifthChorusUIHost"); Object.DontDestroyOnLoad((Object)(object)val); val.AddComponent<FifthChorusMenu>(); ModLog.Info<Plugin>("Fifth Chorus UI initialized."); _rootHarmony = new Harmony("com.prodigg.fifthchorus"); PostLoadPatches.Initialize(); _rootHarmony.PatchAll(typeof(PostLoadPatches)); _rootHarmony.PatchAll(typeof(PlayMakerFSMAwakePatch)); _rootHarmony.PatchAll(typeof(InputCursorPatches.Patch_SetCursorEnabled)); _rootHarmony.PatchAll(typeof(InputCursorPatches.Patch_InputHandler_Update)); _rootHarmony.PatchAll(typeof(SaveGamePatches.Patch_SaveGame_Nullify)); ModLog.Info<Plugin>("Harmony patches applied."); } } } namespace FifthChorus.Util { internal static class FsmDebugUtils { internal static void LogAllDataInFSM(Fsm fsm) { //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) ModLog.Debug(typeof(FsmDebugUtils), "Logging all states in FSM: " + fsm.Name); FsmState[] states = fsm.States; foreach (FsmState val in states) { ModLog.Debug(typeof(FsmDebugUtils), "State: " + val.Name); FsmStateAction[] actions = val.Actions; foreach (FsmStateAction val2 in actions) { ModLog.Debug(typeof(FsmDebugUtils), " Action: " + ((object)val2).GetType().Name); SetParent val3 = (SetParent)(object)((val2 is SetParent) ? val2 : null); if (val3 != null) { ModLog.Debug(typeof(FsmDebugUtils), " GameObject: " + ((NamedVariable)val3.gameObject.GameObject).Name); ModLog.Debug(typeof(FsmDebugUtils), " Parent: " + ((NamedVariable)val3.parent).Name); } SendEventByName val4 = (SendEventByName)(object)((val2 is SendEventByName) ? val2 : null); if (val4 != null) { ModLog.Debug(typeof(FsmDebugUtils), " Event Target GameObject Name: " + ((NamedVariable)val4.eventTarget.gameObject.GameObject).Name); ModLog.Debug(typeof(FsmDebugUtils), " Event: " + val4.sendEvent.Value); ModLog.Debug(typeof(FsmDebugUtils), $" Delay: {val4.delay.Value}"); } ActivateGameObject val5 = (ActivateGameObject)(object)((val2 is ActivateGameObject) ? val2 : null); if (val5 != null) { ModLog.Debug(typeof(FsmDebugUtils), " GameObject: " + ((NamedVariable)val5.gameObject.GameObject).Name); ModLog.Debug(typeof(FsmDebugUtils), $" Activate: {val5.activate.Value}"); } ActivateGameObjectDelay val6 = (ActivateGameObjectDelay)(object)((val2 is ActivateGameObjectDelay) ? val2 : null); if (val6 != null) { ModLog.Debug(typeof(FsmDebugUtils), " GameObject: " + ((NamedVariable)val6.gameObject.GameObject).Name); ModLog.Debug(typeof(FsmDebugUtils), $" Activate: {val6.activate.Value}"); ModLog.Debug(typeof(FsmDebugUtils), $" Delay: {val6.delay.Value}"); } PlayParticleEmitter val7 = (PlayParticleEmitter)(object)((val2 is PlayParticleEmitter) ? val2 : null); if (val7 != null) { ModLog.Debug(typeof(FsmDebugUtils), " GameObject: " + ((NamedVariable)val7.gameObject.GameObject).Name); } PlayParticleEmitterChildren val8 = (PlayParticleEmitterChildren)(object)((val2 is PlayParticleEmitterChildren) ? val2 : null); if (val8 != null) { ModLog.Debug(typeof(FsmDebugUtils), " GameObject: " + ((NamedVariable)val8.gameObject.GameObject).Name); } AnimatePositionTo val9 = (AnimatePositionTo)(object)((val2 is AnimatePositionTo) ? val2 : null); if (val9 != null) { Type typeFromHandle = typeof(FsmDebugUtils); FsmGameObject gameObject = val9.gameObject.GameObject; object obj; if (gameObject == null) { obj = null; } else { GameObject value = gameObject.Value; obj = ((value != null) ? ((Object)value).name : null); } ModLog.Debug(typeFromHandle, " GameObject: " + (string?)obj); ModLog.Debug(typeof(FsmDebugUtils), $" OwnerOption: {val9.gameObject.OwnerOption}"); ModLog.Debug(typeof(FsmDebugUtils), $" ToValue: {val9.toValue.Value}"); ModLog.Debug(typeof(FsmDebugUtils), $" Time: {((EaseFsmAction)val9).time.Value}"); ModLog.Debug(typeof(FsmDebugUtils), $" EaseType: {((EaseFsmAction)val9).easeType}"); } SetPosition val10 = (SetPosition)(object)((val2 is SetPosition) ? val2 : null); if (val10 != null) { Type typeFromHandle2 = typeof(FsmDebugUtils); FsmGameObject gameObject2 = val10.gameObject.GameObject; object obj2; if (gameObject2 == null) { obj2 = null; } else { GameObject value2 = gameObject2.Value; obj2 = ((value2 != null) ? ((Object)value2).name : null); } ModLog.Debug(typeFromHandle2, " GameObject: " + (string?)obj2); ModLog.Debug(typeof(FsmDebugUtils), $" OwnerOption: {val10.gameObject.OwnerOption}"); ModLog.Debug(typeof(FsmDebugUtils), $" Vector: ({val10.x}, {val10.y}, {val10.z})"); ModLog.Debug(typeof(FsmDebugUtils), $" Space: {val10.space}"); ModLog.Debug(typeof(FsmDebugUtils), $" EveryFrame: {val10.everyFrame}"); ModLog.Debug(typeof(FsmDebugUtils), $" LateUpdate: {val10.lateUpdate}"); } if (val2 is AimSlamSelectAndSend aimSlamSelectAndSend) { Type typeFromHandle3 = typeof(FsmDebugUtils); FsmFloat heroX = aimSlamSelectAndSend.heroX; ModLog.Debug(typeFromHandle3, " Hero X Variable: " + ((heroX != null) ? ((NamedVariable)heroX).Name : null)); Type typeFromHandle4 = typeof(FsmDebugUtils); FsmString lastSlam = aimSlamSelectAndSend.lastSlam; ModLog.Debug(typeFromHandle4, " Last Slam Variable: " + ((lastSlam != null) ? ((NamedVariable)lastSlam).Name : null)); } Wait val11 = (Wait)(object)((val2 is Wait) ? val2 : null); if (val11 != null) { ModLog.Debug(typeof(FsmDebugUtils), string.Format(" Wait: time={0}, finishEvent={1}", val11.time, (val11.finishEvent != null) ? val11.finishEvent.Name : "<null>")); } } if (val.Transitions != null) { FsmTransition[] transitions = val.Transitions; foreach (FsmTransition val12 in transitions) { Type typeFromHandle5 = typeof(FsmDebugUtils); string[] obj3 = new string[7] { " Transition: Event '", null, null, null, null, null, null }; FsmEvent fsmEvent = val12.FsmEvent; obj3[1] = ((fsmEvent != null) ? fsmEvent.Name : null) ?? "<null>"; obj3[2] = "' -> State '"; obj3[3] = val12.ToState; obj3[4] = "' (ToFsmState="; FsmState toFsmState = val12.ToFsmState; obj3[5] = ((toFsmState != null) ? toFsmState.Name : null) ?? "null"; obj3[6] = ")"; ModLog.Debug(typeFromHandle5, string.Concat(obj3)); } } } ModLog.Debug(typeof(FsmDebugUtils), "FSM Variables:"); NamedVariable[] allNamedVariables = fsm.Variables.GetAllNamedVariables(); foreach (NamedVariable val13 in allNamedVariables) { ModLog.Debug(typeof(FsmDebugUtils), "- " + val13.Name + " (Type: " + ((object)val13).GetType().Name + ")"); } } } internal static class FsmUtils { internal static FsmEvent EnsureEvent(Fsm fsm, string name, bool isGlobal = false) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown FsmEvent val = fsm.Events?.FirstOrDefault((Func<FsmEvent, bool>)((FsmEvent e) => e != null && e.Name == name)); if (val != null) { return val; } val = new FsmEvent(name); val.IsGlobal = isGlobal; FsmEvent[] array = fsm.Events ?? Array.Empty<FsmEvent>(); Array.Resize(ref array, array.Length + 1); array[^1] = val; fsm.Events = array; ModLog.Info(typeof(FsmUtils), $"Created new FSM event '{name}' (IsGlobal={isGlobal})"); return val; } internal static void EnsureVariable(Fsm fsm, Type varType, string name) { NamedVariable variable = fsm.Variables.GetVariable(name); if (variable == null) { switch (varType.Name) { case "FsmInt": CreateNewIntVariable(fsm, name); break; case "FsmFloat": CreateNewFloatVariable(fsm, name); break; case "FsmBool": CreateNewBoolVariable(fsm, name); break; case "FsmString": CreateNewStringVariable(fsm, name); break; default: ModLog.Error(typeof(FsmUtils), "Unsupported variable type for EnsureVariable: " + varType.Name); break; } ModLog.Info(typeof(FsmUtils), "Created new FSM variable '" + name + "' of type " + varType.Name); } } internal static void CreateNewIntVariable(Fsm fsm, string name, int defaultValue = 0) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown NamedVariable variable = fsm.Variables.GetVariable(name); if (variable == null) { FsmInt element = new FsmInt { Name = name, Value = defaultValue, UseVariable = false }; fsm.Variables.IntVariables = fsm.Variables.IntVariables.Append(element).ToArray(); } } internal static void CreateNewFloatVariable(Fsm fsm, string name, float defaultValue = 0f) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown NamedVariable variable = fsm.Variables.GetVariable(name); if (variable == null) { FsmFloat element = new FsmFloat { Name = name, Value = defaultValue, UseVariable = false }; fsm.Variables.FloatVariables = fsm.Variables.FloatVariables.Append(element).ToArray(); } } internal static void CreateNewBoolVariable(Fsm fsm, string name, bool defaultValue = false) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown NamedVariable variable = fsm.Variables.GetVariable(name); if (variable == null) { FsmBool element = new FsmBool { Name = name, Value = defaultValue, UseVariable = false }; fsm.Variables.BoolVariables = fsm.Variables.BoolVariables.Append(element).ToArray(); } } internal static void CreateNewStringVariable(Fsm fsm, string name, string defaultValue = "") { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown NamedVariable variable = fsm.Variables.GetVariable(name); if (variable == null) { FsmString element = new FsmString { Name = name, Value = defaultValue, UseVariable = false }; fsm.Variables.StringVariables = fsm.Variables.StringVariables.Append(element).ToArray(); } } internal static FsmTransition[] AppendTransition(FsmTransition[] existing, FsmTransition addition) { if (existing == null) { return (FsmTransition[])(object)new FsmTransition[1] { addition }; } List<FsmTransition> list = existing.ToList(); list.Add(addition); ModLog.Info(typeof(FsmUtils), $"Appending new transition on event '{addition.FsmEvent.Name}' to state transitions (was {existing.Length} transitions)"); return list.ToArray(); } } public enum LogLevelFlag { Info, Warn, Error, Debug, Message, Fatal } internal static class ModLog { private enum Level { Info, Warn, Error, Debug, Message, Fatal } private static ManualLogSource _source; private static readonly HashSet<Type> _allowedTypes = new HashSet<Type>(); private static bool _infoEnabled = true; private static bool _warnEnabled = true; private static bool _errorEnabled = true; private static bool _debugEnabled = true; private static bool _messageEnabled = true; private static bool _fatalEnabled = true; private static bool _initialized; public static void Init(ManualLogSource src, IEnumerable<Type> allowedTypes = null, IEnumerable<LogLevelFlag> disabledLevels = null) { _source = src; _allowedTypes.Clear(); if (allowedTypes != null) { foreach (Type allowedType in allowedTypes) { if (allowedType != null) { _allowedTypes.Add(allowedType); } } } _infoEnabled = true; _warnEnabled = true; _errorEnabled = true; _debugEnabled = true; _messageEnabled = true; _fatalEnabled = true; if (disabledLevels != null) { using IEnumerator<LogLevelFlag> enumerator2 = disabledLevels.GetEnumerator(); while (enumerator2.MoveNext()) { switch (enumerator2.Current) { case LogLevelFlag.Info: _infoEnabled = false; break; case LogLevelFlag.Warn: _warnEnabled = false; break; case LogLevelFlag.Error: _errorEnabled = false; break; case LogLevelFlag.Debug: _debugEnabled = false; break; case LogLevelFlag.Message: _messageEnabled = false; break; case LogLevelFlag.Fatal: _fatalEnabled = false; break; } } } _initialized = true; } private static bool ShouldLog(Type from, Level level) { if (!_initialized) { return true; } if (from == null) { return true; } switch (level) { case Level.Info: if (!_infoEnabled) { return false; } break; case Level.Warn: if (!_warnEnabled) { return false; } break; case Level.Error: if (!_errorEnabled) { return false; } break; case Level.Debug: if (!_debugEnabled) { return false; } break; case Level.Message: if (!_messageEnabled) { return false; } break; case Level.Fatal: if (!_fatalEnabled) { return false; } break; } if (_allowedTypes.Count > 0 && !_allowedTypes.Contains(from)) { return false; } return true; } private static string Format(Type from, string msg) { string text = from?.Name ?? "Unknown"; return "[" + text + "] " + msg; } public static void Info<T>(string msg) { Info(typeof(T), msg); } public static void Info(Type from, string msg) { if (ShouldLog(from, Level.Info)) { ManualLogSource source = _source; if (source != null) { source.LogInfo((object)Format(from, msg)); } } } public static void Warn<T>(string msg) { Warn(typeof(T), msg); } public static void Warn(Type from, string msg) { if (ShouldLog(from, Level.Warn)) { ManualLogSource source = _source; if (source != null) { source.LogWarning((object)Format(from, msg)); } } } public static void Error<T>(string msg) { Error(typeof(T), msg); } public static void Error(Type from, string msg) { if (ShouldLog(from, Level.Error)) { ManualLogSource source = _source; if (source != null) { source.LogError((object)Format(from, msg)); } } } public static void Debug<T>(string msg) { Debug(typeof(T), msg); } public static void Debug(Type from, string msg) { if (ShouldLog(from, Level.Debug)) { ManualLogSource source = _source; if (source != null) { source.LogDebug((object)Format(from, msg)); } } } public static void Message<T>(string msg) { Message(typeof(T), msg); } public static void Message(Type from, string msg) { if (ShouldLog(from, Level.Message)) { ManualLogSource source = _source; if (source != null) { source.LogMessage((object)Format(from, msg)); } } } public static void Fatal<T>(string msg) { Fatal(typeof(T), msg); } public static void Fatal(Type from, string msg) { if (ShouldLog(from, Level.Fatal)) { ManualLogSource source = _source; if (source != null) { source.LogFatal((object)Format(from, msg)); } } } } } namespace FifthChorus.UI { public class FifthChorusMenu : MonoBehaviour { [CompilerGenerated] private sealed class <StartSelected>d__13 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public FifthChorusDifficulty diff; public FifthChorusMenu <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <StartSelected>d__13(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>4__this.ToggleMenu(visible: false); ModLog.Info(typeof(FifthChorusMenu), $"Start selected. Beginning bossfight: {diff}"); <>2__current = FifthChorusDifficultyConfig.TeleportToFourthChorus(diff); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private GameObject _canvas; private GameObject _panel; private Text _description; private Button _startBtn; private FifthChorusDifficulty? _selected; public static bool MenuVisible { get; private set; } private void Awake() { CreateMenu(); ToggleMenu(visible: false); SceneManager.sceneLoaded += delegate { ToggleMenu(visible: false); }; } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = Plugin.PracticeMenuKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { GameManager instance = GameManager.instance; if ((Object)(object)((instance != null) ? instance.hero_ctrl : null) != (Object)null) { ToggleMenu(!MenuVisible); if (MenuVisible) { UIManager.instance.inputModule.allowMouseInput = true; } } } if (MenuVisible) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } private void CreateMenu() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Expected O, but got Unknown //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Expected O, but got Unknown //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Expected O, but got Unknown //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Expected O, but got Unknown //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown _canvas = new GameObject("BossPracticeCanvas"); Object.DontDestroyOnLoad((Object)(object)_canvas); Canvas val = _canvas.AddComponent<Canvas>(); val.renderMode = (RenderMode)0; _canvas.AddComponent<CanvasScaler>(); _canvas.AddComponent<GraphicRaycaster>(); if ((Object)(object)Object.FindFirstObjectByType<EventSystem>() == (Object)null) { GameObject val2 = new GameObject("EventSystem"); Object.DontDestroyOnLoad((Object)(object)val2); val2.AddComponent<EventSystem>(); val2.AddComponent<StandaloneInputModule>(); } _panel = new GameObject("BossPracticePanel"); _panel.transform.SetParent(_canvas.transform, false); Image val3 = _panel.AddComponent<Image>(); ((Graphic)val3).color = new Color(0f, 0f, 0f, 0.75f); RectTransform component = _panel.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.sizeDelta = new Vector2(480f, 300f); component.anchoredPosition = Vector2.zero; _panel.transform.localScale = new Vector3(1.15f, 1.15f, 1f); AddLabel(_panel.transform, "Fifth Chorus Config", 22, new Vector2(0f, 110f), (TextAnchor)4); Button val4 = CreateButton(_panel.transform, "Free Play", new Vector2(-165f, 50f)); Button val5 = CreateButton(_panel.transform, "Easy", new Vector2(-55f, 50f)); Button val6 = CreateButton(_panel.transform, "Normal", new Vector2(55f, 50f)); Button val7 = CreateButton(_panel.transform, "Hard", new Vector2(165f, 50f)); ((UnityEvent)val4.onClick).AddListener((UnityAction)delegate { SelectDifficulty(FifthChorusDifficulty.FreePlay); }); ((UnityEvent)val5.onClick).AddListener((UnityAction)delegate { SelectDifficulty(FifthChorusDifficulty.Easy); }); ((UnityEvent)val6.onClick).AddListener((UnityAction)delegate { SelectDifficulty(FifthChorusDifficulty.Normal); }); ((UnityEvent)val7.onClick).AddListener((UnityAction)delegate { SelectDifficulty(FifthChorusDifficulty.Hard); }); _description = AddMultiline(_panel.transform, "Select a difficulty to see details.\nThen press Start to begin.", 16, new Vector2(0f, -30f), new Vector2(420f, 110f)); _startBtn = CreateButton(_panel.transform, "Start", new Vector2(0f, -90f)); ((UnityEvent)_startBtn.onClick).AddListener((UnityAction)delegate { if (_selected.HasValue) { FifthChorusDifficulty value = _selected.Value; ModLog.Info(typeof(FifthChorusMenu), $"Start button clicked, selected={value}"); ((MonoBehaviour)this).StartCoroutine(StartSelected(value)); } }); ((Selectable)_startBtn).interactable = false; AddLabel(_panel.transform, $"Toggle: {Plugin.PracticeMenuKey.Value}", 12, new Vector2(0f, -125f), (TextAnchor)4); } private void SelectDifficulty(FifthChorusDifficulty diff) { _selected = diff; _description.text = DifficultyDescription(diff); ((Selectable)_startBtn).interactable = true; } [IteratorStateMachine(typeof(<StartSelected>d__13))] private IEnumerator StartSelected(FifthChorusDifficulty diff) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <StartSelected>d__13(0) { <>4__this = this, diff = diff }; } private void ToggleMenu(bool visible) { MenuVisible = visible; if ((Object)(object)_panel != (Object)null) { _panel.SetActive(visible); } if ((Object)(object)_canvas != (Object)null) { _canvas.SetActive(visible); } if (!visible) { _selected = null; if ((Object)(object)_description != (Object)null) { _description.text = "Select a difficulty to see details.\nThen press Start to begin."; } if ((Object)(object)_startBtn != (Object)null) { ((Selectable)_startBtn).interactable = false; } } } private static Button CreateButton(Transform parent, string text, Vector2 pos) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(text + "Button"); val.transform.SetParent(parent, false); Image val2 = val.AddComponent<Image>(); ((Graphic)val2).color = new Color(0.2f, 0.2f, 0.2f, 0.9f); RectTransform component = val.GetComponent<RectTransform>(); component.sizeDelta = new Vector2(110f, 40f); component.anchoredPosition = pos; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); component.pivot = val3; Vector2 anchorMin = (component.anchorMax = val3); component.anchorMin = anchorMin; Button val5 = val.AddComponent<Button>(); ColorBlock colors = ((Selectable)val5).colors; ((ColorBlock)(ref colors)).normalColor = ((Graphic)val2).color; ((ColorBlock)(ref colors)).highlightedColor = new Color(0.4f, 0.4f, 0.4f, 0.95f); ((ColorBlock)(ref colors)).pressedColor = new Color(0.12f, 0.12f, 0.12f, 1f); ((Selectable)val5).colors = colors; GameObject val6 = new GameObject("Text"); val6.transform.SetParent(val.transform, false); Text val7 = val6.AddComponent<Text>(); val7.text = text; val7.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); val7.alignment = (TextAnchor)4; ((Graphic)val7).color = Color.white; RectTransform component2 = val6.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; return val5; } private static Text AddLabel(Transform parent, string text, int fontSize, Vector2 pos, TextAnchor align) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Label"); val.transform.SetParent(parent, false); Text val2 = val.AddComponent<Text>(); val2.text = text; val2.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); val2.fontSize = fontSize; val2.alignment = align; ((Graphic)val2).color = Color.white; RectTransform component = val.GetComponent<RectTransform>(); component.sizeDelta = new Vector2(440f, 30f); component.anchoredPosition = pos; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); component.pivot = val3; Vector2 anchorMin = (component.anchorMax = val3); component.anchorMin = anchorMin; return val2; } private static Text AddMultiline(Transform parent, string text, int fontSize, Vector2 pos, Vector2 size) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Description"); val.transform.SetParent(parent, false); Text val2 = val.AddComponent<Text>(); val2.text = text; val2.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); val2.fontSize = fontSize; val2.alignment = (TextAnchor)0; ((Graphic)val2).color = Color.white; val2.horizontalOverflow = (HorizontalWrapMode)0; val2.verticalOverflow = (VerticalWrapMode)0; RectTransform component = val.GetComponent<RectTransform>(); component.sizeDelta = size; component.anchoredPosition = pos; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 0.5f); component.pivot = val3; Vector2 anchorMin = (component.anchorMax = val3); component.anchorMin = anchorMin; return val2; } private static string DifficultyDescription(FifthChorusDifficulty d) { return d switch { FifthChorusDifficulty.FreePlay => "Free Play:\n• Use your current save’s gear, tools, masks, and silk.\n• No changes applied.", FifthChorusDifficulty.Easy => "Easy:\n• 7 masks, 9 silk\n• No upgrades", FifthChorusDifficulty.Normal => "Normal:\n• 6 masks, 9 silk\n• No upgrades, no extra silk skills", FifthChorusDifficulty.Hard => "Hard:\n• 5 masks, 9 silk\n• No tools, no upgrades, no extra silk skills", _ => "", }; } } } namespace FifthChorus.Systems { public enum FifthChorusDifficulty { FreePlay, Easy, Normal, Hard } internal static class FifthChorusDifficultyConfig { [CompilerGenerated] private sealed class <TeleportToFourthChorus>d__15 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public FifthChorusDifficulty diff; private PlayerData <pd>5__1; private FifthChorusDifficulty <>s__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <TeleportToFourthChorus>d__15(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <pd>5__1 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: { <>1__state = -1; ModLog.Info(typeof(FifthChorusDifficultyConfig), $"Warping to Fourth Chorus (diff={diff})"); if (firstInit) { <pd>5__1 = PlayerData.instance; <pd>5__1.ShellShards = 9999; baseNailUpgrades = <pd>5__1.nailUpgrades; baseToolPouchUpgrades = <pd>5__1.ToolPouchUpgrades; baseToolKitUpgrades = <pd>5__1.ToolKitUpgrades; baseMaxHealth = <pd>5__1.maxHealth; baseMaxSilk = <pd>5__1.silkMax; baseHasDash = <pd>5__1.hasDash; baseHasBrolly = <pd>5__1.hasBrolly; baseHasWallJump = <pd>5__1.hasWalljump; baseHasDoubleJump = <pd>5__1.hasDoubleJump; baseHasSuperJump = <pd>5__1.hasSuperJump; baseHasHarpoonDash = <pd>5__1.hasHarpoonDash; baseSilkRegen = <pd>5__1.silkRegenMax; firstInit = false; <pd>5__1 = null; } SetupFourthChorusBase(); FifthChorusDifficulty fifthChorusDifficulty = diff; <>s__2 = fifthChorusDifficulty; switch (<>s__2) { case FifthChorusDifficulty.FreePlay: SetupFreePlay(); break; case FifthChorusDifficulty.Easy: SetupEasy(); break; case FifthChorusDifficulty.Normal: SetupNormal(); break; case FifthChorusDifficulty.Hard: SetupHard(); break; } <>2__current = SceneTransitionUtil.DoTransition("Bone_East_08", "right1"); <>1__state = 1; return true; } case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private const string FourthChorusScene = "Bone_East_08"; private const string FourthChorusGate = "right1"; public static bool firstInit = true; private static int baseNailUpgrades; private static int baseToolPouchUpgrades; private static int baseToolKitUpgrades; private static int baseMaxHealth; private static int baseMaxSilk; private static int baseSilkRegen; private static bool baseHasDash; private static bool baseHasBrolly; private static bool baseHasWallJump; private static bool baseHasDoubleJump; private static bool baseHasSuperJump; private static bool baseHasHarpoonDash; [IteratorStateMachine(typeof(<TeleportToFourthChorus>d__15))] public static IEnumerator TeleportToFourthChorus(FifthChorusDifficulty diff) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <TeleportToFourthChorus>d__15(0) { diff = diff }; } private static void SetupFourthChorusBase() { PlayerData instance = PlayerData.instance; instance.defeatedSongGolem = false; instance.destroyedSongGolemRock = false; instance.encounteredSongGolem = false; } private static void SetupFreePlay() { PlayerData instance = PlayerData.instance; PlayerStateUtils.SetMasks(baseMaxHealth); PlayerStateUtils.SetSilk(baseMaxSilk); instance.nailUpgrades = baseNailUpgrades; instance.ToolPouchUpgrades = baseToolPouchUpgrades; instance.ToolKitUpgrades = baseToolKitUpgrades; instance.hasDash = baseHasDash; instance.hasBrolly = baseHasBrolly; instance.hasWalljump = baseHasWallJump; instance.hasDoubleJump = baseHasDoubleJump; instance.hasSuperJump = baseHasSuperJump; instance.hasHarpoonDash = baseHasHarpoonDash; instance.silkRegenMax = baseSilkRegen; PlayMakerFSM.BroadcastEvent("UPDATE NAIL DAMAGE"); PlayerStateUtils.RefreshMasks(); PlayerStateUtils.RefreshSpool(); } private static void SetupEasy() { PlayerData instance = PlayerData.instance; instance.hasDash = true; instance.hasBrolly = true; PlayerStateUtils.SetMasks(7); PlayerStateUtils.SetSilk(9); PlayerStateUtils.DisableUpgrades(); } private static void SetupNormal() { PlayerData instance = PlayerData.instance; instance.hasDash = true; instance.hasBrolly = true; PlayerStateUtils.SetMasks(6); PlayerStateUtils.SetSilk(9); PlayerStateUtils.DisableUpgrades(); PlayerStateUtils.DisableSilkSkills(); } private static void SetupHard() { PlayerData instance = PlayerData.instance; instance.hasDash = true; instance.hasBrolly = true; PlayerStateUtils.SetMasks(5); PlayerStateUtils.SetSilk(9); PlayerStateUtils.DisableUpgrades(); PlayerStateUtils.DisableSilkSkills(); PlayerStateUtils.RemoveAllTools(); } } internal static class PlayerStateUtils { public static void SetMasks(int newMax) { PlayerData instance = PlayerData.instance; int maxHealth = instance.maxHealth; if (newMax > maxHealth) { int num = newMax - maxHealth; for (int i = 0; i < num; i++) { instance.MaxHealth(); instance.AddToMaxHealth(1); } } else if (newMax < maxHealth) { int num2 = maxHealth - newMax; for (int j = 0; j < num2; j++) { instance.maxHealth--; instance.maxHealthBase--; instance.health = Math.Min(instance.health, instance.maxHealth); } } RefreshMasks(); } public static void RefreshMasks() { //IL_009f: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)GameCameras.instance.hudCanvasSlideOut).transform; GameObject val = null; for (int i = 0; i < transform.childCount; i++) { GameObject gameObject = ((Component)transform.GetChild(i)).gameObject; if (((Object)gameObject).name == "Health") { val = gameObject; break; } } if ((Object)(object)val == (Object)null) { return; } PlayMakerFSM val2 = FSMUtility.LocateMyFSM(val, "Low Health FX"); val2.FsmVariables.FindFsmGameObject("Health 1").Value.transform.localPosition = val2.FsmVariables.FindFsmVector3("H1 Initial Pos").Value; val2.SetState("Check Health"); PlayMakerFSM[] componentsInChildren = val.GetComponentsInChildren<PlayMakerFSM>(); foreach (PlayMakerFSM val3 in componentsInChildren) { if (!(val3.FsmName != "health_display")) { if (((Component)val3).gameObject.activeSelf) { val3.Fsm.OnEnable(); } else { ((Component)val3).gameObject.SetActive(true); } val3.FsmVariables.FindFsmBool("Initialised").Value = true; val3.SetState("Check Max HP"); } } } public static void SetSilk(int newMax) { PlayerData instance = PlayerData.instance; HeroController instance2 = HeroController.instance; int silkMax = instance.silkMax; if (newMax > silkMax) { int num = newMax - silkMax; for (int i = 0; i < num; i++) { instance2.AddToMaxSilk(1); } } else if (newMax < silkMax) { int num2 = silkMax - newMax; for (int j = 0; j < num2; j++) { instance.silkMax--; instance.silk = Math.Min(instance.silk, instance.silkMax); } } RefreshSpool(); instance.IsSilkSpoolBroken = false; EventRegister.SendEvent("SPOOL UNBROKEN", (GameObject)null); } public static void RefreshSpool() { SilkSpool silkSpool = GameCameras.instance.silkSpool; silkSpool.DrawSpool(); } public static void DisableUpgrades() { PlayerData instance = PlayerData.instance; instance.ToolKitUpgrades = 0; instance.ToolPouchUpgrades = 0; instance.nailUpgrades = 0; PlayMakerFSM.BroadcastEvent("UPDATE NAIL DAMAGE"); } public static void DisableSilkSkills() { PlayerData instance = PlayerData.instance; instance.hasHarpoonDash = false; instance.hasWalljump = false; instance.hasDoubleJump = false; instance.hasSuperJump = false; instance.silkRegenMax = 1; } public static void RemoveAllTools() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown PlayerData instance = PlayerData.instance; ToolCrest crestByName = ToolItemManager.GetCrestByName(instance.CurrentCrestID); ToolItemManager.AutoEquip(crestByName, false, true); instance.ExtraToolEquips = new FloatingCrestSlotsData(); } } internal static class SceneTransitionUtil { [CompilerGenerated] private sealed class <DoTransition>d__0 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public string scene; public string gate; private AudioSourceFadeControl[] <>s__1; private int <>s__2; private AudioSourceFadeControl <src>5__3; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DoTransition>d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>s__1 = null; <src>5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; ScreenFaderUtils.Fade(ScreenFaderUtils.GetColour(), Color.black, 1f); <>2__current = (object)new WaitForSeconds(2f); <>1__state = 1; return true; case 1: <>1__state = -1; <>s__1 = Object.FindObjectsByType<AudioSourceFadeControl>((FindObjectsInactive)1, (FindObjectsSortMode)0); for (<>s__2 = 0; <>s__2 < <>s__1.Length; <>s__2++) { <src>5__3 = <>s__1[<>s__2]; <src>5__3.FadeDown(); <src>5__3 = null; } <>s__1 = null; GameManager.instance.BeginSceneTransition(new SceneLoadInfo { SceneName = scene, EntryGateName = gate, Visualization = (SceneLoadVisualizations)0, PreventCameraFadeOut = true }); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(<DoTransition>d__0))] public static IEnumerator DoTransition(string scene, string gate) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DoTransition>d__0(0) { scene = scene, gate = gate }; } } } namespace FifthChorus.Patches { internal static class InputCursorPatches { [HarmonyPatch(typeof(InputHandler), "SetCursorEnabled")] internal static class Patch_SetCursorEnabled { [HarmonyPrefix] private static bool Prefix(ref bool isEnabled) { if (FifthChorusMenu.MenuVisible) { isEnabled = true; } return true; } } [HarmonyPatch(typeof(InputHandler), "Update")] internal static class Patch_InputHandler_Update { [HarmonyPostfix] private static void Postfix() { if (FifthChorusMenu.MenuVisible) { Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; } } } } [HarmonyPatch(typeof(Language), "Get", new Type[] { typeof(string), typeof(string) })] internal static class LanguagePatches { [HarmonyPostfix] private static void PatchText(string key, string sheetTitle, ref string __result) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Invalid comparison between Unknown and I4 //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Invalid comparison between Unknown and I4 ModLog.Debug(typeof(LanguagePatches), "Language.Get called with key='" + key + "', sheetTitle='" + sheetTitle + "', original result='" + __result + "'"); if (key == "SONG_GOLEM_SUPER") { LanguageCode val = Language.CurrentLanguage(); if ((int)val == 44) { __result = "Fifth"; ModLog.Info(typeof(LanguagePatches), "Patched SONG_GOLEM_SUPER text to '" + __result + "'"); } } if (key == "ARCHITECT_MELODY_GAINED") { LanguageCode val2 = Language.CurrentLanguage(); if (!(sheetTitle != "Under") && (int)val2 == 44) { __result = "<hpage>Master, in my travels I met a large construct of fine design. Shaped for song and combat both. Their craft bears your mark. Tell me, why were they made?<page>Chorus units, yes. Harmony, purpose, p-p-pattern. Directive demanded their creation not by choice, by code. To b-b-build as commanded, to sing for Pharloom eternal.<page>But one failed its song, silenced by a warrior beyond the Citadel’s reach. The loss brought shame, retribution was required.<hpage>Retribution? In what sense?<page>Directive: replace. Improve. The next must surpass all before it. Swift, unyielding, p-p-perfect. It would silence what the others could not.<page>It was the..."; } } } } internal static class PostLoadPatches { [CompilerGenerated] private sealed class <OnReturnToMenu>d__3 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public IEnumerator result; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <OnReturnToMenu>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if (result.MoveNext()) { <>2__current = result.Current; <>1__state = 1; return true; } _lateHarmony.UnpatchSelf(); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static Harmony _lateHarmony; internal static void Initialize() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown _lateHarmony = new Harmony("com.prodigg.silksongtestmod.late"); } [HarmonyPostfix] [HarmonyPatch(typeof(GameManager), "SetLoadedGameData", new Type[] { typeof(SaveGameData), typeof(int) })] private static void OnGameLoaded(GameManager __instance) { __instance.GetSaveStatsForSlot(PlayerData.instance.profileID, (Action<SaveStats, string>)delegate { _lateHarmony.PatchAll(typeof(LanguagePatches)); }); } [IteratorStateMachine(typeof(<OnReturnToMenu>d__3))] [HarmonyPostfix] [HarmonyPatch(typeof(GameManager), "ReturnToMainMenu")] private static IEnumerator OnReturnToMenu(IEnumerator result) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <OnReturnToMenu>d__3(0) { result = result }; } } internal static class SaveGamePatches { [HarmonyPatch(typeof(GameManager), "SaveGame", new Type[] { typeof(int), typeof(Action<bool>), typeof(bool), typeof(AutoSaveName) })] internal static class Patch_SaveGame_Nullify { [HarmonyPrefix] private static bool Prefix(int saveSlot, Action<bool> ogCallback, bool withAutoSave, AutoSaveName autoSaveName) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) ModLog.Warn(typeof(Patch_SaveGame_Nullify), $"Blocked GameManager.SaveGame(slot={saveSlot}, auto={withAutoSave}, name={autoSaveName}). " + "Fifth Chorus mod keeps saves unchanged."); ogCallback?.Invoke(obj: true); return false; } } } } namespace FifthChorus.Patches.FSM { internal class FifthChorusCameraControlPatcher { public static void TryPatch(PlayMakerFSM __instance) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown GameObject val = ((__instance != null) ? ((Component)__instance).gameObject : null); if ((Object)(object)val == (Object)null || !((Object)val).name.StartsWith("Boss Scene", StringComparison.OrdinalIgnoreCase) || !string.Equals(__instance.FsmName, "Camera Control", StringComparison.OrdinalIgnoreCase)) { return; } ModLog.Info(typeof(FifthChorusCameraControlPatcher), "Patching Boss Scene Camera Control FSM"); try { Fsm fsm = __instance.Fsm; FsmState state = fsm.GetState("Rock Lock"); if (state == null) { ModLog.Warn(typeof(FifthChorusCameraControlPatcher), "There was no state named Rock Lock. Aborting patch"); return; } state.Transitions = state.Transitions.Append(new FsmTransition { FsmEvent = FsmEvent.GetFsmEvent("Lock Camera"), ToState = "Bot Lock", ToFsmState = fsm.GetState("Bot Lock") }).ToArray(); FsmState state2 = fsm.GetState("State 1"); if (state2 == null) { ModLog.Warn(typeof(FifthChorusCameraControlPatcher), "There was no state named State 1. Aborting patch"); return; } state2.Transitions = state2.Transitions.Append(new FsmTransition { FsmEvent = FsmEvent.GetFsmEvent("Lock Camera"), ToState = "Bot Lock", ToFsmState = fsm.GetState("Bot Lock") }).ToArray(); FsmDebugUtils.LogAllDataInFSM(fsm); ModLog.Info(typeof(FifthChorusCameraControlPatcher), "Patched Camera Control FSM"); } catch (Exception arg) { ModLog.Error(typeof(FifthChorusCameraControlPatcher), $"Exception while patching FSM: {arg}"); } } } internal static class FifthChorusControlPatcher { public static void TryPatch(PlayMakerFSM __instance) { GameObject val = ((__instance != null) ? ((Component)__instance).gameObject : null); if ((Object)(object)val == (Object)null || !((Object)val).name.StartsWith("song_golem", StringComparison.OrdinalIgnoreCase) || !string.Equals(__instance.FsmName, "Control", StringComparison.OrdinalIgnoreCase)) { return; } ModLog.Info(typeof(FifthChorusControlPatcher), "Patching song_golem Control FSM"); try { Fsm fsm = __instance.Fsm; FsmUtils.EnsureVariable(fsm, typeof(FsmString), "LastSlam"); FsmUtils.EnsureVariable(fsm, typeof(FsmInt), "AimSlamCount"); FsmUtils.EnsureEvent(fsm, "P5"); FsmUtils.EnsureEvent(fsm, "Lock Camera", isGlobal: true); CreatePhase5(fsm); PatchPunchState(fsm); PatchPhaseCheck(fsm); PatchPhase1(fsm); PatchPhase2(fsm); PatchPhase3(fsm); PatchPhase4(fsm); PatchHandSlamAntic(fsm); PatchAimSlam(fsm); PatchSummon2(fsm); FsmDebugUtils.LogAllDataInFSM(fsm); ModLog.Info(typeof(FifthChorusControlPatcher), "Patched song_golem Control FSM"); } catch (Exception arg) { ModLog.Error(typeof(FifthChorusControlPatcher), $"Exception while patching FSM: {arg}"); } } private static SendEventByName DuplicateSendEventByNameAction(SendEventByName original, FsmFloat newDelay) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown return new SendEventByName { eventTarget = original.eventTarget, sendEvent = original.sendEvent, delay = newDelay, everyFrame = original.everyFrame }; } private static void PatchPunchState(Fsm fsm) { FsmState state = fsm.GetState("Punch"); if (state == null) { ModLog.Warn(typeof(FifthChorusControlPatcher), "There was no state named Punch. Aborting patch"); return; } List<SendEventByName> list = (from a in state.Actions.OfType<SendEventByName>() where a.sendEvent.Value == "DROP" select a).ToList(); List<FsmStateAction> list2 = new List<FsmStateAction>(); int i; for (i = 0; i < state.Actions.Length; i++) { FsmStateAction obj = state.Actions[i]; SendEventByName val = (SendEventByName)(object)((obj is SendEventByName) ? obj : null); if (val != null && val.sendEvent.Value == "DROP") { break; } list2.Add(state.Actions[i]); } foreach (SendEventByName item in list) { list2.Add((FsmStateAction)(object)DuplicateSendEventByNameAction(item, FsmFloat.op_Implicit(0f))); list2.Add((FsmStateAction)(object)DuplicateSendEventByNameAction(item, FsmFloat.op_Implicit(0f))); list2.Add((FsmStateAction)(object)DuplicateSendEventByNameAction(item, FsmFloat.op_Implicit(0f))); } for (i += list.Count; i < state.Actions.Length; i++) { list2.Add(state.Actions[i]); } state.Actions = list2.ToArray(); Wait val2 = state.Actions.OfType<Wait>().FirstOrDefault(); if (val2 != null) { val2.time = FsmFloat.op_Implicit(0.9f); } ModLog.Info(typeof(FifthChorusControlPatcher), "Successfully patched Punch state."); } private static void PatchPhaseCheck(Fsm fsm) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown FsmState state = fsm.GetState("Phase Check"); if (state == null) { ModLog.Warn(typeof(FifthChorusControlPatcher), "There was no state named Phase Check. Aborting patch"); return; } IntSwitch val = state.Actions.OfType<IntSwitch>().FirstOrDefault(); if (val != null) { FsmInt[] array = val.compareTo; Array.Resize(ref array, array.Length + 1); array[^1] = FsmInt.op_Implicit(5); val.compareTo = array; FsmEvent[] array2 = val.sendEvent; Array.Resize(ref array2, array2.Length + 1); array2[^1] = FsmEvent.GetFsmEvent("P5"); val.sendEvent = array2; } state.Transitions = FsmUtils.AppendTransition(state.Transitions, new FsmTransition { FsmEvent = FsmEvent.GetFsmEvent("P5"), ToState = "P5", ToFsmState = fsm.GetState("P5") }); ModLog.Info(typeof(FifthChorusControlPatcher), "Successfully patched Phase Check."); } private static void PatchPhase1(Fsm fsm) { FsmState state = fsm.GetState("P1"); if (state == null) { ModLog.Warn(typeof(FifthChorusControlPatcher), "There was no state named P1. Aborting patch"); return; } SetFloatValue val = state.Actions.OfType<SetFloatValue>().FirstOrDefault((Func<SetFloatValue, bool>)((SetFloatValue a) => ((NamedVariable)a.floatVariable).Name == "Idle Time")); if (val != null) { val.floatValue = FsmFloat.op_Implicit(0.1f); } SendRandomEventV4 val2 = state.Actions.OfType<SendRandomEventV4>().FirstOrDefault(); if (val2 != null) { val2.weights = (FsmFloat[])(object)new FsmFloat[3] { FsmFloat.op_Implicit(1f), FsmFloat.op_Implicit(0f), FsmFloat.op_Implicit(0f) }; } ModLog.Info(typeof(FifthChorusControlPatcher), "Successfully patched Phase 1."); } private static void PatchPhase2(Fsm fsm) { FsmState state = fsm.GetState("P2"); if (state == null) { ModLog.Warn(typeof(FifthChorusControlPatcher), "There was no state named P2. Aborting patch"); return; } SetFloatValue val = state.Actions.OfType<SetFloatValue>().FirstOrDefault((Func<SetFloatValue, bool>)((SetFloatValue a) => ((NamedVariable)a.floatVariable).Name == "Idle Time")); if (val != null) { val.floatValue = FsmFloat.op_Implicit(0.2f); } SendRandomEventV4 val2 = state.Actions.OfType<SendRandomEventV4>().FirstOrDefault(); if (val2 != null) { val2.weights = (FsmFloat[])(object)new FsmFloat[4] { FsmFloat.op_Implicit(1f), FsmFloat.op_Implicit(0f), FsmFloat.op_Implicit(0f), FsmFloat.op_Implicit(0f) }; val2.eventMax = (FsmInt[])(object)new FsmInt[4] { FsmInt.op_Implicit(1), FsmInt.op_Implicit(0), FsmInt.op_Implicit(0), FsmInt.op_Implicit(1) }; val2.missedMax = (FsmInt[])(object)new FsmInt[4] { FsmInt.op_Implicit(1), FsmInt.op_Implicit(99), FsmInt.op_Implicit(99), FsmInt.op_Implicit(1) }; } ModLog.Info(typeof(FifthChorusControlPatcher), "Successfully patched Phase 2."); } private static void PatchPhase3(Fsm fsm) { FsmState state = fsm.GetState("P3"); if (state == null) { ModLog.Warn(typeof(FifthChorusControlPatcher), "There was no state named P3. Aborting patch"); return; } SetFloatValue val = state.Actions.OfType<SetFloatValue>().FirstOrDefault((Func<SetFloatValue, bool>)((SetFloatValue a) => ((NamedVariable)a.floatVariable).Name == "Idle Time")); if (val != null) { val.floatValue = FsmFloat.op_Implicit(0.15f); } SendRandomEventV4 val2 = state.Actions.OfType<SendRandomEventV4>().FirstOrDefault(); if (val2 != null) { val2.weights = (FsmFloat[])(object)new FsmFloat[4] { FsmFloat.op_Implicit(1f), FsmFloat.op_Implicit(0f), FsmFloat.op_Implicit(0f), FsmFloat.op_Implicit(0f) }; val2.eventMax = (FsmInt[])(object)new FsmInt[4] { FsmInt.op_Implicit(2), FsmInt.op_Implicit(0), FsmInt.op_Implicit(0), FsmInt.op_Implicit(1) }; val2.missedMax = (FsmInt[])(object)new FsmInt[4] { FsmInt.op_Implicit(1), FsmInt.op_Implicit(99), FsmInt.op_Implicit(99), FsmInt.op_Implicit(2) }; } ModLog.Info(typeof(FifthChorusControlPatcher), "Successfully patched Phase 3."); } private static void PatchPhase4(Fsm fsm) { FsmState state = fsm.GetState("P4"); if (state == null) { ModLog.Warn(typeof(FifthChorusControlPatcher), "There was no state named P4. Aborting patch"); return; } SetFloatValue val = state.Actions.OfType<SetFloatValue>().FirstOrDefault((Func<SetFloatValue, bool>)((SetFloatValue a) => ((NamedVariable)a.floatVariable).Name == "Idle Time")); if (val != null) { val.floatValue = FsmFloat.op_Implicit(0.15f); } SendRandomEventV4 val2 = state.Actions.OfType<SendRandomEventV4>().FirstOrDefault(); if (val2 != null) { val2.weights = (FsmFloat[])(object)new FsmFloat[3] { FsmFloat.op_Implicit(1f), FsmFloat.op_Implicit(0f), FsmFloat.op_Implicit(0f) }; val2.eventMax = (FsmInt[])(object)new FsmInt[3] { FsmInt.op_Implicit(99), FsmInt.op_Implicit(0), FsmInt.op_Implicit(0) }; val2.missedMax = (FsmInt[])(object)new FsmInt[3] { FsmInt.op_Implicit(99), FsmInt.op_Implicit(99), FsmInt.op_Implicit(99) }; } ModLog.Info(typeof(FifthChorusControlPatcher), "Successfully patched Phase 4."); } private static void CreatePhase5(Fsm fsm) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Expected O, but got Unknown //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Expected O, but got Unknown FsmState val = new FsmState(fsm) { Name = "P5" }; fsm.States = fsm.States.Append(val).ToArray(); SetFloatValue val2 = new SetFloatValue { floatVariable = fsm.Variables.GetFsmFloat("Idle Time"), floatValue = FsmFloat.op_Implicit(0.15f) }; SendRandomEventV4 val3 = new SendRandomEventV4(); val3.events = (FsmEvent[])(object)new FsmEvent[2] { ((IEnumerable<FsmEvent>)fsm.Events).FirstOrDefault((Func<FsmEvent, bool>)((FsmEvent e) => string.Equals(e.Name, "AIM SLAM", StringComparison.Ordinal))), ((IEnumerable<FsmEvent>)fsm.Events).FirstOrDefault((Func<FsmEvent, bool>)((FsmEvent e) => string.Equals(e.Name, "COAL BARRAGE", StringComparison.Ordinal))) }; val3.weights = (FsmFloat[])(object)new FsmFloat[2] { FsmFloat.op_Implicit(1f), FsmFloat.op_Implicit(0f) }; val3.eventMax = (FsmInt[])(object)new FsmInt[2] { FsmInt.op_Implicit(2), FsmInt.op_Implicit(1) }; val3.missedMax = (FsmInt[])(object)new FsmInt[2] { FsmInt.op_Implicit(1), FsmInt.op_Implicit(1) }; val3.activeBool = FsmBool.op_Implicit(false); SendRandomEventV4 val4 = val3; val.Actions = (FsmStateAction[])(object)new FsmStateAction[2] { (FsmStateAction)val2, (FsmStateAction)val4 }; val.Transitions = (FsmTransition[])(object)new FsmTransition[2] { new FsmTransition { FsmEvent = ((IEnumerable<FsmEvent>)fsm.Events).FirstOrDefault((Func<FsmEvent, bool>)((FsmEvent e) => string.Equals(e.Name, "AIM SLAM", StringComparison.Ordinal))), ToState = "Aim Slam", ToFsmState = fsm.GetState("Aim Slam") }, new FsmTransition { FsmEvent = ((IEnumerable<FsmEvent>)fsm.Events).FirstOrDefault((Func<FsmEvent, bool>)((FsmEvent e) => string.Equals(e.Name, "COAL BARRAGE", StringComparison.Ordinal))), ToState = "Punch Antic", ToFsmState = fsm.GetState("Punch Antic") } }; } private static void PatchHandSlamAntic(Fsm fsm) { FsmState state = fsm.GetState("HandSlam Antic"); if (state == null) { ModLog.Warn(typeof(FifthChorusControlPatcher), "There was no state named Hand Slam Antic. Aborting patch"); } Wait val = state.Actions.OfType<Wait>().FirstOrDefault(); if (val != null) { val.time = FsmFloat.op_Implicit(0.4f); } ModLog.Info(typeof(FifthChorusControlPatcher), "Successfully patched Hand Slam Antic state."); } private static void PatchAimSlam(Fsm fsm) { FsmState state = fsm.GetState("Aim Slam"); if (state == null) { ModLog.Warn(typeof(FifthChorusControlPatcher), "There was no state named Aim Slam. Aborting patch"); return; } FsmStateAction val = state.Actions.FirstOrDefault(); if (val != null) { state.Actions = (FsmStateAction[])(object)new FsmStateAction[1] { val }; } AimSlamSelectAndSend item = new AimSlamSelectAndSend { heroX = state.Actions.OfType<GetPosition>().FirstOrDefault()?.x, lastSlam = VariableExtensionsGeneric.GetVariable<FsmString>((object)fsm, "LastSlam"), phase = fsm.Variables.GetFsmInt("Phase"), aimSlamCount = fsm.Variables.GetFsmInt("AimSlamCount") }; List<FsmStateAction> list = state.Actions.ToList(); list.Add((FsmStateAction)(object)item); state.Actions = list.ToArray(); ModLog.Info(typeof(FifthChorusControlPatcher), "Successfully patched Aim Slam state."); } private static void PatchSummon2(Fsm fsm) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown FsmState state = fsm.GetState("Summon 2"); if (state == null) { ModLog.Warn(typeof(FifthChorusControlPatcher), "There was no state named Summon 2. Aborting patch"); return; } FsmGameObject fsmGameObject = fsm.Variables.GetFsmGameObject("Head"); SetInvincibilityDirection item = new SetInvincibilityDirection { gameObject = new FsmOwnerDefault { OwnerOption = (OwnerDefaultOption)1, GameObject = fsmGameObject }, invincibilityDirection = new FsmInt { Value = 0 } }; List<FsmStateAction> list = state.Actions.ToList(); list.Add((FsmStateAction)(object)item); state.Actions = list.ToArray(); ModLog.Info(typeof(FifthChorusControlPatcher), "Successfully patched Summon 2 state."); } } internal static class FifthChorusEnvironmentPatcher { public static void TryPatch(PlayMakerFSM __instance) { try { RemoveUpdraftRegion(__instance); } catch (Exception arg) { ModLog.Error(typeof(FifthChorusEnvironmentPatcher), $"Exception while patching environment FSMs: {arg}"); } } private static void RemoveUpdraftRegion(PlayMakerFSM __instance) { GameObject val = ((__instance != null) ? ((Component)__instance).gameObject : null); if (!((Object)(object)val == (Object)null) && (((Object)val).name.Equals("Updraft Region", StringComparison.OrdinalIgnoreCase) || ((Object)val).name.Equals("Updraft Region (1)", StringComparison.OrdinalIgnoreCase)) && string.Equals(__instance.FsmName, "Control", StringComparison.OrdinalIgnoreCase)) { ModLog.Info(typeof(FifthChorusCameraControlPatcher), "Patching " + ((Object)val).name); val.SetActive(false); ModLog.Info(typeof(FifthChorusCameraControlPatcher), "Patched " + ((Object)val).name); } } } internal static class FifthChorusHeadPatcher { public static void TryPatch(PlayMakerFSM __instance) { GameObject val = ((__instance != null) ? ((Component)__instance).gameObject : null); if ((Object)(object)val == (Object)null || !((Object)val).name.StartsWith("SG_head", StringComparison.OrdinalIgnoreCase)) { return; } ModLog.Info(typeof(FifthChorusHeadPatcher), "Patching song_golem_head object"); HealthManager component = val.GetComponent<HealthManager>(); if ((Object)(object)component == (Object)null) { return; } component.hp = 515; ModLog.Error(typeof(FifthChorusCameraControlPatcher), $"HealthManager found: Starting Health = {component.hp}"); component.IsInvincible = true; ModLog.Info(typeof(FifthChorusHeadPatcher), $"Patched song_golem_head HealthManager: InvincibleFromDirection = {component.InvincibleFromDirection}, IsInvincible = {component.IsInvincible}"); try { ModLog.Info(typeof(FifthChorusHeadPatcher), "Patching song_golem_head FSMs"); Fsm fsm = __instance.Fsm; PatchFourthChorusHeadExplosionFSM(fsm); PatchFourthChorusHeadPhaseControl(fsm); FsmDebugUtils.LogAllDataInFSM(fsm); ModLog.Info(typeof(FifthChorusCameraControlPatcher), "Patched song_golem_head FSMs"); } catch (Exception arg) { ModLog.Error(typeof(FifthChorusCameraControlPatcher), $"Exception while patching FSM: {arg}"); } } private static void PatchFourthChorusHeadPhaseControl(Fsm fsm) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown if (!string.Equals(fsm.Name, "Phase Control", StringComparison.OrdinalIgnoreCase)) { return; } ModLog.Info(typeof(FifthChorusCameraControlPatcher), "Patching song_golem_head Control FSM"); GameObject val = GameObject.Find("DropBomb Rock SG"); GameObject obj = GameObject.Find("explode_wall"); GameObject obj2 = GameObject.Find("explode_wall (1)"); List<GameObject> list = new List<GameObject>(); AddToEnableListIfNotNull(list, val, "Rock"); AddToEnableListIfNotNull(list, obj, "Wall"); AddToEnableListIfNotNull(list, obj2, "Wall 2"); FsmState state = fsm.GetState("Stun 3"); foreach (GameObject item2 in list) { ActivateGameObject item = new ActivateGameObject { gameObject = new FsmOwnerDefault { OwnerOption = (OwnerDefaultOption)1, GameObject = FsmGameObject.op_Implicit(item2) }, activate = FsmBool.op_Implicit(true), recursive = FsmBool.op_Implicit(false), resetOnExit = false, everyFrame = false }; List<FsmStateAction> list2 = state.Actions.ToList(); list2.Add((FsmStateAction)(object)item); state.Actions = list2.ToArray(); ModLog.Info(typeof(FifthChorusCameraControlPatcher), "Added ActivateGameObject action in Stun 3 state"); } ModLog.Debug(typeof(FifthChorusCameraControlPatcher), $"Found rock: {(Object)(object)val != (Object)null}"); ModLog.Info(typeof(FifthChorusCameraControlPatcher), "Patched song_golem_head Control FSM"); } private static void AddToEnableListIfNotNull(List<GameObject> list, GameObject obj, string textForWarning) { if ((Object)(object)obj == (Object)null) { ModLog.Warn(typeof(FifthChorusCameraControlPatcher), "Object " + textForWarning + " to enable is null, skipping."); return; } list.Add(obj); obj.SetActive(false); } private static void PatchFourthChorusHeadExplosionFSM(Fsm fsm) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_00f0: Expected O, but got Unknown //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Expected O, but got Unknown //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Expected O, but got Unknown //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Expected O, but got Unknown if (string.Equals(fsm.Name, "Receive Explosion Dmg", StringComparison.OrdinalIgnoreCase)) { ModLog.Info(typeof(FifthChorusCameraControlPatcher), "Patching song_golem_head Recieve Explosion Dmg FSM"); FsmState state = fsm.GetState("Take Damage"); TakeDamage val = state.Actions.OfType<TakeDamage>().FirstOrDefault(); val.DamageDealt = FsmInt.op_Implicit(0); SetInvincibilityDirection item = new SetInvincibilityDirection { gameObject = new FsmOwnerDefault { OwnerOption = (OwnerDefaultOption)0 }, invincibilityDirection = new FsmInt { Value = 4 } }; FsmGameObject fsmGameObject = fsm.Variables.GetFsmGameObject("Golem"); SetFsmInt item2 = new SetFsmInt { gameObject = new FsmOwnerDefault { OwnerOption = (OwnerDefaultOption)1, GameObject = fsmGameObject }, fsmName = FsmString.op_Implicit("Control"), variableName = FsmString.op_Implicit("Phase"), setValue = new FsmInt { Value = 5 } }; GameObject obj = GameObject.Find("Boss Scene"); PlayMakerFSM val2 = ((obj != null) ? ((IEnumerable<PlayMakerFSM>)obj.GetComponents<PlayMakerFSM>()).FirstOrDefault((Func<PlayMakerFSM, bool>)((PlayMakerFSM f) => f.FsmName == "Camera Control")) : null); ModLog.Info(typeof(FifthChorusCameraControlPatcher), $"Found Camera Control FSM: {(Object)(object)val2 != (Object)null}"); SendEventByName item3 = new SendEventByName { eventTarget = new FsmEventTarget { target = (EventTarget)3, fsmComponent = val2 }, sendEvent = new FsmString { Value = "Lock Camera" }, delay = new FsmFloat { Value = 0f }, everyFrame = false }; List<FsmStateAction> list = state.Actions.ToList(); list.Add((FsmStateAction)(object)item); list.Add((FsmStateAction)(object)item2); list.Add((FsmStateAction)(object)item3); state.Actions = list.ToArray(); ModLog.Info(typeof(FifthChorusCameraControlPatcher), "Patched song_golem_head Recieve Explosion Dmg FSM"); } } } internal static class PlayMakerFSMAwakePatch { [HarmonyPostfix] [HarmonyPatch(typeof(PlayMakerFSM), "Awake")] private static void Postfix(PlayMakerFSM __instance) { GameObject val = ((__instance != null) ? ((Component)__instance).gameObject : null); if ((Object)(object)val != (Object)null && ((__instance != null) ? __instance.FsmName : null) != null) { ModLog.Debug(typeof(PlayMakerFSMAwakePatch), "Found FSM: " + ((Object)val).name + " - " + __instance.FsmName); } FifthChorusControlPatcher.TryPatch(__instance); FifthChorusHeadPatcher.TryPatch(__instance); FifthChorusCameraControlPatcher.TryPatch(__instance); FifthChorusEnvironmentPatcher.TryPatch(__instance); } } } namespace FifthChorus.Patches.FSM.Fourth_Chorus { internal static class FifthChorusConstants { public const string LAST_SLAM_VARIABLE_NAME = "LastSlam"; public const string AIM_SLAM_COUNT_VARIABLE_NAME = "AimSlamCount"; public const string PHASE_VARIABLE_NAME = "Phase"; public const string LOCK_CAMERA_VARIABLE_NAME = "Lock Camera"; public const string BOT_LOCK_VARIABLE_NAME = "Bot Lock"; public const string PHASE_5_EVENT_NAME = "P5"; public const string PHASE_5_STATE_NAME = "P5"; } } namespace SilksongTestMod.Actions { [ActionCategory(/*Could not decode attribute arguments.*/)] [Tooltip("Selects slam from Hero X; if it repears LastSlam, nudge to the nearest neighbor; then sends the SLAM event")] public class AimSlamSelectAndSend : FsmStateAction { public FsmFloat heroX; public FsmString lastSlam; public FsmInt aimSlamCount; public FsmInt phase; private const float EDGE_L_ML = 74.55f; private const float EDGE_ML_M = 76.73f; private const float EDGE_M_MR = 83.6f; private const float EDGE_MR_R = 86.26f; private bool phase1OrderInit; private string[] phase1Order; public override void OnEnter() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown if (aimSlamCount == null) { aimSlamCount = new FsmInt { Value = 0 }; } if (lastSlam == null) { lastSlam = new FsmString(); } if (phase != null && phase.Value == 1 && aimSlamCount.Value < 3) { if (!phase1OrderInit) { List<string> list = new List<string> { "SLAM L", "SLAM R" }; int num = Random.Range(0, 2); List<string> list2 = list; int index = num; string value = list[num]; string value2 = list[0]; list[0] = value; list2[index] = value2; int index2 = Random.Range(1, 3); list.Insert(index2, "SLAM M"); phase1Order = list.ToArray(); phase1OrderInit = true; ModLog.Info(typeof(AimSlamSelectAndSend), "Phase 1 slam order initialized: " + string.Join(", ", phase1Order)); } string state = phase1Order[aimSlamCount.Value]; lastSlam.Value = state; FsmEvent val = ((IEnumerable<FsmEvent>)((FsmStateAction)this).Fsm.Events).FirstOrDefault((Func<FsmEvent, bool>)((FsmEvent e) => string.Equals(e.Name, state, StringComparison.Ordinal))); if (val != null) { ((FsmStateAction)this).Fsm.Event(val); } FsmInt obj = aimSlamCount; obj.Value += 1; ((FsmStateAction)this).Finish(); } else { float value3 = heroX.Value; string picked = PickBaseState(value3); string text = lastSlam.Value ?? ""; if (!string.IsNullOrEmpty(text) && string.Equals(picked, text, StringComparison.Ordinal)) { picked = Nudge(picked, value3); } lastSlam.Value = picked; FsmEvent[] events = ((FsmStateAction)this).Fsm.Events; FsmEvent val2 = ((IEnumerable<FsmEvent>)events).FirstOrDefault((Func<FsmEvent, bool>)((FsmEvent e) => string.Equals(e.Name, picked, StringComparison.Ordinal))); if (val2 == null) { ModLog.Error(typeof(AimSlamSelectAndSend), "Could not find event for slam state '" + picked + "'"); ((FsmStateAction)this).Finish(); } else { ((FsmStateAction)this).Fsm.Event(val2); ((FsmStateAction)this).Finish(); } } } private static string PickBaseState(float x) { if (x < 74.55f) { return "SLAM L"; } if (x < 76.73f) { return "SLAM ML"; } if (x < 83.6f) { return "SLAM M"; } if (x < 86.26f) { return "SLAM MR"; } return "SLAM R"; } private static string Nudge(string cand, float x) { float num = 75.64f; float num2 = 80.165f; float num3 = 84.93f; return cand switch { "SLAM L" => "SLAM ML", "SLAM R" => "SLAM MR", "SLAM ML" => (x < num) ? "SLAM L" : "SLAM M", "SLAM M" => (x < num2) ? "SLAM ML" : "SLAM MR", "SLAM MR" => (x < num3) ? "SLAM M" : "SLAM R", _ => cand, }; } public override string ErrorCheck() { if (heroX == null) { return "Hero X is not set."; } if (lastSlam == null) { return "LastSlam is not set."; } return ""; } } [ActionCategory(/*Could not decode attribute arguments.*/)] [Tooltip("Sets the invincibilityDirection of the gameObject")] public class SetInvincibilityDirection : FsmStateAction { [RequiredField] [Tooltip("The GameObject to set the invincibility direction on.")] public FsmOwnerDefault gameObject; [Tooltip("The invincibility direction to set.")] public FsmInt invincibilityDirection; public override void Reset() { gameObject = null; invincibilityDirection = FsmInt.op_Implicit(4); } public override void OnEnter() { GameObject ownerDefaultTarget = ((FsmStateAction)this).Fsm.GetOwnerDefaultTarget(gameObject); if ((Object)(object)ownerDefaultTarget == (Object)null) { ModLog.Warn(typeof(SetInvincibilityDirection), "SetInvincibilityDirection: GameObject is null"); ((FsmStateAction)this).Finish(); return; } HealthManager component = ownerDefaultTarget.GetComponent<HealthManager>(); if ((Object)(object)component == (Object)null) { ModLog.Warn(typeof(SetInvincibilityDirection), "SetInvincibilityDirection: HealthManager component not found on GameObject"); ((FsmStateAction)this).Finish(); return; } component.InvincibleFromDirection = invincibilityDirection.Value; if (invincibilityDirection.Value == 4) { component.IsInvincible = false; } ((FsmStateAction)this).Finish(); } } }