public static void FixBottleFSM(GameObject jar, string item, string location, bool unrandomized)
        {
            PersistentBoolData pbd = jar.GetComponent <PersistentBoolItem>().persistentBoolData;

            pbd.id        = location;
            pbd.sceneName = jar.scene.name;

            PlayMakerFSM fsm = FSMUtility.LocateFSM(jar, "Bottle Control");

            // It's easiest to simply use the sceneData check to decide whether to destroy the bottle
            // FsmState init = fsm.GetState("Init");
            // init.RemoveActionsOfType<BoolTest>();
            // init.AddFirstAction(new RandomizerExecuteLambda(() => fsm.SendEvent(RandomizerMod.Instance.Settings.CheckLocationFound(location) ? "ACTIVATE" : null)));

            // The bottle FSM already takes care of granting the grub and playing happy grub noises
            // We have to add the GiveItem action before incrementing the grub count so the RecentItems
            // correctly notes the grub index
            if (!unrandomized)
            {
                fsm.GetState("Shatter").AddFirstAction(new RandomizerExecuteLambda(() => GiveItem(GiveAction.None, item, location)));
            }

            // It seems pointless to mark this scene as having been cleared of grub jars
            fsm.GetState("Set Map?").ClearTransitions();
        }
Exemple #2
0
        private void OnTriggerEnter2D(Collider2D other)
        {
            if (other.gameObject.layer != (int)PhysLayers.HERO_ATTACK)
            {
                return;
            }

            if (!other.gameObject.name.Contains("Slash"))
            {
                return;
            }

            SceneData sd = GameManager.instance.sceneData;

            PersistentBoolData pbd = sd.FindMyState(BoolData) ?? BoolData;

            if (pbd.activated)
            {
                return;
            }

            pbd.activated = true;

            OnHit();

            sd.SaveMyState(pbd);
        }
 public Lever()
 {
     BoolData = new PersistentBoolData {
         sceneName = USceneManager.GetActiveScene().name,
         id        = name
     };
 }
        private static bool CheckIfSceneDataActivated(string sceneName, string id)
        {
            PersistentBoolData preBoolData = new PersistentBoolData {
                sceneName = sceneName, id = id
            };
            PersistentBoolData boolData = SceneData.instance.FindMyState(preBoolData) ?? preBoolData;

            return(boolData.activated && !boolData.semiPersistent);
        }
Exemple #5
0
        public void OnChangeScene(string sceneName)
        {
            if (sceneName != floor.deploySceneName)
            {
                return;
            }
            GameObject f = floor.DeployAndReturn();

            if (GameManager.instance.entryGateName == entryGate)
            {
                PersistentBoolData data = f.GetComponent <PersistentBoolItem>().persistentBoolData;
                data.activated = true;
                GameManager.instance.sceneData.SaveMyState(data);
            }
        }
 public CreateInactiveShiny(string sceneName, string parent, string newShinyName, float x, float y, string boolDataScene, string boolDataId)
 {
     _sceneName    = sceneName;
     _newShinyName = newShinyName;
     _parent       = parent;
     _x            = x;
     _y            = y;
     _activeCheck  = () =>
     {
         PersistentBoolData boolData = new PersistentBoolData()
         {
             id = boolDataId, sceneName = boolDataScene
         };
         boolData = SceneData.instance.FindMyState(boolData) ?? boolData;
         return(boolData.activated && !boolData.semiPersistent);
     };
 }
        public static void FixMimicFSMs(GameObject bottle, GameObject top, GameObject mimic, GameObject dialogue, string item, string location, string sceneName, bool unrandomized)
        {
            // Use the game's in-built scenedata feature to decide what to do with the bottle and mimic
            PersistentBoolData bottleData = bottle.GetComponent <PersistentBoolItem>().persistentBoolData;

            bottleData.sceneName = sceneName;
            bottleData.id        = location + " bottle";
            PersistentBoolData mimicData = mimic.GetComponent <PersistentBoolItem>().persistentBoolData;

            mimicData.sceneName = sceneName;
            mimicData.id        = location + " mimic";

            // Correctly link the top to the bottle
            PlayMakerFSM bottleFSM  = FSMUtility.LocateFSM(bottle, "Bottle Control");
            FsmState     bottleInit = bottleFSM.GetState("Init");

            bottleInit.GetActionOfType <SendEventByName>().eventTarget.gameObject.GameObject.Value = top.gameObject;
            FsmState bottleShatter = bottleFSM.GetState("Shatter");

            bottleShatter.GetActionsOfType <SendEventByName>()[1].eventTarget.gameObject.GameObject.Value = top.gameObject;

            // Correctly link the Dialogue to the top
            PlayMakerFSM topFSM = FSMUtility.LocateFSM(top, "Grub Control");

            topFSM.GetState("Pause").GetActionOfType <SetParent>().gameObject.GameObject.Value = dialogue;


            if (!unrandomized)
            {
                // When mimics aren't randomized, simply use the scene data to decide whether to break the grub jar
                bottleInit.RemoveActionsOfType <BoolTest>();
                bottleInit.AddFirstAction(new RandomizerExecuteLambda(() => bottleFSM.SendEvent(RandomizerMod.Instance.Settings.CheckLocationFound(location) ? "ACTIVATE" : null)));

                // Run the randomizer code when we free the grub mimic
                bottleShatter.AddFirstAction(new RandomizerExecuteLambda(() => GiveItem(GiveAction.None, item, location)));
            }
        }
Exemple #8
0
 public static void SavePersistentBoolItemState(PersistentBoolData pbd)
 {
     GameManager.instance.sceneData.SaveMyState(pbd);
     QueuedPersistentBoolData.Add(pbd);
 }