예제 #1
0
        private void RerollItem(DebrisObject debris)
        {
            int          checkLimit   = 0;
            PickupObject targetedItem = debris.gameObject.GetComponent <PickupObject>();

            if (targetedItem != null)
            {
                ItemQuality  targetTier               = targetedItem.quality;
                int          chanceToDowngrade        = 10;
                int          chanceToUpgrade          = 80;
                ItemQuality  newItemQuality           = targetTier;
                PickupObject newItemObject            = PickupObjectDatabase.GetByName("cel:test_item");
                int          RollToCheckUpgradeStatus = UnityEngine.Random.Range(0, 101);
                if (RollToCheckUpgradeStatus <= chanceToDowngrade && targetTier != ItemQuality.D)
                {
                    newItemQuality = targetTier - 1;
                }
                else if (RollToCheckUpgradeStatus >= chanceToUpgrade && targetTier != ItemQuality.S)
                {
                    newItemQuality = targetTier + 1;
                }
                GenericLootTable lootTableItems = GameManager.Instance.RewardManager.ItemsLootTable;

                if (targetedItem is PassiveItem)
                {
                    do
                    {
                        newItemObject = LootEngine.GetItemOfTypeAndQuality <PassiveItem>(newItemQuality, lootTableItems);
                        checkLimit++;
                    } while (newItemObject.PickupObjectId == targetedItem.PickupObjectId && checkLimit < 10);
                }
                else if (targetedItem is PlayerItem)
                {
                    do
                    {
                        newItemObject = LootEngine.GetItemOfTypeAndQuality <PlayerItem>(newItemQuality, lootTableItems);
                        checkLimit++;
                    } while (newItemObject.PickupObjectId == targetedItem.PickupObjectId && checkLimit < 10);
                }

                if (UnityEngine.Random.Range(0, 101) <= 1)
                {
                    Chest rainbow_Chest = GameManager.Instance.RewardManager.Rainbow_Chest;
                    Chest chest2        = Chest.Spawn(rainbow_Chest, targetedItem.sprite.WorldCenter.ToIntVector2(VectorConversions.Round));
                    chest2.BecomeGlitchChest();
                    chest2.sprite.renderer.material.shader = ShaderCache.Acquire("Brave/Internal/RainbowChestShader");

                    chest2.RegisterChestOnMinimap(chest2.GetAbsoluteParentRoom());
                }
                else
                {
                    LootEngine.DoDefaultPurplePoof(targetedItem.sprite.WorldCenter);
                    LootEngine.SpawnItem(newItemObject.gameObject, targetedItem.sprite.WorldCenter, Vector2.zero, 0);
                }
                Destroy(targetedItem.gameObject);
            }
        }
