Example #1
0
        public override void Init()
        {
            ExceptionText  = string.Empty;
            ExceptionText2 = string.Empty;

            ZipFilePath   = Metadata.Archive;
            FilePath      = Metadata.Directory;
            ResourcesPath = ETGMod.ResourcesDirectory;

            try { ExpandSettings.LoadSettings(); } catch (Exception ex) { ExceptionText2 = ex.ToString(); }

            itemList = new List <string>()
            {
                "Baby Good Hammer",
                "Corruption Bomb",
                "Table Tech Assassin",
                "ex:bloodied_scarf",
                "Cronenberg Bullets",
                "Mimiclay",
                "The Lead Key",
                "RockSlide",
                "Corrupted Master Round",
                "Wooden Crest",
                "Bootleg Pistol",
                "Bootleg Shotgun",
                "Bootleg Machine Pistol",
                "Bulletkin Gun",
                "Baby Sitter",
                "Pow Block",
                "Cursed Brick",
                "Black Revolver",
                "Golden Revolver",
                "Sonic Box"
            };

            ExpandAssets.InitCustomAssetBundles();

            if (ExpandSettings.EnableLogo)
            {
                ModLogo = ExpandAssets.LoadAsset <Texture2D>("EXLogo");
            }

            try {
                ExpandSharedHooks.InstallMidGameSaveHooks();
                if (ExpandSettings.EnableLogo)
                {
                    MainMenuFoyerUpdateHook = new Hook(
                        typeof(MainMenuFoyerController).GetMethod("Update", BindingFlags.NonPublic | BindingFlags.Instance),
                        typeof(ExpandTheGungeon).GetMethod(nameof(MainMenuUpdateHook), BindingFlags.NonPublic | BindingFlags.Instance),
                        typeof(MainMenuFoyerController)
                        );
                }
                GameManager.Instance.OnNewLevelFullyLoaded += ExpandObjectMods.InitSpecialMods;
            } catch (Exception ex) {
                // ETGModConsole can't be called by anything that occurs in Init(), so write message to static strinng and check it later.
                ExceptionText = "[ExpandTheGungeon] ERROR: Exception occured while installing hooks!";
                Debug.LogException(ex);
                return;
            }
        }
Example #2
0
        public static void InitCustomAssetBundle()
        {
            FieldInfo m_AssetBundlesField = typeof(ResourceManager).GetField("LoadedBundles", BindingFlags.Static | BindingFlags.NonPublic);
            Dictionary <string, AssetBundle> m_AssetBundles = (Dictionary <string, AssetBundle>)m_AssetBundlesField.GetValue(typeof(ResourceManager));

            AssetBundle m_ExpandSharedAssets1 = null;

            try {
                m_ExpandSharedAssets1 = ExpandAssets.LoadFromModZIPOrModFolder();
                if (m_ExpandSharedAssets1 != null)
                {
                    m_AssetBundles.Add("ExpandSharedAuto", m_ExpandSharedAssets1);
                }
                else
                {
                    string ErrorMessage = "[ExpandTheGungeon] ERROR: ExpandSharedAuto asset bundle not found!";
                    Debug.Log(ErrorMessage);
                    ExceptionText = ErrorMessage;
                    return;
                }
            } catch (Exception ex) {
                string ErrorMessage = "[ExpandTheGungeon] ERROR: Exception while loading ExpandSharedAuto asset bundle! Possible GUID conflict with other custom AssetBundles?";
                Debug.Log(ErrorMessage);
                Debug.LogException(ex);
                ExceptionText = ErrorMessage;
                return;
            }
        }
        public static void SaveSettings()
        {
            string CachedJSONText = string.Empty;

            ExpandCachedStats cachedStats = ScriptableObject.CreateInstance <ExpandCachedStats>();

            CachedJSONText = JsonUtility.ToJson(cachedStats);

            if (File.Exists(Path.Combine(ETGMod.ResourcesDirectory, ExpandTheGungeon.ModSettingsFileName)))
            {
                File.Delete(Path.Combine(ETGMod.ResourcesDirectory, ExpandTheGungeon.ModSettingsFileName));
            }

            ExpandAssets.SaveStringToFile(CachedJSONText, ETGMod.ResourcesDirectory, ExpandTheGungeon.ModSettingsFileName);
            return;
        }
