Decompiled source of ExposeCreativeMode v0.0.20
ExposeCreativeMode.dll
Decompiled a year ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using CommonAPI; using CommonAPI.Systems; using CommonAPI.Systems.ModLocalization; using DysonSphereProgram.Modding.ExposeCreativeMode.UI.Builder; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.EventSystems; 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.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("ExposeCreativeMode")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.0.20.0")] [assembly: AssemblyInformationalVersion("0.0.20+f7de881607195dc3e92d4719b760339cfd29b733")] [assembly: AssemblyProduct("ExposeCreativeMode")] [assembly: AssemblyTitle("ExposeCreativeMode")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.20.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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; } } public record IsExternalInit; } namespace DysonSphereProgram.Modding.ExposeCreativeMode { public static class CreativeModeConfig { public const string ConfigSection = "Auto-Enable"; public static ConfigEntry<bool> autoEnableInfiniteInventory; public static ConfigEntry<bool> autoEnableInfiniteReach; public static ConfigEntry<bool> autoEnableInfinitePower; public static ConfigEntry<bool> autoEnableInstantResearch; public static ConfigEntry<bool> autoEnableInstantBuild; public static ConfigEntry<bool> autoEnableInstantReplicate; public static void Init(ConfigFile confFile) { autoEnableInfiniteInventory = confFile.Bind<bool>("Auto-Enable", "Auto-enable Infinite Inventory", true, ConfigDescription.Empty); autoEnableInfiniteReach = confFile.Bind<bool>("Auto-Enable", "Auto-enable Infinite Reach", true, ConfigDescription.Empty); autoEnableInfinitePower = confFile.Bind<bool>("Auto-Enable", "Auto-enable Infinite Power", true, ConfigDescription.Empty); autoEnableInstantResearch = confFile.Bind<bool>("Auto-Enable", "Auto-enable Instant Research", true, ConfigDescription.Empty); autoEnableInstantBuild = confFile.Bind<bool>("Auto-Enable", "Auto-enable Instant Build", true, ConfigDescription.Empty); autoEnableInstantReplicate = confFile.Bind<bool>("Auto-Enable", "Auto-enable Instant Replicate", true, ConfigDescription.Empty); } } public class CreativeModeController { private const string uiCreativeModeContainerPath = "UI Root/Overlay Canvas/In Game"; private const string uiCreativeModeTextName = "creative-mode-text"; private const string uiCreativeModeTextPath = "UI Root/Overlay Canvas/In Game/creative-mode-text"; private const string uiVersionTextName = "version-text"; private const string uiVersionTextPath = "UI Root/Overlay Canvas/In Game/version-text"; private const float uiCreativeModeTextOffset = 0.55f; public bool veinsBury; private bool active; public Player player; public InfiniteInventory infiniteInventory; public InfiniteStation infiniteStation; public InfiniteReach infiniteReach; public InfinitePower infinitePower; public InstantResearch instantResearch; public InstantBuild instantBuild; public InstantReplicate instantReplicate; private const int saveLogicVersion = 2; public bool Active { get { return active; } set { SetActive(value); } } public void Free() { InstantReplicatePatch.Unregister(instantReplicate); InstantResearchPatch.Unregister(instantResearch); InfiniteReachPatch.Unregister(infiniteReach); InfinitePowerPatch.Unregister(infinitePower); InfiniteInventoryPatch.Unregister(infiniteInventory); Active = false; player = null; } public void Init(Player _player) { player = _player; InfiniteInventoryPatch.Register(infiniteInventory = new InfiniteInventory(player)); InfinitePowerPatch.Register(infinitePower = new InfinitePower()); InfiniteReachPatch.Register(infiniteReach = new InfiniteReach(player)); InstantResearchPatch.Register(instantResearch = new InstantResearch()); infiniteStation = new InfiniteStation(); instantBuild = new InstantBuild(player); InstantReplicatePatch.Register(instantReplicate = new InstantReplicate()); } public void OnInputUpdate() { if (CustomKeyBindSystem.GetKeyBind("ToggleCreativeMode").keyValue) { UIModWindowBase uIModWindowBase = UIManager.Instance?.window; if (Object.op_Implicit((Object)(object)uIModWindowBase)) { if (((ManualBehaviour)uIModWindowBase).active) { ((ManualBehaviour)uIModWindowBase)._Close(); } else { ((ManualBehaviour)uIModWindowBase)._Open(); ((Component)uIModWindowBase).transform.SetAsLastSibling(); } } } if (active) { if (CustomKeyBindSystem.GetKeyBind("FlattenPlanet").keyValue && player.factory != null) { Plugin.Log.LogDebug((object)"Flatten Keybind pressed"); bool flag = (CombineKey.currModifier & 2) == 2; int num = (((CombineKey.currModifier & 1) == 1) ? ((!flag) ? 1 : 0) : ((!flag) ? 3 : 2)); int modLevel = num; PlanetReform.SetPlanetModLevel(player.factory, veinsBury, modLevel); } if (CustomKeyBindSystem.GetKeyBind("ToggleAllVeinsOnPlanet").keyValue && player.factory != null) { veinsBury = !veinsBury; PlanetReform.ModifyAllVeinsHeight(player.factory, veinsBury); } if (CustomKeyBindSystem.GetKeyBind("ToggleInstantResearch").keyValue) { instantResearch.Toggle(); } if (CustomKeyBindSystem.GetKeyBind("ToggleInfiniteInventory").keyValue) { infiniteInventory.Toggle(); } if (CustomKeyBindSystem.GetKeyBind("ToggleInfiniteStation").keyValue) { infiniteStation.Toggle(); } if (CustomKeyBindSystem.GetKeyBind("ToggleInstantBuild").keyValue) { instantBuild.Toggle(); } if (CustomKeyBindSystem.GetKeyBind("ForwardUniverseSimulation").keyValue) { OrbitalMechanicsOverride.Offset += 10L; } if (CustomKeyBindSystem.GetKeyBind("BackwardUniverseSimulation").keyValue) { OrbitalMechanicsOverride.Offset -= 10L; } } } public void SetActive(bool value) { if (value == active) { return; } active = value; if (active) { player.controller.gameData.gameDesc.achievementEnable = false; if (CreativeModeConfig.autoEnableInfiniteInventory.Value) { infiniteInventory.IsEnabled = true; } if (CreativeModeConfig.autoEnableInstantBuild.Value) { instantBuild.IsEnabled = true; } if (CreativeModeConfig.autoEnableInstantResearch.Value) { instantResearch.IsEnabled = true; } if (CreativeModeConfig.autoEnableInfiniteReach.Value) { infiniteReach.IsEnabled = true; } if (CreativeModeConfig.autoEnableInfinitePower.Value) { infinitePower.IsEnabled = true; } if (CreativeModeConfig.autoEnableInstantReplicate.Value) { instantReplicate.IsEnabled = true; } } else { infiniteInventory.IsEnabled = false; infiniteStation.IsEnabled = false; instantBuild.IsEnabled = false; instantResearch.IsEnabled = false; infiniteReach.IsEnabled = false; infinitePower.IsEnabled = false; instantReplicate.IsEnabled = false; } OnActiveChange(active); } public void GameTick() { infiniteInventory.GameTick(); infiniteStation.GameTick(); instantResearch.GameTick(); instantBuild.GameTick(infiniteInventory.IsEnabled); } private void OnActiveChange(bool active) { GameObject val = GameObject.Find("UI Root/Overlay Canvas/In Game/creative-mode-text"); if ((Object)(object)val == (Object)null) { val = MakeCreativeModeTextUI(); } if (!((Object)(object)val == (Object)null)) { val.GetComponent<Text>().text = (active ? "Creative Mode" : ""); } } private static GameObject MakeCreativeModeTextUI() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("UI Root/Overlay Canvas/In Game/version-text"); if ((Object)(object)val == (Object)null) { return null; } GameObject obj = Object.Instantiate<GameObject>(val, val.transform.parent); ((Object)obj).name = "creative-mode-text"; UIVersionText component = obj.GetComponent<UIVersionText>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } obj.transform.Translate(Vector2.op_Implicit(Vector2.down * 0.55f)); obj.transform.SetSiblingIndex(val.transform.GetSiblingIndex() + 1); return obj; } public void PreserveVanillaSaveBefore() { infiniteInventory.PreserveVanillaSaveBefore(); infiniteReach.PreserveVanillaSaveBefore(); OrbitalMechanicsOverride.PreserveVanillaSaveBefore(); } public void PreserveVanillaSaveAfter() { infiniteInventory.PreserveVanillaSaveAfter(); infiniteReach.PreserveVanillaSaveAfter(); OrbitalMechanicsOverride.PreserveVanillaSaveAfter(); } public void Export(BinaryWriter w) { w.Write(2); w.Write(Active); w.Write(infiniteInventory.IncludeLocked); w.Write(infiniteInventory.IsEnabled); w.Write(infiniteStation.IsEnabled); w.Write(infiniteReach.IsEnabled); w.Write(infinitePower.IsEnabled); w.Write(instantResearch.IsEnabled); w.Write(instantResearch.EnableLocking); w.Write(instantBuild.IsEnabled); w.Write(instantReplicate.IsInstant); w.Write(instantReplicate.IsFree); w.Write(instantReplicate.AllowAll); w.Write(instantReplicate.IsEnabled); } public void Import(BinaryReader r) { int num = r.ReadInt32(); Active = r.ReadBoolean(); infiniteInventory.IncludeLocked = r.ReadBoolean(); infiniteInventory.IsEnabled = r.ReadBoolean(); infiniteStation.IsEnabled = r.ReadBoolean(); infiniteReach.IsEnabled = r.ReadBoolean(); infinitePower.IsEnabled = r.ReadBoolean(); instantResearch.IsEnabled = r.ReadBoolean(); instantResearch.EnableLocking = ((num > 1) ? r.ReadBoolean() : instantResearch.IsEnabled); instantBuild.IsEnabled = r.ReadBoolean(); instantReplicate.IsInstant = r.ReadBoolean(); instantReplicate.IsFree = r.ReadBoolean(); instantReplicate.AllowAll = r.ReadBoolean(); instantReplicate.IsEnabled = r.ReadBoolean(); } } [BepInPlugin("dev.raptor.dsp.ExposeCreativeMode", "ExposeCreativeMode", "0.0.20")] [BepInDependency(/*Could not decode attribute arguments.*/)] [CommonAPISubmoduleDependency(new string[] { "LocalizationModule", "CustomKeyBindSystem" })] public class Plugin : BaseUnityPlugin, IModCanSave { private Harmony _harmony; internal static ManualLogSource Log; private void Awake() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown CommonAPIPlugin.LoadModules(new Type[2] { typeof(LocalizationModule), typeof(CustomKeyBindSystem) }); Log = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("dev.raptor.dsp.ExposeCreativeMode"); CreativeModeConfig.Init(((BaseUnityPlugin)this).Config); _harmony.PatchAll(typeof(InfiniteInventoryPatch)); _harmony.PatchAll(typeof(InfinitePowerPatch)); _harmony.PatchAll(typeof(InfiniteReachPatch)); _harmony.PatchAll(typeof(InstantResearchPatch)); _harmony.PatchAll(typeof(InstantReplicatePatch)); _harmony.PatchAll(typeof(UIPatches)); _harmony.PatchAll(typeof(OrbitalMechanicsOverride)); CreativeModeLifecyclePatches.ApplyPatch(_harmony); _harmony.PatchAll(typeof(VanillaSavePreservationPatch)); KeyBinds.RegisterKeyBinds(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"ExposeCreativeMode Awake() called"); } private void OnDestroy() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"ExposeCreativeMode OnDestroy() called"); CreativeModeLifecyclePatches.DestroyPatch(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } Log = null; } public void Export(BinaryWriter w) { CreativeModeLifecyclePatches.instance.Export(w); } public void Import(BinaryReader r) { CreativeModeLifecyclePatches.instance.Import(r); } public void IntoOtherSave() { } } [HarmonyPatch] public static class CreativeModeLifecyclePatches { internal static CreativeModeController instance; public static void ApplyPatch(Harmony harmony) { harmony.PatchAll(typeof(CreativeModeLifecyclePatches)); UIBuilderPlugin.Create("dev.raptor.dsp.ExposeCreativeMode", UIManager.CreateUIManager); Player __result = GameMain.mainPlayer; if (__result != null) { Create(ref __result); } } public static void DestroyPatch() { Free(); UIManager.DestroyUIManager(); UIBuilderPlugin.Destroy(); } [HarmonyPostfix] [HarmonyPatch(typeof(Player), "Create")] private static void Create(ref Player __result) { if (!DSPGame.IsMenuDemo) { if (instance != null) { instance.Free(); } instance = new CreativeModeController(); instance.Init(__result); UIManager.Instance?.Init(instance); } } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerController), "GameTick")] private static void GameTick() { instance?.GameTick(); } [HarmonyPostfix] [HarmonyPatch(typeof(VFInput), "OnUpdate")] private static void InputUpdate() { instance?.OnInputUpdate(); } [HarmonyPrefix] [HarmonyPatch(typeof(Player), "Free")] private static void Free() { if (instance != null) { UIManager.Instance?.Free(); instance.Free(); instance = null; } } } [HarmonyPatch(typeof(GameSave), "SaveCurrentGame")] internal class VanillaSavePreservationPatch { [HarmonyPrefix] private static void Prefix() { CreativeModeLifecyclePatches.instance?.PreserveVanillaSaveBefore(); } [HarmonyPostfix] private static void Postfix() { CreativeModeLifecyclePatches.instance?.PreserveVanillaSaveAfter(); } } public class InfiniteInventory { private readonly ref struct InventoryWindowDeactivationContext { private readonly bool wasActive; private readonly UIGame uiGame; public InventoryWindowDeactivationContext() { uiGame = ((Object.op_Implicit((Object)(object)UIRoot.instance) && Object.op_Implicit((Object)(object)UIRoot.instance.uiGame)) ? UIRoot.instance.uiGame : null); wasActive = Object.op_Implicit((Object)(object)uiGame) && Object.op_Implicit((Object)(object)uiGame.inventoryWindow) && ((ManualBehaviour)uiGame.inventoryWindow).active; if (wasActive) { uiGame.ShutPlayerInventory(); } } public void Dispose() { if (wasActive) { uiGame.OpenPlayerInventory(); } } } [CompilerGenerated] private static class <>O { public static Func<ItemProto, bool> <0>__AllItemsPredicate; public static Func<ItemProto, bool> <1>__OnlyUnlockedItemsPredicate; } private readonly Player player; private readonly StorageComponent infiniteInventory; private long? sandRestore; private StorageComponent infiniteInventoryRestore; private int prevInventorySize; private IList<int> cachedItemIds; private float cachedTime; private bool isEnabled; public bool IncludeLocked = true; private const int infiniteItemCount = 536870911; private const int infiniteItemStack = 1073741823; public bool IsEnabled { get { return isEnabled; } set { if (isEnabled != value) { if (value) { Enable(); } else { Disable(); } } } } public StorageComponent storage => infiniteInventory; private Func<ItemProto, bool> itemFilter { get { Func<ItemProto, bool> func; if (!IncludeLocked) { func = <>O.<1>__OnlyUnlockedItemsPredicate; if (func == null) { return <>O.<1>__OnlyUnlockedItemsPredicate = OnlyUnlockedItemsPredicate; } } else { func = AllItemsPredicate; } return func; } } private static InventoryWindowDeactivationContext InventoryWindowDeactivatedScope => new InventoryWindowDeactivationContext(); public InfiniteInventory(Player player) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown this.player = player; infiniteInventory = new StorageComponent(((ProtoTable)LDB.items).Length) { type = (EStorageType)9 }; } public void Enable() { sandRestore = player.sandCount; infiniteInventoryRestore = player.package; using (InventoryWindowDeactivatedScope) { RefreshCachedItemIds(); infiniteInventory.SetSize(GetRequiredSize(cachedItemIds.Count)); player.package = infiniteInventory; prevInventorySize = infiniteInventory.size; } UpdateUI(enabled: true); isEnabled = true; Plugin.Log.LogDebug((object)"Infinite Inventory Enabled"); } public void Disable() { if (infiniteInventoryRestore != null) { using (InventoryWindowDeactivatedScope) { player.package = infiniteInventoryRestore; } infiniteInventoryRestore = null; } if (sandRestore.HasValue) { player.sandCount = sandRestore.Value; } sandRestore = null; UpdateUI(enabled: false); isEnabled = false; Plugin.Log.LogDebug((object)"Infinite Inventory Disabled"); } public void Toggle() { if (!isEnabled) { Enable(); } else { Disable(); } } private void UpdateUI(bool enabled) { GameObject obj = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Player Inventory/panel-bg/title-text"); Text val = ((obj != null) ? obj.GetComponent<Text>() : null); if ((Object)(object)val != (Object)null) { if (enabled) { val.text = val.text.Replace("(Infinite)", "").Trim() + " (Infinite)"; } else { val.text = val.text.Replace("(Infinite)", "").Trim(); } } } public void GameTick() { if (isEnabled) { if (Time.time - cachedTime > 1f) { RefreshCachedItemIds(); } int requiredSize = GetRequiredSize(cachedItemIds.Count); if (player.package.size != prevInventorySize) { infiniteInventoryRestore.SetSize(player.package.size); } if (player.package.size != requiredSize) { player.package.SetSize(requiredSize); } prevInventorySize = player.package.size; RestockInfiniteInventory(cachedItemIds); player.sandCount = 999999L; } } private void RefreshCachedItemIds() { cachedItemIds = GetItemIdsFiltered(); cachedTime = Time.time; } private void RestockInfiniteInventory(IList<int> itemIds) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) GRID[] grids = infiniteInventory.grids; bool flag = false; GRID g3 = default(GRID); g3.stackSize = 1073741823; g3.count = 536870911; g3.inc = 0; for (int i = 0; i < itemIds.Count; i++) { g3.itemId = (g3.filter = itemIds[i]); if (!IsEqual(in grids[i], in g3)) { flag = true; grids[i] = g3; } } g3.itemId = 0; g3.filter = int.MaxValue; g3.stackSize = (g3.count = (g3.inc = 0)); for (int j = itemIds.Count; j < infiniteInventory.size; j++) { if (!IsEqual(in grids[j], in g3)) { flag = true; grids[j] = g3; } } if (flag) { infiniteInventory.NotifyStorageChange(); } static bool IsEqual(in GRID g1, in GRID g2) { if (g1.itemId == g2.itemId && g1.filter == g2.filter && g1.stackSize == g2.stackSize && g1.count == g2.count) { return g1.inc == g2.inc; } return false; } } private IList<int> GetItemIdsFiltered() { return (from x in ((ProtoSet<ItemProto>)(object)LDB.items).dataArray.Where(itemFilter) select ((Proto)x).ID).ToList(); } private static bool OnlyUnlockedItemsPredicate(ItemProto item) { if (((Proto)item).ID != 1099) { return GameMain.history.ItemUnlocked(((Proto)item).ID); } return false; } private static bool AllItemsPredicate(ItemProto item) { return ((Proto)item).ID != 1099; } private static int GetRequiredSize(int count) { int colCount = UIRoot.instance.uiGame.inventoryWindow.inventory.colCount; return count + ((count % colCount > 0) ? (colCount - count % colCount) : 0); } public void PreserveVanillaSaveBefore() { if (isEnabled) { if (infiniteInventoryRestore != null) { player.package = infiniteInventoryRestore; } if (sandRestore.HasValue) { player.sandCount = sandRestore.Value; } } } public void PreserveVanillaSaveAfter() { if (isEnabled) { player.package = infiniteInventory; player.sandCount = 999999L; } } } [HarmonyPatch] public static class InfiniteInventoryPatch { private static InfiniteInventory infiniteInventory; public static void Register(InfiniteInventory instance) { infiniteInventory = instance; } public static void Unregister(InfiniteInventory instance) { if (infiniteInventory == instance) { infiniteInventory = null; } } [HarmonyPostfix] [HarmonyPatch(typeof(UIStorageGrid), "OnStorageContentChanged")] private static void EnsureThatInfiniteInventoryHasProperTextColors(UIStorageGrid __instance) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (infiniteInventory == null || __instance.storage != infiniteInventory.storage) { return; } GRID[] grids = __instance.storage.grids; for (int i = 0; i < grids.Length; i++) { if ((Object)(object)__instance.numTexts[i] != (Object)null) { ((Graphic)__instance.numTexts[i]).color = ((Graphic)__instance.prefabNumText).color; __instance.numTexts[i].text = "∞"; } } } [HarmonyPostfix] [HarmonyPatch(typeof(UIItemupNode), "SetData")] [HarmonyPatch(typeof(UIItemupNode), "_OnUpdate")] private static void SetCountTextToInfinity__UIItemupNode(UIItemupNode __instance) { InfiniteInventory infiniteInventory = InfiniteInventoryPatch.infiniteInventory; if (infiniteInventory != null && infiniteInventory.IsEnabled) { __instance.totalNumText.text = "∞"; } } [HarmonyPostfix] [HarmonyPatch(typeof(UIHandTip), "SetHandTip")] private static void SetCountTextToInfinity__UIHandTip(UIHandTip __instance) { InfiniteInventory infiniteInventory = InfiniteInventoryPatch.infiniteInventory; if (infiniteInventory != null && infiniteInventory.IsEnabled) { ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(__instance.itemId); if (val != null) { __instance.tipText.text = string.Concat(new object[2] { ((Proto)val).name, "\r\n( ∞ )" }); } } } [HarmonyPostfix] [HarmonyPatch(typeof(UIBuildMenu), "SetCurrentCategory")] [HarmonyPatch(typeof(UIBuildMenu), "_OnUpdate")] private static void SetCountTextToInfinity__UIBuildMenu(UIBuildMenu __instance) { InfiniteInventory infiniteInventory = InfiniteInventoryPatch.infiniteInventory; if (infiniteInventory == null || !infiniteInventory.IsEnabled) { return; } int currentCategory = __instance.currentCategory; if ((currentCategory < 1 || currentCategory > 9) ? true : false) { return; } GameHistoryData history = GameMain.history; for (int i = 0; i < 12 && i < __instance.childNumTexts.Length; i++) { if (UIBuildMenu.protos[__instance.currentCategory, i] != null && (Object)(object)__instance.childNumTexts[i] != (Object)null) { int iD = ((Proto)UIBuildMenu.protos[__instance.currentCategory, i]).ID; if (history.ItemUnlocked(iD)) { __instance.childNumTexts[i].text = "∞"; } } } } [HarmonyPrefix] [HarmonyPatch(typeof(GameSave), "SaveCurrentGame")] private static void BeforeSaveCurrentGame(ref bool __state) { __state = false; InfiniteInventory infiniteInventory = InfiniteInventoryPatch.infiniteInventory; if (infiniteInventory != null && infiniteInventory.IsEnabled) { __state = true; InfiniteInventoryPatch.infiniteInventory.Disable(); } } [HarmonyPostfix] [HarmonyPatch(typeof(GameSave), "SaveCurrentGame")] private static void AfterSaveCurrentGame(ref bool __state) { if (__state && infiniteInventory != null) { infiniteInventory.Enable(); } } } public class InfinitePower { private bool isEnabled; public bool IsEnabled { get { return isEnabled; } set { if (isEnabled != value) { if (value) { Enable(); } else { Disable(); } } } } public void Enable() { isEnabled = true; Plugin.Log.LogDebug((object)"Infinite Power Enabled"); } public void Disable() { isEnabled = false; Plugin.Log.LogDebug((object)"Infinite Power Disabled"); } public void Toggle() { if (!isEnabled) { Enable(); } else { Disable(); } } } [HarmonyPatch] public static class InfinitePowerPatch { private static InfinitePower infinitePower; public static void Register(InfinitePower instance) { infinitePower = instance; } public static void Unregister(InfinitePower instance) { if (infinitePower == instance) { infinitePower = null; } } [HarmonyPostfix] [HarmonyPatch(typeof(PowerSystem), "GameTick")] private static void PatchNetworkServes(PowerSystem __instance, bool isActive) { InfinitePower obj = infinitePower; if (obj == null || !obj.IsEnabled) { return; } for (int i = 1; i < __instance.netCursor; i++) { __instance.networkServes[i] = 1f; if (!isActive) { continue; } SignData[] entitySignPool = __instance.factory.entitySignPool; PowerNetwork val = __instance.netPool[i]; if (val != null && val.id == i) { List<int> consumers = val.consumers; for (int j = 0; j < consumers.Count; j++) { entitySignPool[__instance.consumerPool[consumers[j]].entityId].signType = 0u; } } } } [HarmonyTranspiler] [HarmonyPatch(typeof(MonitorComponent), "InternalUpdate")] [HarmonyPatch(typeof(PilerComponent), "InternalUpdate")] [HarmonyPatch(typeof(SpraycoaterComponent), "InternalUpdate")] private static IEnumerable<CodeInstruction> ReplaceConsumerRatioWithNetworkServes(IEnumerable<CodeInstruction> code, ILGenerator generator) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Expected O, but got Unknown //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Expected O, but got Unknown List<CodeInstruction> result = new List<CodeInstruction>(code); CodeMatcher val = new CodeMatcher(code, generator); FieldInfo fieldInfo = AccessTools.Field(typeof(PowerNetwork), "consumerRatio"); FieldInfo fldNetPool = AccessTools.Field(typeof(PowerSystem), "netPool"); FieldInfo fldNetworkServes = AccessTools.Field(typeof(PowerSystem), "networkServes"); CodeMatch val2 = matchStLocToExtractLocal("matchPowerNetworkLocal"); CodeMatch val3 = matchLdLocToExtractLocal("matchNetworkIdLocal"); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fldNetPool, (string)null), val3, new CodeMatch((OpCode?)OpCodes.Ldelem_Ref, (object)null, (string)null), val2 }); if (val.IsInvalid) { return result; } int pos = val.Pos; CodeInstruction item = val.NamedMatch("matchNetworkIdLocal").Clone(); val.MatchBack(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.IsLdloc(ci, (LocalBuilder)null) || CodeInstructionExtensions.IsLdarg(ci, (int?)null)), (string)null) }); if (val.IsInvalid) { return result; } int pos2 = val.Pos; List<CodeInstruction> list = (from x in val.InstructionsInRange(pos2, pos) select (CodeInstruction)(CodeInstructionExtensions.Is(x, OpCodes.Ldfld, (MemberInfo)fldNetPool) ? ((object)new CodeInstruction(OpCodes.Ldfld, (object)fldNetworkServes)) : ((object)x.Clone()))).ToList(); list.Add(item); list.Add(new CodeInstruction(OpCodes.Ldelem_R4, (object)null)); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.IsLdloc(ci, (LocalBuilder)null)), (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo, (string)null), new CodeMatch((OpCode?)OpCodes.Conv_R4, (object)null, (string)null) }); if (val.IsInvalid) { return result; } val.SetAndAdvance(list[0].opcode, list[0].operand); val.SetInstructionAndAdvance(list[1]); val.SetInstructionAndAdvance(list[2]); val.Insert(list.Skip(3)); return val.InstructionEnumeration(); static CodeMatch matchLdLocToExtractLocal(string name) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown return new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.IsLdloc(ci, (LocalBuilder)null)), name); } static CodeMatch matchStLocToExtractLocal(string name) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown return new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.IsStloc(ci, (LocalBuilder)null)), name); } } } public class InfiniteReach { private readonly Player player; private float? buildAreaRestore; private bool isEnabled; public bool IsEnabled { get { return isEnabled; } set { if (isEnabled != value) { if (value) { Enable(); } else { Disable(); } } } } public InfiniteReach(Player player) { this.player = player; } public void Enable() { buildAreaRestore = player.mecha.buildArea; player.mecha.buildArea = 600f; isEnabled = true; Plugin.Log.LogDebug((object)"Infinite Reach Enabled"); } public void Disable() { player.mecha.buildArea = buildAreaRestore.GetValueOrDefault(Configs.freeMode.mechaBuildArea); isEnabled = false; Plugin.Log.LogDebug((object)"Infinite Reach Disabled"); } public void Toggle() { if (!isEnabled) { Enable(); } else { Disable(); } } public void PreserveVanillaSaveBefore() { if (isEnabled) { player.mecha.buildArea = buildAreaRestore.GetValueOrDefault(Configs.freeMode.mechaBuildArea); } } public void PreserveVanillaSaveAfter() { if (isEnabled) { player.mecha.buildArea = 600f; } } } [HarmonyPatch] public static class InfiniteReachPatch { private static InfiniteReach infiniteReach; public static void Register(InfiniteReach instance) { infiniteReach = instance; } public static void Unregister(InfiniteReach instance) { if (infiniteReach == instance) { infiniteReach = null; } } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerAction_Inspect), "GetObjectSelectDistance")] private static void PatchObjectSelectDistance(ref float __result, EObjectType objType, int objid) { InfiniteReach obj = infiniteReach; if (obj != null && obj.IsEnabled) { __result = 600f; } } [HarmonyPrefix] [HarmonyPatch(typeof(GameSave), "SaveCurrentGame")] private static void BeforeSaveCurrentGame(ref bool __state) { __state = false; if (infiniteReach != null && infiniteReach.IsEnabled) { __state = true; infiniteReach.Disable(); } } [HarmonyPostfix] [HarmonyPatch(typeof(GameSave), "SaveCurrentGame")] private static void AfterSaveCurrentGame(ref bool __state) { if (__state && infiniteReach != null) { infiniteReach.Enable(); } } } public class InfiniteStation { private bool isEnabled; public bool IsEnabled { get { return isEnabled; } set { if (isEnabled != value) { if (value) { Enable(); } else { Disable(); } } } } public void Enable() { isEnabled = true; Plugin.Log.LogDebug((object)"Infinite Station Enabled"); } public void Disable() { isEnabled = false; Plugin.Log.LogDebug((object)"Infinite Station Disabled"); } public void Toggle() { if (!isEnabled) { Enable(); } else { Disable(); } } public void GameTick() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Invalid comparison between Unknown and I4 //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Invalid comparison between Unknown and I4 if (!isEnabled) { return; } for (int i = 0; i < GameMain.data.factoryCount; i++) { PlanetTransport transport = GameMain.data.factories[i].transport; if (transport == null) { continue; } for (int j = 1; j < transport.stationCursor; j++) { if (transport.stationPool[j] == null || transport.stationPool[j].id != j) { continue; } StationStore[] storage = transport.stationPool[j].storage; for (int k = 0; k < storage.Length; k++) { if (storage[k].itemId > 0) { ELogisticStorage val = (((int)storage[k].remoteLogic == 0) ? storage[k].localLogic : storage[k].remoteLogic); if ((int)val == 1 && storage[k].count > storage[k].max / 2) { storage[k].count = storage[k].max / 2; } else if ((int)val == 2 && storage[k].count < storage[k].max / 2) { storage[k].count = storage[k].max / 2; } } } } } } } public class InstantBuild { private readonly Player player; private bool isEnabled; public bool IsEnabled { get { return isEnabled; } set { if (isEnabled != value) { if (value) { Enable(); } else { Disable(); } } } } public InstantBuild(Player player) { this.player = player; } public void Enable() { isEnabled = true; Plugin.Log.LogDebug((object)"Instant Build Enabled"); } public void Disable() { isEnabled = false; Plugin.Log.LogDebug((object)"Instant Build Disabled"); } public void Toggle() { if (!isEnabled) { Enable(); } else { Disable(); } } public void GameTick(bool skipInventory) { if (!isEnabled) { return; } PlanetFactory factory = player.factory; if (factory == null || factory.prebuildCount == 0) { return; } int num = 1; if (factory.prebuildRecycleCursor > 0) { num = factory.prebuildRecycleCursor; } int prebuildCursor = factory.prebuildCursor; int[] prebuildRecycle = factory.prebuildRecycle; PrebuildData[] prebuildPool = factory.prebuildPool; StorageComponent package = player.package; int num3 = default(int); for (int i = num; i < prebuildCursor; i++) { int num2 = ((prebuildRecycle[i] > 0) ? prebuildRecycle[i] : i); ref PrebuildData reference = ref prebuildPool[num2]; if (reference.id != num2) { continue; } if (skipInventory) { factory.BuildFinally(player, reference.id, true, true); continue; } if (reference.itemRequired > 0) { int protoId = reference.protoId; int itemRequired = reference.itemRequired; package.TakeTailItems(ref protoId, ref itemRequired, ref num3, false); reference.itemRequired -= itemRequired; } if (reference.itemRequired <= 0) { factory.BuildFinally(player, reference.id, true, true); } } } } public class InstantReplicate { private bool isEnabled; public bool IsInstant = true; public bool IsFree = true; public bool AllowAll = true; public bool IsEnabled { get { return isEnabled; } set { if (isEnabled != value) { if (value) { Enable(); } else { Disable(); } } } } public void Enable() { isEnabled = true; Plugin.Log.LogDebug((object)"Instant Replicate Enabled"); } public void Disable() { isEnabled = false; Plugin.Log.LogDebug((object)"Instant Replicate Disabled"); } public void Toggle() { if (!isEnabled) { Enable(); } else { Disable(); } } } public static class InstantReplicatePatch { private static InstantReplicate instantReplicate; public static void Register(InstantReplicate instance) { instantReplicate = instance; } public static void Unregister(InstantReplicate instance) { if (instantReplicate == instance) { instantReplicate = null; } } [HarmonyPostfix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static void ForgeTaskCreatePostfix(ref ForgeTask __instance) { InstantReplicate instantReplicate = InstantReplicatePatch.instantReplicate; if (instantReplicate != null && instantReplicate.IsEnabled && instantReplicate.IsInstant) { __instance.tickSpend = 1; } } [HarmonyPrefix] [HarmonyPatch(typeof(MechaForge), "PredictTaskCount")] public static void MechaForgePredictTaskCountPrefix(ref int __result, ref int maxShowing, ref bool __runOriginal) { InstantReplicate instantReplicate = InstantReplicatePatch.instantReplicate; if (instantReplicate != null && instantReplicate.IsEnabled && instantReplicate.IsFree) { __result = maxShowing; __runOriginal = false; } } [HarmonyPrefix] [HarmonyPatch(typeof(MechaForge), "TryAddTask")] public static void TryAddTaskPrefix(ref bool __result, ref bool __runOriginal) { InstantReplicate instantReplicate = InstantReplicatePatch.instantReplicate; if (instantReplicate != null && instantReplicate.IsEnabled && instantReplicate.IsFree) { __result = true; __runOriginal = false; } } public static int InterceptReplicateTaskTakeItems(StorageComponent instance, int itemId, int count, out int inc) { InstantReplicate instantReplicate = InstantReplicatePatch.instantReplicate; if (instantReplicate != null && instantReplicate.IsEnabled && instantReplicate.IsFree) { inc = 0; return count; } return instance.TakeItem(itemId, count, ref inc); } [HarmonyTranspiler] [HarmonyPatch(typeof(MechaForge), "AddTaskIterate")] public static IEnumerable<CodeInstruction> DontTakeItemsPatch(IEnumerable<CodeInstruction> code, 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(code, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.Calls(ci, AccessTools.Method(typeof(StorageComponent), "TakeItem", (Type[])null, (Type[])null))), (string)null) }); val.SetAndAdvance(OpCodes.Call, (object)AccessTools.Method(typeof(InstantReplicatePatch), "InterceptReplicateTaskTakeItems", (Type[])null, (Type[])null)); return val.InstructionEnumeration(); } public static bool InterceptReplicateHandcraftCheck(RecipeProto instance) { InstantReplicate instantReplicate = InstantReplicatePatch.instantReplicate; if (instantReplicate == null || !instantReplicate.IsEnabled || !instantReplicate.AllowAll) { return instance.Handcraft; } return true; } [HarmonyTranspiler] [HarmonyPatch(typeof(UIReplicatorWindow), "OnOkButtonClick")] [HarmonyPatch(typeof(UIReplicatorWindow), "_OnUpdate")] public static IEnumerable<CodeInstruction> ReplicatorOkButtonPatch(IEnumerable<CodeInstruction> code, 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(code, generator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.LoadsField(ci, AccessTools.Field(typeof(UIReplicatorWindow), "selectedRecipe"), false)), (string)null), new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction ci) => CodeInstructionExtensions.LoadsField(ci, AccessTools.Field(typeof(RecipeProto), "Handcraft"), false)), (string)null) }); val.Advance(1); val.SetAndAdvance(OpCodes.Call, (object)AccessTools.Method(typeof(InstantReplicatePatch), "InterceptReplicateHandcraftCheck", (Type[])null, (Type[])null)); return val.InstructionEnumeration(); } } public class InstantResearch { private bool isEnabled; public bool EnableLocking = true; public bool IsEnabled { get { return isEnabled; } set { if (isEnabled != value) { if (value) { Enable(); } else { Disable(); } } } } public void Enable() { isEnabled = true; Plugin.Log.LogDebug((object)"Instant Research Enabled"); } public void Disable() { isEnabled = false; Plugin.Log.LogDebug((object)"Instant Research Disabled"); } public void Toggle() { if (!isEnabled) { Enable(); } else { Disable(); } } public void GameTick() { if (isEnabled) { ResearchCurrentTechInstantly(); } } private static void ResearchCurrentTechInstantly() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) GameHistoryData history = GameMain.history; if (history.currentTech > 0) { TechState val = history.TechState(history.currentTech); long num = val.hashNeeded - val.hashUploaded; history.AddTechHash(num); } } } [HarmonyPatch] public static class InstantResearchPatch { private static InstantResearch instantResearch; public static void Register(InstantResearch instance) { instantResearch = instance; } public static void Unregister(InstantResearch instance) { if (instantResearch == instance) { instantResearch = null; } } } public static class KeyBinds { public const string ToggleCreativeMode = "ToggleCreativeMode"; public const string ToggleInfiniteInventory = "ToggleInfiniteInventory"; public const string ToggleInfiniteStation = "ToggleInfiniteStation"; public const string ToggleInstantBuild = "ToggleInstantBuild"; public const string FlattenPlanet = "FlattenPlanet"; public const string UnlockAllPublishedTech = "UnlockAllPublishedTech"; public const string ToggleInstantResearch = "ToggleInstantResearch"; public const string ToggleAllVeinsOnPlanet = "ToggleAllVeinsOnPlanet"; public const string HoldLockResearch = "HoldLockResearch"; public const string ForwardUniverseSimulation = "ForwardUniverseSimulation"; public const string BackwardUniverseSimulation = "BackwardUniverseSimulation"; private static List<string> keyBinds = new List<string> { "ToggleCreativeMode", "ToggleInfiniteInventory", "ToggleInfiniteStation", "ToggleInstantBuild", "FlattenPlanet", "UnlockAllPublishedTech", "ToggleInstantResearch", "ToggleAllVeinsOnPlanet", "HoldLockResearch", "ForwardUniverseSimulation", "BackwardUniverseSimulation" }; private static List<CombineKey> defaultBindings = new List<CombineKey> { new CombineKey(285, (byte)1, (ECombineKeyAction)0, false), new CombineKey(257, (byte)2, (ECombineKeyAction)0, false), new CombineKey(256, (byte)2, (ECombineKeyAction)0, false), new CombineKey(258, (byte)2, (ECombineKeyAction)0, false), new CombineKey(259, (byte)8, (ECombineKeyAction)0, false), new CombineKey(116, (byte)3, (ECombineKeyAction)0, false), new CombineKey(262, (byte)2, (ECombineKeyAction)0, false), new CombineKey(260, (byte)0, (ECombineKeyAction)0, false), new CombineKey(108, (byte)8, (ECombineKeyAction)2, false), new CombineKey(46, (byte)3, (ECombineKeyAction)2, false), new CombineKey(44, (byte)3, (ECombineKeyAction)2, false) }; private static List<string> keyBindDescriptions = new List<string> { "Toggle Creative Mode", "(Creative Mode) Toggle Infinite Inventory", "(Creative Mode) Toggle Infinite Station", "(Creative Mode) Toggle Instant Build", "(Creative Mode) Flatten Planet", "(Creative Mode) Unlock all Tech", "(Creative Mode) Toggle Instant Research", "(Creative Mode) Toggle All Veins on Planet", "(Creative Mode) Lock Research", "(Creative Mode) Fast Forward Orbital Mechanics", "(Creative Mode) Rewind Orbital Mechanics" }; private static int keyBindId(string keyBind) { return keyBinds.IndexOf(keyBind) + 200; } public static void RegisterKeyBinds() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Invalid comparison between Unknown and I4 //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) foreach (string keyBind in keyBinds) { if (!CustomKeyBindSystem.HasKeyBind(keyBind)) { BuiltinKey val = default(BuiltinKey); val.name = keyBind; val.id = keyBindId(keyBind); val.key = defaultBindings[keyBinds.IndexOf(keyBind)]; val.canOverride = true; val.conflictGroup = 4095; BuiltinKey val2 = val; if ((int)val2.key.action == 2) { CustomKeyBindSystem.RegisterKeyBind<HoldKeyBind>(val2); } else { CustomKeyBindSystem.RegisterKeyBind<PressKeyBind>(val2); } LocalizationModule.RegisterTranslation("KEY" + keyBind, keyBindDescriptions[keyBinds.IndexOf(keyBind)]); } } } } [HarmonyPatch] public static class OrbitalMechanicsOverride { public static long Offset; [HarmonyPrefix] [HarmonyPatch(typeof(GalaxyData), "UpdatePoses")] private static void ApplyOffset(ref double time) { time += Offset; } [HarmonyPrefix] [HarmonyPatch(typeof(GameData), "Destroy")] public static void ResetOffset() { Offset = 0L; } public static void PreserveVanillaSaveBefore() { long offset = Offset; Offset = 0L; GameMain.universeSimulator.galaxyData.UpdatePoses(GameMain.instance.timef); GameMain.data.DetermineRelative(); GameMain.mainPlayer.controller.UpdatePhysicsDirect(); Offset = offset; } public static void PreserveVanillaSaveAfter() { } } public static class PlanetReform { public static void SetPlanetModLevel(PlanetFactory factory, bool bury, int modLevel) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) PlanetData planet = factory.planet; if (planet != null && (int)planet.type != 5) { byte[] modData = planet.data.modData; for (int i = 0; i < modData.Length; i++) { modData[i] = (byte)(((uint)modLevel & 3u) | (uint)((modLevel & 3) << 4)); } bool[] dirtyFlags = planet.dirtyFlags; for (int j = 0; j < dirtyFlags.Length; j++) { dirtyFlags[j] = true; } planet.landPercentDirty = true; if (planet.UpdateDirtyMeshes()) { factory.RenderLocalPlanetHeightmap(); } VegeData[] vegePool = factory.vegePool; float num = planet.realRadius + 0.2f; bool flag = (modLevel & 3) == 3; for (int k = 1; k < factory.vegeCursor; k++) { Vector3 pos = vegePool[k].pos; float num2 = (flag ? num : (planet.data.QueryModifiedHeight(pos) - 0.13f)); vegePool[k].pos = ((Vector3)(ref pos)).normalized * num2; GameMain.gpuiManager.AlterModel((int)vegePool[k].modelIndex, vegePool[k].modelId, k, vegePool[k].pos, vegePool[k].rot, false); } ModifyAllVeinsHeight(factory, bury); } } public static void ModifyAllVeinsHeight(PlanetFactory factory, bool bury) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) PlanetData planet = factory.planet; PlanetPhysics physics = planet.physics; VeinData[] veinPool = factory.veinPool; for (int i = 1; i < factory.veinCursor; i++) { Vector3 pos = veinPool[i].pos; int colliderId = veinPool[i].colliderId; float num = (bury ? (planet.realRadius - 50f) : (planet.data.QueryModifiedHeight(veinPool[i].pos) - 0.13f)); ref ColliderData reference = ref physics.colChunks[colliderId >> 20].colliderPool[colliderId & 0xFFFFF]; ColliderData colliderData = physics.GetColliderData(colliderId); reference.pos = ((Vector3)(ref colliderData.pos)).normalized * (num + 0.4f); veinPool[i].pos = ((Vector3)(ref pos)).normalized * num; physics.SetPlanetPhysicsColliderDirty(); GameMain.gpuiManager.AlterModel((int)veinPool[i].modelIndex, veinPool[i].modelId, i, veinPool[i].pos, false); } GameMain.gpuiManager.SyncAllGPUBuffer(); } } public class UIManager { private static UIManager instance; private CreativeModeController controller; public UIModWindowBase window; public static UIManager Instance => instance; public static void CreateUIManager() { if (instance == null) { instance = new UIManager(); instance.CreateUI(); } } public static void DestroyUIManager() { if (instance != null) { instance.Destroy(); instance = null; } } private UIManager() { } public void Init(CreativeModeController controller) { this.controller = controller; } public void Free() { controller = null; } private void Destroy() { Object.Destroy((Object)(object)((Component)window).gameObject); window = null; } private void CreateUI() { //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected O, but got Unknown Transform parent = ((Component)UIRoot.instance.uiGame.statWindow).gameObject.transform.parent; GameObject uiElement = UIBuilderDSL.Create.PlainWindow("Creative Mode Settings").ChildOf(parent).WithAnchor(Anchor.TopLeft) .OfSize(750, 500) .At(300, -180) .WithScrollCapture() .WithTitle("Creative Mode Settings") .InitializeComponent<UIBuilderDSL.PlainWindowContext, UIModWindowBase>(out window) .uiElement; ScrollViewContext scrollViewContext = UIBuilderDSL.Create.ScrollView("window-content", new ScrollViewConfiguration(ScrollViewAxis.BothVerticalAndHorizontal)).ChildOf(uiElement).WithAnchor(Anchor.Stretch) .WithPivot(0f, 1f) .OfSize(-20, -55) .At(10, -45); GameObject gameObject = ((Component)scrollViewContext.scrollRect.content).gameObject; ((Transform)UIBuilderDSL.Create.UIElement("bg").ChildOf((Transform)(object)scrollViewContext.scrollRect.viewport).WithAnchor(Anchor.Stretch) .At(0, 0) .WithComponent<UIElementContext, Image>((Action<Image>)delegate(Image x) { //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_000e: Unknown result type (might be due to invalid IL or missing references) Color black = Color.black; ((Graphic)x).color = ((Color)(ref black)).AlphaMultiplied(0.5f); }) .transform).SetAsFirstSibling(); int num = 10; VerticalLayoutGroupContext root2 = UIBuilderDSL.Select.VerticalLayoutGroup(gameObject).WithPadding(new RectOffset(num, num, num + 10, num + 10)).WithSpacing(10f) .WithChildAlignment((TextAnchor)0) .ForceExpand(width: false, height: false) .ChildControls() .WithContentSizeFitter((FitMode)2, (FitMode)2); DelegateDataBindSource<bool> creativeModeBinding = new DelegateDataBindSource<bool>(() => controller?.Active ?? false, delegate(bool value) { if (controller != null) { controller.Active = value; } }); CreateEntry(root2, "Creative Mode", (RectTransform[])(object)new RectTransform[1] { CreateOnOffToggleButton(creativeModeBinding).transform }); CreateSection(root2, creativeModeBinding, delegate(VerticalLayoutGroupContext mainSection) { DelegateDataBindSource<bool> delegateDataBindSource = new DelegateDataBindSource<bool>(() => (controller?.infiniteInventory?.IsEnabled).GetValueOrDefault(), delegate(bool value) { if (controller?.infiniteInventory != null) { controller.infiniteInventory.IsEnabled = value; } }); CreateEntry(mainSection, "Infinite Inventory", (RectTransform[])(object)new RectTransform[2] { CreateOnOffToggleButton(delegateDataBindSource).BindInteractive(creativeModeBinding).transform, CreateAutoEnableButton(CreativeModeConfig.autoEnableInfiniteInventory).transform }); CreateSection(mainSection, delegateDataBindSource, delegate(VerticalLayoutGroupContext section) { DelegateDataBindSource<bool> binding9 = new DelegateDataBindSource<bool>(() => (controller?.infiniteInventory?.IncludeLocked).GetValueOrDefault(), delegate(bool value) { if (controller?.infiniteInventory != null) { controller.infiniteInventory.IncludeLocked = value; } }); CreateEntry(section, "Include Locked Items", (RectTransform[])(object)new RectTransform[1] { CreateOnOffToggleButton(binding9, "Yes", "No").transform }); }); DelegateDataBindSource<bool> binding2 = new DelegateDataBindSource<bool>(() => (controller?.infiniteStation?.IsEnabled).GetValueOrDefault(), delegate(bool value) { if (controller?.infiniteStation != null) { controller.infiniteStation.IsEnabled = value; } }); CreateEntry(mainSection, "Infinite Station", (RectTransform[])(object)new RectTransform[1] { CreateOnOffToggleButton(binding2).BindInteractive(creativeModeBinding).transform }); DelegateDataBindSource<bool> binding3 = new DelegateDataBindSource<bool>(() => (controller?.infiniteReach?.IsEnabled).GetValueOrDefault(), delegate(bool value) { if (controller?.infiniteReach != null) { controller.infiniteReach.IsEnabled = value; } }); CreateEntry(mainSection, "Infinite Reach", (RectTransform[])(object)new RectTransform[2] { CreateOnOffToggleButton(binding3).BindInteractive(creativeModeBinding).transform, CreateAutoEnableButton(CreativeModeConfig.autoEnableInfiniteReach).transform }); DelegateDataBindSource<bool> binding4 = new DelegateDataBindSource<bool>(() => (controller?.infinitePower?.IsEnabled).GetValueOrDefault(), delegate(bool value) { if (controller?.infinitePower != null) { controller.infinitePower.IsEnabled = value; } }); CreateEntry(mainSection, "Infinite Power", (RectTransform[])(object)new RectTransform[2] { CreateOnOffToggleButton(binding4).BindInteractive(creativeModeBinding).transform, CreateAutoEnableButton(CreativeModeConfig.autoEnableInfinitePower).transform }); DelegateDataBindSource<bool> delegateDataBindSource2 = new DelegateDataBindSource<bool>(() => (controller?.instantResearch?.IsEnabled).GetValueOrDefault(), delegate(bool value) { if (controller?.instantResearch != null) { controller.instantResearch.IsEnabled = value; } }); CreateEntry(mainSection, "Instant Research", (RectTransform[])(object)new RectTransform[2] { CreateOnOffToggleButton(delegateDataBindSource2).BindInteractive(creativeModeBinding).transform, CreateAutoEnableButton(CreativeModeConfig.autoEnableInstantResearch).transform }); CreateSection(mainSection, delegateDataBindSource2, delegate(VerticalLayoutGroupContext section) { CreateEntry(section, "Enable Locking", (RectTransform[])(object)new RectTransform[1] { BrokenText().transform }); CreateEntry(section, "Unlock All Tech", (RectTransform[])(object)new RectTransform[1] { BrokenText().transform }); }); DelegateDataBindSource<bool> binding5 = new DelegateDataBindSource<bool>(() => (controller?.instantBuild?.IsEnabled).GetValueOrDefault(), delegate(bool value) { if (controller?.instantBuild != null) { controller.instantBuild.IsEnabled = value; } }); CreateEntry(mainSection, "Instant Build", (RectTransform[])(object)new RectTransform[2] { CreateOnOffToggleButton(binding5).BindInteractive(creativeModeBinding).transform, CreateAutoEnableButton(CreativeModeConfig.autoEnableInstantBuild).transform }); DelegateDataBindSource<bool> delegateDataBindSource3 = new DelegateDataBindSource<bool>(() => (controller?.instantReplicate?.IsEnabled).GetValueOrDefault(), delegate(bool value) { if (controller?.instantReplicate != null) { controller.instantReplicate.IsEnabled = value; } }); CreateEntry(mainSection, "Instant/Free Replicate", (RectTransform[])(object)new RectTransform[2] { CreateOnOffToggleButton(delegateDataBindSource3).BindInteractive(creativeModeBinding).transform, CreateAutoEnableButton(CreativeModeConfig.autoEnableInstantReplicate).transform }); CreateSection(mainSection, delegateDataBindSource3, delegate(VerticalLayoutGroupContext section) { DelegateDataBindSource<bool> binding6 = new DelegateDataBindSource<bool>(() => (controller?.instantReplicate?.IsInstant).GetValueOrDefault(), delegate(bool value) { if (controller?.instantReplicate != null) { controller.instantReplicate.IsInstant = value; } }); CreateEntry(section, "Is Instant", (RectTransform[])(object)new RectTransform[1] { CreateOnOffToggleButton(binding6, "Yes", "No").transform }); DelegateDataBindSource<bool> binding7 = new DelegateDataBindSource<bool>(() => (controller?.instantReplicate?.IsFree).GetValueOrDefault(), delegate(bool value) { if (controller?.instantReplicate != null) { controller.instantReplicate.IsFree = value; } }); CreateEntry(section, "Is Free", (RectTransform[])(object)new RectTransform[1] { CreateOnOffToggleButton(binding7, "Yes", "No").transform }); DelegateDataBindSource<bool> binding8 = new DelegateDataBindSource<bool>(() => (controller?.instantReplicate?.AllowAll).GetValueOrDefault(), delegate(bool value) { if (controller?.instantReplicate != null) { controller.instantReplicate.AllowAll = value; } }); CreateEntry(section, "Allow All", (RectTransform[])(object)new RectTransform[1] { CreateOnOffToggleButton(binding8, "Yes", "No").transform }); }); HorizontalLayoutGroupContext horizontalLayoutGroupContext3 = CreateEntry(mainSection, "Reform Planet", (RectTransform[])(object)new RectTransform[4] { SetModLevelButton("Ground Level", 3).BindInteractive(creativeModeBinding).transform, SetModLevelButton("Shallow Oceans", 2).BindInteractive(creativeModeBinding).transform, SetModLevelButton("Medium Oceans", 1).BindInteractive(creativeModeBinding).transform, SetModLevelButton("Deep Oceans", 0).BindInteractive(creativeModeBinding).transform }); DelegateDataBindSource<bool> veinsBuryBinding = new DelegateDataBindSource<bool>(() => controller?.veinsBury ?? false, delegate(bool value) { if (controller != null) { controller.veinsBury = value; } }); UIBuilderDSL.Select.UIElement(horizontalLayoutGroupContext3.uiElement.SelectChild("name")).WithComponent<UIElementContext, Localizer>(out Localizer localizer, (Action<Localizer>)delegate(Localizer x) { x.stringKey = (veinsBuryBinding.Value ? "Reform Planet (Will Bury Veins)" : "Reform Planet (Will Restore Veins)"); }).WithComponent<UIElementContext, DataBindValueChangedHandlerBool>((Action<DataBindValueChangedHandlerBool>)delegate(DataBindValueChangedHandlerBool x) { x.Binding = veinsBuryBinding; x.Handler = delegate(bool willBury) { localizer.stringKey = (willBury ? "Reform Planet (Will Bury Veins)" : "Reform Planet (Will Restore Veins)"); localizer.Refresh(); }; }); CreateEntry(mainSection, "Planet Veins", (RectTransform[])(object)new RectTransform[2] { VeinModifyButton("Bury", toBury: true).BindInteractive(creativeModeBinding).transform, VeinModifyButton("Restore", toBury: false).BindInteractive(creativeModeBinding).transform }); }); ((ManualBehaviour)window)._Close(); static TextContext BrokenText() { return UIBuilderDSL.Create.Text("disclaimer").WithText("Broken after combat update. Fix still WIP"); } static ToggleButtonContext CreateAutoEnableButton(ConfigEntry<bool> entry) { return CreateOnOffToggleButton((ConfigEntryDataBindSource<bool>)entry, "Auto-Enable", "Auto-Enable"); } static HorizontalLayoutGroupContext CreateEntry(VerticalLayoutGroupContext root, string configName, RectTransform[] children) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown int num4 = 8; HorizontalLayoutGroupContext horizontalLayoutGroupContext2 = HorizontalOrVerticalLayoutGroupContextExtensions.WithSpacing(UIBuilderDSL.Create.HorizontalLayoutGroup("config-entry").WithChildAlignment((TextAnchor)3).WithPadding(new RectOffset(num4, num4, 0, 0)), num4).ForceExpand(width: false, height: false).ChildControls() .ChildOf((UIElementContext)root); UIBuilderDSL.Create.Text("name").WithLocalizer(configName).WithFontSize(20) .WithAlignment((TextAnchor)3) .WithLayoutSize(250f, 34f) .ChildOf((UIElementContext)horizontalLayoutGroupContext2); horizontalLayoutGroupContext2.AddChildren(children); return horizontalLayoutGroupContext2; } static ToggleButtonContext CreateOnOffToggleButton(IDataBindSource<bool> binding, string onText = "Enabled", string offText = "Disabled") { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) Color normalColor = default(Color); ((Color)(ref normalColor))..ctor(0.24f, 0.6f, 0.72f); Color val4 = default(Color); ((Color)(ref val4))..ctor(0.37f, 0.72f, 0.84f); ColorBlock val5 = UIBuilder.buttonSelectableProperties.colors.Value; ((ColorBlock)(ref val5)).normalColor = normalColor; ((ColorBlock)(ref val5)).highlightedColor = val4; ((ColorBlock)(ref val5)).pressedColor = val4; ((ColorBlock)(ref val5)).fadeDuration = 0.05f; ColorBlock val6 = val5; val5 = val6; Color white = Color.white; ((ColorBlock)(ref val5)).normalColor = ((Color)(ref white)).RGBMultiplied(0.55f); white = Color.white; ((ColorBlock)(ref val5)).highlightedColor = ((Color)(ref white)).RGBMultiplied(0.6f); white = Color.white; ((ColorBlock)(ref val5)).pressedColor = ((Color)(ref white)).RGBMultiplied(0.6f); ColorBlock offState = val5; return UIBuilderDSL.Create.ToggleButton("toggle-button", onText).Bind(binding).WithVisuals<ToggleButtonContext, Image>((IProperties<Image>)GraphicPropertiesBuilder.WithColor(UIBuilder.buttonImgProperties, Color.white)) .WithOnOffVisualsAndText(val6, offState, onText, offText) .WithLayoutSize(100f, 30f); } static HorizontalLayoutGroupContext CreateSection(VerticalLayoutGroupContext root, IOneWayDataBindSource<bool> sectionEnabled, Action<VerticalLayoutGroupContext> sectionDef) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown int num2 = 2; HorizontalLayoutGroupContext horizontalLayoutGroupContext = UIBuilderDSL.Create.HorizontalLayoutGroup("config-section").WithChildAlignment((TextAnchor)3).WithPadding(new RectOffset(num2, num2, 0, 0)) .WithSpacing(0f) .ForceExpand(width: false, height: false) .ChildControls() .ChildOf((UIElementContext)root); int num3 = 3; Color val3 = new Color(1f, 0.5f, 0f); val3 = ((Color)(ref val3)).RGBMultiplied(0.8f); Color onColor = ((Color)(ref val3)).AlphaMultiplied(0.75f); val3 = Color.white; val3 = ((Color)(ref val3)).RGBMultiplied(0.6f); Color offColor = ((Color)(ref val3)).AlphaMultiplied(0.2f); UIBuilderDSL.Create.UIElement("banner").WithLayoutSize(num3, 0f, -1f, -1f, -1f, 1f).ChildOf((UIElementContext)horizontalLayoutGroupContext) .WithComponent<UIElementContext, Image>(out Image bannerImg, (Action<Image>)delegate(Image img) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) ((Graphic)img).material = UIBuilder.materialWidgetAlpha5x; ((Graphic)img).color = (sectionEnabled.Value ? onColor : offColor); }) .WithComponent<UIElementContext, DataBindValueChangedHandlerBool>((Action<DataBindValueChangedHandlerBool>)delegate(DataBindValueChangedHandlerBool x) { x.Binding = sectionEnabled; x.Handler = delegate(bool isOn) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) ((Graphic)bannerImg).color = (isOn ? onColor : offColor); }; }); VerticalLayoutGroupContext obj3 = UIBuilderDSL.Create.VerticalLayoutGroup("section-entries").ChildOf((UIElementContext)horizontalLayoutGroupContext).WithPadding(new RectOffset(0, 0, 0, 0)) .WithSpacing(10f) .WithChildAlignment((TextAnchor)0) .ForceExpand(width: false, height: false) .ChildControls(); sectionDef(obj3); return horizontalLayoutGroupContext; } static ButtonContext MakeFancyButton(string text) { ButtonContext buttonContext = UIBuilderDSL.Create.Button("action-button", text, null).WithLayoutSize(100f, 30f).WithVisuals<ButtonContext, Image>((IProperties<Image>)UIBuilder.buttonImgProperties); CopyFromExtensions.CopyFrom<Selectable>((Selectable)(object)buttonContext.button, (IProperties<Selectable>)UIBuilder.buttonSelectableProperties); return buttonContext; } ButtonContext SetModLevelButton(string text, int modLevel) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown return MakeFancyButton(text).SetClickListener((UnityAction)delegate { CreativeModeController creativeModeController2 = controller; object obj2; if (creativeModeController2 == null) { obj2 = null; } else { Player player2 = creativeModeController2.player; obj2 = ((player2 != null) ? player2.factory : null); } PlanetFactory val2 = (PlanetFactory)obj2; if (val2 != null) { PlanetReform.SetPlanetModLevel(val2, controller.veinsBury, modLevel); } }); } ButtonContext VeinModifyButton(string text, bool toBury) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown return MakeFancyButton(text).SetClickListener((UnityAction)delegate { controller.veinsBury = toBury; CreativeModeController creativeModeController = controller; object obj; if (creativeModeController == null) { obj = null; } else { Player player = creativeModeController.player; obj = ((player != null) ? player.factory : null); } PlanetFactory val = (PlanetFactory)obj; if (val != null) { PlanetReform.ModifyAllVeinsHeight(val, toBury); } }); } } } [HarmonyPatch(typeof(UIGame))] internal class UIPatches { [HarmonyPostfix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static void PatchIsSettingsWindowActive(ref bool __result) { UIModWindowBase uIModWindowBase = UIManager.Instance?.window; __result = __result || (Object.op_Implicit((Object)(object)uIModWindowBase) && ((ManualBehaviour)uIModWindowBase).active); } [HarmonyPostfix] [HarmonyPatch("ShutInventoryConflictsWindows")] [HarmonyPatch("ShutAllFunctionWindow")] private static void PatchShutSettingsWindow() { UIModWindowBase uIModWindowBase = UIManager.Instance?.window; if (Object.op_Implicit((Object)(object)uIModWindowBase)) { ((ManualBehaviour)uIModWindowBase)._Close(); } } } public static class PluginInfo { public const string PLUGIN_GUID = "dev.raptor.dsp.ExposeCreativeMode"; public const string PLUGIN_NAME = "ExposeCreativeMode"; public const string PLUGIN_VERSION = "0.0.20"; } } namespace DysonSphereProgram.Modding.ExposeCreativeMode.UI.Builder { public abstract class DataBindController<T> : MonoBehaviour { public IDataBindSource<T> Binding; protected bool ChangedFromUI; private void LateUpdate() { if (ChangedFromUI) { UIToBinding(); ChangedFromUI = false; } else { BindingToUI(); } } protected abstract void BindingToUI(); protected abstract void UIToBinding(); } public class DataBindSlider : DataBindController<float> { private Slider slider; private void Start() { slider = ((Component)this).GetComponent<Slider>(); ((UnityEvent<float>)(object)slider.onValueChanged).AddListener((UnityAction<float>)ValueChangedHandler); } private void ValueChangedHandler(float _) { ChangedFromUI = true; } protected override void BindingToUI() { slider.value = Binding.Value; } protected override void UIToBinding() { Binding.Value = slider.value; } } public class DataBindToggleBool : DataBindController<bool> { private Toggle toggle; private void Start() { toggle = ((Component)this).GetComponent<Toggle>(); ((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener((UnityAction<bool>)ValueChangedHandler); } private void ValueChangedHandler(bool _) { ChangedFromUI = true; } protected override void BindingToUI() { toggle.isOn = Binding.Value; } protected override void UIToBinding() { Binding.Value = toggle.isOn; } } public class DataBindToggleEnum : DataBindController<Enum> { private Toggle toggle; public Enum linkedValue; private void Start() { toggle = ((Component)this).GetComponent<Toggle>(); ((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener((UnityAction<bool>)ValueChangedHandler); } private void ValueChangedHandler(bool _) { ChangedFromUI = true; } protected override void BindingToUI() { toggle.isOn = Binding.Value.Equals(linkedValue); } protected override void UIToBinding() { if (toggle.isOn) { Binding.Value = linkedValue; } } } public class DataBindInputField : DataBindController<string> { private InputField inputField; private void Start() { inputField = ((Component)this).GetComponent<InputField>(); ((UnityEvent<string>)(object)inputField.onValueChanged).AddListener((UnityAction<string>)ValueChangedHandler); } private void ValueChangedHandler(string _) { ChangedFromUI = true; } protected override void BindingToUI() { inputField.text = Binding.Value; } protected override void UIToBinding() { Binding.Value = inputField.text; } } public interface IOneWayDataBindSource { object Value { get; } } public interface IOneWayDataBindSource<out TVisual> { TVisual Value { get; } } public interface IDataBindSource<TVisual> { TVisual Value { get; set; } } public class DataBindTransform<TLogical, TVisual> { public readonly Func<TLogical, TVisual> LogicalToVisualTransform; public readonly Func<TVisual, TLogical> VisualToLogicalTransform; public DataBindTransform(Func<TLogical, TVisual> forward, Func<TVisual, TLogical> reverse) { LogicalToVisualTransform = forward; VisualToLogicalTransform = reverse; } } public static class DataBindTransform { public static DataBindTransform<TLogical, TVisual> From<TLogical, TVisual>(Func<TLogical, TVisual> forward, Func<TVisual, TLogical> reverse) { return new DataBindTransform<TLogical, TVisual>(forward, reverse); } public static DataBindTransform<T, T> Identity<T>() { return From((T x) => x, (T x) => x); } } public abstract class DataBindSourceBase<TLogical, TVisual> : IDataBindSource<TVisual>, IOneWayDataBindSource<TVisual>, IOneWayDataBindSource { protected readonly DataBindTransform<TLogical, TVisual> transform; object IOneWayDataBindSource.Value => Value; public virtual TVisual Value { get { return transform.LogicalToVisualTransform(Get()); } set { Set(transform.VisualToLogicalTransform(value)); } } protected DataBindSourceBase(DataBindTransform<TLogical, TVisual> transform) { this.transform = transform; } protected abstract TLogical Get(); protected abstract void Set(TLogical value); public DataBindSourceBase<TLogical, UVisual> WithTransform<UVisual>(Func<TLogical, UVisual> forward, Func<UVisual, TLogical> reverse) { return WithTransform(DataBindTransform.From(forward, reverse)); } public abstract DataBindSourceBase<TLogical, UVisual> WithTransform<UVisual>(DataBindTransform<TLogical, UVisual> newTransform); } public class ConfigEntryDataBindSource<TLogical, TVisual> : DataBindSourceBase<TLogical, TVisual> { private readonly ConfigEntry<TLogical> entry; public ConfigEntryDataBindSource(ConfigEntry<TLogical> entry, DataBindTransform<TLogical, TVisual> transform) : base(transform) { this.entry = entry; } protected override TLogical Get() { return entry.Value; } protected override void Set(TLogical value) { entry.Value = value; } public override DataBindSourceBase<TLogical, UVisual> WithTransform<UVisual>(DataBindTransform<TLogical, UVisual> newTransform) { return new ConfigEntryDataBindSource<TLogical, UVisual>(entry, newTransform); } } public class ConfigEntryDataBindSource<T> : ConfigEntryDataBindSource<T, T> { public static implicit operator ConfigEntryDataBindSource<T>(ConfigEntry<T> entry) { return new ConfigEntryDataBindSource<T>(entry); } public ConfigEntryDataBindSource(ConfigEntry<T> entry) : base(entry, DataBindTransform.Identity<T>()) { } } public class MemberDataBindSource<U, TLogical, TVisual> : DataBindSourceBase<TLogical, TVisual> { private readonly U obj; private readonly Func<U, TLogical> getter; private readonly Action<U, TLogical> setter; public MemberDataBindSource(U obj, Func<U, TLogical> getter, Action<U, TLogical> setter, DataBindTransform<TLogical, TVisual> transform) : base(transform) { this.obj = obj; this.getter = getter; this.setter = setter; } protected override TLogical Get() { return getter(obj); } protected override void Set(TLogical value) { setter(obj, value); } public override DataBindSourceBase<TLogical, UVisual> WithTransform<UVisual>(DataBindTransform<TLogical, UVisual> newTransform) { return new MemberDataBindSource<U, TLogical, UVisual>(obj, getter, setter, newTransform); } } public class MemberDataBindSource<U, T> : MemberDataBindSource<U, T, T> { public MemberDataBindSource(U obj, Func<U, T> getter, Action<U, T> setter) : base(obj, getter, setter, DataBindTransform.Identity<T>()) { } } public class DelegateDataBindSource<TLogical, TVisual> : DataBindSourceBase<TLogical, TVisual> { private readonly Func<TLogical> getter; private readonly Action<TLogical> setter; public DelegateDataBindSource(Func<TLogical> getter, Action<TLogical> setter, DataBindTransform<TLogical, TVisual> transform) : base(transform) { this.getter = getter; this.setter = setter; } protected override TLogical Get() { return getter(); } protected override void Set(TLogical value) { setter(value); } public override DataBindSourceBase<TLogical, UVisual> WithTransform<UVisual>(DataBindTransform<TLogical, UVisual> newTransform) { return new DelegateDataBindSource<TLogical, UVisual>(getter, setter, newTransform); } } public class DelegateDataBindSource<T> : DelegateDataBindSource<T, T> { public DelegateDataBindSource(Func<T> getter, Action<T> setter) : base(getter, setter, DataBindTransform.Identity<T>()) { } } public class UIModWindowBase : ManualBehaviour, IInitializeFromContext<UIBuilderDSL.FancyWindowContext>, IInitializeFromContext<UIBuilderDSL.PlainWindowContext>, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { private bool toCaptureScroll; private bool focusPointEnter; public void InitializeFromContext(UIBuilderDSL.FancyWindowContext context) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown InitializeFromContext((UIBuilderDSL.WindowContext<UIBuilderDSL.FancyWindowContext>)context.WithCloseButton(new UnityAction(base._Close))); } public void InitializeFromContext(UIBuilderDSL.PlainWindowContext context) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown InitializeFromContext((UIBuilderDSL.WindowContext<UIBuilderDSL.PlainWindowContext>)context.WithCloseButton(new UnityAction(base._Close))); } private void InitializeFromContext<T>(UIBuilderDSL.WindowContext<T> context) where T : UIBuilderDSL.WindowContext<T> { toCaptureScroll = context.scrollCapture; ((ManualBehaviour)this)._Create(); ((ManualBehaviour)this)._Init((object)null); ((ManualBehaviour)this)._Open(); } public override void _OnClose() { if (toCaptureScroll) { UIBuilder.inScrollView.Remove(this); } ((ManualBehaviour)this)._OnClose(); } public void OnPointerEnter(PointerEventData eventData) { if (toCaptureScroll) { UIBuilder.inScrollView.Add(this); } } public void OnPointerExit(PointerEventData eventData) { if (toCaptureScroll) { UIBuilder.inScrollView.Remove(this); } } private void OnApplicationFocus(bool focus) { if (!toCaptureScroll) { return; } if (!focus) { focusPointEnter = UIBuilder.inScrollView.Contains(this); UIBuilder.inScrollView.Remove(this); } if (focus) { if (focusPointEnter) { UIBuilder.inScrollView.Add(this); } else { UIBuilder.inScrollView.Remove(this); } } } } public class UIWindowResize : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { public EventTrigger resizeTrigger; public RectTransform resizeTrans; public int resizeThreshold = 4; public Vector2 minSize; private bool mouseDown; private bool mouseOver; private Vector2 resizeMouseBegin; private Vector2 resizeSizeDeltaBegin; private Vector2 resizeSizeDeltaWanted; public bool pointerIn; public bool resizing { get; private set; } private void OnEnable() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) Entry val = new Entry(); val.eventID = (EventTriggerType)2; ((UnityEvent<BaseEventData>)(object)val.callback).AddListener((UnityAction<BaseEventData>)OnPointerDown); resizeTrigger.triggers.Add(val); Entry val2 = new Entry(); val2.eventID = (EventTriggerType)3; ((UnityEvent<BaseEventData>)(object)val2.callback).AddListener((UnityAction<BaseEventData>)OnPointerUp); resizeTrigger.triggers.Add(val2); Entry val3 = new Entry(); val3.eventID = (EventTriggerType)0; ((UnityEvent<BaseEventData>)(object)val3.callback).AddListener((UnityAction<BaseEventData>)OnPointerEnterResizeArea); resizeTrigger.triggers.Add(val3); Entry val4 = new Entry(); val4.eventID = (EventTriggerType)1; ((UnityEvent<BaseEventData>)(object)val4.callback).AddListener((UnityAction<BaseEventData>)OnPointerExitResizeArea); resizeTrigger.triggers.Add(val4); if ((Object)(object)resizeTrans == (Object)null) { ref RectTransform reference = ref resizeTrans; Transform transform = ((Component)this).transform; reference = (RectTransform)(object)((transform is RectTransform) ? transform : null); } VFAudio.Create("common-popup-3", (Transform)null, Vector3.zero, true, 2, -1, -1L); } private void OnDisable() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) resizeTrigger.triggers.Clear(); mouseDown = false; resizeMouseBegin = Vector2.zero; resizeSizeDeltaBegin = Vector2.zero; if (resizing) { resizeTrans.sizeDelta = new Vector2(Mathf.Round(resizeSizeDeltaWanted.x), Mathf.Round(resizeSizeDeltaWanted.y)); } pointerIn = false; } private void OnApplicationFocus(bool focus) { if (!focus) { pointerIn = false; } } private void OnPointerDown(BaseEventData eventData) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) mouseDown = true; UIRoot.ScreenPointIntoRect(Input.mousePosition, resizeTrans, ref resizeMouseBegin); resizeSizeDeltaBegin = resizeTrans.sizeDelta; resizeSizeDeltaWanted = resizeTrans.sizeDelta; UICursor.SetCursor((ECursor)2); } private void OnPointerUp(BaseEventData eventData) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) mouseDown = false; resizeMouseBegin = Vector2.zero; resizeSizeDeltaBegin = Vector2.zero; } private void OnPointerEnterResizeArea(BaseEventData eventData) { mouseOver = true; } private void OnPointerExitResizeArea(BaseEventData eventData) { mouseOver = false; } private void BringToFront() { int childCount = ((Component)this).transform.parent.childCount; if (((Component)this).transform.GetSiblingIndex() < childCount - 1) { ((Component)this).transform.SetAsLastSibling(); } } private void Update() { //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) if (mouseDown) { if (!Input.GetMouseButton(0) && !Input.GetMouseButton(1)) { mouseDown = false; } Vector2 val = default(Vector2); UIRoot.ScreenPointIntoRect(Input.mousePosition, resizeTrans, ref val); Vector2 val2 = val - resizeMouseBegin; if (Mathf.Abs(val2.x) + Mathf.Abs(val2.y) > (float)resizeThreshold) { resizing = true; resizeSizeDeltaWanted = resizeSizeDeltaBegin + new Vector2(val2.x, 0f - val2.y); resizeTrans.sizeDelta = new Vector2(Mathf.Round(Mathf.Max(resizeSizeDeltaWanted.x, minSize.x)), Mathf.Round(Mathf.Max(resizeSizeDeltaWanted.y, minSize.y))); } UICursor.SetCursor((ECursor)2); } else { resizing = false; resizeMouseBegin = Vector2.zero; resizeSizeDeltaBegin = Vector2.zero; if (mouseOver) { UICursor.SetCursor((ECursor)3); } } if (pointerIn && (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1))) { BringToFront(); } } public void OnPointerEnter(PointerEventData eventData) { pointerIn = true; } public void OnPointerExit(PointerEventData eventData) { pointerIn = false; } } public abstract class ValueChangeHandler<T> : MonoBehaviour { public Action<T> Handler; protected T prevValue; protected abstract T CurrentValue { get; } private void OnEnable() { Handler?.Invoke(CurrentValue); } private void LateUpdate() { T currentValue; T val = (currentValue = CurrentValue); if (!val.Equals(prevValue)) { Handler?.Invoke(currentValue); prevValue = currentValue; } } } public class DataBindValueChangeHandler : ValueChangeHandler<object> { public IOneWayDataBindSource Binding; protected override object CurrentValue => Binding.Value; } public abstract class DataBindValueChangeHandler<T> : ValueChangeHandler<T> { public IOneWayDataBindSource<T> Binding; protected override T CurrentValue => Binding.Value; } public class DataBindValueChangedHandlerBool : DataBindValueChangeHandler<bool> { } public class ToggleValueChangedHandler : ValueChangeHandler<bool> { public Toggle toggle; protected override bool CurrentValue => toggle.isOn; private void Start() { if (!Object.op_Implicit((Object)(object)toggle)) { toggle = ((Component)this).GetComponent<Toggle>(); } } } public interface IProperties<T> where T : Component { void Apply(T component); } public abstract record GraphicProperties : IProperties<Graphic> { public Material material { get; init; } public Color color { get; init; } = Color.white; public bool raycastTarget { get; init; } = true; public void Apply(Graphic component) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)material != (Object)null) { component.material = material; } component.color = color; component.raycastTarget = raycastTarget; } [CompilerGenerated] protected virtual bool PrintMembers(StringBuilder builder) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) RuntimeHelpers.EnsureSufficientExecutionStack(); builder.Append("material = "); builder.Append(material); builder.Append(", color = "); Color val = color; builder.Append(((object)(Color)(ref val)).ToString()); builder.Append(", raycastTarget = "); builder.Append(raycastTarget.ToString()); return true; } } public abstract record MaskableGraphicProperties : GraphicProperties, IProperties<MaskableGraphic> { public bool maskable { get; init; } = true; public void Apply(MaskableGraphic component) { base.Apply((Graphic)(object)component); component.maskable = maskable; } } public record RawImageProperties : MaskableGraphicProperties, IProperties<RawImage> { public Texture texture { get; init; } public Rect uvRect { get; init; } = new Rect(0f, 0f, 1f, 1f); public void Apply(RawImage component) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) base.Apply((MaskableGraphic)(object)component); if ((Object)(object)texture != (Object)null) { component.texture = texture; } component.uvRect = uvRect; } [CompilerGenerated] protected override bool PrintMembers(StringBuilder builder) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (base.PrintMembers(builder)) { builder.Append(", "); } builder.Append("texture = "); builder.Append(texture); builder.Append(", uvRect = "); Rect val = uvRect; builder.Append(((object)(Rect)(ref val)).ToString()); return true; } } public record ImageProperties : MaskableGraphicProperties, IProperties<Image> { public Sprite sprite { get; init; } public Sprite overrideSprite { get; init; } public Type type { get; init; } public bool preserveAspect { get; init; } public bool fillCenter { get; init; } = true; public FillMethod fillMethod { get; init; } = (FillMethod)4; public bool fillClockwise { get; init; } = true; public int fillOrigin { get; init; } public float alphaHitTestMinimumThreshold { get; init; } public bool useSpriteMesh { get; init; } public void Apply(Image component) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) base.Apply((MaskableGraphic)(object)component); if ((Object)(object)sprite != (Object)null) { component.sprite = sprite; } if ((Object)(object)overrideSprite != (Object)null) { component.overrideSprite = overrideSprite; } component.type = type; component.preserveAspect = preserveAspect; component.fillCenter = fillCenter; component.fillMethod = fillMethod; component.fillClockwise = fillClockwise; component.fillOrigin = fillOrigin; component.alphaHitTestMinimumThreshold = alphaHitTestMinimumThreshold; component.useSpriteMesh = useSpriteMesh; } [CompilerGenerated] protected override bool PrintMembers(StringBuilder builder) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) if (base.PrintMembers(builder)) { builder.Append(", "); } builder.Append("sprite = "); builder.Append(sprite); builder.Append(", overrideSprite = "); builder.Append(overrideSprite); builder.Append(", type = "); Type val = type; builder.Append(((object)(Type)(ref val)).ToString()); builder.Append(", preserveAspect = "); builder.Append(preserveAspect.ToString()); builder.Append(", fillCenter = "); builder.Append(fillCenter.ToString()); builder.Append(", fillMethod = "); FillMethod val2 = fillMethod; builder.Append(((object)(FillMethod)(ref val2)).ToString()); builder.Append(", fillClockwise = "); builder.Append(fillClockwise.ToString()); builder.Append(", fillOrigin = "); builder.Append(fillOrigin.ToString()); builder.Append(", alphaHitTestMinimumThreshold = "); builder.Append(alphaHitTestMinimumThreshold.ToString()); builder.Append(", useSpriteMesh = "); builder.Append(useSpriteMesh.ToString()); return true; } } public static class