Decompiled source of UniverseGenTweaks v1.2.8

UniverseGenTweaks.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UXAssist.Common;
using UXAssist.UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using crecheng.DSPModSave;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("UniverseGenTweaks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("DSP MOD - UniverseGenTweaks")]
[assembly: AssemblyFileVersion("1.2.8.0")]
[assembly: AssemblyInformationalVersion("1.2.8+75147d7bc0985eb86b59e9a6eb4cc59873123fb7")]
[assembly: AssemblyProduct("UniverseGenTweaks")]
[assembly: AssemblyTitle("UniverseGenTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.8.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace UniverseGenTweaks
{
	public static class BirthPlanetPatch
	{
		private struct BackupData
		{
			private bool _inited;

			private int[] _algos;

			private int[] _veinSpot;

			private float[] _veinCount;

			private float[] _veinOpacity;

			private int[] _rareVeins;

			private float[] _rareSettings;

			private float _specifyBirthStarMass;

			private float _specifyBirthStarAge;

			public void FromTheme(ThemeProto theme)
			{
				_algos = theme.Algos.Clone() as int[];
				_veinSpot = theme.VeinSpot.Clone() as int[];
				_veinCount = theme.VeinCount.Clone() as float[];
				_veinOpacity = theme.VeinOpacity.Clone() as float[];
				_rareVeins = theme.RareVeins.Clone() as int[];
				_rareSettings = theme.RareSettings.Clone() as float[];
				_specifyBirthStarMass = StarGen.specifyBirthStarMass;
				_specifyBirthStarAge = StarGen.specifyBirthStarAge;
				_inited = true;
			}

			public void ToTheme(ThemeProto theme)
			{
				if (_inited)
				{
					theme.Algos = _algos.Clone() as int[];
					theme.VeinSpot = _veinSpot.Clone() as int[];
					theme.VeinCount = _veinCount.Clone() as float[];
					theme.VeinOpacity = _veinOpacity.Clone() as float[];
					theme.RareVeins = _rareVeins.Clone() as int[];
					theme.RareSettings = _rareSettings.Clone() as float[];
					StarGen.specifyBirthStarMass = _specifyBirthStarMass;
					StarGen.specifyBirthStarAge = _specifyBirthStarAge;
				}
			}
		}

		public static ConfigEntry<bool> SitiVeinsOnBirthPlanet;

		public static ConfigEntry<bool> FireIceOnBirthPlanet;

		public static ConfigEntry<bool> KimberliteOnBirthPlanet;

		public static ConfigEntry<bool> FractalOnBirthPlanet;

		public static ConfigEntry<bool> OrganicOnBirthPlanet;

		public static ConfigEntry<bool> OpticalOnBirthPlanet;

		public static ConfigEntry<bool> SpiniformOnBirthPlanet;

		public static ConfigEntry<bool> UnipolarOnBirthPlanet;

		public static ConfigEntry<bool> FlatBirthPlanet;

		public static ConfigEntry<bool> HighLuminosityBirthStar;

		private static BackupData _backupData;

		private static bool _initialized;

		private static Harmony _patch;

		public static void Init()
		{
			SitiVeinsOnBirthPlanet.SettingChanged += delegate
			{
				PatchBirthThemeData();
			};
			FireIceOnBirthPlanet.SettingChanged += delegate
			{
				PatchBirthThemeData();
			};
			KimberliteOnBirthPlanet.SettingChanged += delegate
			{
				PatchBirthThemeData();
			};
			FractalOnBirthPlanet.SettingChanged += delegate
			{
				PatchBirthThemeData();
			};
			OrganicOnBirthPlanet.SettingChanged += delegate
			{
				PatchBirthThemeData();
			};
			OpticalOnBirthPlanet.SettingChanged += delegate
			{
				PatchBirthThemeData();
			};
			SpiniformOnBirthPlanet.SettingChanged += delegate
			{
				PatchBirthThemeData();
			};
			UnipolarOnBirthPlanet.SettingChanged += delegate
			{
				PatchBirthThemeData();
			};
			FlatBirthPlanet.SettingChanged += delegate
			{
				PatchBirthThemeData();
			};
			HighLuminosityBirthStar.SettingChanged += delegate
			{
				PatchBirthThemeData();
			};
			PatchBirthThemeData();
			if (_patch == null)
			{
				_patch = Harmony.CreateAndPatchAll(typeof(BirthPlanetPatch), (string)null);
			}
			GameLogic.OnDataLoaded = (Action)Delegate.Combine(GameLogic.OnDataLoaded, new Action(VFPreload_InvokeOnLoadWorkEnded_Postfix));
		}

		public static void Uninit()
		{
			GameLogic.OnDataLoaded = (Action)Delegate.Remove(GameLogic.OnDataLoaded, new Action(VFPreload_InvokeOnLoadWorkEnded_Postfix));
			Harmony patch = _patch;
			if (patch != null)
			{
				patch.UnpatchSelf();
			}
			_patch = null;
		}

		private static void VFPreload_InvokeOnLoadWorkEnded_Postfix()
		{
			PatchBirthThemeData();
		}

		private static void PatchBirthThemeData()
		{
			ThemeProto val = ((ProtoSet<ThemeProto>)(object)LDB.themes).Select(1);
			if (!_initialized)
			{
				_backupData.FromTheme(val);
			}
			else
			{
				_backupData.ToTheme(val);
			}
			if (FlatBirthPlanet.Value)
			{
				val.Algos[0] = 2;
			}
			if (SitiVeinsOnBirthPlanet.Value)
			{
				val.VeinSpot[2] = 2;
				val.VeinSpot[3] = 2;
				val.VeinCount[2] = 0.7f;
				val.VeinCount[3] = 0.7f;
				val.VeinOpacity[2] = 1f;
				val.VeinOpacity[3] = 1f;
			}
			List<int> list = new List<int>();
			List<float> list2 = new List<float>();
			if (FireIceOnBirthPlanet.Value)
			{
				list.Add(8);
				list2.AddRange(new float[4] { 1f, 1f, 0.5f, 1f });
			}
			if (KimberliteOnBirthPlanet.Value)
			{
				list.Add(9);
				list2.AddRange(new float[4] { 1f, 1f, 0.5f, 1f });
			}
			if (FractalOnBirthPlanet.Value)
			{
				list.Add(10);
				list2.AddRange(new float[4] { 1f, 1f, 0.5f, 1f });
			}
			if (OrganicOnBirthPlanet.Value)
			{
				list.Add(11);
				list2.AddRange(new float[4] { 1f, 1f, 0.5f, 1f });
			}
			if (OpticalOnBirthPlanet.Value)
			{
				list.Add(12);
				list2.AddRange(new float[4] { 1f, 1f, 0.5f, 1f });
			}
			if (SpiniformOnBirthPlanet.Value)
			{
				list.Add(13);
				list2.AddRange(new float[4] { 1f, 1f, 0.5f, 1f });
			}
			if (UnipolarOnBirthPlanet.Value)
			{
				list.Add(14);
				list2.AddRange(new float[4] { 1f, 1f, 0.5f, 1f });
			}
			if (list.Count > 0)
			{
				val.RareVeins = list.ToArray();
				val.RareSettings = list2.ToArray();
			}
			if (HighLuminosityBirthStar.Value)
			{
				StarGen.specifyBirthStarMass = 53.81f;
				StarGen.specifyBirthStarAge = 0.01f;
			}
			_initialized = true;
		}
	}
	public static class EpicDifficulty
	{
		public static ConfigEntry<bool> Enabled;

		public static ConfigEntry<float> ResourceMultiplier;

		public static ConfigEntry<float> OilMultiplier;

		private static Harmony _harmony;

		private static readonly float[] ResourceMultipliers = new float[9] { 0.0001f, 0.0005f, 0.001f, 0.005f, 0.01f, 0.02f, 0.03f, 0.04f, 0.05f };

		private static readonly float[] OilMultipliers = new float[10] { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1f };

		public static void Init()
		{
			I18N.Add("究极少", "Micro", "究极少");
			I18N.Add("史诗难度", "Epic Difficulty !!", "史诗难度 !!");
			I18N.Apply();
			Enabled.SettingChanged += delegate
			{
				Enable(Enabled.Value);
			};
			Enable(Enabled.Value);
		}

		public static void Uninit()
		{
			Enable(on: false);
		}

		private static void Enable(bool on)
		{
			if (on)
			{
				if (_harmony == null)
				{
					_harmony = Harmony.CreateAndPatchAll(typeof(EpicDifficulty), (string)null);
				}
				return;
			}
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			_harmony = null;
		}

		public static float IndexToResourceMultiplier(int index)
		{
			return ResourceMultipliers[(index >= 0) ? ((index >= ResourceMultipliers.Length) ? (ResourceMultipliers.Length - 1) : index) : 0];
		}

		public static int ResourceMultiplierToIndex(float mult)
		{
			for (int num = ResourceMultipliers.Length - 1; num > 0; num--)
			{
				if (ResourceMultipliers[num] <= mult)
				{
					return num;
				}
			}
			return 0;
		}

		public static int ResourceMultipliersCount()
		{
			return ResourceMultipliers.Length;
		}

		public static float IndexToOilMultiplier(int index)
		{
			return OilMultipliers[(index >= 0) ? ((index >= OilMultipliers.Length) ? (OilMultipliers.Length - 1) : index) : 0];
		}

		public static int OilMultiplierToIndex(float mult)
		{
			for (int num = OilMultipliers.Length - 1; num > 0; num--)
			{
				if (OilMultipliers[num] <= mult)
				{
					return num;
				}
			}
			return 0;
		}

		public static int OilMultipliersCount()
		{
			return OilMultipliers.Length;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIGalaxySelect), "_OnInit")]
		private static void PatchGalaxyUI_OnInit(UIGalaxySelect __instance)
		{
			__instance.resourceMultiplierSlider.maxValue = 11f;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(UIGalaxySelect), "OnResourceMultiplierValueChange")]
		private static bool UIGalaxySelect_OnResourceMultiplierValueChange_Prefix(UIGalaxySelect __instance, float val)
		{
			float value = __instance.resourceMultiplierSlider.value;
			GameDesc gameDesc = __instance.gameDesc;
			float resourceMultiplier = ((value < 0.5f) ? ResourceMultiplier.Value : ((value < 1.5f) ? 0.1f : ((value < 2.5f) ? 0.3f : ((value < 3.5f) ? 0.5f : ((value < 4.5f) ? 0.8f : ((value < 5.5f) ? 1f : ((value < 6.5f) ? 1.5f : ((value < 7.5f) ? 2f : ((value < 8.5f) ? 3f : ((value < 9.5f) ? 5f : ((!(value < 10.5f)) ? 100f : 8f)))))))))));
			gameDesc.resourceMultiplier = resourceMultiplier;
			__instance.UpdateParametersUIDisplay();
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(UIGalaxySelect), "UpdateParametersUIDisplay")]
		private static bool UIGalaxySelect_UpdateParametersUIDisplay_Prefix(UIGalaxySelect __instance)
		{
			float resourceMultiplier = __instance.gameDesc.resourceMultiplier;
			string text = "";
			Slider resourceMultiplierSlider = __instance.resourceMultiplierSlider;
			float value = ((resourceMultiplier < 0.09f) ? 0f : ((resourceMultiplier < 0.11f) ? 1f : ((resourceMultiplier < 0.31f) ? 2f : ((resourceMultiplier < 0.51f) ? 3f : ((resourceMultiplier < 0.81f) ? 4f : ((resourceMultiplier < 1.01f) ? 5f : ((resourceMultiplier < 1.51f) ? 6f : ((resourceMultiplier < 2.01f) ? 7f : ((resourceMultiplier < 3.01f) ? 8f : ((resourceMultiplier < 5.01f) ? 9f : ((!(resourceMultiplier < 8.01f)) ? 11f : 10f)))))))))));
			resourceMultiplierSlider.value = value;
			string text2 = ((resourceMultiplier < 100f) ? ((resourceMultiplier > 0.1f) ? (resourceMultiplier + "x") : ((!(resourceMultiplier < 0.09f)) ? Localization.Translate("极少") : Localization.Translate("究极少"))) : ((!(resourceMultiplier >= 100f)) ? text : Localization.Translate("无限")));
			text = text2;
			__instance.resourceMultiplierText.text = text;
			__instance.propertyMultiplierText.text = Localization.Translate("元数据生成倍率") + " " + __instance.gameDesc.propertyMultiplier.ToString("P0");
			__instance.addrText.text = __instance.gameDesc.clusterString;
			bool flag = resourceMultiplier < 0.11f && !__instance.gameDesc.isSandboxMode;
			__instance.difficultTipGroup.SetActive(flag);
			if (!flag)
			{
				return false;
			}
			((Component)__instance.difficultTipGroup.transform.Find("difficult-tip-text")).GetComponent<Text>().text = Localization.Translate((resourceMultiplier < 0.09f) ? "史诗难度" : "非常困难");
			return false;
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(GameDesc), "get_oilAmountMultiplier")]
		private static IEnumerable<CodeInstruction> GameDesc_get_oilAmountMultiplier_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, generator);
			if (Math.Abs(OilMultiplier.Value - 1f) > 1E-05f)
			{
				Label label = generator.DefineLabel();
				val.Start().InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[4]
				{
					new CodeInstruction(OpCodes.Ldarg_0, (object)null),
					new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(GameDesc), "resourceMultiplier")),
					new CodeInstruction(OpCodes.Ldc_R4, (object)0.05f),
					new CodeInstruction(OpCodes.Ble_S, (object)label)
				}).End()
					.Advance(1)
					.Insert((CodeInstruction[])(object)new CodeInstruction[2]
					{
						CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldc_R4, (object)(0.5f * OilMultiplier.Value)), new Label[1] { label }),
						new CodeInstruction(OpCodes.Ret, (object)null)
					});
			}
			return val.InstructionEnumeration();
		}
	}
	public class MoreSettings
	{
		private static class PermanentPatch
		{
			private static void ResetSettings()
			{
				_gameMinDist = 2.0;
				_gameMinStep = 2.0;
				_gameMaxStep = 3.2;
				_gameFlatten = 0.18;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(GameData), "Import")]
			private static void GameData_Import_Prefix(GameData __instance)
			{
				ResetSettings();
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(GameData), "SetForNewGame")]
			private static void GameData_SetForNewGame_Prefix(GameData __instance)
			{
				if (!Enabled.Value)
				{
					ResetSettings();
				}
			}

			[HarmonyTranspiler]
			[HarmonyPatch(/*Could not decode attribute arguments.*/)]
			private static IEnumerable<CodeInstruction> GalaxyData_Constructor_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected O, but got Unknown
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Expected O, but got Unknown
				CodeMatcher val = new CodeMatcher(instructions, generator);
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.opcode == OpCodes.Ldc_I4 && CodeInstructionExtensions.OperandIs(ci, (object)25700)), (string)null)
				});
				val.Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
				{
					m.SetAndAdvance(OpCodes.Ldc_I4, (object)102500);
				}, (Action<string>)null);
				return val.InstructionEnumeration();
			}

			[HarmonyTranspiler]
			[HarmonyPatch(typeof(SectorModel), "CreateGalaxyAstroBuffer")]
			[HarmonyPatch(typeof(SpaceColliderLogic), "UpdateCollidersPose")]
			private static IEnumerable<CodeInstruction> SectorModel_CreateGalaxyAstroBuffer_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected O, but got Unknown
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Expected O, but got Unknown
				CodeMatcher val = new CodeMatcher(instructions, generator);
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.opcode == OpCodes.Ldc_I4 && CodeInstructionExtensions.OperandIs(ci, (object)25600)), (string)null)
				});
				val.Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
				{
					m.SetAndAdvance(OpCodes.Ldc_I4, (object)102500);
				}, (Action<string>)null);
				return val.InstructionEnumeration();
			}

			[HarmonyTranspiler]
			[HarmonyPatch(typeof(UniverseGen), "CreateGalaxy")]
			private static IEnumerable<CodeInstruction> UniverseGen_CreateGalaxy_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected O, but got Unknown
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Expected O, but got Unknown
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Expected O, but got Unknown
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0093: Expected O, but got Unknown
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Expected O, but got Unknown
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Expected O, but got Unknown
				CodeMatcher val = new CodeMatcher(instructions, generator);
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(UniverseGen), "GenerateTempPoses", (Type[])null, (Type[])null), (string)null)
				}).Advance(-4).RemoveInstructions(4)
					.Insert((CodeInstruction[])(object)new CodeInstruction[4]
					{
						new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MoreSettings), "_gameMinDist")),
						new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MoreSettings), "_gameMinStep")),
						new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MoreSettings), "_gameMaxStep")),
						new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MoreSettings), "_gameFlatten"))
					});
				return val.InstructionEnumeration();
			}

			[HarmonyTranspiler]
			[HarmonyPatch(typeof(UniverseGen), "RandomPoses")]
			private static IEnumerable<CodeInstruction> UniverseGen_RandomPoses_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected O, but got Unknown
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Expected O, but got Unknown
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Expected O, but got Unknown
				CodeMatcher val = new CodeMatcher(instructions, generator);
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
				{
					new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null),
					new CodeMatch((OpCode?)OpCodes.Ldarg_2, (object)null, (string)null)
				});
				val.Repeat((Action<CodeMatcher>)delegate(CodeMatcher m)
				{
					//IL_000d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0017: Expected O, but got Unknown
					m.Advance(1).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Ldarg_3, (object)null));
				}, (Action<string>)null);
				return val.InstructionEnumeration();
			}
		}

		public static ConfigEntry<bool> Enabled;

		public static ConfigEntry<int> MaxStarCount;

		private static double _minDist = 2.0;

		private static double _minStep = 2.0;

		private static double _maxStep = 3.2;

		private static double _flatten = 0.18;

		private static Text _minDistTitle;

		private static Text _minStepTitle;

		private static Text _maxStepTitle;

		private static Text _flattenTitle;

		private static Slider _minDistSlider;

		private static Slider _minStepSlider;

		private static Slider _maxStepSlider;

		private static Slider _flattenSlider;

		private static Text _minDistText;

		private static Text _minStepText;

		private static Text _maxStepText;

		private static Text _flattenText;

		private static Harmony _patch;

		private static Harmony _permanentPatch;

		private static double _gameMinDist = 2.0;

		private static double _gameMinStep = 2.0;

		private static double _gameMaxStep = 3.2;

		private static double _gameFlatten = 0.18;

		public static void Init()
		{
			I18N.Add("恒星最小距离", "Star Distance Min", "恒星最小距离");
			I18N.Add("步进最小距离", "Step Distance Min", "步进最小距离");
			I18N.Add("步进最大距离", "Step Distance Max", "步进最大距离");
			I18N.Add("扁平度", "Flatness", "扁平度");
			I18N.Apply();
			if (_permanentPatch == null)
			{
				_permanentPatch = Harmony.CreateAndPatchAll(typeof(PermanentPatch), (string)null);
			}
			Enabled.SettingChanged += delegate
			{
				Enable(Enabled.Value);
			};
			Enable(Enabled.Value);
		}

		public static void Uninit()
		{
			Enable(on: false);
			Harmony permanentPatch = _permanentPatch;
			if (permanentPatch != null)
			{
				permanentPatch.UnpatchSelf();
			}
			_permanentPatch = null;
		}

		private static void Enable(bool on)
		{
			if (on)
			{
				if (_patch == null)
				{
					_patch = Harmony.CreateAndPatchAll(typeof(MoreSettings), (string)null);
				}
				return;
			}
			Harmony patch = _patch;
			if (patch != null)
			{
				patch.UnpatchSelf();
			}
			_patch = null;
		}

		private static void CreateSliderWithText(Slider orig, out Text title, out Slider slider, out Text text, out Localizer loc)
		{
			Text component = ((Component)((Component)orig).transform.parent).GetComponent<Text>();
			title = Object.Instantiate<Text>(component, ((Component)component).transform.parent);
			slider = ((Component)CommonUtils.FindChildRecur(((Component)title).transform, "Slider")).GetComponent<Slider>();
			text = ((Component)CommonUtils.FindChildRecur(((Component)slider).transform, "Text")).GetComponent<Text>();
			loc = ((Component)title).GetComponent<Localizer>();
		}

		private static void TransformDeltaY(Transform trans, float delta)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 anchoredPosition3D = ((RectTransform)trans).anchoredPosition3D;
			anchoredPosition3D.y += delta;
			((RectTransform)trans).anchoredPosition3D = anchoredPosition3D;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIGalaxySelect), "_OnCreate")]
		private static void UIGalaxySelect__OnCreate_Postfix(UIGalaxySelect __instance)
		{
			__instance.starCountSlider.maxValue = MaxStarCount.Value;
			CreateSliderWithText(__instance.starCountSlider, out _minDistTitle, out _minDistSlider, out _minDistText, out var loc);
			CreateSliderWithText(__instance.starCountSlider, out _minStepTitle, out _minStepSlider, out _minStepText, out var loc2);
			CreateSliderWithText(__instance.starCountSlider, out _maxStepTitle, out _maxStepSlider, out _maxStepText, out var loc3);
			CreateSliderWithText(__instance.starCountSlider, out _flattenTitle, out _flattenSlider, out _flattenText, out var loc4);
			loc.stringKey = "恒星最小距离";
			loc2.stringKey = "步进最小距离";
			loc3.stringKey = "步进最大距离";
			loc4.stringKey = "扁平度";
			((Object)_minDistTitle).name = "min-dist";
			_minDistSlider.minValue = 10f;
			_minDistSlider.maxValue = 50f;
			_minDistSlider.value = (float)(_minDist * 10.0);
			((Object)_minStepTitle).name = "min-step";
			_minStepSlider.minValue = 10f;
			_minStepSlider.maxValue = (float)(_maxStep * 10.0 - 1.0);
			_minStepSlider.value = (float)(_minStep * 10.0);
			((Object)_maxStepTitle).name = "max-step";
			_maxStepSlider.minValue = (float)(_minStep * 10.0 + 1.0);
			_maxStepSlider.maxValue = 100f;
			_maxStepSlider.value = (float)(_maxStep * 10.0);
			((Object)_flattenTitle).name = "flatten";
			_flattenSlider.minValue = 1f;
			_flattenSlider.maxValue = 50f;
			_flattenSlider.value = (float)(_flatten * 50.0);
			TransformDeltaY(((Component)_minDistTitle).transform, -36f);
			TransformDeltaY(((Component)_minStepTitle).transform, -72f);
			TransformDeltaY(((Component)_maxStepTitle).transform, -108f);
			TransformDeltaY(((Component)_flattenTitle).transform, -144f);
			TransformDeltaY(((Component)__instance.darkFogToggle).transform.parent, -144f);
			TransformDeltaY(((Component)__instance.resourceMultiplierSlider).transform.parent, -144f);
			TransformDeltaY(((Component)__instance.sandboxToggle).transform.parent, -144f);
			TransformDeltaY(((Component)__instance.propertyMultiplierText).transform, -144f);
			TransformDeltaY(((Component)__instance.addrText).transform.parent, -144f);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(UIGalaxySelect), "_OnOpen")]
		private static void UIGalaxySelect__OnOpen_Prefix()
		{
			_minDistText.text = _minDist.ToString();
			_minStepText.text = _minStep.ToString();
			_maxStepText.text = _maxStep.ToString();
			_flattenText.text = _flatten.ToString();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIGalaxySelect), "_OnRegEvent")]
		private static void UIGalaxySelect__OnRegEvent_Postfix(UIGalaxySelect __instance)
		{
			((UnityEventBase)_minDistSlider.onValueChanged).RemoveAllListeners();
			((UnityEvent<float>)(object)_minDistSlider.onValueChanged).AddListener((UnityAction<float>)delegate(float val)
			{
				double gameMinDist = (double)Mathf.Round(val) / 10.0;
				if (!gameMinDist.Equals(_minDist))
				{
					_minDist = (_gameMinDist = gameMinDist);
					_minDistText.text = _minDist.ToString();
					if (_minStep < _minDist)
					{
						_minStep = (_gameMinStep = _minDist);
						_minStepSlider.value = (float)(_minStep * 10.0);
						_minStepText.text = _minStep.ToString();
						if (_maxStep < _minStep)
						{
							_maxStep = (_gameMaxStep = _minStep);
							_maxStepSlider.value = (float)(_maxStep * 10.0);
							_maxStepText.text = _maxStep.ToString();
						}
					}
					__instance.SetStarmapGalaxy();
				}
			});
			((UnityEventBase)_minStepSlider.onValueChanged).RemoveAllListeners();
			((UnityEvent<float>)(object)_minStepSlider.onValueChanged).AddListener((UnityAction<float>)delegate(float val)
			{
				double num2 = (double)Mathf.Round(val) / 10.0;
				if (!num2.Equals(_minStep))
				{
					_minStep = (_gameMinStep = num2);
					_maxStepSlider.minValue = (float)(num2 * 10.0);
					_minStepText.text = _minStep.ToString();
					__instance.SetStarmapGalaxy();
				}
			});
			((UnityEventBase)_maxStepSlider.onValueChanged).RemoveAllListeners();
			((UnityEvent<float>)(object)_maxStepSlider.onValueChanged).AddListener((UnityAction<float>)delegate(float val)
			{
				double num = (double)Mathf.Round(val) / 10.0;
				if (!num.Equals(_maxStep))
				{
					_maxStep = (_gameMaxStep = num);
					_minStepSlider.maxValue = (float)(num * 10.0);
					_maxStepText.text = _maxStep.ToString();
					__instance.SetStarmapGalaxy();
				}
			});
			((UnityEventBase)_flattenSlider.onValueChanged).RemoveAllListeners();
			((UnityEvent<float>)(object)_flattenSlider.onValueChanged).AddListener((UnityAction<float>)delegate(float val)
			{
				double gameFlatten = (double)Mathf.Round(val) / 50.0;
				if (!gameFlatten.Equals(_flatten))
				{
					_flatten = (_gameFlatten = gameFlatten);
					_flattenText.text = _flatten.ToString();
					__instance.SetStarmapGalaxy();
				}
			});
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIGalaxySelect), "_OnUnregEvent")]
		private static void UIGalaxySelect__OnUnregEvent_Postfix()
		{
			((UnityEventBase)_minDistSlider.onValueChanged).RemoveAllListeners();
			((UnityEventBase)_minStepSlider.onValueChanged).RemoveAllListeners();
			((UnityEventBase)_maxStepSlider.onValueChanged).RemoveAllListeners();
			((UnityEventBase)_flattenSlider.onValueChanged).RemoveAllListeners();
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(UIGalaxySelect), "OnStarCountSliderValueChange")]
		private static IEnumerable<CodeInstruction> UIGalaxySelect_OnStarCountSliderValueChange_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, generator);
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => ci.opcode == OpCodes.Ldc_I4_S && CodeInstructionExtensions.OperandIs(ci, (object)80)), (string)null)
			}).SetAndAdvance(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MoreSettings), "MaxStarCount")).Insert((CodeInstruction[])(object)new CodeInstruction[1]
			{
				new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(ConfigEntry<int>), "Value"))
			});
			return val.InstructionEnumeration();
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(UIGalaxySelect), "ApplySetting")]
		private static void UIGalaxySelect_EnterGame_Prefix()
		{
			_gameMinDist = _minDist;
			_gameMinStep = _minStep;
			_gameMaxStep = _maxStep;
			_gameFlatten = _flatten;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UICombatSettingsDF), "_OnCreate")]
		private static void UICombatSettingsDF__OnCreate_Postfix(UICombatSettingsDF __instance)
		{
			__instance.initLevelSlider.maxValue = 30f;
			__instance.initGrowthSlider.maxValue = 10f;
			__instance.initOccupiedSlider.maxValue = 10f;
			__instance.growthSpeedSlider.maxValue = 7f;
			__instance.powerThreatSlider.maxValue = 10f;
			__instance.combatThreatSlider.maxValue = 10f;
			__instance.DFExpSlider.maxValue = 10f;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(UICombatSettingsDF), "OnInitLevelSliderChanged")]
		private static bool UICombatSettingsDF_OnInitLevelSliderChanged_Prefix(UICombatSettingsDF __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_ = __instance.combatSettings;
			float value = __instance.initLevelSlider.value;
			float initialLevel = ((value < 0.5f) ? 0f : ((value < 1.5f) ? 1f : ((value < 2.5f) ? 2f : ((value < 3.5f) ? 3f : ((value < 4.5f) ? 4f : ((value < 5.5f) ? 5f : ((value < 6.5f) ? 6f : ((value < 7.5f) ? 7f : ((value < 8.5f) ? 8f : ((value < 9.5f) ? 9f : ((value < 10.5f) ? 10f : ((value < 11.5f) ? 11f : ((value < 12.5f) ? 12f : ((value < 13.5f) ? 13f : ((value < 14.5f) ? 14f : ((value < 15.5f) ? 15f : ((value < 16.5f) ? 16f : ((value < 17.5f) ? 17f : ((value < 18.5f) ? 18f : ((value < 19.5f) ? 19f : ((value < 20.5f) ? 20f : ((value < 21.5f) ? 21f : ((value < 22.5f) ? 22f : ((value < 23.5f) ? 23f : ((value < 24.5f) ? 24f : ((value < 25.5f) ? 25f : ((value < 26.5f) ? 26f : ((value < 27.5f) ? 27f : ((value < 28.5f) ? 28f : ((!(value < 29.5f)) ? 30f : 29f))))))))))))))))))))))))))))));
			__instance.combatSettings.initialLevel = initialLevel;
			__instance.UpdateUIParametersDisplay();
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(UICombatSettingsDF), "OnInitGrowthSliderChanged")]
		private static bool UICombatSettingsDF_OnInitGrowthSliderChanged_Prefix(UICombatSettingsDF __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_ = __instance.combatSettings;
			float value = __instance.initGrowthSlider.value;
			float initialGrowth = ((value < 0.5f) ? 0f : ((value < 1.5f) ? 0.25f : ((value < 2.5f) ? 0.5f : ((value < 3.5f) ? 0.75f : ((value < 4.5f) ? 1f : ((value < 5.5f) ? 1.5f : ((value < 6.5f) ? 2f : ((value < 7.5f) ? 2.5f : ((value < 8.5f) ? 3f : ((!(value < 9.5f)) ? 4f : 3.5f))))))))));
			__instance.combatSettings.initialGrowth = initialGrowth;
			__instance.UpdateUIParametersDisplay();
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(UICombatSettingsDF), "OnInitOccupiedSliderChanged")]
		private static bool UICombatSettingsDF_OnInitOccupiedSliderChanged_Prefix(UICombatSettingsDF __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_ = __instance.combatSettings;
			float value = __instance.initOccupiedSlider.value;
			float initialColonize = ((value < 0.5f) ? 0.01f : ((value < 1.5f) ? 0.25f : ((value < 2.5f) ? 0.5f : ((value < 3.5f) ? 0.75f : ((value < 4.5f) ? 1f : ((value < 5.5f) ? 1.5f : ((value < 6.5f) ? 2f : ((value < 7.5f) ? 2.5f : ((value < 8.5f) ? 3f : ((!(value < 9.5f)) ? 4f : 3.5f))))))))));
			__instance.combatSettings.initialColonize = initialColonize;
			__instance.UpdateUIParametersDisplay();
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(UICombatSettingsDF), "OnGrowthSpeedSliderChanged")]
		private static bool UICombatSettingsDF_OnGrowthSpeedSliderChanged_Prefix(UICombatSettingsDF __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_ = __instance.combatSettings;
			float value = __instance.growthSpeedSlider.value;
			float growthSpeedFactor = ((value < 0.5f) ? 0.25f : ((value < 1.5f) ? 0.5f : ((value < 2.5f) ? 1f : ((value < 3.5f) ? 2f : ((value < 4.5f) ? 3f : ((value < 5.5f) ? 4f : ((!(value < 6.5f)) ? 6f : 5f)))))));
			__instance.combatSettings.growthSpeedFactor = growthSpeedFactor;
			__instance.UpdateUIParametersDisplay();
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(UICombatSettingsDF), "OnPowerThreatSliderChanged")]
		private static bool UICombatSettingsDF_OnPowerThreatSliderChanged_Prefix(UICombatSettingsDF __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_ = __instance.combatSettings;
			float value = __instance.powerThreatSlider.value;
			float powerThreatFactor = ((value < 0.5f) ? 0.01f : ((value < 1.5f) ? 0.1f : ((value < 2.5f) ? 0.2f : ((value < 3.5f) ? 0.5f : ((value < 4.5f) ? 1f : ((value < 5.5f) ? 2f : ((value < 6.5f) ? 5f : ((value < 7.5f) ? 8f : ((value < 8.5f) ? 10f : ((!(value < 9.5f)) ? 20f : 15f))))))))));
			__instance.combatSettings.powerThreatFactor = powerThreatFactor;
			__instance.UpdateUIParametersDisplay();
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(UICombatSettingsDF), "OnCombatThreatSliderChanged")]
		private static bool UICombatSettingsDF_OnCombatThreatSliderChanged_Prefix(UICombatSettingsDF __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_ = __instance.combatSettings;
			float value = __instance.combatThreatSlider.value;
			float battleThreatFactor = ((value < 0.5f) ? 0.01f : ((value < 1.5f) ? 0.1f : ((value < 2.5f) ? 0.2f : ((value < 3.5f) ? 0.5f : ((value < 4.5f) ? 1f : ((value < 5.5f) ? 2f : ((value < 6.5f) ? 5f : ((value < 7.5f) ? 8f : ((value < 8.5f) ? 10f : ((!(value < 9.5f)) ? 20f : 15f))))))))));
			__instance.combatSettings.battleThreatFactor = battleThreatFactor;
			__instance.UpdateUIParametersDisplay();
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(UICombatSettingsDF), "OnEXPSliderChanged")]
		private static bool UICombatSettingsDF_OnEXPSliderChanged_Prefix(UICombatSettingsDF __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_ = __instance.combatSettings;
			float value = __instance.DFExpSlider.value;
			float battleExpFactor = ((value < 0.5f) ? 0.01f : ((value < 1.5f) ? 0.1f : ((value < 2.5f) ? 0.2f : ((value < 3.5f) ? 0.5f : ((value < 4.5f) ? 1f : ((value < 5.5f) ? 2f : ((value < 6.5f) ? 5f : ((value < 7.5f) ? 8f : ((value < 8.5f) ? 10f : ((!(value < 9.5f)) ? 20f : 15f))))))))));
			__instance.combatSettings.battleExpFactor = battleExpFactor;
			__instance.UpdateUIParametersDisplay();
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(UICombatSettingsDF), "UpdateUIParametersDisplay")]
		private static bool UICombatSettingsDF_UpdateUIParametersDisplay_Prefix(UICombatSettingsDF __instance)
		{
			//IL_09e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e6: Expected O, but got Unknown
			//IL_0a3e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a45: Invalid comparison between Unknown and I4
			//IL_0a6d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a72: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			Slider aggresiveSlider = __instance.aggresiveSlider;
			float aggressiveness = __instance.combatSettings.aggressiveness;
			float value = ((aggressiveness < -0.99f) ? 0f : ((aggressiveness < 0.01f) ? 1f : ((aggressiveness < 0.51f) ? 2f : ((aggressiveness < 1.01f) ? 3f : ((!(aggressiveness < 2.01f)) ? 5f : 4f)))));
			aggresiveSlider.value = value;
			text = (int)(__instance.aggresiveSlider.value + 0.5f) switch
			{
				0 => Localization.Translate("活靶子"), 
				1 => Localization.Translate("被动"), 
				2 => Localization.Translate("消极"), 
				3 => Localization.Translate("正常"), 
				4 => Localization.Translate("积极"), 
				5 => Localization.Translate("狂暴"), 
				_ => text, 
			};
			__instance.aggresiveText.text = text;
			float initialLevel = __instance.combatSettings.initialLevel;
			Slider initLevelSlider = __instance.initLevelSlider;
			aggressiveness = ((initialLevel < 0.01f) ? 0f : ((initialLevel < 1.01f) ? 1f : ((initialLevel < 2.01f) ? 2f : ((initialLevel < 3.01f) ? 3f : ((initialLevel < 4.01f) ? 4f : ((initialLevel < 5.01f) ? 5f : ((initialLevel < 6.01f) ? 6f : ((initialLevel < 7.01f) ? 7f : ((initialLevel < 8.01f) ? 8f : ((initialLevel < 9.01f) ? 9f : ((initialLevel < 10.01f) ? 10f : ((initialLevel < 11.01f) ? 11f : ((initialLevel < 12.01f) ? 12f : ((initialLevel < 13.01f) ? 13f : ((initialLevel < 14.01f) ? 14f : ((initialLevel < 15.01f) ? 15f : ((initialLevel < 16.01f) ? 16f : ((initialLevel < 17.01f) ? 17f : ((initialLevel < 18.01f) ? 18f : ((initialLevel < 19.01f) ? 19f : ((initialLevel < 20.01f) ? 20f : ((initialLevel < 21.01f) ? 21f : ((initialLevel < 22.01f) ? 22f : ((initialLevel < 23.01f) ? 23f : ((initialLevel < 24.01f) ? 24f : ((initialLevel < 25.01f) ? 25f : ((initialLevel < 26.01f) ? 26f : ((initialLevel < 27.01f) ? 27f : ((initialLevel < 28.01f) ? 28f : ((!(initialLevel < 29.01f)) ? 30f : 29f))))))))))))))))))))))))))))));
			initLevelSlider.value = aggressiveness;
			__instance.initLevelText.text = initialLevel.ToString();
			initialLevel = __instance.combatSettings.initialGrowth;
			Slider initGrowthSlider = __instance.initGrowthSlider;
			aggressiveness = ((initialLevel < 0.01f) ? 0f : ((initialLevel < 0.26f) ? 1f : ((initialLevel < 0.51f) ? 2f : ((initialLevel < 0.76f) ? 3f : ((initialLevel < 1.01f) ? 4f : ((initialLevel < 1.51f) ? 5f : ((initialLevel < 2.01f) ? 6f : ((initialLevel < 2.51f) ? 7f : ((initialLevel < 3.01f) ? 8f : ((!(initialLevel < 3.51f)) ? 10f : 9f))))))))));
			initGrowthSlider.value = aggressiveness;
			text = initialLevel * 100f + "%";
			__instance.initGrowthText.text = text;
			initialLevel = __instance.combatSettings.initialColonize;
			Slider initOccupiedSlider = __instance.initOccupiedSlider;
			aggressiveness = ((initialLevel < 0.02f) ? 0f : ((initialLevel < 0.26f) ? 1f : ((initialLevel < 0.51f) ? 2f : ((initialLevel < 0.76f) ? 3f : ((initialLevel < 1.01f) ? 4f : ((initialLevel < 1.51f) ? 5f : ((initialLevel < 2.01f) ? 6f : ((initialLevel < 2.51f) ? 7f : ((initialLevel < 3.01f) ? 8f : ((!(initialLevel < 3.51f)) ? 10f : 9f))))))))));
			initOccupiedSlider.value = aggressiveness;
			text = initialLevel * 100f + "%";
			__instance.initOccupiedText.text = text;
			initialLevel = __instance.combatSettings.maxDensity;
			Slider maxDensitySlider = __instance.maxDensitySlider;
			aggressiveness = ((initialLevel < 1.01f) ? 0f : ((initialLevel < 1.51f) ? 1f : ((initialLevel < 2.01f) ? 2f : ((!(initialLevel < 2.51f)) ? 4f : 3f))));
			maxDensitySlider.value = aggressiveness;
			text = initialLevel + "x";
			__instance.maxDensityText.text = text;
			initialLevel = __instance.combatSettings.growthSpeedFactor;
			Slider growthSpeedSlider = __instance.growthSpeedSlider;
			aggressiveness = ((initialLevel < 0.26f) ? 0f : ((initialLevel < 0.51f) ? 1f : ((initialLevel < 1.01f) ? 2f : ((initialLevel < 2.01f) ? 3f : ((initialLevel < 3.01f) ? 4f : ((initialLevel < 4.01f) ? 5f : ((!(initialLevel < 5.01f)) ? 7f : 6f)))))));
			growthSpeedSlider.value = aggressiveness;
			text = initialLevel * 100f + "%";
			__instance.growthSpeedText.text = text;
			initialLevel = __instance.combatSettings.powerThreatFactor;
			Slider powerThreatSlider = __instance.powerThreatSlider;
			aggressiveness = ((initialLevel < 0.02f) ? 0f : ((initialLevel < 0.11f) ? 1f : ((initialLevel < 0.21000001f) ? 2f : ((initialLevel < 0.51f) ? 3f : ((initialLevel < 1.01f) ? 4f : ((initialLevel < 2.01f) ? 5f : ((initialLevel < 5.01f) ? 6f : ((initialLevel < 8.01f) ? 7f : ((initialLevel < 10.01f) ? 8f : ((!(initialLevel < 15.01f)) ? 10f : 9f))))))))));
			powerThreatSlider.value = aggressiveness;
			text = initialLevel * 100f + "%";
			__instance.powerThreatText.text = text;
			initialLevel = __instance.combatSettings.battleThreatFactor;
			Slider combatThreatSlider = __instance.combatThreatSlider;
			aggressiveness = ((initialLevel < 0.02f) ? 0f : ((initialLevel < 0.11f) ? 1f : ((initialLevel < 0.21000001f) ? 2f : ((initialLevel < 0.51f) ? 3f : ((initialLevel < 1.01f) ? 4f : ((initialLevel < 2.01f) ? 5f : ((initialLevel < 5.01f) ? 6f : ((initialLevel < 8.01f) ? 7f : ((initialLevel < 10.01f) ? 8f : ((!(initialLevel < 15.01f)) ? 10f : 9f))))))))));
			combatThreatSlider.value = aggressiveness;
			text = initialLevel * 100f + "%";
			__instance.combatThreatText.text = text;
			initialLevel = __instance.combatSettings.battleExpFactor;
			Slider dFExpSlider = __instance.DFExpSlider;
			aggressiveness = ((initialLevel < 0.02f) ? 0f : ((initialLevel < 0.11f) ? 1f : ((initialLevel < 0.21000001f) ? 2f : ((initialLevel < 0.51f) ? 3f : ((initialLevel < 1.01f) ? 4f : ((initialLevel < 2.01f) ? 5f : ((initialLevel < 5.01f) ? 6f : ((initialLevel < 8.01f) ? 7f : ((initialLevel < 10.01f) ? 8f : ((!(initialLevel < 15.01f)) ? 10f : 9f))))))))));
			dFExpSlider.value = aggressiveness;
			text = initialLevel * 100f + "%";
			__instance.DFExpText.text = text;
			GameDesc val = new GameDesc();
			float difficulty = ((CombatSettings)(ref __instance.combatSettings)).difficulty;
			string arg = ((difficulty >= 9.9999f) ? difficulty.ToString("0.00") : difficulty.ToString("0.000"));
			__instance.difficultyText.text = string.Format(Localization.Translate("难度系数值"), arg);
			__instance.difficultTipGroupDF.SetActive(((int)((CombatSettings)(ref __instance.combatSettings)).aggressiveLevel == 40 && difficulty > 4.5f) || difficulty > 6f);
			__instance.gameDesc.CopyTo(val);
			val.combatSettings = __instance.combatSettings;
			__instance.propertyMultiplierText.text = Localization.Translate("元数据生成倍率") + " " + val.propertyMultiplier.ToString("0%");
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static bool CombatSettings_difficulty_Getter_Prefix(CombatSettings __instance, ref float __result)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			float aggressiveness = __instance.aggressiveness;
			float num = ((aggressiveness < -0.1f) ? (-0.2f) : ((aggressiveness < 0.25f) ? 0f : ((aggressiveness < 0.75f) ? 0.5f : ((aggressiveness < 1.5f) ? 0.75f : ((!(aggressiveness < 2.5f)) ? 1.125f : 0.875f)))));
			float num2 = num;
			float num3 = __instance.initialLevel * 0.8f;
			num = __instance.initialGrowth;
			aggressiveness = ((num < 0.15f) ? 0f : ((num < 0.3f) ? 0.25f : ((num < 0.65f) ? 0.5f : ((num < 0.8f) ? 0.75f : ((num < 1.15f) ? 1f : ((num < 1.65f) ? 1.25f : ((num < 2.15f) ? 1.5f : ((num < 2.65f) ? 1.75f : ((num < 3.15f) ? 2f : ((!(num < 3.65f)) ? 2.5f : 2.25f))))))))));
			float num4 = aggressiveness;
			aggressiveness = __instance.initialColonize;
			num = ((aggressiveness < 0.15f) ? 0f : ((aggressiveness < 0.3f) ? 0.25f : ((aggressiveness < 0.65f) ? 0.5f : ((aggressiveness < 0.8f) ? 0.75f : ((aggressiveness < 1.15f) ? 1f : ((aggressiveness < 1.65f) ? 1.25f : ((aggressiveness < 2.15f) ? 1.5f : ((aggressiveness < 2.65f) ? 1.75f : ((aggressiveness < 3.15f) ? 2f : ((!(aggressiveness < 3.65f)) ? 2.5f : 2.25f))))))))));
			float num5 = num;
			float num6 = __instance.maxDensity - 1f;
			num = __instance.growthSpeedFactor;
			aggressiveness = ((num < 0.35f) ? 0.3f : ((num < 0.75f) ? 0.7f : ((num < 1.5f) ? 1f : ((num < 2.5f) ? 1.2f : ((num < 3.5f) ? 1.5f : ((num < 4.5f) ? 1.6f : ((!(num < 5.5f)) ? 2f : 1.8f)))))));
			float num7 = aggressiveness;
			aggressiveness = __instance.powerThreatFactor;
			num = ((aggressiveness < 0.05f) ? 0.125f : ((aggressiveness < 0.15f) ? 0.3f : ((aggressiveness < 0.25f) ? 0.6f : ((aggressiveness < 0.55f) ? 0.8f : ((aggressiveness < 1.15f) ? 1f : ((aggressiveness < 2.15f) ? 1.2f : ((aggressiveness < 5.15f) ? 1.5f : ((aggressiveness < 8.15f) ? 1.8f : ((aggressiveness < 10.15f) ? 2f : ((!(aggressiveness < 15.15f)) ? 3f : 2.5f))))))))));
			float num8 = num;
			num = __instance.battleThreatFactor;
			aggressiveness = ((num < 0.05f) ? 0.125f : ((num < 0.15f) ? 0.3f : ((num < 0.25f) ? 0.6f : ((num < 0.55f) ? 0.8f : ((num < 1.15f) ? 1f : ((num < 2.15f) ? 1.2f : ((num < 5.15f) ? 1.5f : ((num < 8.15f) ? 1.8f : ((num < 10.15f) ? 2f : ((!(num < 15.15f)) ? 3f : 2.5f))))))))));
			float num9 = aggressiveness;
			aggressiveness = __instance.battleExpFactor;
			num = ((aggressiveness < 0.05f) ? 0f : ((aggressiveness < 0.15f) ? 1f : ((aggressiveness < 0.25f) ? 3f : ((aggressiveness < 0.55f) ? 6f : ((aggressiveness < 1.15f) ? 10f : ((aggressiveness < 2.15f) ? 12f : ((aggressiveness < 5.15f) ? 14f : ((aggressiveness < 8.15f) ? 16f : ((aggressiveness < 10.15f) ? 18f : ((!(aggressiveness < 15.15f)) ? 20f : 19f))))))))));
			float num10 = num;
			float num11 = ((num2 < 0f) ? 0f : (0.25f + num2 * (num8 * 0.5f + num9 * 0.5f)));
			float num12 = 0.375f + 0.625f * ((num3 + num10) / 10f);
			float num13 = 0.375f + 0.625f * ((num5 * 0.6f + num4 * 0.4f * (num5 * 0.75f + 0.25f)) * 0.6f + num7 * 0.4f * (num5 * 0.8f + 0.2f) + num6 * 0.29f * (num5 * 0.5f + 0.5f));
			__result = (float)(int)(num11 * num12 * num13 * 10000f + 0.5f) / 10000f;
			return false;
		}

		public static void Export(BinaryWriter w)
		{
			w.Write(_gameMinDist);
			w.Write(_gameMinStep);
			w.Write(_gameMaxStep);
			w.Write(_gameFlatten);
		}

		public static void Import(BinaryReader r)
		{
			_gameMinDist = r.ReadDouble();
			_gameMinStep = r.ReadDouble();
			_gameMaxStep = r.ReadDouble();
			_gameFlatten = r.ReadDouble();
		}
	}
	public static class UIConfigWindow
	{
		private static RectTransform _windowTrans;

		public static void Init()
		{
			I18N.Add("UniverseGen", "UniverseGen", "宇宙生成");
			I18N.Add("Birth Star", "Birth Star", "母星系");
			I18N.Add("Enable more settings on UniverseGen", "Enable more settings on UniverseGen", "启用更多宇宙生成设置");
			I18N.Add("* Requires game restart to take effect", "* Requires game restart to take effect", "* 需要重启游戏才能生效");
			I18N.Add("Maximum star count", "Maximum star count", "最大恒星数");
			I18N.Add("Enable Epic difficulty", "Enable Epic difficulty", "启用史诗难度");
			I18N.Add("Resource multiplier", "Resource multiplier", "资源倍率");
			I18N.Add("Oil multiplier (relative to Very Hard)", "Oil multiplier (relative to Very Hard)", "石油倍率(相对于非常困难)");
			I18N.Add("Silicon/Titanium on birth planet", "Silicon/Titanium on birth planet", "母星有硅和钛");
			I18N.Add("Fire ice on birth planet", "Fire ice on birth planet", "母星有可燃冰");
			I18N.Add("Kimberlite on birth planet", "Kimberlite on birth planet", "母星有金伯利矿");
			I18N.Add("Fractal silicon on birth planet", "Fractal silicon on birth planet", "母星有分形硅");
			I18N.Add("Organic crystal on birth planet", "Organic crystal on birth planet", "母星有有机晶体");
			I18N.Add("Optical grating crystal on birth planet", "Optical grating crystal on birth planet", "母星有光栅石");
			I18N.Add("Spiniform stalagmite crystal on birth planet", "Spiniform stalagmite crystal on birth planet", "母星有刺笋结晶");
			I18N.Add("Unipolar magnet on birth planet", "Unipolar magnet on birth planet", "母星有单极磁石");
			I18N.Add("Birth planet is solid flat (no water at all)", "Birth planet is solid flat (no water at all)", "母星是纯平的(没有水)");
			I18N.Add("Birth star has high luminosity", "Birth star has high luminosity", "母星系恒星高亮");
			I18N.Apply();
			MyConfigWindow.OnUICreated = (Action<MyConfigWindow, RectTransform>)Delegate.Combine(MyConfigWindow.OnUICreated, new Action<MyConfigWindow, RectTransform>(CreateUI));
		}

		private static void CreateUI(MyConfigWindow wnd, RectTransform trans)
		{
			_windowTrans = trans;
			float num = 0f;
			float num2 = 10f;
			((MyWindowWithTabs)wnd).AddSplitter(trans, 10f);
			((MyWindowWithTabs)wnd).AddTabGroup(trans, "UniverseGen", "tab-group-galaxygen");
			RectTransform val = ((MyWindowWithTabs)wnd).AddTab(_windowTrans, "General");
			MyCheckBox.CreateCheckBox(num, num2, val, MoreSettings.Enabled, "Enable more settings on UniverseGen", 15);
			num += 20f;
			num2 += 26f;
			MyWindow.AddText(num, num2, val, "* Requires game restart to take effect", 13, "label");
			num -= 20f;
			num2 += 36f;
			num += 10f;
			MyWindow.AddText(num, num2, val, "Maximum star count", 16, "label");
			num += 20f;
			num2 += 26f;
			MySlider sl0 = MySlider.CreateSlider(num, num2, val, (float)MoreSettings.MaxStarCount.Value, 64f, 1024f, "G", 240f);
			sl0.OnValueChanged += delegate
			{
				MySlider obj = sl0;
				int num5 = (MoreSettings.MaxStarCount.Value = (Mathf.RoundToInt(sl0.Value) + 7) & -8);
				obj.Value = num5;
			};
			num -= 30f;
			num2 += 36f;
			MyCheckBox.CreateCheckBox(num, num2, val, EpicDifficulty.Enabled, "Enable Epic difficulty", 15);
			num2 += 36f;
			num += 10f;
			MyWindow.AddText(num, num2, val, "Resource multiplier", 16, "label");
			num += 20f;
			num2 += 26f;
			int num3 = EpicDifficulty.ResourceMultiplierToIndex(EpicDifficulty.ResourceMultiplier.Value);
			MySlider sl1 = MySlider.CreateSlider(num, num2, val, (float)num3, 0f, (float)EpicDifficulty.ResourceMultipliersCount() - 1f, "G", 240f);
			sl1.SetLabelText(EpicDifficulty.IndexToResourceMultiplier(Mathf.RoundToInt(sl1.Value)).ToString(sl1.labelFormat));
			sl1.OnValueChanged += delegate
			{
				float value2 = EpicDifficulty.IndexToResourceMultiplier(Mathf.RoundToInt(sl1.Value));
				EpicDifficulty.ResourceMultiplier.Value = value2;
				sl1.SetLabelText(value2.ToString(sl1.labelFormat));
			};
			num -= 30f;
			num2 += 31f;
			num += 10f;
			MyWindow.AddText(num, num2, val, "Oil multiplier (relative to Very Hard)", 16, "label");
			num += 20f;
			num2 += 26f;
			num3 = EpicDifficulty.OilMultiplierToIndex(EpicDifficulty.OilMultiplier.Value);
			MySlider sl2 = MySlider.CreateSlider(num, num2, val, (float)num3, 0f, (float)EpicDifficulty.OilMultipliersCount() - 1f, "G", 240f);
			sl2.SetLabelText(EpicDifficulty.IndexToOilMultiplier(Mathf.RoundToInt(sl2.Value)).ToString(sl2.labelFormat));
			sl2.OnValueChanged += delegate
			{
				float value = EpicDifficulty.IndexToOilMultiplier(Mathf.RoundToInt(sl2.Value));
				EpicDifficulty.OilMultiplier.Value = value;
				sl2.SetLabelText(value.ToString(sl2.labelFormat));
			};
			RectTransform val2 = ((MyWindowWithTabs)wnd).AddTab(_windowTrans, "Birth Star");
			num = 0f;
			num2 = 10f;
			MyCheckBox.CreateCheckBox(num, num2, val2, BirthPlanetPatch.SitiVeinsOnBirthPlanet, "Silicon/Titanium on birth planet", 15);
			num2 += 36f;
			MyCheckBox.CreateCheckBox(num, num2, val2, BirthPlanetPatch.FireIceOnBirthPlanet, "Fire ice on birth planet", 15);
			num2 += 36f;
			MyCheckBox.CreateCheckBox(num, num2, val2, BirthPlanetPatch.KimberliteOnBirthPlanet, "Kimberlite on birth planet", 15);
			num2 += 36f;
			MyCheckBox.CreateCheckBox(num, num2, val2, BirthPlanetPatch.FractalOnBirthPlanet, "Fractal silicon on birth planet", 15);
			num2 += 36f;
			MyCheckBox.CreateCheckBox(num, num2, val2, BirthPlanetPatch.OrganicOnBirthPlanet, "Organic crystal on birth planet", 15);
			num2 += 36f;
			MyCheckBox.CreateCheckBox(num, num2, val2, BirthPlanetPatch.OpticalOnBirthPlanet, "Optical grating crystal on birth planet", 15);
			num2 += 36f;
			MyCheckBox.CreateCheckBox(num, num2, val2, BirthPlanetPatch.SpiniformOnBirthPlanet, "Spiniform stalagmite crystal on birth planet", 15);
			num2 += 36f;
			MyCheckBox.CreateCheckBox(num, num2, val2, BirthPlanetPatch.UnipolarOnBirthPlanet, "Unipolar magnet on birth planet", 15);
			num = 300f;
			num2 = 10f;
			MyCheckBox.CreateCheckBox(num, num2, val2, BirthPlanetPatch.FlatBirthPlanet, "Birth planet is solid flat (no water at all)", 15);
			num2 += 36f;
			MyCheckBox.CreateCheckBox(num, num2, val2, BirthPlanetPatch.HighLuminosityBirthStar, "Birth star has high luminosity", 15);
		}
	}
	[BepInPlugin("org.soardev.universegentweaks", "UniverseGenTweaks", "1.2.8")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[ModSaveSettings(/*Could not decode attribute arguments.*/)]
	public class UniverseGenTweaks : BaseUnityPlugin, IModCanSave
	{
		public static readonly ManualLogSource Logger = Logger.CreateLogSource("UniverseGenTweaks");

		private const ushort ModSaveVersion = 1;

		private void Awake()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			MoreSettings.Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("MoreSettings", "Enabled", true, "Enable more settings on Universe Generation");
			MoreSettings.MaxStarCount = ((BaseUnityPlugin)this).Config.Bind<int>("MoreSettings", "MaxStarCount", 128, new ConfigDescription("(32 ~ 1024)\nMaximum star count for Universe Generation, enable MoreSettings.Enabled to take effect", (AcceptableValueBase)(object)new AcceptableValueRange<int>(32, 1024), new object[1]
			{
				new { }
			}));
			EpicDifficulty.Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("EpicDifficulty", "Enabled", true, "Enable Epic difficulty");
			EpicDifficulty.ResourceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("EpicDifficulty", "ResourceMultiplier", 0.01f, new ConfigDescription("Resource multiplier for Epic difficulty", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.0001f, 0.05f), new object[1]
			{
				new { }
			}));
			EpicDifficulty.OilMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("EpicDifficulty", "OilMultiplier", 0.5f, new ConfigDescription("Oil multiplier for Epic difficulty relative to the Very-Hard difficulty", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), new object[1]
			{
				new { }
			}));
			BirthPlanetPatch.SitiVeinsOnBirthPlanet = ((BaseUnityPlugin)this).Config.Bind<bool>("Birth", "SiTiVeinsOnBirthPlanet", false, "Silicon/Titanium on birth planet");
			BirthPlanetPatch.FireIceOnBirthPlanet = ((BaseUnityPlugin)this).Config.Bind<bool>("Birth", "FireIceOnBirthPlanet", false, "Fire ice on birth planet");
			BirthPlanetPatch.KimberliteOnBirthPlanet = ((BaseUnityPlugin)this).Config.Bind<bool>("Birth", "KimberliteOnBirthPlanet", false, "Kimberlite on birth planet");
			BirthPlanetPatch.FractalOnBirthPlanet = ((BaseUnityPlugin)this).Config.Bind<bool>("Birth", "FractalOnBirthPlanet", false, "Fractal silicon on birth planet");
			BirthPlanetPatch.OrganicOnBirthPlanet = ((BaseUnityPlugin)this).Config.Bind<bool>("Birth", "OrganicOnBirthPlanet", false, "Organic crystal on birth planet");
			BirthPlanetPatch.OpticalOnBirthPlanet = ((BaseUnityPlugin)this).Config.Bind<bool>("Birth", "OpticalOnBirthPlanet", false, "Optical grating crystal on birth planet");
			BirthPlanetPatch.SpiniformOnBirthPlanet = ((BaseUnityPlugin)this).Config.Bind<bool>("Birth", "SpiniformOnBirthPlanet", false, "Spiniform stalagmite crystal on birth planet");
			BirthPlanetPatch.UnipolarOnBirthPlanet = ((BaseUnityPlugin)this).Config.Bind<bool>("Birth", "UnipolarOnBirthPlanet", false, "Unipolar magnet on birth planet");
			BirthPlanetPatch.FlatBirthPlanet = ((BaseUnityPlugin)this).Config.Bind<bool>("Birth", "FlatBirthPlanet", false, "Birth planet is solid flat (no water at all)");
			BirthPlanetPatch.HighLuminosityBirthStar = ((BaseUnityPlugin)this).Config.Bind<bool>("Birth", "HighLuminosityBirthStar", false, "Birth star has high luminosity");
			UIConfigWindow.Init();
			MoreSettings.Init();
			EpicDifficulty.Init();
			BirthPlanetPatch.Init();
		}

		private void OnDestroy()
		{
			BirthPlanetPatch.Uninit();
			EpicDifficulty.Uninit();
			MoreSettings.Uninit();
		}

		public void Export(BinaryWriter w)
		{
			w.Write((ushort)1);
			MoreSettings.Export(w);
		}

		public void Import(BinaryReader r)
		{
			if (r.ReadUInt16() > 0)
			{
				MoreSettings.Import(r);
			}
		}

		public void IntoOtherSave()
		{
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "org.soardev.universegentweaks";

		public const string PLUGIN_NAME = "UniverseGenTweaks";

		public const string PLUGIN_VERSION = "1.2.8";
	}
}