Example #4
0
        public override void Start()
        {
            if (!string.IsNullOrEmpty(ExceptionText) | !string.IsNullOrEmpty(ExceptionText2))
            {
                if (!string.IsNullOrEmpty(ExceptionText))
                {
                    ETGModConsole.Log(ExceptionText);
                }
                if (!string.IsNullOrEmpty(ExceptionText2))
                {
                    ETGModConsole.Log(ExceptionText2);
                }
                return;
            }

            ExpandSharedHooks.InstallRequiredHooks();

            AssetBundle expandSharedAssets1 = ResourceManager.LoadAssetBundle(ModAssetBundleName);
            AssetBundle sharedAssets        = ResourceManager.LoadAssetBundle("shared_auto_001");
            AssetBundle sharedAssets2       = ResourceManager.LoadAssetBundle("shared_auto_002");
            AssetBundle braveResources      = ResourceManager.LoadAssetBundle("brave_resources_001");
            AssetBundle enemiesBase         = ResourceManager.LoadAssetBundle("enemies_base_001");

            ExpandAssets.InitAudio(expandSharedAssets1, ModSoundBankName);

            ExpandObjectDatabase.BuildDatabase();


            // Init Custom GameLevelDefinitions
            ExpandCustomDungeonPrefabs.InitCustomGameLevelDefinitions(braveResources);

            // Init Custom Sprite Collections
            ExpandPrefabs.InitSpriteCollections(expandSharedAssets1);
            ExpandCustomEnemyDatabase.InitSpriteCollections(expandSharedAssets1);

            // Init ItemAPI
            SetupItemAPI(expandSharedAssets1);

            try
            {
                // Init Prefab Databases
                ExpandPrefabs.InitCustomPrefabs(expandSharedAssets1, sharedAssets, sharedAssets2, braveResources, enemiesBase);
                // Init Custom Enemy Prefabs
                ExpandCustomEnemyDatabase.InitPrefabs(expandSharedAssets1);
                // Init Custom Room Prefabs
                ExpandRoomPrefabs.InitCustomRooms(expandSharedAssets1, sharedAssets, sharedAssets2, braveResources, enemiesBase);
                // Init Custom DungeonFlow(s)
                ExpandDungeonFlow.InitDungeonFlows(sharedAssets2);
                // Post Init
                // Things that need existing stuff created first have code run here
                BootlegGuns.PostInit();
                // Dungeon Prefabs
                ExpandCustomDungeonPrefabs.InitDungoenPrefabs(expandSharedAssets1, sharedAssets, sharedAssets2, braveResources);

                ExpandLists.InvalidRatFloorRainRooms = new List <string>()
                {
                    ExpandRoomPrefabs.SecretBossRoom.name,
                    ExpandRoomPrefabs.ThwompCrossingVerticalNoRain.name,
                    ExpandRoomPrefabs.SecretRewardRoom.name,
                    ExpandPrefabs.DragunBossFoyerRoom.name,
                    ExpandPrefabs.DraGunExitRoom.name,
                    ExpandPrefabs.DraGunEndTimesRoom.name,
                    ExpandPrefabs.BlacksmithShop.name,
                    "Zelda Puzzle Room 1",
                    "Zelda Puzzle Room 2",
                    "Zelda Puzzle Room 3",
                    "Special Entrance"
                };
            } catch (Exception ex) {
                ETGModConsole.Log("[ExpandTheGungeon] ERROR: Exception occured while building prefabs!", true);
                Debug.LogException(ex);
                expandSharedAssets1 = null;
                sharedAssets        = null;
                sharedAssets2       = null;
                braveResources      = null;
                enemiesBase         = null;
                return;
            }

            // Modified version of Anywhere mod
            DungeonFlowModule.Install();

            InitConsoleCommands(ConsoleCommandName);

            GameManager.Instance.StartCoroutine(WaitForFoyerLoad());

            if (ExpandSettings.EnableLanguageFix)
            {
                GameManager.Options.CurrentLanguage = StringTableManager.GungeonSupportedLanguages.ENGLISH;
                StringTableManager.CurrentLanguage  = StringTableManager.GungeonSupportedLanguages.ENGLISH;
            }

            // Null bundles when done with them to avoid game crash issues
            expandSharedAssets1 = null;
            sharedAssets        = null;
            sharedAssets2       = null;
            braveResources      = null;
            enemiesBase         = null;
        }