public static void NewGameInit() { var memory = Randomizer.Memory; if (!memory.IsLoadingGame()) { Randomizer.Log("New Game Init", false); SaveController.SetAbility(AbilityType.SpiritEdge); foreach (UberState s in DefaultUberStates) { memory.WriteUberState(s); } foreach (UberState s in Kuberstates) { memory.WriteUberState(s); } foreach (UberState s in DialogAndRumors) { memory.WriteUberState(s); } if (SeedController.KSDoorsOpen) { foreach (UberState s in KeystoneDoors) { memory.WriteUberState(s); } } if (!AHK.IniFlag("ShowShortCutscenes")) { foreach (UberState s in ShortCutscenes) { memory.WriteUberState(s); } } if (!AHK.IniFlag("ShowLongCutscenes")) { foreach (UberState s in LongCutscenes) { memory.WriteUberState(s); } } if (PsuedoLocs.GAME_START.Pickup().NonEmpty) { Randomizer.InputUnlockCallback = () => { PsuedoLocs.GAME_START.Pickup().Grant(); InterOp.magic_function(); InterOp.save(); }; } InterOp.discover_everything(); InterOp.bind_sword(); InterOp.save(); NeedsNewGameInit = false; } }
public virtual void Grant(bool skipBase = false) { if (skipBase) { return; } if (Frames > 0) { AHK.Pickup(ToString(), Frames); } SaveController.Data.FoundCount++; if (NeedsMagic()) { InterOp.magic_function(); } }
public static void OnLoad(int slot, int backupSlot = -1) { try { if (slot != CurrentSlot) { if (Randomizer.InputUnlockCallback != null) { AHK.Print("Warning: Callback overwritten on slot change!", 240); Randomizer.InputUnlockCallback = null; } // slot swap CurrentSlot = slot; Data = new SaveData(slot); } UberStateController.SkipListenersNextUpdate = true; Data.Load(backupSlot); if (DidWeJustDie) { InterOp.magic_function(); } } catch (Exception e) { Randomizer.Error("SaveCont.OnLoad", e); } }
public static void Tick() { var signal = Engine.ExecFunction("Tick"); if (signal != null && signal != "none") { Engine.SetVar("signal", "none"); switch (signal) { case "reload": if (FramesTillUnlockReload == 0) { FramesTillNextSend = 0; SeedController.ReadSeed(); Randomizer.Memory.OnInit(); if (Randomizer.Memory.GameState == Memory.GameState.Game) { PsuedoLocs.RELOAD_SEED.Pickup().Grant(); } FramesTillUnlockReload = 60; } break; case "lastPickup": FramesTillNextSend = 1; // the only reason this isn't = 0 is that spamming this could get really annoying MessageQueue.Enqueue(Last); break; case "hintMessage": HintsController.ShowHintMessage(); break; case "dev": Randomizer.Dev = !Randomizer.Dev; Randomizer.Log($"Dev: {Randomizer.Dev}"); break; case "exitapp": Environment.Exit(Environment.ExitCode); break; case "toggleDebug": Randomizer.Memory.Debug = !Randomizer.Memory.Debug; Print($"Debug {(Randomizer.Memory.Debug ? "enabled" : "disabled")}", toMessageLog: false); break; case "toggleCursorLock": Print($"Cursor Lock {(InterOp.toggle_cursorlock() ? "enabled" : "disabled")}", toMessageLog: false); break; case "test1": PsuedoLocs.BINDING_ONE.Pickup().Grant(); break; case "test2": PsuedoLocs.BINDING_TWO.Pickup().Grant(); break; case "test3": PsuedoLocs.BINDING_THREE.Pickup().Grant(); break; case "test4": Print("magic", 180, false); InterOp.magic_function(); break; case "test5": tpCheatToggle = !tpCheatToggle; Print($"TPCheat {(tpCheatToggle ? "enabled" : "disabled")}"); break; default: Randomizer.Log($"Recieved unknown signal {signal}"); break; } } FramesTillUnlockReload = Math.Max(0, FramesTillUnlockReload - 1); if (FramesTillNextSend > 0) { FramesTillNextSend--; } else { if (CanPrint) { Current = MessageQueue.Peek(); FramesTillNextSend = Current.Frames; try { InterOp.clear_visible_hints(); InterOp.display_hint(InterOp.Util.getIl2cppStringPointer(Current.Text), Current.Frames / 60f); if (IniFlag("LogOnPrint")) { Randomizer.Log($"Sending {Current.Text} for {Current.Frames} ({MessageQueue.Count} remaining in queue)", false); } MessageQueue.Dequeue(); } catch (Exception e) { Randomizer.Error("AHK.sendMsg", e, false); } } else { Current = null; } } }