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 action to potentially despawn the object
            pdBool.AddAction(new RandomizerBoolTest(_boolName, null, "COLLECTED", true));

            // Force the FSM into the charm state, set it to the correct charm
            charm.ClearTransitions();
            charm.AddTransition("FINISHED", "Get Charm");
            getCharm.RemoveActionsOfType <SetPlayerDataBool>();
            getCharm.AddAction(new RandomizerSetBool(_boolName, true, true));
            getCharm.AddFirstAction(new RandomizerExecuteLambda(() => RandomizerMod.Instance.Settings.UpdateObtainedProgressionByBoolName(_boolName)));
            getCharm.AddAction(new RandomizerExecuteLambda(() => RandoLogger.UpdateHelperLog()));
            getCharm.AddAction(new RandomizerExecuteLambda(() => RandoLogger.LogItemToTrackerByBoolName(_boolName, _location)));
            fsm.GetState("Normal Msg").GetActionsOfType <SetFsmInt>()[0].setValue = _charmNum;
        }
        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?");

            // 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(_boolName, null, "COLLECTED"));

            // The "Charm?" state is a good entry point for our geo spawning
            charm.AddAction(new RandomizerExecuteLambda(() => RandoLogger.UpdateHelperLog()));
            charm.AddAction(new RandomizerExecuteLambda(() => RandoLogger.LogItemToTrackerByBoolName(_boolName, _location)));
            charm.AddFirstAction(new RandomizerExecuteLambda(() => AreaRando.Instance.Settings.UpdateObtainedProgressionByBoolName(_boolName)));
            charm.AddFirstAction(new RandomizerSetBool(_boolName, true));
            charm.AddFirstAction(new RandomizerAddGeo(fsm.gameObject, _geoAmount));

            // Skip all the other type checks
            charm.ClearTransitions();
            charm.AddTransition("FINISHED", "Flash");
        }
Example #3
0
        public override void Process(string scene, UnityEngine.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 trinkFlash  = fsm.GetState("Trink Flash");
            FsmState giveTrinket = fsm.GetState("Store Key");

            // 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(_boolName, null, "COLLECTED", true));

            // Force the FSM to follow the path for the correct trinket
            charm.ClearTransitions();

            charm.AddTransition("FINISHED", "Trink Flash");
            trinkFlash.ClearTransitions();
            fsm.GetState("Trinket Type").ClearTransitions();
            trinkFlash.AddTransition("FINISHED", "Store Key");

            giveTrinket.AddFirstAction(new RandomizerExecuteLambda(() => AreaRando.Instance.Settings.UpdateObtainedProgressionByBoolName(_boolName)));
            giveTrinket.AddAction(new RandomizerExecuteLambda(() => RandoLogger.LogItemToTrackerByBoolName(_boolName, _location)));
            giveTrinket.AddAction(new RandomizerExecuteLambda(() => RandoLogger.UpdateHelperLog()));
            giveTrinket.GetActionsOfType <SetPlayerDataBool>().First().boolName = _boolName;

            // Makes sure the correct icon and text appear
            switch (_trinketNum)
            {
            case 1:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_TRINKET1";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = AreaRando.GetSprite("ShopIcons.WanderersJournal");
                break;

            case 2:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_TRINKET2";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = AreaRando.GetSprite("ShopIcons.HallownestSeal");
                break;

            case 3:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_TRINKET3";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = AreaRando.GetSprite("ShopIcons.KingsIdol");
                break;

            case 4:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_TRINKET4";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = AreaRando.GetSprite("ShopIcons.ArcaneEgg");
                break;

            case 6:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_TRAM_PASS";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = AreaRando.GetSprite("ShopIcons.TramPass");
                break;

            case 8:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_STOREKEY";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = AreaRando.GetSprite("ShopIcons.ShopkeepersKey");
                break;

            case 9:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_CITYKEY";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = AreaRando.GetSprite("ShopIcons.CityKey");
                break;

            case 10:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_LOVEKEY";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = AreaRando.GetSprite("ShopIcons.LoveKey");
                break;

            case 11:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_RANCIDEGG";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = AreaRando.GetSprite("ShopIcons.RancidEgg");
                break;

            case 12:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_SIMPLEKEY";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = AreaRando.GetSprite("ShopIcons.SimpleKey");
                break;

            case 13:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "RANDOMIZER_NAME_CHARM_NOTCH";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = AreaRando.GetSprite("ShopIcons.CharmNotch");
                break;

            case 14:
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "RANDOMIZER_NAME_PALE_ORE";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = AreaRando.GetSprite("ShopIcons.PaleOre");
                break;

            case 20:     //lantern
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_LANTERN";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = AreaRando.GetSprite("ShopIcons.Lantern");
                break;

            case 21:     //elegant key
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "INV_NAME_WHITEKEY";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = AreaRando.GetSprite("ShopIcons.ElegantKey");
                break;

            case 22:     //mask shards
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "RANDOMIZER_NAME_MASK_SHARD";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = AreaRando.GetSprite("ShopIcons.MaskShard");
                break;

            case 23:     //vessel fragments
                giveTrinket.GetActionsOfType <GetLanguageString>().First().convName     = "RANDOMIZER_NAME_VESSEL_FRAGMENT";
                giveTrinket.GetActionsOfType <SetSpriteRendererSprite>().First().sprite = AreaRando.GetSprite("ShopIcons.VesselFragment");
                break;
            }
        }
