예제 #1
0
        public override void OnEnableFsm(PlayMakerFSM fsm)
        {
            if (fsm.FsmName == "Geo Rock" && fsm.gameObject.name == GeoRockUtility.GetGeoRockName(this))
            {
                GeoRockUtility.ModifyGeoRock(fsm, location.flingType, this, items);
            }

            if (fsm.FsmName == "Shiny Control" && ShinyUtility.TryGetItemFromShinyName(fsm.gameObject.name, this, out var item))
            {
                ShinyUtility.ModifyShiny(fsm, location.flingType, this, item);
                if (!HasVisited() && location.flingType == FlingType.Everywhere)
                {
                    ShinyUtility.FlingShinyRandomly(fsm);
                }
                else
                {
                    ShinyUtility.FlingShinyDown(fsm);
                }
                fsm.gameObject.transform.Translate(new Vector3(0, 0, -0.1f));
            }

            if (fsm.FsmName == "Shiny Control" && ShinyUtility.GetShinyPrefix(this) == fsm.gameObject.name)
            {
                ShinyUtility.ModifyMultiShiny(fsm, location.flingType, this, items);
                if (!HasVisited() && location.flingType == FlingType.Everywhere)
                {
                    ShinyUtility.FlingShinyRandomly(fsm);
                }
                else
                {
                    ShinyUtility.FlingShinyDown(fsm);
                }
                fsm.gameObject.transform.Translate(new Vector3(0, 0, -0.1f));
            }

            if (fsm.FsmName == "Bottle Control" && fsm.gameObject.name == GrubJarUtility.GetGrubJarName(this))
            {
                GrubJarUtility.ModifyBottleFsm(fsm.gameObject, location.flingType, this, items);
            }

            if (fsm.FsmName == "Chest Control" && fsm.gameObject.name == ChestUtility.GetChestName(this))
            {
                ChestUtility.ModifyChest(fsm, location.flingType, this, items);
            }
        }
예제 #2
0
        public override void OnEnableFsm(PlayMakerFSM fsm)
        {
            RepairCosts();

            if (fsm.FsmName == "Inspection" && fsm.gameObject.name == TabletUtility.GetTabletName(this))
            {
                fsm.FsmVariables.FindFsmString("Convo Name").Value = fsm.gameObject.name;
                fsm.FsmVariables.FindFsmString("Sheet Name").Value = "ItemChanger.Locations";
            }

            if (fsm.FsmName == "Shiny Control" && ShinyUtility.TryGetItemFromShinyName(fsm.gameObject.name, this, out var shinyItem))
            {
                ShinyUtility.ModifyShiny(fsm, chestLocation.flingType, this, shinyItem);
                if (chestLocation.flingType == FlingType.Everywhere)
                {
                    ShinyUtility.FlingShinyRandomly(fsm);
                }
                else
                {
                    ShinyUtility.FlingShinyDown(fsm);
                }
            }

            if (fsm.FsmName == "Chest Control" && fsm.gameObject.name == ChestUtility.GetChestName(this))
            {
                FsmState init       = fsm.GetState("Init");
                FsmState spawnItems = fsm.GetState("Spawn Items");

                FsmStateAction checkAction = new RandomizerExecuteLambda(() => fsm.SendEvent(items.All(i => i.IsObtained()) ? "ACTIVATE" : null));

                init.RemoveActionsOfType <BoolTest>();
                init.AddAction(checkAction);

                // Destroy any existing shinies in the chest
                GameObject itemParent = fsm.gameObject.transform.Find("Item").gameObject;
                foreach (Transform t in itemParent.transform)
                {
                    GameObject.Destroy(t.gameObject);
                }

                // 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;
                }

                FsmStateAction generateItems = new RandomizerExecuteLambda(() =>
                {
                    for (int i = 0; i < items.Count; i++)
                    {
                        var item = items[i];
                        var cost = costs[i];

                        if (!item.IsObtained())
                        {
                            if (cost != null && !cost.Paid() && !cost.CanPay())
                            {
                                continue;
                            }
                            if (cost != null && !cost.Paid())
                            {
                                cost.Pay();
                            }
                            if (item.GiveEarly(Container.Chest))
                            {
                                item.Give(this, Container.Chest, chestLocation.flingType, fsm.gameObject.transform, MessageType.Corner);
                            }
                            else
                            {
                                GameObject shiny = ShinyUtility.MakeNewShiny(this, item);
                                ShinyUtility.PutShinyInContainer(itemParent, shiny);
                            }
                        }
                    }
                });

                fsm.GetState("Open").AddAction(generateItems);
            }
        }