public override void Process(string scene, Object changeObj) { if (scene != _sceneName || !(changeObj is PlayMakerFSM fsm) || fsm.FsmName != _fsmName || fsm.gameObject.name != _objectName) { return; } FsmState pdBool = fsm.GetState("PD Bool?"); FsmState charm = fsm.GetState("Charm?"); FsmState getCharm = fsm.GetState("Get Charm"); // Remove actions that stop shiny from spawning pdBool.RemoveActionsOfType <PlayerDataBoolTest>(); pdBool.RemoveActionsOfType <StringCompare>(); // Add our own check to stop the shiny from being grabbed twice pdBool.AddAction( new RandomizerExecuteLambda(() => fsm.SendEvent( RandomizerMod.Instance.Settings.CheckLocationFound(_location) ? "COLLECTED" : null ))); // Mimic the way geo spawns work. charm.ClearTransitions(); charm.AddTransition("FINISHED", "Get Charm"); getCharm.RemoveActionsOfType <SetPlayerDataBool>(); getCharm.RemoveActionsOfType <IncrementPlayerDataInt>(); getCharm.RemoveActionsOfType <SendMessage>(); getCharm.AddAction(new RandomizerExecuteLambda(() => GiveItemActions.GiveItem(GiveItemActions.GiveAction.None, _item, _location))); getCharm.AddAction(new RandomizerAddLifeblood(_masksAmount)); getCharm.ClearTransitions(); getCharm.AddTransition("FINISHED", "Flash"); }
public override void Process(string scene, Object changeObj) { if (scene != _sceneName || !(changeObj is PlayMakerFSM fsm) || fsm.FsmName != _fsmName || fsm.gameObject.name != _objectName) { return; } // Remove actions that activate shiny item FsmState spawnItems = fsm.GetState("Spawn Items"); spawnItems.RemoveActionsOfType <ActivateAllChildren>(); fsm.GetState("Activated").RemoveActionsOfType <ActivateAllChildren>(); // Add geo to chest // Chest geo pool cannot be trusted, often spawns less than it should spawnItems.AddAction(new RandomizerAddGeo(fsm.gameObject, _geoAmount)); spawnItems.AddAction(new RandomizerExecuteLambda(() => GiveItemActions.GiveItem(GiveItemActions.GiveAction.None, _item, _location))); // Remove pre-existing geo from chest foreach (FlingObjectsFromGlobalPool fling in spawnItems.GetActionsOfType <FlingObjectsFromGlobalPool>()) { fling.spawnMin = 0; fling.spawnMax = 0; } // Need to check SpawnFromPool action too because of Mantis Lords chest foreach (SpawnFromPool spawn in spawnItems.GetActionsOfType <SpawnFromPool>()) { spawn.spawnMin = 0; spawn.spawnMax = 0; } }
public override void Process(string scene, Object changeObj) { if (scene != _sceneName || !(changeObj is PlayMakerFSM fsm) || fsm.FsmName != _fsmName || fsm.gameObject.name != _objectName) { return; } FsmState pdBool = fsm.GetState("PD Bool?"); FsmState charm = fsm.GetState("Charm?"); FsmState getCharm = fsm.GetState("Get Charm"); // Remove actions that stop shiny from spawning pdBool.RemoveActionsOfType <PlayerDataBoolTest>(); pdBool.RemoveActionsOfType <StringCompare>(); // Add our own check to stop the shiny from being grabbed twice pdBool.AddAction(new RandomizerBoolTest(_item, null, "COLLECTED")); // The "Charm?" state is a bad entry point for our geo spawning charm.ClearTransitions(); charm.AddTransition("FINISHED", "Get Charm"); // The "Get Charm" state is a good entry point for our geo spawning getCharm.RemoveActionsOfType <SetPlayerDataBool>(); getCharm.RemoveActionsOfType <IncrementPlayerDataInt>(); getCharm.RemoveActionsOfType <SendMessage>(); getCharm.AddAction(new RandomizerExecuteLambda(() => GiveItemActions.GiveItem(GiveItemActions.GiveAction.None, _item, _location))); getCharm.AddAction(new RandomizerAddGeo(fsm.gameObject, _geoAmount)); // Skip all the other type checks getCharm.ClearTransitions(); getCharm.AddTransition("FINISHED", "Flash"); }
public override void Process(string scene, Object changeObj) { if (scene != _sceneName || !(changeObj is PlayMakerFSM fsm) || fsm.FsmName != _fsmName || fsm.gameObject.name != _objectName) { return; } // Open the chest if the item has already been collected FsmState init = fsm.GetState("Init"); RandomizerExecuteLambda disableChest = new RandomizerExecuteLambda(() => fsm.SendEvent( RandomizerMod.Instance.Settings.CheckLocationFound(_location) ? "ACTIVATE" : null )); init.Actions = new FsmStateAction[] { init.Actions[0], init.Actions[1], init.Actions[2], init.Actions[3], init.Actions[4], disableChest, init.Actions[5], init.Actions[6], }; // Remove actions that activate shiny item FsmState spawnItems = fsm.GetState("Spawn Items"); spawnItems.RemoveActionsOfType <ActivateAllChildren>(); fsm.GetState("Activated").RemoveActionsOfType <ActivateAllChildren>(); // Add geo to chest // Chest geo pool cannot be trusted, often spawns less than it should spawnItems.AddAction(new RandomizerAddGeo(fsm.gameObject, _geoAmount)); spawnItems.AddAction(new RandomizerExecuteLambda(() => GiveItemActions.GiveItem(GiveItemActions.GiveAction.None, _item, _location))); // Remove pre-existing geo from chest foreach (FlingObjectsFromGlobalPool fling in spawnItems.GetActionsOfType <FlingObjectsFromGlobalPool>()) { fling.spawnMin = 0; fling.spawnMax = 0; } // Need to check SpawnFromPool action too because of Mantis Lords chest foreach (SpawnFromPool spawn in spawnItems.GetActionsOfType <SpawnFromPool>()) { spawn.spawnMin = 0; spawn.spawnMax = 0; } }
public override void Process(string scene, Object changeObj) { if (scene != _sceneName || !(changeObj is PlayMakerFSM fsm) || fsm.FsmName != _fsmName || fsm.gameObject.name != _objectName) { return; } FsmState pdBool = fsm.GetState("PD Bool?"); FsmState charm = fsm.GetState("Charm?"); FsmState getCharm = fsm.GetState("Get Charm"); // Remove actions that stop shiny from spawning pdBool.RemoveActionsOfType <PlayerDataBoolTest>(); pdBool.RemoveActionsOfType <StringCompare>(); // Add our own check to stop the shiny from being grabbed twice pdBool.AddAction( new RandomizerExecuteLambda(() => fsm.SendEvent( RandomizerMod.Instance.Settings.CheckLocationFound(_location) ? "COLLECTED" : null ))); // The "Charm?" state is a bad entry point for our lore showing charm.ClearTransitions(); charm.AddTransition("FINISHED", "Get Charm"); // The "Get Charm" state is a good entry point for our lore showing getCharm.RemoveActionsOfType <SetPlayerDataBool>(); getCharm.RemoveActionsOfType <IncrementPlayerDataInt>(); getCharm.RemoveActionsOfType <SendMessage>(); getCharm.AddAction(new RandomizerExecuteLambda(() => GiveItemActions.GiveItem(GiveItemActions.GiveAction.None, _item, _location))); getCharm.ClearTransitions(); // Begin showing lore state FsmState startReading = new FsmState(fsm.GetState("Idle")) { Name = "Lore Start Reading" }; startReading.ClearTransitions(); startReading.RemoveActionsOfType <FsmStateAction>(); if (_textType == TextType.MajorLore) { startReading.AddAction(new RandomizerExecuteLambda(() => { AudioSource audio = fsm.gameObject.GetComponent <AudioSource>(); audio.PlayOneShot(ObjectCache.LoreSound); })); startReading.AddAction(new RandomizerExecuteLambda(() => PlayMakerFSM.BroadcastEvent("LORE PROMPT UP"))); } else { startReading.AddAction(new RandomizerExecuteLambda(() => GameObject.Find("DialogueManager") .LocateMyFSM("Box Open").SendEvent("BOX UP"))); } startReading.AddAction(new Wait() { time = _textType == TextType.MajorLore ? 0.85f : 0.3f, finishEvent = FsmEvent.Finished }); // Reading FsmState loreReading = new FsmState(fsm.GetState("Idle")) { Name = "Lore Reading" }; loreReading.ClearTransitions(); loreReading.RemoveActionsOfType <FsmStateAction>(); loreReading.AddAction(new RandomizerCallStaticMethod(GetType(), nameof(ShowLoreDialogue), fsm.gameObject, _key, _sheetTitle, _textType)); // Finished Reading FsmState finishReading = new FsmState(fsm.GetState("Idle")) { Name = "Lore Finish Reading" }; finishReading.ClearTransitions(); finishReading.RemoveActionsOfType <FsmStateAction>(); finishReading.AddAction(new RandomizerCallStaticMethod(GetType(), nameof(HideLoreDialogue), _textType)); if (_textType == TextType.MajorLore) { finishReading.AddAction(new Wait() { time = 0.5f, finishEvent = FsmEvent.Finished }); } // Once we're done we have to reset the text box fsm.GetState("Flash").AddFirstAction(new RandomizerCallStaticMethod(GetType(), nameof(ResetTextBox))); // Cancel Reading (Hero Damaged) FsmState cancelReading = new FsmState(fsm.GetState("Idle")) { Name = "Lore Cancel Reading" }; cancelReading.ClearTransitions(); cancelReading.RemoveActionsOfType <FsmStateAction>(); cancelReading.AddAction(new RandomizerCallStaticMethod(GetType(), nameof(HideLoreDialogue), _textType)); cancelReading.AddAction(new RandomizerCallStaticMethod(GetType(), nameof(ResetTextBox))); // The code in "Finish" doesn't yeet the inspect region - we can do it here just by doing this cancelReading.AddAction(new RandomizerExecuteLambda(() => Object.Destroy(fsm.gameObject))); // Adding states getCharm.AddTransition("FINISHED", startReading.Name); startReading.AddTransition("FINISHED", loreReading.Name); startReading.AddTransition("HERO DAMAGED", cancelReading.Name); loreReading.AddTransition("CONVO_FINISH", finishReading.Name); loreReading.AddTransition("HERO DAMAGED", cancelReading.Name); finishReading.AddTransition("FINISHED", "Flash"); finishReading.AddTransition("HERO DAMAGED", cancelReading.Name); cancelReading.AddTransition("FINISHED", "Finish"); fsm.AddState(startReading); fsm.AddState(loreReading); fsm.AddState(finishReading); fsm.AddState(cancelReading); }