Esempio n. 1
0
            public static void Prefix(ref int width, ref int height)
            {
                Debug.Log(" === GridSettings_ResetMod INI === ");

                // 8x12 default
                //    if ()
                {
                    width  = 12 * 32;
                    height = 16 * 32;
                }
                return;

                //  ModConfig Config = new ModConfig(ModName);

                //   return;

                if (Game.Instance == null)
                {
                    return;
                }

                SettingConfig settingConfig         = Game.Instance.customSettings.QualitySettings[UseCustomWorldSize];
                SettingLevel  currentQualitySetting =
                    Game.Instance.customSettings.GetCurrentQualitySetting(UseCustomWorldSize);

                bool allowCustomSize = settingConfig?.IsDefaultLevel(currentQualitySetting.id) == true;

                if (!allowCustomSize)
                {
                    return;
                }

                SettingLevel currentQualitySettingX = Game.Instance.customSettings.GetCurrentQualitySetting(WorldsizeX);
                SettingLevel currentQualitySettingY = Game.Instance.customSettings.GetCurrentQualitySetting(WorldsizeY);

                if (Int32.TryParse(currentQualitySettingX.id, out width))
                {
                    width *= 32;
                }
                if (Int32.TryParse(currentQualitySettingY.id, out height))
                {
                    height *= 32;
                }

                //  if (Config.Enabled && Config.CustomWorldSize)
                //{
                //    width  = Config.width;
                //    height = Config.height;
                //}
            }
        public static void Prefix(ref int width, ref int height)
        {
            // 256x512 default

            Debug.Log(" === CWS: Using custom world size ... === ");
            //if (!CustomGameSettings.Get().is_custom_game)
            //if (!CustomGameSettings.Instance.is_custom_game)
            Debug.Log(" === " + CustomGameSettings.Instance.customGameMode + " === ");
            if (CustomGameSettings.Instance.customGameMode != CustomGameSettings.CustomGameMode.Custom)
            {
                Debug.Log(" === CWS: Nah, no custom game ... === ");
                return;
            }

            //SettingConfig settingConfig = CustomGameSettings.Get().QualitySettings[CustomWorldMod.UseCustomWorldSize];
            SettingConfig settingConfig         = CustomGameSettings.Instance.QualitySettings[CustomWorldMod.UseCustomWorldSize];
            SettingLevel  currentQualitySetting =
                //CustomGameSettings.Get().GetCurrentQualitySetting(CustomWorldMod.UseCustomWorldSize);
                CustomGameSettings.Instance.GetCurrentQualitySetting(CustomWorldMod.UseCustomWorldSize);

            bool allowCustomSize = !settingConfig.IsDefaultLevel(currentQualitySetting.id);

            if (!allowCustomSize)
            {
                Debug.Log(" === CWS: No custom size allowed ... === ");
                return;
            }

            //SettingLevel currentQualitySettingX = CustomGameSettings.Get().GetCurrentQualitySetting(CustomWorldMod.WorldsizeX);
            //SettingLevel currentQualitySettingY = CustomGameSettings.Get().GetCurrentQualitySetting(CustomWorldMod.WorldsizeY);
            SettingLevel currentQualitySettingX = CustomGameSettings.Instance.GetCurrentQualitySetting(CustomWorldMod.WorldsizeX);
            SettingLevel currentQualitySettingY = CustomGameSettings.Instance.GetCurrentQualitySetting(CustomWorldMod.WorldsizeY);

            Int32.TryParse(currentQualitySettingX.id, out width);
            Int32.TryParse(currentQualitySettingY.id, out height);

            Debug.Log(" === CWS: Using " + width + "/" + height + " as new world size === ");

            //  if (Config.Enabled && Config.CustomWorldSize)
            //{
            //    width  = Config.width;
            //    height = Config.height;
            //}
        }
        public static void Postfix(WorldGenSettings __instance, ref string worldName, ref List <string> traits)
        {
            // 256x512 default

            Debug.Log(" === CWS: Using custom world size ... Default: " + __instance.world.worldsize.x + "/" + __instance.world.worldsize.y + " === ");
            //if (!CustomGameSettings.Get().is_custom_game)
            //if (!CustomGameSettings.Instance.is_custom_game)
            Debug.Log(" === " + CustomGameSettings.Instance.customGameMode + " === ");
            if (CustomGameSettings.Instance.customGameMode != CustomGameSettings.CustomGameMode.Custom)
            {
                Debug.Log(" === CWS: Nah, no custom game ... === ");
                return;
            }

            //SettingConfig settingConfig = CustomGameSettings.Get().QualitySettings[CustomWorldSize.UseCustomWorldSize];
            SettingConfig settingConfig         = CustomGameSettings.Instance.QualitySettings[CustomWorldSize.UseCustomWorldSize];
            SettingLevel  currentQualitySetting =
                //CustomGameSettings.Get().GetCurrentQualitySetting(CustomWorldSize.UseCustomWorldSize);
                CustomGameSettings.Instance.GetCurrentQualitySetting(CustomWorldSize.UseCustomWorldSize);

            bool allowCustomSize = !settingConfig.IsDefaultLevel(currentQualitySetting.id);

            if (!allowCustomSize)
            {
                Debug.Log(" === CWS: No custom size applied ... === " + "Using " + __instance.world.worldsize.x + " / " + __instance.world.worldsize.y + " as new world size === ");
                return;
            }

            //SettingLevel currentQualitySettingX = CustomGameSettings.Get().GetCurrentQualitySetting(CustomWorldSize.WorldsizeX);
            //SettingLevel currentQualitySettingY = CustomGameSettings.Get().GetCurrentQualitySetting(CustomWorldSize.WorldsizeY);
            SettingLevel currentQualitySettingX = CustomGameSettings.Instance.GetCurrentQualitySetting(CustomWorldSize.WorldsizeX);
            SettingLevel currentQualitySettingY = CustomGameSettings.Instance.GetCurrentQualitySetting(CustomWorldSize.WorldsizeY);


            int width  = __instance.world.worldsize.x;
            int height = __instance.world.worldsize.y;

            Int32.TryParse(currentQualitySettingX.id, out width);
            Int32.TryParse(currentQualitySettingY.id, out height);

            Vector2I worldsize = __instance.world.worldsize;

            worldsize.x = width;
            worldsize.y = height;

            if (worldsize.x > worldsize.y)
            {
                Debug.Log(" === CWS: Fixing width. Width must be equals or less than height. There is a bug in ONI code somewhere :( otherwise, game crashes === ");
                worldsize.x = worldsize.y;
            }

            AccessTools.Property(typeof(ProcGen.World), "worldsize").SetValue(__instance.world, worldsize, null);

            Debug.Log(" === CWS: Using " + __instance.world.worldsize.x + "/" + __instance.world.worldsize.y + " as new world size === ");

            //  if (Config.Enabled && Config.CustomWorldSize)
            //{
            //    width  = Config.width;
            //    height = Config.height;
            //}
        }