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.5.0")]
[assembly: AssemblyInformationalVersion("1.2.5+3308f5d625e29c2dc65a4aeec761bd0e9687ff77")]
[assembly: AssemblyProduct("UniverseGenTweaks")]
[assembly: AssemblyTitle("UniverseGenTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.5.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);
}
}
public static void Uninit()
{
Harmony patch = _patch;
if (patch != null)
{
patch.UnpatchSelf();
}
_patch = null;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
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 = 10f;
}
[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.5f : ((value < 3.5f) ? 0.8f : ((value < 4.5f) ? 1f : ((value < 5.5f) ? 1.5f : ((value < 6.5f) ? 2f : ((value < 7.5f) ? 3f : ((value < 8.5f) ? 5f : ((!(value < 9.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.51f) ? 2f : ((resourceMultiplier < 0.81f) ? 3f : ((resourceMultiplier < 1.01f) ? 4f : ((resourceMultiplier < 1.51f) ? 5f : ((resourceMultiplier < 2.01f) ? 6f : ((resourceMultiplier < 3.01f) ? 7f : ((resourceMultiplier < 5.01f) ? 8f : ((!(resourceMultiplier < 8.01f)) ? 10f : 9f))))))))));
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
{
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 _harmony;
public static void Init()
{
I18N.Add("恒星最小距离", "Star Distance Min", "恒星最小距离");
I18N.Add("步进最小距离", "Step Distance Min", "步进最小距离");
I18N.Add("步进最大距离", "Step Distance Max", "步进最大距离");
I18N.Add("扁平度", "Flatness", "扁平度");
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(MoreSettings), (string)null);
}
return;
}
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
_harmony = 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 minDist = (double)Mathf.Round(val) / 10.0;
if (!minDist.Equals(_minDist))
{
_minDist = minDist;
_minDistText.text = _minDist.ToString();
if (_minStep < _minDist)
{
_minStep = _minDist;
_minStepSlider.value = (float)(_minStep * 10.0);
_minStepText.text = _minStep.ToString();
if (_maxStep < _minStep)
{
_maxStep = _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 = 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 = 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 flatten = (double)Mathf.Round(val) / 50.0;
if (!flatten.Equals(_flatten))
{
_flatten = flatten;
_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();
}
[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)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Expected O, but got Unknown
m.SetAndAdvance(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MoreSettings), "MaxStarCount")).Insert((CodeInstruction[])(object)new CodeInstruction[5]
{
new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(ConfigEntry<int>), "Value")),
new CodeInstruction(OpCodes.Ldc_I4_1, (object)null),
new CodeInstruction(OpCodes.Add, (object)null),
new CodeInstruction(OpCodes.Ldc_I4_S, (object)100),
new CodeInstruction(OpCodes.Mul, (object)null)
});
}, (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)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Expected O, but got Unknown
m.SetAndAdvance(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MoreSettings), "MaxStarCount")).Insert((CodeInstruction[])(object)new CodeInstruction[5]
{
new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(ConfigEntry<int>), "Value")),
new CodeInstruction(OpCodes.Ldc_I4_1, (object)null),
new CodeInstruction(OpCodes.Add, (object)null),
new CodeInstruction(OpCodes.Ldc_I4_S, (object)100),
new CodeInstruction(OpCodes.Mul, (object)null)
});
}, (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), "_minDist")),
new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MoreSettings), "_minStep")),
new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MoreSettings), "_maxStep")),
new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MoreSettings), "_flatten"))
});
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 void Export(BinaryWriter w)
{
w.Write(_minDist);
w.Write(_minStep);
w.Write(_maxStep);
w.Write(_flatten);
}
public static void Import(BinaryReader r)
{
_minDist = r.ReadDouble();
_minStep = r.ReadDouble();
_maxStep = r.ReadDouble();
_flatten = 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.5")]
[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.5";
}
}