Example #4
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 bigGetFlash = fsm.GetState("Big Get Flash");

            // Remove actions that stop shiny from spawning
            pdBool.RemoveActionsOfType <StringCompare>();

            // Change pd bool test to our new bool
            PlayerDataBoolTest boolTest = pdBool.GetActionsOfType <PlayerDataBoolTest>()[0];

            if (_playerdata)
            {
                boolTest.boolName = _boolName;
            }
            else
            {
                RandomizerBoolTest randBoolTest = new RandomizerBoolTest(_boolName, boolTest.isFalse, boolTest.isTrue);
                pdBool.RemoveActionsOfType <PlayerDataBoolTest>();
                pdBool.AddFirstAction(randBoolTest);
            }

            string logBoolName = string.Empty;

            for (int i = 0; i < _itemDefs.Length; i++)
            {
                if (!Ref.PD.GetBool(_itemDefs[i].BoolName))
                {
                    logBoolName = _itemDefs[i].BoolName;
                    break;
                }
            }

            // Force the FSM to show the big item flash
            charm.ClearTransitions();
            charm.AddTransition("FINISHED", "Big Get Flash");

            bigGetFlash.AddAction(new RandomizerExecuteLambda(() => RandoLogger.LogItemToTrackerByBoolName(logBoolName, _location)));
            bigGetFlash.AddAction(new RandomizerExecuteLambda(() => RandoLogger.UpdateHelperLog()));
            bigGetFlash.AddFirstAction(new RandomizerExecuteLambda(() => RandomizerMod.Instance.Settings.UpdateObtainedProgressionByBoolName(logBoolName)));
            // Set bool and show the popup after the flash
            bigGetFlash.AddAction(new RandomizerCallStaticMethod(
                                      typeof(BigItemPopup),
                                      nameof(BigItemPopup.ShowAdditive),
                                      _itemDefs,
                                      fsm.gameObject,
                                      "GET ITEM MSG END"));

            // Don't actually need to set the skill here, that happens in BigItemPopup
            // Maybe change that at some point, it's not where it should happen
            if (!_playerdata)
            {
                bigGetFlash.AddAction(new RandomizerSetBool(_boolName, true));
            }

            // Exit the fsm after the popup
            bigGetFlash.ClearTransitions();
            bigGetFlash.AddTransition("GET ITEM MSG END", "Hero Up");
            bigGetFlash.AddTransition("HERO DAMAGED", "Finish");
        }