예제 #2
0
        public override void Init()
        {
            System.IO.Directory.CreateDirectory("MagicSmokeSaves");

            _AutocompletionSettings = new AutocompletionSettings((input) => {
                List <string> ret = new List <string>();
                foreach (var stat in _Stats)
                {
                    if (stat.Key.AutocompletionMatch(input.ToLower()))
                    {
                        ret.Add(stat.Key);
                    }
                }
                return(ret.ToArray());
            });

            _AutocompletionChests = new AutocompletionSettings((input) => {
                List <string> ret = new List <string>();
                foreach (var stat in _Chests)
                {
                    if (stat.Key.AutocompletionMatch(input.ToLower()))
                    {
                        ret.Add(stat.Key);
                    }
                }
                return(ret.ToArray());
            });

            _StatGet = (args) => {
                if (_Stats.ContainsKey(args[0]))
                {
                    ETGModConsole.Log(_Stats[args[0]] + " value is: <color=#ff0000ff>" + GameManager.Instance.PrimaryPlayer.stats.GetStatValue(_Stats[args[0]]) + "</color>");
                }
                else
                {
                    ETGModConsole.Log($"Please check your command and try again");
                }
            };



            _StatGetAll = (args) => {
                ETGModConsole.Log("Available stats:");
                foreach (var stat in _Stats)
                {
                    ETGModConsole.Log($"- {stat.Key} <color=#ff0000ff>" + GameManager.Instance.PrimaryPlayer.stats.GetStatValue(stat.Value) + "</color>");
                }
            };

            ETGModConsole.Commands.AddGroup("ms", (string[] args) =>
            {
                ETGModConsole.Log("<size=100><color=#ff0000ff>MagicSmoke v1 by flagmaggot</color></size>", false);
                ETGModConsole.Log("<size=100><color=#ff0000ff>DOES NOT WORK WHILE IN THE BREACH</color></size>", false);
                ETGModConsole.Log("<size=100><color=#ff0000ff>--------------------------------</color></size>", false);
                ETGModConsole.Log("Use \"ms help\" for help!", false);
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("help", (string[] args) =>
            {
                ETGModConsole.Log("<size=100><color=#ff0000ff>MagicSmoke v1 by flagmaggot</color></size>", false);
                ETGModConsole.Log("<size=100><color=#ff0000ff>DOES NOT WORK WHILE IN THE BREACH</color></size>", false);
                ETGModConsole.Log("<size=100><color=#ff0000ff>--------------------------------</color></size>", false);
                ETGModConsole.Log("Magic Smoke Command Reference:", false);
                ETGModConsole.Log("", false);
                ETGModConsole.Log("<color=#FFFF33>ms help</color> - Displays this help", false);
                ETGModConsole.Log("<color=#FFFF33>ms get <stat name></color> - gets the state value", false);
                ETGModConsole.Log("<color=#FFFF33>ms set <stat name> [arg]</color> - sets the player speed (decimal values)", false);
                ETGModConsole.Log("<color=#FFFF33>ms getallstats</color> - returns all the stats and their values", false);
                ETGModConsole.Log("<color=#FFFF33>ms forcedualwield [gunid]</color> - forces the player to dual wield, use gun names, it will autocomplete to help.", false);
                ETGModConsole.Log("<color=#FFFF33>ms spawnsynergy</color> - spawns synergy chest", false);
                ETGModConsole.Log("<color=#FFFF33>ms spawnrainbowsynergy</color> - spawns rainbow synergy chest", false);
                ETGModConsole.Log("<color=#FFFF33>ms savesettings [name</color> - saves player settings to a file [name].json", false);
                ETGModConsole.Log("<color=#FFFF33>ms loadsettings [name]</color> - loads player settings from a file [name].json", false);
                ETGModConsole.Log("<color=#FFFF33>ms spawnglitched [arg] [true]</color> - spawns a glitch chest, [arg] can be a,b,c,d,s,red,green,blue,brown,black [use true after if you want to warp to glitched level]", false);
                ETGModConsole.Log("<color=#FFFF33>ms setmagnificense [arg]</color> - sets the magnificence value", false);
                ETGModConsole.Log("<color=#FFFF33>ms getmagnificense [arg]</color> - gets the current magnificence value", false);
                ETGModConsole.Log("<color=#FFFF33>ms saveclipboard</color>  - copies the encoded settings to the clipboard", false);
                ETGModConsole.Log("<color=#FFFF33>ms loadclipboard</color> - loads the settings directly from clipboard", false);
                ETGModConsole.Log("<color=#FFFF33>ms loadclipboard [arg</color>] - loads the settings based off the encoded pasted data [arg]", false);
                ETGModConsole.Log("<color=#FFFF33>ms pollthegungeon</color> - Request from YouTuber Hutts, finds all chests on current floor and spawns 3 additional random chests.", false);
                ETGModConsole.Log("<color=#FFFF33>ms findchests</color> - gives coordinates for all chests currently on the floor (you can teleport to them by using tp <first number> <second number>", false);
                ETGModConsole.Log("<color=#FFFF33>ms addteleporters</color> - adds teleporters to almost all the rooms on the current dungeon", false);
                ETGModConsole.Log("<color=#FFFF33>ms visitallrooms</color> - marks all rooms as visited, makes all visible on minimap", false);
                ETGModConsole.Log("<color=#FFFF33>ms revealrooms</color> - makes all rooms visible (similar to Floor revealed item)", false);
                ETGModConsole.Log("<color=#FFFF33>ms dropactives</color> - drops all active items", false);
                ETGModConsole.Log("<color=#FFFF33>ms droppassives</color> - drops all passive items", false);
                ETGModConsole.Log("<color=#FFFF33>ms dropall</color> - drop all items and guns (except defauilt gun)", false);
                ETGModConsole.Log("<color=#FFFF33>ms clearall</color> - clears all active and passive items.", false);
                ETGModConsole.Log("<color=#FFFF33>ms clearpassives</color> - clears passive items", false);
                ETGModConsole.Log("<color=#FFFF33>ms clearactives</color> - clears active items", false);
                ETGModConsole.Log("<color=#FFFF33>ms dropguns</color> - drops all guns (except default gun)", false);
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("forcedualwield", DualWieldItem, _GiveAutocompletionSettings);

            _MagnificenceSet = (args) => {
                float value;
                if (float.TryParse(args[0], out value))
                {
                    GameManager.Instance.PrimaryPlayer.stats.AddFloorMagnificence(value);
                    ETGModConsole.Log("Magnificence set to: <color=#ff0000ff>" + value + "</color>");
                }
                else
                {
                    ETGModConsole.Log($"Please check your command and try again");
                }
            };


            _MagnificenceGet = (args) => {
                ETGModConsole.Log("Magnificence set to: <color=#ff0000ff>" + GameManager.Instance.PrimaryPlayer.stats.Magnificence + "</color>");
            };

            _StatSet = (args) => {
                float value;
                if (_Stats.ContainsKey(args[0]) && float.TryParse(args[1], out value))
                {
                    GameManager.Instance.PrimaryPlayer.stats.SetBaseStatValue(_Stats[args[0]], value, GameManager.Instance.PrimaryPlayer);
                    ETGModConsole.Log(_Stats[args[0]] + " set to: <color=#ff0000ff>" + value + "</color>");
                }
                else
                {
                    ETGModConsole.Log($"Please check your command and try again");
                }
            };

            ETGModConsole.Commands.GetGroup("ms").AddUnit("spawnsynergy", (string[] args) =>
            {
                Chest synergy_Chest = GameManager.Instance.RewardManager.Synergy_Chest;
                //if(args.Length != 0)
                //{

                //     synergy_Chest.IsRainbowChest = true;
                //}
                synergy_Chest.IsRainbowChest = false;
                synergy_Chest.ForceUnlock();
                IntVector2 basePosition = new IntVector2((int)GameManager.Instance.PrimaryPlayer.transform.position.x, (int)GameManager.Instance.PrimaryPlayer.transform.position.y);
                Chest.Spawn(synergy_Chest, basePosition);
                synergy_Chest.ForceUnlock();
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("spawnrainbowsynergy", (string[] args) =>
            {
                Chest synergy_Chest          = GameManager.Instance.RewardManager.Synergy_Chest;
                synergy_Chest.IsRainbowChest = true;
                IntVector2 basePosition      = new IntVector2((int)GameManager.Instance.PrimaryPlayer.transform.position.x, (int)GameManager.Instance.PrimaryPlayer.transform.position.y);
                Chest.Spawn(synergy_Chest, basePosition);
                synergy_Chest.ForceUnlock();
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("savesettings", (string[] args) =>
            {
                SaveSettings(args[0]);
                ETGModConsole.Log("Settings file saved as: " + args[0] + ".json");
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("saveclipboard", (string[] args) =>
            {
                SaveSettingsToClipboard();
                ETGModConsole.Log("Settings copied to clipboard");
            });

            //ETGModConsole.Commands.GetGroup("ms").AddUnit("summon", (string[] args) =>
            //{
            //    //ResourceManager.LoadAssetBundle("./shared_auto_001/Shrine_Mirror55");
            //    AdvancedShrineController ads = new AdvancedShrineController();
            //    ads.IsBlankShrine = true;

            //    ads.Start();
            //    ETGModConsole.Log("No");
            //});

            ETGModConsole.Commands.GetGroup("ms").AddUnit("zoom", (string[] args) =>
            {
                if (args.Count() > 0)
                {
                    float zoomScale;
                    float.TryParse(args[0], out zoomScale);
                    GameManager.Instance.MainCameraController.OverrideZoomScale = zoomScale;
                    ETGModConsole.Log($"Camera zoom set to {zoomScale}");
                }
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("pollthegungeon", (string[] args) =>
            {
                List <Chest> chests = new List <Chest>();
                chests = StaticReferenceManager.AllChests;

                foreach (Chest c in chests.ToList())
                {
                    RoomHandler room = c.GetAbsoluteParentRoom();
                    while (room.GetComponentsAbsoluteInRoom <Chest>().Count() < 4)
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            SpawnChests(room);
                        }
                    }
                }
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("findchests", (string[] args) =>
            {
                List <Chest> chests = StaticReferenceManager.AllChests;

                foreach (Chest c in chests)
                {
                    ETGModConsole.Log($"Chest location: <color=#ff0000ff>{c.transform.position}</color>");
                }
            });

            //ETGModConsole.Commands.GetGroup("ms").AddUnit("open", (string[] args) =>
            //{
            //    List<Chest> chests = StaticReferenceManager.AllChests;

            //    foreach (Chest c in chests)
            //    {
            //        ETGModConsole.Log($"Chest location: <color=#ff0000ff>{c.transform.position}</color>");
            //    }
            //});

            ETGModConsole.Commands.GetGroup("ms").AddUnit("addteleporters", (string[] args) =>
            {
                List <RoomHandler> rooms = GameManager.Instance.Dungeon.data.rooms;
                foreach (RoomHandler room in rooms)
                {
                    try
                    {
                        room.AddProceduralTeleporterToRoom();
                    }
                    catch (Exception)
                    {
                        //do nothing
                    }
                }
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("visitallrooms", (string[] args) =>
            {
                List <RoomHandler> rooms = GameManager.Instance.Dungeon.data.rooms;
                foreach (RoomHandler room in rooms)
                {
                    room.visibility = RoomHandler.VisibilityStatus.VISITED;
                }
                Minimap.Instance.RevealAllRooms(true);
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("revealrooms", (string[] args) =>
            {
                List <RoomHandler> rooms = GameManager.Instance.Dungeon.data.rooms;

                foreach (RoomHandler room in rooms)
                {
                    Minimap.Instance.RevealAllRooms(true);
                }
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("getroomname", (string[] args) =>
            {
                ETGModConsole.Log($"{GameManager.Instance.PrimaryPlayer.GetAbsoluteParentRoom().GetRoomName()}");
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("loadsettings", (string[] args) =>
            {
                LoadSettings(args[0]);
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("dropactives", (string[] args) =>
            {
                foreach (PlayerItem i in GameManager.Instance.PrimaryPlayer.activeItems.ToList())
                {
                    GameManager.Instance.PrimaryPlayer.DropActiveItem(i);
                }
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("droppassives", (string[] args) =>
            {
                foreach (PassiveItem i in GameManager.Instance.PrimaryPlayer.passiveItems.ToList())
                {
                    GameManager.Instance.PrimaryPlayer.DropPassiveItem(i);
                }
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("dropall", (string[] args) =>
            {
                foreach (PassiveItem i in GameManager.Instance.PrimaryPlayer.passiveItems.ToList())
                {
                    GameManager.Instance.PrimaryPlayer.DropPassiveItem(i);
                }
                foreach (PlayerItem i in GameManager.Instance.PrimaryPlayer.activeItems.ToList())
                {
                    GameManager.Instance.PrimaryPlayer.DropActiveItem(i);
                }
                foreach (Gun i in GameManager.Instance.PrimaryPlayer.inventory.AllGuns.ToList())
                {
                    GameManager.Instance.PrimaryPlayer.ForceDropGun(i);
                }
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("clearall", (string[] args) =>
            {
                GameManager.Instance.PrimaryPlayer.RemoveAllActiveItems();
                GameManager.Instance.PrimaryPlayer.RemoveAllPassiveItems();
                foreach (Gun i in GameManager.Instance.PrimaryPlayer.inventory.AllGuns.ToList())
                {
                    GameManager.Instance.PrimaryPlayer.ForceDropGun(i);
                }
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("clearactives", (string[] args) =>
            {
                GameManager.Instance.PrimaryPlayer.RemoveAllActiveItems();
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("clearpassives", (string[] args) =>
            {
                GameManager.Instance.PrimaryPlayer.RemoveAllPassiveItems();
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("dropguns", (string[] args) =>
            {
                foreach (Gun i in GameManager.Instance.PrimaryPlayer.inventory.AllGuns.ToList())
                {
                    GameManager.Instance.PrimaryPlayer.ForceDropGun(i);
                }
            });

            ETGModConsole.Commands.GetGroup("ms").AddUnit("charmall", (string[] args) =>
            {
                if (args.Count() == 0 || args[0] == "true")
                {
                    foreach (AIActor actor in StaticReferenceManager.AllEnemies)
                    {
                        //AkSoundEngine.PostEvent("Play_OBJ_enemy_charmed_01", GameManager.Instance.gameObject);
                        AIActor aiactor          = actor as AIActor;
                        aiactor.CanTargetEnemies = true;
                        aiactor.CanTargetPlayers = false;
                    }
                }
                else if (args[0] == "false")
                {
                    foreach (AIActor actor in StaticReferenceManager.AllEnemies)
                    {
                        //AkSoundEngine.PostEvent("Play_OBJ_enemy_charmed_01", GameManager.Instance.gameObject);
                        AIActor aiactor          = actor as AIActor;
                        aiactor.CanTargetEnemies = false;
                        aiactor.CanTargetPlayers = true;
                    }
                }
            });

            //ETGModConsole.Commands.GetGroup("ms").AddUnit("removeallcompanions", (string[] args) =>
            //{
            //    //GameManager.Instance.PrimaryPlayer.companions.RemoveAll(AIActor);
            //    GameManager.Instance.PrimaryPlayer.companions.Clear();
            //});

            ETGModConsole.Commands.GetGroup("ms").AddUnit("loadclipboard", (string[] args) =>
            {
                if (args.Count() == 0)
                {
                    LoadSettingsFromClipBoard();
                }
                else
                {
                    LoadSettingsFromClipBoard(args[0]);
                }
                ETGModConsole.Log("Loading settings from clipboard");
            });

            _GlitchSpawn = (args) => {
                if (_Chests.ContainsKey(args[0]))
                {
                    Chest glitchedchest = _Chests[args[0]];
                    glitchedchest.ForceGlitchChest = true;
                    glitchedchest.ForceUnlock();
                    glitchedchest.BecomeGlitchChest();
                    IntVector2 basePosition = new IntVector2((int)GameManager.Instance.PrimaryPlayer.transform.position.x, (int)GameManager.Instance.PrimaryPlayer.transform.position.y);
                    Chest.Spawn(glitchedchest, basePosition);
                    if (args.Count() == 2)
                    {
                        if (args[1] == "true")
                        {
                            ETGMod.Chest.OnPostOpen += glitchopen;
                        }
                    }
                }
                else
                {
                    ETGModConsole.Log($"Please check your command and try again");
                }
            };


            _MsGroup           = ETGModConsole.Commands.GetGroup("ms");
            _SetGroup          = _MsGroup.AddUnit("set", _StatSet, _AutocompletionSettings);
            _SetGroup          = _MsGroup.AddUnit("get", _StatGet, _AutocompletionSettings);
            _SynergyChestGroup = _MsGroup.AddUnit("spawnglitched", _GlitchSpawn, _AutocompletionChests);
            _GetGroup          = _MsGroup.AddUnit("getallstats", _StatGetAll, _AutocompletionSettings);
            _SetGroup          = _MsGroup.AddUnit("getmagnificence", _MagnificenceGet, _AutocompletionSettings);
            _SetGroup          = _MsGroup.AddUnit("setmagnificence", _MagnificenceSet, _AutocompletionSettings);
        }
        public static Chest SpawnChestEasy(IntVector2 location, ChestTier tier, bool locked, Chest.GeneralChestType type = Chest.GeneralChestType.UNSPECIFIED, ThreeStateValue mimic = ThreeStateValue.UNSPECIFIED, ThreeStateValue fused = ThreeStateValue.UNSPECIFIED)
        {
            GameObject chestPrefab = null;

            switch (tier)
            {
            case ChestTier.BLACK:
                chestPrefab = GameManager.Instance.RewardManager.S_Chest.gameObject;
                break;

            case ChestTier.BLUE:
                chestPrefab = GameManager.Instance.RewardManager.C_Chest.gameObject;
                break;

            case ChestTier.BROWN:
                chestPrefab = GameManager.Instance.RewardManager.D_Chest.gameObject;
                break;

            case ChestTier.GREEN:
                chestPrefab = GameManager.Instance.RewardManager.B_Chest.gameObject;
                break;

            case ChestTier.RED:
                chestPrefab = GameManager.Instance.RewardManager.A_Chest.gameObject;
                break;

            case ChestTier.SYNERGY:
                chestPrefab = GameManager.Instance.RewardManager.Synergy_Chest.gameObject;
                break;

            case ChestTier.RAINBOW:
                chestPrefab = GameManager.Instance.RewardManager.Rainbow_Chest.gameObject;
                break;

            case ChestTier.SECRETRAINBOW:
                chestPrefab = GameManager.Instance.RewardManager.D_Chest.gameObject;
                break;

            case ChestTier.GLITCHED:
                chestPrefab = GameManager.Instance.RewardManager.B_Chest.gameObject;
                break;

            case ChestTier.RAT:
                chestPrefab = LoadHelper.LoadAssetFromAnywhere <GameObject>("chest_rat");
                break;

            case ChestTier.TRUTH:
                Debug.LogError("ERROR: Chest Toolbox cannot spawn Truth Chest.");
                break;

            case ChestTier.OTHER:
                Debug.LogError("ERROR: Chest Toolbox cannot spawn 'Other' Chest.");
                break;
            }
            if (chestPrefab != null)
            {
                Chest spawnedChest = Chest.Spawn(chestPrefab.GetComponent <Chest>(), location);
                if (locked)
                {
                    spawnedChest.IsLocked = true;
                }
                else
                {
                    spawnedChest.IsLocked = false;
                }
                if (tier == ChestTier.GLITCHED)
                {
                    spawnedChest.BecomeGlitchChest();
                }
                if (tier == ChestTier.SECRETRAINBOW)
                {
                    spawnedChest.IsRainbowChest  = true;
                    spawnedChest.ChestIdentifier = Chest.SpecialChestIdentifier.SECRET_RAINBOW;
                }
                if (type == Chest.GeneralChestType.ITEM)
                {
                    spawnedChest.lootTable.lootTable = GameManager.Instance.RewardManager.ItemsLootTable;
                }
                else if (type == Chest.GeneralChestType.WEAPON)
                {
                    spawnedChest.lootTable.lootTable = GameManager.Instance.RewardManager.GunsLootTable;
                }
                else if (type == Chest.GeneralChestType.UNSPECIFIED)
                {
                    bool IsAGun = UnityEngine.Random.value <= 0.5f;
                    spawnedChest.lootTable.lootTable = (IsAGun ? GameManager.Instance.RewardManager.GunsLootTable : GameManager.Instance.RewardManager.ItemsLootTable);
                }

                if (mimic == ThreeStateValue.FORCEYES)
                {
                    spawnedChest.overrideMimicChance = 100;
                }
                if (mimic == ThreeStateValue.FORCENO)
                {
                    spawnedChest.overrideMimicChance = 0;
                }
                spawnedChest.MaybeBecomeMimic();

                if (fused == ThreeStateValue.FORCEYES)
                {
                    spawnedChest.AddFuse();
                }
                if (fused == ThreeStateValue.FORCENO)
                {
                    spawnedChest.PreventFuse = true;
                }

                spawnedChest.RegisterChestOnMinimap(spawnedChest.GetAbsoluteParentRoom());

                return(spawnedChest);
            }
            else
            {
                return(null);
            }
        }
예제 #4
0
    void SpawnChest(string[] args)
    {
        if (!ArgCount(args, 1, 2))
        {
            return;
        }
        Dungeonator.RoomHandler currentRoom = GameManager.Instance.PrimaryPlayer.CurrentRoom;
        Chest  chest;
        bool   glitched = false;
        string name     = args[0].ToLower();

        switch (name)
        {
        case "brown":
        case "d":
            chest = GameManager.Instance.RewardManager.D_Chest;
            break;

        case "blue":
        case "c":
            chest = GameManager.Instance.RewardManager.C_Chest;
            break;

        case "green":
        case "b":
            chest = GameManager.Instance.RewardManager.B_Chest;
            break;

        case "red":
        case "a":
            chest = GameManager.Instance.RewardManager.A_Chest;
            break;

        case "black":
        case "s":
            chest = GameManager.Instance.RewardManager.S_Chest;
            break;

        case "rainbow":
        case "r":
            chest = GameManager.Instance.RewardManager.Rainbow_Chest;
            break;

        case "glitched":
        case "g":
            chest    = GameManager.Instance.RewardManager.B_Chest;
            glitched = true;
            break;

        default:
            Log("Chest type " + args[0] + " doesn't exist! Valid types: brown, blue, green, red, black, rainbow");
            return;
        }
        WeightedGameObject wGameObject = new WeightedGameObject();

        wGameObject.rawGameObject = chest.gameObject;
        WeightedGameObjectCollection wGameObjectCollection = new WeightedGameObjectCollection();

        wGameObjectCollection.Add(wGameObject);
        int   count           = 1;
        float origMimicChance = chest.overrideMimicChance;

        chest.overrideMimicChance = 0f;
        if (args.Length > 1)
        {
            bool success = int.TryParse(args[1], out count);
            if (!success)
            {
                Log("Second argument must be an integer (number)");
                return;
            }
        }
        for (int i = 0; i < count; i++)
        {
            Chest spawnedChest = currentRoom.SpawnRoomRewardChest(wGameObjectCollection, currentRoom.GetBestRewardLocation(new IntVector2(2, 1), Dungeonator.RoomHandler.RewardLocationStyle.PlayerCenter, true));
            spawnedChest.ForceUnlock();
            if (glitched)
            {
                spawnedChest.BecomeGlitchChest();
            }
        }
        chest.overrideMimicChance = origMimicChance;
    }
예제 #5
0
        protected override void DoEffect(PlayerController user)
        {
            IPlayerInteractable nearestInteractable = user.CurrentRoom.GetNearestInteractable(user.CenterPosition, 1f, user);

            if (!(nearestInteractable is Chest))
            {
                return;
            }

            AkSoundEngine.PostEvent("Play_ENM_electric_charge_01", user.gameObject);

            Chest rerollChest = nearestInteractable as Chest;
            int   selected    = UnityEngine.Random.Range(1, 15);

            ETGModConsole.Log(selected.ToString());

            VFXToolbox.GlitchScreenForSeconds(1.5f);


            switch (selected)
            {
            case 1:     //Blow up chest
                if (user.PlayerHasActiveSynergy("KEYGEN"))
                {
                    SpareChest(rerollChest);
                }
                else
                {
                    Exploder.DoDefaultExplosion(rerollChest.specRigidbody.UnitCenter, Vector2.zero);
                    if (rerollChest.IsMimic)
                    {
                        OMITBReflectionHelpers.ReflectSetField <bool>(typeof(Chest), "m_isMimic", false, rerollChest);
                    }
                    rerollChest.majorBreakable.Break(Vector2.zero);
                    if (rerollChest.GetChestTier() == ChestToolbox.ChestTier.RAT)
                    {
                        UnityEngine.Object.Destroy(rerollChest.gameObject);
                    }
                }
                break;

            case 2:     //Open Chest
                rerollChest.ForceOpen(user);
                break;

            case 3:     //Break Lock
                if (user.PlayerHasActiveSynergy("KEYGEN"))
                {
                    SpareChest(rerollChest);
                }
                else
                {
                    if (rerollChest.IsLocked)
                    {
                        rerollChest.BreakLock();
                    }
                    else
                    {
                        rerollChest.majorBreakable.Break(Vector2.zero);
                    }
                }
                break;

            case 4:     //Duplicate Chest
                DupeChest(rerollChest, user);
                break;

            case 5:     //Turn into mimic
                if (!rerollChest.IsMimic)
                {
                    rerollChest.overrideMimicChance = 100; rerollChest.MaybeBecomeMimic();
                }
                rerollChest.ForceOpen(user);
                break;

            case 6:     //Englitch
                List <GlobalDungeonData.ValidTilesets> bannedGlitchFloors = new List <GlobalDungeonData.ValidTilesets>()
                {
                    GlobalDungeonData.ValidTilesets.CATACOMBGEON,
                    GlobalDungeonData.ValidTilesets.HELLGEON,
                    GlobalDungeonData.ValidTilesets.OFFICEGEON,
                    GlobalDungeonData.ValidTilesets.FORGEGEON,
                };
                if (!bannedGlitchFloors.Contains(GameManager.Instance.Dungeon.tileIndices.tilesetId))
                {
                    rerollChest.BecomeGlitchChest();
                }
                else
                {
                    if (!rerollChest.IsMimic)
                    {
                        rerollChest.MaybeBecomeMimic();
                    }
                    rerollChest.ForceOpen(user);
                }
                break;

            case 7:     //Enrainbow
                if (UnityEngine.Random.value <= 0.65f)
                {
                    UpgradeChest(rerollChest, user);
                }
                else
                {
                    rerollChest.BecomeRainbowChest();
                }
                break;

            case 8:     //Reroll
                RerollChest(rerollChest, user);
                break;

            case 9:     //Turn into pickups
                if (user.PlayerHasActiveSynergy("KEYGEN"))
                {
                    SpareChest(rerollChest);
                }
                else
                {
                    for (int i = 0; i < 5; i++)
                    {
                        LootEngine.SpawnItem(PickupObjectDatabase.GetById(BraveUtility.RandomElement(BabyGoodChanceKin.lootIDlist)).gameObject, rerollChest.sprite.WorldCenter, Vector2.zero, 0);
                    }
                    LootEngine.SpawnCurrency(rerollChest.sprite.WorldCenter, UnityEngine.Random.Range(5, 11));
                    user.CurrentRoom.DeregisterInteractable(rerollChest);
                    rerollChest.DeregisterChestOnMinimap();
                    UnityEngine.Object.Destroy(rerollChest.gameObject);
                }
                break;

            case 10:     //Fuse
                if (user.PlayerHasActiveSynergy("KEYGEN"))
                {
                    SpareChest(rerollChest);
                }
                else
                {
                    var type = typeof(Chest);
                    var func = type.GetMethod("TriggerCountdownTimer", BindingFlags.Instance | BindingFlags.NonPublic);
                    var ret  = func.Invoke(rerollChest, null);
                    AkSoundEngine.PostEvent("Play_OBJ_fuse_loop_01", rerollChest.gameObject);
                }
                break;

            case 11:     //Unlock
                if (rerollChest.IsLocked)
                {
                    rerollChest.ForceUnlock();
                }
                else
                {
                    rerollChest.ForceOpen(user);
                }
                break;

            case 12:     //Enjam
                rerollChest.gameObject.GetOrAddComponent <JammedChestBehav>();
                break;

            case 13:     //TeleportChest
                TeleportChest(rerollChest, user);
                break;

            case 14:     //Drill
                FauxDrill(rerollChest, user);
                break;
            }
        }