using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using CommonAPI; using CommonAPI.Systems; using CommonAPI.Systems.ModLocalization; using CommonAPI.Systems.UI; using GalacticScale; using HarmonyLib; using NebulaAPI; using NebulaAPI.Interfaces; using NebulaAPI.Networking; using NebulaAPI.Packets; using Newtonsoft.Json; using PCGSharp; using PowerNetworkStructures; using ProjectOrbitalRing.Compatibility; using ProjectOrbitalRing.Patches.Logic; using ProjectOrbitalRing.Patches.Logic.AddVein; using ProjectOrbitalRing.Patches.Logic.AssemblerModule; using ProjectOrbitalRing.Patches.Logic.BattleRelated; using ProjectOrbitalRing.Patches.Logic.Farm; using ProjectOrbitalRing.Patches.Logic.MathematicalRateEngine; using ProjectOrbitalRing.Patches.Logic.MegaAssembler; using ProjectOrbitalRing.Patches.Logic.ModifyUpgradeTech; using ProjectOrbitalRing.Patches.Logic.OrbitalRing; using ProjectOrbitalRing.Patches.Logic.PlanetFocus; using ProjectOrbitalRing.Patches.Logic.QuantumStorage; using ProjectOrbitalRing.Patches.UI; using ProjectOrbitalRing.Patches.UI.PlanetFocus; using ProjectOrbitalRing.Patches.UI.UIOrbitalRingStorageWindow; using ProjectOrbitalRing.Patches.UI.Utils; using ProjectOrbitalRing.Utils; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; using crecheng.DSPModSave; using xiaoye97; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace ProjectOrbitalRing { [BepInPlugin("org.ProfessorCat305.OrbitalRing", "OrbitalRing", "1.0.9")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [CommonAPISubmoduleDependency(new string[] { "ProtoRegistry", "TabSystem", "LocalizationModule" })] [ModSaveSettings(/*Could not decode attribute arguments.*/)] public class ProjectOrbitalRing : BaseUnityPlugin, IModCanSave, IMultiplayerMod { public const string MODGUID = "org.ProfessorCat305.OrbitalRing"; public const string MODNAME = "OrbitalRing"; public const string VERSION = "1.0.9"; public const string DEBUGVERSION = ""; public static int importVersion; public static bool LoadCompleted; public static bool MoreMegaStructureCompatibility; internal static ManualLogSource logger; internal static ConfigFile configFile; internal static UIPlanetFocusWindow PlanetFocusWindow; internal static UIOrbitalRingStorageWindow OrbitalRingStorageWindow; internal static int[] TableID; internal static string ModPath; internal static ConfigEntry LDBToolCacheEntry; internal static ConfigEntry HideTechModeEntry; internal static ConfigEntry ShowMessageBoxEntry; internal static ConfigEntry ProductOverflowEntry; internal static ConfigEntry QToolsHotkey; private Harmony Harmony; public string Version => "1.0.9"; public void Awake() { //IL_007e: 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_00c9: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Expected O, but got Unknown //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Expected O, but got Unknown //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Expected O, but got Unknown //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Expected O, but got Unknown logger = ((BaseUnityPlugin)this).Logger; logger.Log((LogLevel)16, (object)"OrbitalRing Awake"); configFile = ((BaseUnityPlugin)this).Config; LDBToolCacheEntry = ((BaseUnityPlugin)this).Config.Bind("config", "UseLDBToolCache", false, "Enable LDBTool Cache, which allows you use config to fix some compatibility issues.\n启用LDBTool缓存,允许使用配置文件修复部分兼容性问题"); ShowMessageBoxEntry = ((BaseUnityPlugin)this).Config.Bind("config", "ShowMessageBox", true, "Show message when OrbitalRing is loaded.\n首次加载时的提示信息"); QToolsHotkey = ((BaseUnityPlugin)this).Config.Bind("config", "QToolsHotkey", KeyboardShortcut.Deserialize("BackQuote"), "Shortcut to open QTools window"); ((BaseUnityPlugin)this).Config.Save(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); ModPath = Path.GetDirectoryName(executingAssembly.Location); ResourceData val = new ResourceData("org.ProfessorCat305.OrbitalRing", "genesis-models", ModPath); val.LoadAssetBundle("genesis-models"); ProtoRegistry.AddResource(val); ResourceData val2 = new ResourceData("org.ProfessorCat305.OrbitalRing", "genesis-models-lab", ModPath); val2.LoadAssetBundle("genesis-models-lab"); ProtoRegistry.AddResource(val2); Shader replacementShader = val.bundle.LoadAsset("Assets/genesis-models/shaders/PBR Standard Vein Stone COLOR.shader"); SwapShaderPatches.AddSwapShaderMapping("VF Shaders/Forward/PBR Standard Vein Stone", replacementShader); Shader replacementShader2 = val.bundle.LoadAsset("Assets/genesis-models/shaders/PBR Standard Vein Metal COLOR.shader"); SwapShaderPatches.AddSwapShaderMapping("VF Shaders/Forward/PBR Standard Vein Metal", replacementShader2); Shader replacementShader3 = val2.bundle.LoadAsset("Assets/genesis-models/shaders/PBR Standard Vertex Toggle Lab REPLACE.shader"); SwapShaderPatches.AddSwapShaderMapping("VF Shaders/Forward/PBR Standard Vertex Toggle Lab", replacementShader3); NebulaModAPI.RegisterPackets(executingAssembly); NebulaModAPI.OnPlanetLoadRequest = (Action)Delegate.Combine(NebulaModAPI.OnPlanetLoadRequest, (Action)delegate(int planetId) { NebulaModAPI.MultiplayerSession.Network.SendPacket(new OrbitalRingPlanetLoadRequest(planetId)); }); NebulaModAPI.OnPlanetLoadFinished = (Action)Delegate.Combine(NebulaModAPI.OnPlanetLoadFinished, new Action(OrbitalRingPlanetDataProcessor.ProcessBytesLater)); Harmony = new Harmony("org.ProfessorCat305.OrbitalRing"); ResearchLabPatches.ApplyPatch(Harmony); MoonPatch.ApplyPatch(Harmony); Type[] types = executingAssembly.GetTypes(); foreach (Type type in types) { string? @namespace = type.Namespace; if (@namespace != null && @namespace.StartsWith("ProjectOrbitalRing.Patches", StringComparison.Ordinal)) { Harmony.PatchAll(type); } } TableID = new int[3] { TabSystem.RegisterTab("org.ProfessorCat305.OrbitalRing:org.ProfessorCat305.OrbitalRingTab1", new TabData("精炼页面".TranslateFromJsonSpecial(), "Assets/texpack/矿物处理")), TabSystem.RegisterTab("org.ProfessorCat305.OrbitalRing:org.ProfessorCat305.OrbitalRingTab2", new TabData("化工页面".TranslateFromJsonSpecial(), "Assets/texpack/化工科技")), TabSystem.RegisterTab("org.ProfessorCat305.OrbitalRing:org.ProfessorCat305.OrbitalRingTab3", new TabData("防御页面".TranslateFromJsonSpecial(), "Assets/texpack/防御")) }; TranslateUtils.RegisterStrings(); AddVeinPatches.ModifyVeinData(); LDBTool.PreAddDataAction = (Action)Delegate.Combine(LDBTool.PreAddDataAction, new Action(PreAddDataAction)); LDBTool.PostAddDataAction = (Action)Delegate.Combine(LDBTool.PostAddDataAction, new Action(PostAddDataAction)); LoadCompleted = true; } private void Update() { if (!VFInput.inputing) { } } public void Export(BinaryWriter w) { w.Write(VersionNumber()); MegaAssemblerPatches.Export(w); PlanetFocusPatches.Export(w); QuantumStoragePatches.Export(w); AdvancedLaserPatches.Export(w); GlobalPowerSupplyPatches.Export(w); Unlock_Save_Load.Export(w); StarGate.Export(w); OrbitalStationManager.Export(w); AssemblerModulePatches.Export(w); MoonPatch.Export(w); EnergyCalculate.Export(w); FarmAssembler.Export(w); InfiniteTank.Export(w); } public void Import(BinaryReader r) { int num = r.ReadInt32(); importVersion = num; MegaAssemblerPatches.Import(r); PlanetFocusPatches.Import(r); QuantumStoragePatches.Import(r); AdvancedLaserPatches.Import(r); GlobalPowerSupplyPatches.Import(r); Unlock_Save_Load.Import(r); StarGate.Import(r); OrbitalStationManager.Import(r); AssemblerModulePatches.Import(r); MoonPatch.Import(r); EnergyCalculate.Import(r); FarmAssembler.Import(r); InfiniteTank.Import(r); } public void IntoOtherSave() { MegaAssemblerPatches.IntoOtherSave(); PlanetFocusPatches.IntoOtherSave(); QuantumStoragePatches.IntoOtherSave(); AdvancedLaserPatches.IntoOtherSave(); GlobalPowerSupplyPatches.IntoOtherSave(); Unlock_Save_Load.IntoOtherSave(); StarGate.IntoOtherSave(); OrbitalStationManager.IntoOtherSave(); AssemblerModulePatches.IntoOtherSave(); MoonPatch.IntoOtherSave(); EnergyCalculate.IntoOtherSave(); FarmAssembler.IntoOtherSave(); InfiniteTank.IntoOtherSave(); OrbitalBeacon.IntoOtherSave(); } public bool CheckVersion(string hostVersion, string clientVersion) { return hostVersion.Equals(clientVersion); } private void PreAddDataAction() { PosTool.InitializeMarkerAngles(); global::ProjectOrbitalRing.Patches.Logic.MathematicalRateEngine.UI.GetDysonVanillaUITexts(); ((ProtoSet)(object)LDB.items).OnAfterDeserialize(); ModifyPlanetTheme.ModifyPlanetThemeDataVanilla(); LogisticsInterchangePatches.StationPrefabDescPostAdd(); CopyModelUtils.AddCopiedModelProto(); AddVeinPatches.AddEffectEmitterProto(); JsonDataUtils.ImportJson(TableID); ModifyUpgradeTech.ModifyUpgradeTeches(); } private void PostAddDataAction() { VegeProto val = ((ProtoSet)(object)LDB.veges).Select(9999); val.MiningItem = new int[5] { 2303, 2001, 2011, 7609, 2204 }; val.MiningCount = new int[5] { 4, 500, 300, 1, 1 }; val.MiningChance = new float[5] { 1f, 1f, 1f, 1f, 1f }; val.Preload(); LabComponent.matrixPoints = new int[8]; LabComponent.matrixIds = new int[8] { 6001, 6002, 6003, 6004, 6005, 6006, 6278, 6279 }; LabComponent.matrixShaderStates = new float[10] { 0f, 11111.2f, 22222.2f, 33333.2f, 44444.2f, 55555.2f, 66666.2f, 77777.2f, 88888.2f, 271826f / (float)Math.E }; ((ProtoSet)(object)LDB.items).OnAfterDeserialize(); ((ProtoSet)(object)LDB.recipes).OnAfterDeserialize(); ((ProtoSet)(object)LDB.techs).OnAfterDeserialize(); ((ProtoSet)(object)LDB.models).OnAfterDeserialize(); ((ProtoSet)(object)LDB.milestones).OnAfterDeserialize(); ((ProtoSet)(object)LDB.journalPatterns).OnAfterDeserialize(); ((ProtoSet)(object)LDB.themes).OnAfterDeserialize(); ((ProtoSet)(object)LDB.veins).OnAfterDeserialize(); if ((Object)(object)GameMain.instance != (Object)null) { GameMain.instance.CreateGPUInstancing(); GameMain.instance.CreateBPGPUInstancing(); } JsonDataUtils.PrefabDescPostFix(); LogisticsInterchangePatches.StationPrefabDescPostAdd810(); HPAdjust.OurSideHPAdjust(); CopyModelUtils.ModelPostFix(); ProtoPreload(); HPAdjust.ModifyEnemyHpUpgrade(); AddVeinPatches.SetMinerMk2Color(); ChemicalRecipeFcolPatches.SetChemicalRecipeFcol(); AddVeinPatches.SetEffectEmitterProto(); SatellitePowerDistributionPatch.ChangeWeiXinPowerPoint(); VFEffectEmitter.Init(); ItemProto.InitFuelNeeds(); ItemProto.InitTurretNeeds(); ItemProto.InitFluids(); ItemProto.InitTurrets(); ItemProto.InitEnemyDropTables(); ItemProto.InitConstructableItems(); ItemProto.InitItemIds(); ItemProto.InitItemIndices(); ItemProto.InitMechaMaterials(); ItemProto.InitFighterIndices(); ItemProto.InitPowerFacilityIndices(); ModelProto.InitMaxModelIndex(); ModelProto.InitModelIndices(); ModelProto.InitModelOrders(); RecipeProto.InitFractionatorNeeds(); RaycastLogic.LoadStatic(); ItemProto.stationCollectorId = 2105; CopyModelUtils.ItemPostFix(); StorageComponent.staticLoaded = false; StorageComponent.LoadStatic(); UIBuildMenu.staticLoaded = false; UIBuildMenu.StaticLoad(); SpaceSector.PrefabDescByModelIndex = null; SpaceSector.InitPrefabDescArray(); PlanetFactory.PrefabDescByModelIndex = null; PlanetFactory.InitPrefabDescArray(); ref MechaMaterialSetting reference = ref Configs.builtin.mechaArmorMaterials[21]; reference.itemId = 7705; reference.density = 19.35f; reference.durability = 4.35f; } private static void ProtoPreload() { MilestoneProto[] dataArray = ((ProtoSet)(object)LDB.milestones).dataArray; foreach (MilestoneProto val in dataArray) { val.Preload(); } JournalPatternProto[] dataArray2 = ((ProtoSet)(object)LDB.journalPatterns).dataArray; foreach (JournalPatternProto val2 in dataArray2) { val2.Preload(); } VeinProto[] dataArray3 = ((ProtoSet)(object)LDB.veins).dataArray; foreach (VeinProto val3 in dataArray3) { val3.Preload(); } TechProto[] dataArray4 = ((ProtoSet)(object)LDB.techs).dataArray; foreach (TechProto val4 in dataArray4) { val4.Preload(); } for (int m = 0; m < ((ProtoSet)(object)LDB.items).dataArray.Length; m++) { ItemProto val5 = ((ProtoSet)(object)LDB.items).dataArray[m]; val5.recipes = null; val5.rawMats = null; val5.Preload(m); } for (int n = 0; n < ((ProtoSet)(object)LDB.recipes).dataArray.Length; n++) { ((ProtoSet)(object)LDB.recipes).dataArray[n].Preload(n); } TechProto[] dataArray5 = ((ProtoSet)(object)LDB.techs).dataArray; foreach (TechProto val6 in dataArray5) { val6.PreTechsImplicit = val6.PreTechsImplicit.Except(val6.PreTechs).ToArray(); val6.UnlockRecipes = val6.UnlockRecipes.Distinct().ToArray(); val6.Preload2(); } } internal static void SetConfig(bool currentLDBToolCache, bool currentShowMessageBox, int currentProductOverflow) { LDBToolCacheEntry.Value = currentLDBToolCache; ShowMessageBoxEntry.Value = currentShowMessageBox; logger.LogInfo((object)"SettingChanged"); configFile.Save(); } internal static void LogInfo(object data) { logger.LogInfo(data); } internal static void LogWarning(object data) { logger.LogWarning(data); } internal static void LogError(object data) { logger.LogError(data); } internal static int VersionNumber() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) Version val = default(Version); ((Version)(ref val)).FromFullString("1.0.9"); return ((Version)(ref val)).sig; } } } namespace ProjectOrbitalRing.Utils { internal static class CopyModelUtils { internal static void AddCopiedModelProto() { //IL_0017: 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_0079: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0548: Unknown result type (might be due to invalid IL or missing references) CopyModelProto(50, 801, Color.HSVToRGB(0.071f, 0.7412f, 0.8941f)); CopyModelProto(117, 802); CopyModelProto(50, 803, Color.HSVToRGB(0.5571f, 0.3188f, 0.898f)); CopyModelProto(50, 804, Color.HSVToRGB(0.2275f, 0.3804f, 0.6431f)); CopyModelProto(49, 805, Color.HSVToRGB(0.1404f, 0.8294f, 0.9882f)); CopyModelProto(50, 806, Color32.op_Implicit(new Color32((byte)60, (byte)179, (byte)113, byte.MaxValue))); CopyModelProto(56, 807); CopyModelProto(56, 821); CopyModelProto(68, 808, Color.HSVToRGB(0.0833f, 0.8f, 1f)); CopyModelProto(46, 809, Color.HSVToRGB(0.4174f, 0.742f, 0.9686f)); CopyModelProto(50, 810, (Color?)new Color(0.3216f, 0.8157f, 0.0902f)); CopyModelProto(50, 811, (Color?)new Color(0.3059f, 0.2196f, 0.4941f)); CopyModelProto(50, 814); CopyModelProto(432, 813, (Color?)new Color(0.3059f, 0.2196f, 0.4941f)); CopyModelProto(375, 815, (Color?)new Color(0.2275f, 0.3804f, 0.6431f)); CopyModelProto(373, 816, (Color?)new Color(0.5765f, 0.4392f, 0.8588f)); CopyModelProto(490, 817); CopyModelProto(488, 818); CopyModelProto(46, 812, Color.HSVToRGB(0.0833f, 0.8f, 1f)); CopyModelProto(48, 819); CopyModelProto(50, 820, (Color?)new Color(0.7373f, 0.2118f, 0.851f)); CopyModelProto(36, 826, (Color?)new Color(0.7373f, 0.2118f, 0.851f)); CopyModelProto(72, 822, (Color?)new Color(0.1404f, 0.8294f, 0.9882f)); CopyModelProto(49, 823, Color.HSVToRGB(0.071f, 0.7412f, 0.8941f)); CopyModelProto(35, 824, (Color?)new Color(1f, 1f, 1f)); CopyModelProto(37, 825, (Color?)new Color(1f, 1f, 1f)); CopyModelProto(402, 827, (Color?)new Color(1f, 1f, 1f)); CopyModelProto(51, 828, (Color?)new Color(0f, 0f, 0f)); CopyModelProto(37, 829, (Color?)new Color(0f, 0f, 0f)); CopyModelProto(403, 830); CopyModelProto(403, 831, (Color?)new Color(1f, 1f, 1f)); CopyModelProto(403, 832, (Color?)new Color(0f, 0f, 0f)); CopyModelProto(56, 833, (Color?)new Color(0f, 0f, 0f)); CopyModelProto(403, 834, Color.red); CopyModelProto(455, 835, Color.HSVToRGB(0.4174f, 0.742f, 0.9686f)); CopyModelProto(64, 836, (Color?)new Color(1f, 1f, 1f)); CopyModelProto(432, 837, Color.red); CopyModelProto(403, 838, (Color?)new Color(0f, 0f, 0f)); CopyModelProto(121, 839, (Color?)new Color(0f, 0f, 0f)); ChangeAccumulatorColor(); } private static void ChangeAccumulatorColor() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) ModelProto val = ((ProtoSet)(object)LDB.models).Select(46); PrefabDesc prefabDesc = val.prefabDesc; Material[][] lodMaterials = val.prefabDesc.lodMaterials; foreach (Material[] array in lodMaterials) { if (array == null) { continue; } for (int j = 0; j < array.Length; j++) { ref Material reference = ref array[j]; if (!((Object)(object)reference == (Object)null)) { reference = new Material(reference); reference.SetColor("_Color", new Color(0.3529f, 0.8235f, 1f)); } } } } private static void CopyModelProto(int oriId, int id, Color? color = null) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) ModelProto val = ((ProtoSet)(object)LDB.models).Select(oriId); ModelProto val2 = val.Copy(); ((Proto)val2).Name = id.ToString(); ((Proto)val2).ID = id; PrefabDesc prefabDesc = val.prefabDesc; GameObject val3 = (Object.op_Implicit((Object)(object)prefabDesc.prefab) ? prefabDesc.prefab : Resources.Load(val.PrefabPath)); GameObject val4 = (Object.op_Implicit((Object)(object)prefabDesc.colliderPrefab) ? prefabDesc.colliderPrefab : Resources.Load(val._colliderPath)); ref PrefabDesc prefabDesc2 = ref val2.prefabDesc; prefabDesc2 = (PrefabDesc)(((Object)(object)val3 == (Object)null) ? ((object)PrefabDesc.none) : ((object)(((Object)(object)val4 == (Object)null) ? new PrefabDesc(id, val3) : new PrefabDesc(id, val3, val4)))); Material[][] lodMaterials = prefabDesc2.lodMaterials; foreach (Material[] array in lodMaterials) { if (array == null) { continue; } for (int j = 0; j < array.Length; j++) { ref Material reference = ref array[j]; if (!((Object)(object)reference == (Object)null)) { reference = new Material(reference); if (color.HasValue) { reference.SetColor("_Color", color.Value); } } } } prefabDesc2.modelIndex = id; prefabDesc2.hasBuildCollider = prefabDesc.hasBuildCollider; prefabDesc2.colliders = prefabDesc.colliders; prefabDesc2.buildCollider = prefabDesc.buildCollider; prefabDesc2.buildColliders = prefabDesc.buildColliders; prefabDesc2.colliderPrefab = prefabDesc.colliderPrefab; prefabDesc2.dragBuild = prefabDesc.dragBuild; prefabDesc2.dragBuildDist = prefabDesc.dragBuildDist; prefabDesc2.blueprintBoxSize = prefabDesc.blueprintBoxSize; prefabDesc2.roughHeight = prefabDesc.roughHeight; prefabDesc2.roughWidth = prefabDesc.roughWidth; prefabDesc2.roughRadius = prefabDesc.roughRadius; prefabDesc2.barHeight = prefabDesc.barHeight; prefabDesc2.barWidth = prefabDesc.barWidth; ((Proto)val2).sid = ""; ((Proto)val2).SID = ""; LDBTool.PreAddProto((Proto)(object)val2); } private static ModelProto Copy(this ModelProto proto) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0041: 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_0059: 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_0071: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00b1: Expected O, but got Unknown return new ModelProto { ObjectType = proto.ObjectType, RuinType = proto.RuinType, RendererType = proto.RendererType, HpMax = proto.HpMax, HpUpgrade = proto.HpUpgrade, HpRecover = proto.HpRecover, RuinId = proto.RuinId, RuinCount = proto.RuinCount, RuinLifeTime = proto.RuinLifeTime, PrefabPath = proto.PrefabPath, _colliderPath = proto._colliderPath, _ruinPath = proto._ruinPath, _wreckagePath = proto._wreckagePath, _ruinOriginModelIndex = proto._ruinOriginModelIndex }; } internal static void ModelPostFix() { //IL_0063: 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) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) ModelProto val = ((ProtoSet)(object)LDB.models).Select(806); val._ruinPath = "Entities/Prefabs/Ruins/interstellar-logistic-station-ruins"; val._wreckagePath = "Entities/Prefabs/Wreckages/interstellar-logistic-station-wreckages"; PrefabDesc prefabDesc = ((ProtoSet)(object)LDB.models).Select(809).prefabDesc; prefabDesc.lodMaterials[0][2].SetColor("_TintColor", new Color(0.2715f, 1.7394f, 0.193f)); prefabDesc = ((ProtoSet)(object)LDB.models).Select(807).prefabDesc; Texture texture = (Texture)(object)TextureHelper.GetTexture("人造恒星MK2材质"); ref Material[] reference = ref prefabDesc.lodMaterials[0]; reference[0].SetTexture("_EmissionTex", texture); reference[1].SetColor("_TintColor", new Color(0.1804f, 0.4953f, 1.3584f)); reference[1].SetColor("_TintColor1", new Color(0.1294f, 0.313f, 1.1508f)); reference[1].SetColor("_RimColor", new Color(0.4157f, 0.6784f, 1f)); prefabDesc = ((ProtoSet)(object)LDB.models).Select(821).prefabDesc; reference = ref prefabDesc.lodMaterials[0]; reference[0].SetTexture("_EmissionTex", texture); reference[1].SetColor("_TintColor", new Color(0f, 0.1f, 0f)); reference[1].SetColor("_TintColor1", new Color(0f, 0f, 0f)); reference[1].SetColor("_RimColor", new Color(0.1f, 1.084f, 0.1f)); prefabDesc = ((ProtoSet)(object)LDB.models).Select(70).prefabDesc; reference = ref prefabDesc.lodMaterials[0]; ModifyLabColor(reference[0]); ModifyLabColor(reference[2]); reference = ref prefabDesc.lodMaterials[1]; ModifyLabColor(reference[0]); ModifyLabColor(reference[2]); ModifyLabColor(prefabDesc.lodMaterials[2][0]); prefabDesc = ((ProtoSet)(object)LDB.models).Select(455).prefabDesc; reference = ref prefabDesc.lodMaterials[0]; ModifyLabColor(reference[0]); ModifyLabColor(reference[2]); reference = ref prefabDesc.lodMaterials[1]; ModifyLabColor(reference[0]); ModifyLabColor(reference[2]); ModifyLabColor(prefabDesc.lodMaterials[2][0]); } private static void ModifyLabColor(Material material) { //IL_0016: 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_0056: Unknown result type (might be due to invalid IL or missing references) material.SetColor("_LabColor7", new Color(1f, 0.451f, 0.0039f)); material.SetColor("_LabColor8", new Color(1f, 0.0431f, 0.5843f)); material.SetColor("_LabColor9", new Color(0.402f, 0.402f, 0.402f)); } internal static void ItemPostFix() { //IL_0060: 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_0081: Unknown result type (might be due to invalid IL or missing references) ref int[] reference = ref ItemProto.turretNeeds[1]; reference[1] = 7607; reference[2] = 1603; ref int[] reference2 = ref ItemProto.turretNeeds[7]; reference2 = new int[3] { 1607, 0, 0 }; ItemProto val = ((ProtoSet)(object)LDB.items).Select(6514); val.prefabDesc.stationShipPos = new Vector3(0f, 100f, 0f); val = ((ProtoSet)(object)LDB.items).Select(3010); val.prefabDesc.turretAmmoType = (EAmmoType)7; } } internal static class DictionaryExtend { public static void TryAddOrInsert(this ConcurrentDictionary> dict, TKey key, TValue value) { if (dict.ContainsKey(key)) { dict[key].Add(value); return; } dict[key] = new List { value }; } public static void TryRemove(this ConcurrentDictionary> dict, TKey key, TValue value) { if (dict.ContainsKey(key)) { dict[key].Remove(value); } } public static bool Contains(this ConcurrentDictionary> dict, TKey key, TValue value) { List value2; return dict.TryGetValue(key, out value2) && value2.Contains(value); } } public enum ERecipeType { None = 0, Smelt = 1, Chemical = 2, Refine = 3, Assemble = 4, Particle = 5, Exchange = 6, PhotonStore = 7, Fractionate = 8, 太空船坞 = 9, 粒子打印 = 10, 等离子熔炼 = 11, 物质重组 = 12, 生物化工 = 14, Research = 15, 低温工厂 = 16, 所有化工 = 17, 黑盒 = 18, 所有熔炉 = 19 } internal static class IconDescUtils { internal abstract class ModIconDesc { internal Color Color; protected ModIconDesc(Color color) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Color = color; } internal abstract IconDesc ToIconDesc(); } internal class FluidIconDesc : ModIconDesc { public FluidIconDesc(Color color) : base(color) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //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_0029: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_0074: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, reserved0 = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = new Color(0.2f, 0.2f, 0.2f, 1f), metallic = 1f, smoothness = 0.302f, liquidity = 1f, solidAlpha = 0f, iconAlpha = 1f }; } } internal class NoIconFluidIconDesc : ModIconDesc { internal NoIconFluidIconDesc(Color color) : base(color) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //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_0029: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, reserved0 = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = Color.clear, metallic = 1f, liquidity = 1f, smoothness = 0.302f, solidAlpha = 0f, iconAlpha = 0f }; } } internal class OreIconDesc : ModIconDesc { public OreIconDesc(Color color) : base(color) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //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_0029: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0077: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, reserved0 = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = Color.clear, metallic = 0.8f, smoothness = 0.5f, solidAlpha = 1f, iconAlpha = 1f }; } } internal class NoIconMetalIconDesc : ModIconDesc { public NoIconMetalIconDesc(Color color) : base(color) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = Color.clear, metallic = 1f, smoothness = 0.6f, solidAlpha = 1f, iconAlpha = 0f }; } } internal class FullIconDesc : ModIconDesc { public FullIconDesc(Color color) : base(color) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = Color.clear, metallic = 0f, smoothness = 0.5f, solidAlpha = 1f, iconAlpha = 1f }; } } internal class ComponentIconDesc : ModIconDesc { public ComponentIconDesc(Color color) : base(color) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_001d: 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_0027: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown return new IconDesc { faceColor = Color.white, sideColor = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = Color.clear, metallic = 0.8f, smoothness = 0.5f, solidAlpha = 1f, iconAlpha = 1f }; } } internal class GlassIconDesc : ModIconDesc { public GlassIconDesc(Color color) : base(color) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //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_0029: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0077: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, reserved0 = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = Color.clear, metallic = 1f, smoothness = 0.5f, solidAlpha = 0.8f, iconAlpha = 0f }; } } internal class RodIconDesc : ModIconDesc { public RodIconDesc(Color color) : base(color) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //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_0029: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0077: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, reserved0 = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = Color.clear, metallic = 1f, smoothness = 0.5f, solidAlpha = 0.6f, iconAlpha = 1f }; } } internal class WhiteIconDesc : ModIconDesc { public WhiteIconDesc() : base(Color.white) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_004d: 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_005d: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = new Color(0.2f, 0.2f, 0.2f, 1f), metallic = 0.8f, smoothness = 0.5f, solidAlpha = 1f, iconAlpha = 1f }; } } internal class MartixIconDesc : ModIconDesc { private readonly Color _emission; public MartixIconDesc(Color color, Color emission) : base(color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) _emission = emission; } internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_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) //IL_0040: 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_0056: 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_006d: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, faceEmission = _emission, sideEmission = _emission, iconEmission = Color.clear, metallic = 0f, smoothness = 0f, solidAlpha = 0.5f, iconAlpha = 0f }; } } internal class DefaultIconDesc : ModIconDesc { private readonly Color _emission; public DefaultIconDesc(Color color, Color emission) : base(color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) _emission = emission; } internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, faceEmission = _emission, sideEmission = _emission, iconEmission = new Color(0.2f, 0.2f, 0.2f, 1f), metallic = 0.8f, smoothness = 0.5f, solidAlpha = 1f, iconAlpha = 1f }; } } internal static readonly Dictionary IconDescs = new Dictionary { { 7019, new FluidIconDesc(Color32.op_Implicit(new Color32((byte)129, (byte)199, (byte)241, byte.MaxValue))) }, { 6220, new FluidIconDesc(Color32.op_Implicit(new Color32((byte)137, (byte)242, (byte)178, byte.MaxValue))) }, { 6234, new FluidIconDesc(Color32.op_Implicit(new Color32((byte)244, byte.MaxValue, (byte)183, byte.MaxValue))) }, { 6235, new FluidIconDesc(Color32.op_Implicit(new Color32((byte)210, (byte)222, (byte)142, byte.MaxValue))) }, { 6205, new FluidIconDesc(Color32.op_Implicit(new Color32((byte)90, (byte)248, (byte)244, byte.MaxValue))) }, { 6208, new FluidIconDesc(Color32.op_Implicit(new Color32((byte)0, (byte)243, byte.MaxValue, byte.MaxValue))) }, { 6212, new FluidIconDesc(Color32.op_Implicit(new Color32(byte.MaxValue, (byte)0, (byte)0, byte.MaxValue))) }, { 6202, new FluidIconDesc(Color32.op_Implicit(new Color32(byte.MaxValue, (byte)86, (byte)0, byte.MaxValue))) }, { 1114, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32((byte)138, (byte)83, (byte)43, byte.MaxValue))) }, { 6251, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32(byte.MaxValue, (byte)165, (byte)0, byte.MaxValue))) }, { 7018, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32((byte)97, (byte)132, (byte)186, byte.MaxValue))) }, { 7009, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32((byte)188, (byte)182, (byte)5, byte.MaxValue))) }, { 6225, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32((byte)42, (byte)97, (byte)32, byte.MaxValue))) }, { 7014, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32((byte)195, (byte)198, (byte)234, byte.MaxValue))) }, { 6226, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32((byte)167, byte.MaxValue, (byte)39, byte.MaxValue))) }, { 6207, new OreIconDesc(Color32.op_Implicit(new Color32((byte)230, (byte)239, (byte)137, byte.MaxValue))) }, { 6222, new OreIconDesc(Color32.op_Implicit(new Color32((byte)106, (byte)175, (byte)78, byte.MaxValue))) }, { 6201, new OreIconDesc(Color32.op_Implicit(new Color32((byte)30, (byte)29, (byte)30, byte.MaxValue))) }, { 7706, new OreIconDesc(Color32.op_Implicit(new Color32((byte)230, (byte)230, (byte)230, byte.MaxValue))) }, { 7803, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)228, (byte)153, byte.MaxValue, byte.MaxValue))) }, { 7804, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)228, (byte)153, byte.MaxValue, byte.MaxValue))) }, { 7805, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)93, (byte)191, byte.MaxValue, byte.MaxValue))) }, { 7806, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)228, (byte)153, byte.MaxValue, byte.MaxValue))) }, { 6263, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)150, (byte)173, (byte)240, byte.MaxValue))) }, { 6267, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)147, (byte)244, (byte)241, byte.MaxValue))) }, { 6221, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)122, (byte)227, (byte)130, byte.MaxValue))) }, { 6261, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)41, (byte)221, byte.MaxValue, byte.MaxValue))) }, { 6229, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)164, (byte)218, byte.MaxValue, byte.MaxValue))) }, { 6231, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)213, (byte)82, byte.MaxValue, byte.MaxValue))) }, { 6230, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)196, byte.MaxValue, (byte)106, byte.MaxValue))) }, { 7617, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)77, (byte)182, (byte)241, byte.MaxValue))) }, { 7618, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)140, (byte)64, (byte)219, byte.MaxValue))) }, { 6501, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)234, (byte)163, (byte)87, byte.MaxValue))) }, { 6502, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)87, byte.MaxValue, (byte)191, byte.MaxValue))) }, { 6503, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)53, (byte)206, byte.MaxValue, byte.MaxValue))) }, { 7501, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)210, (byte)157, (byte)118, byte.MaxValue))) }, { 7504, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)109, (byte)196, byte.MaxValue, byte.MaxValue))) }, { 6257, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)241, (byte)158, (byte)60, byte.MaxValue))) }, { 6258, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)71, (byte)132, (byte)253, byte.MaxValue))) }, { 6259, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)249, byte.MaxValue, (byte)89, byte.MaxValue))) }, { 6260, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)201, (byte)50, (byte)65, byte.MaxValue))) }, { 6264, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)71, (byte)188, (byte)84, byte.MaxValue))) }, { 6265, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)106, (byte)61, (byte)172, byte.MaxValue))) }, { 7612, new FullIconDesc(Color32.op_Implicit(new Color32((byte)173, (byte)207, (byte)172, byte.MaxValue))) }, { 7613, new FullIconDesc(Color32.op_Implicit(new Color32((byte)187, (byte)172, (byte)252, byte.MaxValue))) }, { 7615, new FullIconDesc(Color32.op_Implicit(new Color32((byte)187, (byte)172, (byte)252, byte.MaxValue))) }, { 6204, new FullIconDesc(Color32.op_Implicit(new Color32((byte)161, (byte)157, (byte)152, byte.MaxValue))) }, { 7707, new FullIconDesc(Color32.op_Implicit(new Color32((byte)51, (byte)51, (byte)57, byte.MaxValue))) }, { 6271, new FullIconDesc(Color32.op_Implicit(new Color32((byte)221, (byte)218, byte.MaxValue, byte.MaxValue))) }, { 7608, new FullIconDesc(Color32.op_Implicit(new Color32((byte)81, (byte)83, (byte)90, byte.MaxValue))) }, { 7609, new FullIconDesc(Color32.op_Implicit(new Color32((byte)221, (byte)218, byte.MaxValue, byte.MaxValue))) }, { 7616, new FullIconDesc(Color32.op_Implicit(new Color32((byte)187, (byte)172, (byte)252, byte.MaxValue))) }, { 6252, new FullIconDesc(Color32.op_Implicit(new Color32((byte)160, (byte)216, byte.MaxValue, byte.MaxValue))) }, { 6253, new FullIconDesc(Color32.op_Implicit(new Color32((byte)237, (byte)176, (byte)150, byte.MaxValue))) }, { 6273, new FullIconDesc(Color32.op_Implicit(new Color32((byte)218, (byte)212, (byte)195, byte.MaxValue))) }, { 6254, new FullIconDesc(Color32.op_Implicit(new Color32((byte)153, (byte)236, (byte)182, byte.MaxValue))) }, { 6255, new FullIconDesc(Color32.op_Implicit(new Color32((byte)232, (byte)236, byte.MaxValue, byte.MaxValue))) }, { 6281, new FullIconDesc(Color32.op_Implicit(new Color32((byte)32, (byte)33, (byte)36, byte.MaxValue))) }, { 6256, new FullIconDesc(Color32.op_Implicit(new Color32((byte)56, (byte)57, (byte)62, byte.MaxValue))) }, { 6277, new FullIconDesc(Color32.op_Implicit(new Color32(byte.MaxValue, byte.MaxValue, (byte)142, byte.MaxValue))) }, { 7002, new FullIconDesc(Color32.op_Implicit(new Color32((byte)96, byte.MaxValue, (byte)114, byte.MaxValue))) }, { 7017, new FullIconDesc(Color32.op_Implicit(new Color32((byte)251, (byte)251, (byte)251, byte.MaxValue))) }, { 6227, new FullIconDesc(Color32.op_Implicit(new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue))) }, { 6203, new NoIconMetalIconDesc(Color32.op_Implicit(new Color32((byte)186, (byte)176, (byte)144, byte.MaxValue))) }, { 7705, new NoIconMetalIconDesc(Color32.op_Implicit(new Color32((byte)43, (byte)44, (byte)48, byte.MaxValue))) }, { 6228, new NoIconMetalIconDesc(Color32.op_Implicit(new Color32((byte)239, (byte)83, (byte)90, byte.MaxValue))) }, { 7006, new NoIconMetalIconDesc(Color32.op_Implicit(new Color32(byte.MaxValue, (byte)177, (byte)0, byte.MaxValue))) }, { 7015, new NoIconMetalIconDesc(Color32.op_Implicit(new Color32((byte)0, byte.MaxValue, (byte)157, byte.MaxValue))) }, { 6217, new RodIconDesc(Color32.op_Implicit(new Color32((byte)163, (byte)145, (byte)85, byte.MaxValue))) }, { 6216, new RodIconDesc(Color32.op_Implicit(new Color32((byte)198, (byte)207, (byte)111, byte.MaxValue))) }, { 6242, new RodIconDesc(Color32.op_Implicit(new Color32((byte)33, (byte)170, (byte)87, byte.MaxValue))) }, { 6241, new RodIconDesc(Color32.op_Implicit(new Color32((byte)204, (byte)74, (byte)78, byte.MaxValue))) }, { 6243, new RodIconDesc(Color32.op_Implicit(new Color32((byte)153, (byte)157, (byte)169, byte.MaxValue))) }, { 6244, new RodIconDesc(Color32.op_Implicit(new Color32((byte)245, (byte)250, (byte)105, byte.MaxValue))) }, { 6245, new RodIconDesc(Color32.op_Implicit(new Color32((byte)147, (byte)77, byte.MaxValue, byte.MaxValue))) }, { 6206, new RodIconDesc(Color32.op_Implicit(new Color32((byte)96, byte.MaxValue, byte.MaxValue, byte.MaxValue))) }, { 6278, new MartixIconDesc(new Color(1f, 0.4117f, 0.3137f, 0.1961f), new Color(1f, 0.2706f, 0f, 0f)) }, { 6279, new MartixIconDesc(new Color(1f, 0.753f, 0.7961f, 0.1961f), new Color(0.7804f, 0.0824f, 0.5216f, 0f)) }, { 6280, new MartixIconDesc(new Color(0.402f, 0.402f, 0.402f, 0.1961f), new Color(0.3f, 0.3f, 0.3f, 0f)) }, { 7610, new WhiteIconDesc() }, { 7611, new WhiteIconDesc() } }; private static readonly IconDesc Default = new IconDesc { faceColor = Color.white, sideColor = new Color(0.4667f, 0.5333f, 0.6f, 1f), faceEmission = Color.black, sideEmission = Color.black, iconEmission = new Color(0.2f, 0.2f, 0.2f, 1f), metallic = 0.8f, smoothness = 0.5f, solidAlpha = 1f, iconAlpha = 1f }; internal static IconDesc GetIconDesc(int itemid) { ModIconDesc value; return IconDescs.TryGetValue(itemid, out value) ? value.ToIconDesc() : Default; } internal static IconDesc ExportIconDesc(int itemId) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) IconSet iconSet = GameMain.iconSet; IconDesc val = new IconDesc(); uint num = iconSet.itemIconIndex[itemId]; if (num == 0) { return val; } FieldInfo[] fields = typeof(IconDesc).GetFields(BindingFlags.Instance | BindingFlags.Public); uint num2 = 0u; FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { if (fieldInfo.FieldType == typeof(float)) { fieldInfo.SetValue(val, iconSet.itemDescArr[num * 40 + num2++]); } else if (fieldInfo.FieldType == typeof(Color)) { float num3 = iconSet.itemDescArr[num * 40 + num2++]; float num4 = iconSet.itemDescArr[num * 40 + num2++]; float num5 = iconSet.itemDescArr[num * 40 + num2++]; float num6 = iconSet.itemDescArr[num * 40 + num2++]; fieldInfo.SetValue(val, (object)new Color(num3, num4, num5, num6)); } } return val; } } internal static class JsonDataUtils { private static bool IsMoreMegaStructureItem(int itemID) { if (itemID > 9000) { ((ProtoSet)(object)LDB.items).Exist(itemID); return true; } return false; } internal static void ImportJson(int[] tableID) { //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Expected O, but got Unknown ref Dictionary reference = ref AccessTools.StaticFieldRefAccess>(typeof(ProtoRegistry), "itemIconDescs"); JsonHelper.TechProtoJson[] jsonContent = JsonHelper.GetJsonContent("techs"); foreach (JsonHelper.TechProtoJson techProtoJson in jsonContent) { if (((ProtoSet)(object)LDB.techs).Exist(techProtoJson.ID)) { techProtoJson.ToProto(((ProtoSet)(object)LDB.techs).Select(techProtoJson.ID)); } else { LDBTool.PreAddProto((Proto)(object)techProtoJson.ToProto()); } } JsonHelper.ItemProtoJson[] jsonContent2 = JsonHelper.GetJsonContent("items_mod"); foreach (JsonHelper.ItemProtoJson itemProtoJson in jsonContent2) { if (!ProjectOrbitalRing.MoreMegaStructureCompatibility || !IsMoreMegaStructureItem(itemProtoJson.ID)) { itemProtoJson.GridIndex = GetTableID(itemProtoJson.GridIndex); reference.Add(itemProtoJson.ID, IconDescUtils.GetIconDesc(itemProtoJson.ID)); LDBTool.PreAddProto((Proto)(object)itemProtoJson.ToProto()); } } JsonHelper.ItemProtoJson[] jsonContent3 = JsonHelper.GetJsonContent("items_vanilla"); foreach (JsonHelper.ItemProtoJson itemProtoJson2 in jsonContent3) { itemProtoJson2.GridIndex = GetTableID(itemProtoJson2.GridIndex); ItemProto val = ((ProtoSet)(object)LDB.items).Select(itemProtoJson2.ID); if (val.IconPath != itemProtoJson2.IconPath) { reference.Add(itemProtoJson2.ID, IconDescUtils.GetIconDesc(itemProtoJson2.ID)); } itemProtoJson2.ToProto(val); } RecipeProto.recipeExecuteData = new Dictionary(); JsonHelper.RecipeProtoJson[] jsonContent4 = JsonHelper.GetJsonContent("recipes"); foreach (JsonHelper.RecipeProtoJson recipeProtoJson in jsonContent4) { if (!ProjectOrbitalRing.MoreMegaStructureCompatibility || recipeProtoJson.ID < 530 || recipeProtoJson.ID > 550) { recipeProtoJson.GridIndex = GetTableID(recipeProtoJson.GridIndex); if (((ProtoSet)(object)LDB.recipes).Exist(recipeProtoJson.ID)) { recipeProtoJson.ToProto(((ProtoSet)(object)LDB.recipes).Select(recipeProtoJson.ID)); } else { LDBTool.PreAddProto((Proto)(object)recipeProtoJson.ToProto()); } RecipeExecuteData value = new RecipeExecuteData(recipeProtoJson.Input, recipeProtoJson.InCounts, recipeProtoJson.Output, recipeProtoJson.OutCounts, recipeProtoJson.Time * 10000, recipeProtoJson.Time * 100000, !recipeProtoJson.NonProductive); RecipeProto.recipeExecuteData.Add(recipeProtoJson.ID, value); } } JsonHelper.TutorialProtoJson[] jsonContent5 = JsonHelper.GetJsonContent("tutorials"); foreach (JsonHelper.TutorialProtoJson tutorialProtoJson in jsonContent5) { LDBTool.PreAddProto((Proto)(object)tutorialProtoJson.ToProto()); } int GetTableID(int gridIndex) { if (gridIndex >= 5000) { return (tableID[2] - 5) * 1000 + gridIndex; } if (gridIndex >= 4000) { return (tableID[1] - 4) * 1000 + gridIndex; } if (gridIndex >= 3000) { return (tableID[0] - 3) * 1000 + gridIndex; } return gridIndex; } } internal static void PrefabDescPostFix() { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) JsonHelper.PrefabDescJson[] jsonContent = JsonHelper.GetJsonContent("prefabDescs"); JsonHelper.PrefabDescJson[] array = jsonContent; foreach (JsonHelper.PrefabDescJson prefabDescJson in array) { prefabDescJson.ToPrefabDesc(((ProtoSet)(object)LDB.models).Select(prefabDescJson.ModelID).prefabDesc); } PrefabDesc prefabDesc = ((ProtoSet)(object)LDB.models).Select(830).prefabDesc; prefabDesc.beaconSignalRadius = 0f; prefabDesc = ((ProtoSet)(object)LDB.models).Select(831).prefabDesc; prefabDesc.beaconSignalRadius = 0f; prefabDesc = ((ProtoSet)(object)LDB.models).Select(832).prefabDesc; prefabDesc.beaconSignalRadius = 0f; prefabDesc = ((ProtoSet)(object)LDB.models).Select(834).prefabDesc; prefabDesc.beaconSignalRadius = 0f; prefabDesc = ((ProtoSet)(object)LDB.models).Select(838).prefabDesc; prefabDesc.beaconSignalRadius = 0f; prefabDesc = ((ProtoSet)(object)LDB.models).Select(835).prefabDesc; prefabDesc.isLab = false; prefabDesc = ((ProtoSet)(object)LDB.models).Select(839).prefabDesc; prefabDesc.portPoses = (Pose[])(object)new Pose[1] { prefabDesc.portPoses[0] }; prefabDesc = ((ProtoSet)(object)LDB.models).Select(73).prefabDesc; prefabDesc.powerProductHeat = 12000000000L; } } internal static class JsonHelper { [Serializable] public class ItemProtoJson { public int ID { get; set; } public string Name { get; set; } public string Description { get; set; } public string IconPath { get; set; } public string IconTag { get; set; } public int GridIndex { get; set; } public int StackSize { get; set; } public int Type { get; set; } public int PreTechOverride { get; set; } public int[] DescFields { get; set; } public int FuelType { get; set; } public long HeatValue { get; set; } public float ReactorInc { get; set; } public bool IsFluid { get; set; } public bool Productive { get; set; } public int SubID { get; set; } public string MiningFrom { get; set; } public string ProduceFrom { get; set; } public int Grade { get; set; } public int[] Upgrades { get; set; } public bool IsEntity { get; set; } public bool CanBuild { get; set; } public bool BuildInGas { get; set; } public int ModelIndex { get; set; } public int ModelCount { get; set; } public int HpMax { get; set; } public int Ability { get; set; } public long Potential { get; set; } public int BuildIndex { get; set; } public int BuildMode { get; set; } public int UnlockKey { get; set; } public int MechaMaterialID { get; set; } public int AmmoType { get; set; } public int BombType { get; set; } public int CraftType { get; set; } public float DropRate { get; set; } public int EnemyDropLevel { get; set; } public float[] EnemyDropRange { get; set; } public float EnemyDropCount { get; set; } public int EnemyDropMask { get; set; } public float EnemyDropMaskRatio { get; set; } public static ItemProtoJson FromProto(ItemProto i) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected I4, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected I4, but got Unknown //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Expected I4, but got Unknown ItemProtoJson itemProtoJson = new ItemProtoJson(); itemProtoJson.ID = ((Proto)i).ID; itemProtoJson.Name = ((Proto)i).Name; itemProtoJson.Description = i.Description; itemProtoJson.IconPath = i.IconPath; itemProtoJson.IconTag = i.IconTag; itemProtoJson.GridIndex = i.GridIndex; itemProtoJson.StackSize = i.StackSize; itemProtoJson.FuelType = i.FuelType; itemProtoJson.HeatValue = i.HeatValue; itemProtoJson.ReactorInc = i.ReactorInc; itemProtoJson.DescFields = i.DescFields; itemProtoJson.IsFluid = i.IsFluid; itemProtoJson.Type = (int)i.Type; itemProtoJson.SubID = i.SubID; itemProtoJson.MiningFrom = i.MiningFrom; itemProtoJson.ProduceFrom = i.ProduceFrom; itemProtoJson.Grade = i.Grade; itemProtoJson.Upgrades = i.Upgrades; itemProtoJson.IsEntity = i.IsEntity; itemProtoJson.CanBuild = i.CanBuild; itemProtoJson.BuildInGas = i.BuildInGas; itemProtoJson.ModelIndex = i.ModelIndex; itemProtoJson.ModelCount = i.ModelCount; itemProtoJson.HpMax = i.HpMax; itemProtoJson.Ability = i.Ability; itemProtoJson.Potential = i.Potential; itemProtoJson.BuildIndex = i.BuildIndex; itemProtoJson.BuildMode = i.BuildMode; itemProtoJson.UnlockKey = i.UnlockKey; itemProtoJson.PreTechOverride = i.PreTechOverride; itemProtoJson.Productive = i.Productive; itemProtoJson.MechaMaterialID = i.MechaMaterialID; itemProtoJson.AmmoType = (int)i.AmmoType; itemProtoJson.BombType = (int)i.BombType; itemProtoJson.CraftType = i.CraftType; itemProtoJson.DropRate = i.DropRate; itemProtoJson.EnemyDropLevel = i.EnemyDropLevel; itemProtoJson.EnemyDropRange = new float[2] { i.EnemyDropRange.x, i.EnemyDropRange.y }; itemProtoJson.EnemyDropCount = i.EnemyDropCount; itemProtoJson.EnemyDropMask = i.EnemyDropMask; itemProtoJson.EnemyDropMaskRatio = i.EnemyDropMaskRatio; return itemProtoJson; } public ItemProto ToProto() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown return ToProto(new ItemProto()); } public ItemProto ToProto(ItemProto proto) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) ((Proto)proto).ID = ID; ((Proto)proto).Name = Name; proto.Description = Description; proto.IconPath = IconPath; proto.IconTag = IconTag; proto.GridIndex = GridIndex; proto.StackSize = StackSize; proto.FuelType = FuelType; proto.HeatValue = HeatValue; proto.ReactorInc = ReactorInc; proto.DescFields = DescFields ?? Array.Empty(); proto.IsFluid = IsFluid; proto.Type = (EItemType)Type; proto.SubID = SubID; proto.MiningFrom = MiningFrom; proto.ProduceFrom = ProduceFrom; proto.Grade = Grade; proto.Upgrades = Upgrades ?? Array.Empty(); proto.IsEntity = IsEntity; proto.CanBuild = CanBuild; proto.BuildInGas = BuildInGas; proto.ModelIndex = ModelIndex; proto.ModelCount = ModelCount; proto.HpMax = HpMax; proto.Ability = Ability; proto.Potential = Potential; proto.BuildIndex = BuildIndex; proto.BuildMode = BuildMode; proto.UnlockKey = UnlockKey; proto.MechaMaterialID = MechaMaterialID; proto.PreTechOverride = PreTechOverride; proto.Productive = Productive; proto.AmmoType = (EAmmoType)(byte)AmmoType; proto.BombType = (EBombType)BombType; proto.CraftType = CraftType; proto.DropRate = DropRate; proto.EnemyDropLevel = EnemyDropLevel; proto.EnemyDropRange = new Vector2(EnemyDropRange[0], EnemyDropRange[1]); proto.EnemyDropCount = EnemyDropCount; proto.EnemyDropMask = EnemyDropMask; proto.EnemyDropMaskRatio = EnemyDropMaskRatio; return proto; } } [Serializable] public class RecipeProtoJson { public int ID { get; set; } public string Name { get; set; } public string Description { get; set; } public string IconPath { get; set; } public string IconTag { get; set; } public int Type { get; set; } public int GridIndex { get; set; } public int Time { get; set; } public int[] Input { get; set; } public int[] InCounts { get; set; } public int[] Output { get; set; } public int[] OutCounts { get; set; } public bool Explicit { get; set; } public bool Handcraft { get; set; } public bool NonProductive { get; set; } public static RecipeProtoJson FromProto(RecipeProto i) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected I4, but got Unknown return new RecipeProtoJson { ID = ((Proto)i).ID, Explicit = i.Explicit, Name = ((Proto)i).Name, Handcraft = i.Handcraft, Type = (int)i.Type, Time = i.TimeSpend, Input = (i.Items ?? Array.Empty()), InCounts = (i.ItemCounts ?? Array.Empty()), Output = (i.Results ?? Array.Empty()), OutCounts = (i.ResultCounts ?? Array.Empty()), Description = i.Description, GridIndex = i.GridIndex, IconPath = i.IconPath, IconTag = i.IconTag, NonProductive = i.NonProductive }; } public RecipeProto ToProto() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown return ToProto(new RecipeProto()); } public RecipeProto ToProto(RecipeProto proto) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) ((Proto)proto).ID = ID; proto.Explicit = Explicit; ((Proto)proto).Name = Name; proto.Handcraft = Handcraft; proto.Type = (ERecipeType)(byte)Type; proto.TimeSpend = Time; proto.Items = Input; proto.ItemCounts = InCounts; proto.Results = Output ?? Array.Empty(); proto.ResultCounts = OutCounts ?? Array.Empty(); proto.Description = Description; proto.GridIndex = GridIndex; proto.IconPath = IconPath; proto.IconTag = IconTag; proto.NonProductive = NonProductive; return proto; } } [Serializable] public class TechProtoJson { public int ID { get; set; } public string Name { get; set; } public string IconPath { get; set; } public string IconTag { get; set; } public string Desc { get; set; } public string Conclusion { get; set; } public bool IsHiddenTech { get; set; } public int[] PreItem { get; set; } public float[] Position { get; set; } public int[] PreTechs { get; set; } public int[] PreTechsImplicit { get; set; } public int[] Items { get; set; } public int[] ItemPoints { get; set; } public long HashNeeded { get; set; } public int[] UnlockRecipes { get; set; } public int[] UnlockFunctions { get; set; } public double[] UnlockValues { get; set; } public bool Published { get; set; } public int Level { get; set; } public int MaxLevel { get; set; } public int LevelCoef1 { get; set; } public int LevelCoef2 { get; set; } public bool IsLabTech { get; set; } public bool PreTechsMax { get; set; } public int[] AddItems { get; set; } public int[] AddItemCounts { get; set; } public int[] PropertyOverrideItems { get; set; } public int[] PropertyItemCounts { get; set; } public static TechProtoJson FromProto(TechProto i) { TechProtoJson techProtoJson = new TechProtoJson(); techProtoJson.ID = ((Proto)i).ID; techProtoJson.Name = ((Proto)i).Name; techProtoJson.Desc = i.Desc; techProtoJson.Conclusion = i.Conclusion; techProtoJson.IsHiddenTech = i.IsHiddenTech; techProtoJson.PreItem = i.PreItem; techProtoJson.Published = i.Published; techProtoJson.Level = i.Level; techProtoJson.MaxLevel = i.MaxLevel; techProtoJson.LevelCoef1 = i.LevelCoef1; techProtoJson.LevelCoef2 = i.LevelCoef2; techProtoJson.IconPath = i.IconPath; techProtoJson.IconTag = i.IconTag; techProtoJson.IsLabTech = i.IsLabTech; techProtoJson.PreTechs = i.PreTechs; techProtoJson.PreTechsImplicit = i.PreTechsImplicit; techProtoJson.PreTechsMax = i.PreTechsMax; techProtoJson.Items = i.Items; techProtoJson.ItemPoints = i.ItemPoints; techProtoJson.HashNeeded = i.HashNeeded; techProtoJson.UnlockRecipes = i.UnlockRecipes; techProtoJson.UnlockFunctions = i.UnlockFunctions; techProtoJson.UnlockValues = i.UnlockValues; techProtoJson.AddItems = i.AddItems; techProtoJson.AddItemCounts = i.AddItemCounts; techProtoJson.Position = new float[2] { i.Position.x, i.Position.y }; techProtoJson.PropertyOverrideItems = i.PropertyOverrideItems; techProtoJson.PropertyItemCounts = i.PropertyItemCounts; return techProtoJson; } public TechProto ToProto() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown return ToProto(new TechProto()); } public TechProto ToProto(TechProto proto) { //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) ((Proto)proto).ID = ID; ((Proto)proto).Name = Name; proto.Desc = Desc; proto.Conclusion = Conclusion; proto.IsHiddenTech = IsHiddenTech; proto.PreItem = PreItem ?? Array.Empty(); proto.Published = Published; proto.IconPath = IconPath; proto.IconTag = IconTag; proto.IsLabTech = IsLabTech; proto.PreTechs = PreTechs ?? Array.Empty(); proto.PreTechsImplicit = PreTechsImplicit ?? Array.Empty(); proto.PreTechsMax = PreTechsMax; proto.Items = Items ?? Array.Empty(); proto.ItemPoints = ItemPoints ?? Array.Empty(); proto.AddItems = AddItems ?? Array.Empty(); proto.AddItemCounts = AddItemCounts ?? Array.Empty(); proto.Position = new Vector2(Position[0], Position[1]); proto.HashNeeded = HashNeeded; proto.UnlockRecipes = UnlockRecipes ?? Array.Empty(); proto.UnlockFunctions = UnlockFunctions ?? Array.Empty(); proto.UnlockValues = UnlockValues ?? Array.Empty(); proto.Level = Level; proto.MaxLevel = MaxLevel; proto.LevelCoef1 = LevelCoef1; proto.LevelCoef2 = LevelCoef2; proto.PropertyOverrideItems = PropertyOverrideItems ?? Array.Empty(); proto.PropertyItemCounts = PropertyItemCounts ?? Array.Empty(); return proto; } } [Serializable] public class GoalProtoJson { public int ID { get; set; } public string Name { get; set; } public string TooltipText { get; set; } public int Level { get; set; } public int QueueJumpPriority { get; set; } public int ParentId { get; set; } public int NeedCombatMode { get; set; } public double[] DisplayParams { get; set; } public string DeterminatorName { get; set; } public long[] DeterminatorParams { get; set; } public long[] IgnoreParamsLevel1 { get; set; } public long[] IgnoreParamsLevel2 { get; set; } public long[] PatchIgnoreParams { get; set; } public long[] PatchCompleteParams { get; set; } public long[] OnLoadIgnoreParams { get; set; } public long[] EnterQueueIgnoreParams { get; set; } public int[] Childs { get; set; } public static GoalProtoJson FromProto(GoalProto i) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected I4, but got Unknown return new GoalProtoJson { ID = ((Proto)i).ID, Name = ((Proto)i).Name, TooltipText = i.TooltipText, Level = (int)i.Level, QueueJumpPriority = i.QueueJumpPriority, ParentId = i.ParentId, NeedCombatMode = i.NeedCombatMode, DisplayParams = i.DisplayParams, DeterminatorName = i.DeterminatorName, DeterminatorParams = i.DeterminatorParams, IgnoreParamsLevel1 = i.IgnoreParamsLevel1, IgnoreParamsLevel2 = i.IgnoreParamsLevel2, PatchIgnoreParams = i.PatchIgnoreParams, PatchCompleteParams = i.PatchCompleteParams, OnLoadIgnoreParams = i.OnLoadIgnoreParams, EnterQueueIgnoreParams = i.EnterQueueIgnoreParams, Childs = i.Childs }; } public GoalProto ToProto() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown return ToProto(new GoalProto()); } public GoalProto ToProto(GoalProto proto) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) ((Proto)proto).ID = ID; ((Proto)proto).Name = Name; proto.TooltipText = TooltipText; proto.Level = (EGoalLevel)Level; proto.QueueJumpPriority = QueueJumpPriority; proto.ParentId = ParentId; proto.NeedCombatMode = NeedCombatMode; proto.DisplayParams = DisplayParams ?? Array.Empty(); proto.DeterminatorName = DeterminatorName; proto.DeterminatorParams = DeterminatorParams ?? Array.Empty(); proto.IgnoreParamsLevel1 = IgnoreParamsLevel1 ?? Array.Empty(); proto.IgnoreParamsLevel2 = IgnoreParamsLevel2 ?? Array.Empty(); proto.PatchIgnoreParams = PatchIgnoreParams ?? Array.Empty(); proto.PatchCompleteParams = PatchCompleteParams ?? Array.Empty(); proto.OnLoadIgnoreParams = OnLoadIgnoreParams ?? Array.Empty(); proto.EnterQueueIgnoreParams = EnterQueueIgnoreParams ?? Array.Empty(); proto.Childs = Childs ?? Array.Empty(); return proto; } } [Serializable] public class StringProtoJson { public string Name { get; set; } public string ZHCN { get; set; } public string ENUS { get; set; } } [Serializable] public class TutorialProtoJson { public int ID { get; set; } public string Name { get; set; } public string PreText { get; set; } public string LayoutFileName { get; set; } public string DeterminatorName { get; set; } public long[] DeterminatorParams { get; set; } public TutorialProto ToProto() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0029: 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_0042: Expected O, but got Unknown return new TutorialProto { ID = ID, Name = Name, LayoutFileName = LayoutFileName, DeterminatorName = DeterminatorName, DeterminatorParams = DeterminatorParams }; } } [Serializable] public class PrefabDescJson { public int ItemID { get; set; } public int ModelID { get; set; } public bool? isAccumulator { get; set; } = null; public bool? isAssembler { get; set; } = null; public bool? isCollectStation { get; set; } = null; public bool? isFractionator { get; set; } = null; public bool? isPowerGen { get; set; } = null; public bool? isPowerConsumer { get; set; } = null; public bool? isStation { get; set; } = null; public bool? isStellarStation { get; set; } = null; public int? assemblerRecipeType { get; set; } = null; public long? idleEnergyPerTick { get; set; } = null; public long? workEnergyPerTick { get; set; } = null; public int? assemblerSpeed { get; set; } = null; public int? minerPeriod { get; set; } = null; public int? ejectorChargeFrame { get; set; } = null; public int? ejectorColdFrame { get; set; } = null; public int? siloChargeFrame { get; set; } = null; public int? siloColdFrame { get; set; } = null; public int? labAssembleSpeed { get; set; } = null; public float? labResearchSpeed { get; set; } = null; public float? powerConnectDistance { get; set; } = null; public float? powerCoverRadius { get; set; } = null; public long? genEnergyPerTick { get; set; } = null; public long? useFuelPerTick { get; set; } = null; public int? beltSpeed { get; set; } = null; public int? inserterSTT { get; set; } = null; public int? fluidStorageCount { get; set; } = null; public int? fuelMask { get; set; } = null; public int? minerType { get; set; } = null; public int? minimapType { get; set; } = null; public int? stationCollectSpeed { get; set; } = null; public long? maxAcuEnergy { get; set; } = null; public long? inputEnergyPerTick { get; set; } = null; public long? outputEnergyPerTick { get; set; } = null; public long? maxExcEnergy { get; set; } = null; public long? exchangeEnergyPerTick { get; set; } = null; public long? stationMaxEnergyAcc { get; set; } = null; public int? stationMaxItemCount { get; set; } = null; public int? stationMaxItemKinds { get; set; } = null; public int? stationMaxDroneCount { get; set; } = null; public int? stationMaxShipCount { get; set; } = null; public float? AmmoBlastRadius1 { get; set; } = null; public float? AmmoMoveAcc { get; set; } = null; public float? AmmoTurnAcc { get; set; } = null; public int? turretMuzzleInterval { get; set; } = null; public int? turretRoundInterval { get; set; } = null; public float? turretMaxAttackRange { get; set; } = null; public float? turretDamageScale { get; set; } = null; public float? turretSpaceAttackRange { get; set; } = null; public int? turretAddEnemyExppBase { get; set; } = null; public float? turretAddEnemyExppCoef { get; set; } = null; public int? turretAddEnemyHatredBase { get; set; } = null; public float? turretAddEnemyHatredCoef { get; set; } = null; public int? turretAddEnemyThreatBase { get; set; } = null; public float? turretAddEnemyThreatCoef { get; set; } = null; public int? enemyGenMatter { get; set; } = null; public int? enemySpMax { get; set; } = null; public int? unitAttackDamage0 { get; set; } = null; public int? unitAttackDamageInc0 { get; set; } = null; public bool? multiLevel { get; set; } = null; public int? storageCol { get; set; } = null; public int? storageRow { get; set; } = null; public bool? isStorage { get; set; } = null; public int? subId { get; set; } = null; public bool? allowBuildInWater { get; set; } = null; public bool? needBuildInWaterTech { get; set; } = null; public int[] waterTypes { get; set; } = null; public float? turretMinAttackRange { get; set; } = null; public static PrefabDescJson FromPrefabDesc(PrefabDesc i, int itemID, int modelID) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected I4, but got Unknown //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected I4, but got Unknown return new PrefabDescJson { ItemID = itemID, ModelID = modelID, isAccumulator = i.isAccumulator, isAssembler = i.isAssembler, isFractionator = i.isFractionator, isPowerGen = i.isPowerGen, isStation = i.isStation, isStellarStation = i.isStellarStation, isCollectStation = i.isCollectStation, isPowerConsumer = i.isPowerConsumer, assemblerSpeed = i.assemblerSpeed, assemblerRecipeType = (int)i.assemblerRecipeType, workEnergyPerTick = i.workEnergyPerTick, idleEnergyPerTick = i.idleEnergyPerTick, minerPeriod = i.minerPeriod, ejectorChargeFrame = i.ejectorChargeFrame, ejectorColdFrame = i.ejectorColdFrame, siloChargeFrame = i.siloChargeFrame, siloColdFrame = i.siloColdFrame, labAssembleSpeed = i.labAssembleSpeed, labResearchSpeed = i.labResearchSpeed, powerConnectDistance = i.powerConnectDistance, powerCoverRadius = i.powerCoverRadius, genEnergyPerTick = i.genEnergyPerTick, useFuelPerTick = i.useFuelPerTick, beltSpeed = i.beltSpeed, inserterSTT = i.inserterSTT, fluidStorageCount = i.fluidStorageCount, fuelMask = i.fuelMask, minerType = (int)i.minerType, minimapType = i.minimapType, maxAcuEnergy = i.maxAcuEnergy, maxExcEnergy = i.maxExcEnergy, inputEnergyPerTick = i.inputEnergyPerTick, outputEnergyPerTick = i.outputEnergyPerTick, exchangeEnergyPerTick = i.exchangeEnergyPerTick, stationCollectSpeed = i.stationCollectSpeed, stationMaxEnergyAcc = i.stationMaxEnergyAcc, stationMaxItemCount = i.stationMaxItemCount, stationMaxItemKinds = i.stationMaxItemKinds, stationMaxShipCount = i.stationMaxShipCount, stationMaxDroneCount = i.stationMaxDroneCount, AmmoBlastRadius1 = i.AmmoBlastRadius1, AmmoMoveAcc = i.AmmoMoveAcc, AmmoTurnAcc = i.AmmoTurnAcc, turretMuzzleInterval = i.turretMuzzleInterval, turretRoundInterval = i.turretRoundInterval, turretMaxAttackRange = i.turretMaxAttackRange, turretDamageScale = i.turretDamageScale, turretSpaceAttackRange = i.turretSpaceAttackRange, turretAddEnemyExppBase = i.turretAddEnemyExppBase, turretAddEnemyExppCoef = i.turretAddEnemyExppCoef, turretAddEnemyHatredBase = i.turretAddEnemyHatredBase, turretAddEnemyHatredCoef = i.turretAddEnemyHatredCoef, turretAddEnemyThreatBase = i.turretAddEnemyThreatBase, turretAddEnemyThreatCoef = i.turretAddEnemyThreatCoef, enemyGenMatter = i.enemyGenMatter, enemySpMax = i.enemySpMax, unitAttackDamage0 = i.unitAttackDamage0, unitAttackDamageInc0 = i.unitAttackDamageInc0, multiLevel = i.multiLevel, storageCol = i.storageCol, storageRow = i.storageRow, isStorage = i.isStorage, subId = i.subId, allowBuildInWater = i.allowBuildInWater, needBuildInWaterTech = i.needBuildInWaterTech, waterTypes = i.waterTypes, turretMinAttackRange = i.turretMinAttackRange }; } public void ToPrefabDesc(PrefabDesc desc) { //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) if (isAccumulator.HasValue) { desc.isAccumulator = isAccumulator.Value; } if (isAssembler.HasValue) { desc.isAssembler = isAssembler.Value; } if (isFractionator.HasValue) { desc.isFractionator = isFractionator.Value; } if (isPowerGen.HasValue) { desc.isPowerGen = isPowerGen.Value; } if (isStation.HasValue) { desc.isStation = isStation.Value; } if (isStellarStation.HasValue) { desc.isStellarStation = isStellarStation.Value; } if (isCollectStation.HasValue) { desc.isCollectStation = isCollectStation.Value; } if (isPowerConsumer.HasValue) { desc.isPowerConsumer = isPowerConsumer.Value; } if (assemblerSpeed.HasValue) { desc.assemblerSpeed = assemblerSpeed.Value; } if (assemblerRecipeType.HasValue) { desc.assemblerRecipeType = (ERecipeType)(byte)assemblerRecipeType.Value; } if (workEnergyPerTick.HasValue) { desc.workEnergyPerTick = workEnergyPerTick.Value; } if (idleEnergyPerTick.HasValue) { desc.idleEnergyPerTick = idleEnergyPerTick.Value; } if (minerPeriod.HasValue) { desc.minerPeriod = minerPeriod.Value; } if (ejectorChargeFrame.HasValue) { desc.ejectorChargeFrame = ejectorChargeFrame.Value; } if (ejectorColdFrame.HasValue) { desc.ejectorColdFrame = ejectorColdFrame.Value; } if (siloChargeFrame.HasValue) { desc.siloChargeFrame = siloChargeFrame.Value; } if (siloColdFrame.HasValue) { desc.siloColdFrame = siloColdFrame.Value; } if (labAssembleSpeed.HasValue) { desc.labAssembleSpeed = labAssembleSpeed.Value; } if (labResearchSpeed.HasValue) { desc.labResearchSpeed = labResearchSpeed.Value; } if (powerConnectDistance.HasValue) { desc.powerConnectDistance = powerConnectDistance.Value; } if (powerCoverRadius.HasValue) { desc.powerCoverRadius = powerCoverRadius.Value; } if (genEnergyPerTick.HasValue) { desc.genEnergyPerTick = genEnergyPerTick.Value; } if (useFuelPerTick.HasValue) { desc.useFuelPerTick = useFuelPerTick.Value; } if (beltSpeed.HasValue) { desc.beltSpeed = beltSpeed.Value; } if (inserterSTT.HasValue) { desc.inserterSTT = inserterSTT.Value; } if (fluidStorageCount.HasValue) { desc.fluidStorageCount = fluidStorageCount.Value; } if (fuelMask.HasValue) { desc.fuelMask = fuelMask.Value; } if (minerType.HasValue) { desc.minerType = (EMinerType)minerType.Value; } if (minimapType.HasValue) { desc.minimapType = minimapType.Value; } if (maxAcuEnergy.HasValue) { desc.maxAcuEnergy = maxAcuEnergy.Value; } if (maxExcEnergy.HasValue) { desc.maxExcEnergy = maxExcEnergy.Value; } if (inputEnergyPerTick.HasValue) { desc.inputEnergyPerTick = inputEnergyPerTick.Value; } if (outputEnergyPerTick.HasValue) { desc.outputEnergyPerTick = outputEnergyPerTick.Value; } if (exchangeEnergyPerTick.HasValue) { desc.exchangeEnergyPerTick = exchangeEnergyPerTick.Value; } if (stationCollectSpeed.HasValue) { desc.stationCollectSpeed = stationCollectSpeed.Value; } if (stationMaxEnergyAcc.HasValue) { desc.stationMaxEnergyAcc = stationMaxEnergyAcc.Value; } if (stationMaxItemCount.HasValue) { desc.stationMaxItemCount = stationMaxItemCount.Value; } if (stationMaxItemKinds.HasValue) { desc.stationMaxItemKinds = stationMaxItemKinds.Value; } if (stationMaxShipCount.HasValue) { desc.stationMaxShipCount = stationMaxShipCount.Value; } if (stationMaxDroneCount.HasValue) { desc.stationMaxDroneCount = stationMaxDroneCount.Value; } if (AmmoBlastRadius1.HasValue) { desc.AmmoBlastRadius1 = AmmoBlastRadius1.Value; } if (AmmoMoveAcc.HasValue) { desc.AmmoMoveAcc = AmmoMoveAcc.Value; } if (AmmoTurnAcc.HasValue) { desc.AmmoTurnAcc = AmmoTurnAcc.Value; } if (turretMuzzleInterval.HasValue) { desc.turretMuzzleInterval = turretMuzzleInterval.Value; } if (turretRoundInterval.HasValue) { desc.turretRoundInterval = turretRoundInterval.Value; } if (turretMaxAttackRange.HasValue) { desc.turretMaxAttackRange = turretMaxAttackRange.Value; } if (turretDamageScale.HasValue) { desc.turretDamageScale = turretDamageScale.Value; } if (turretSpaceAttackRange.HasValue) { desc.turretSpaceAttackRange = turretSpaceAttackRange.Value; } if (turretAddEnemyExppBase.HasValue) { desc.turretAddEnemyExppBase = turretAddEnemyExppBase.Value; } if (turretAddEnemyExppCoef.HasValue) { desc.turretAddEnemyExppCoef = turretAddEnemyExppCoef.Value; } if (turretAddEnemyHatredBase.HasValue) { desc.turretAddEnemyHatredBase = turretAddEnemyHatredBase.Value; } if (turretAddEnemyHatredCoef.HasValue) { desc.turretAddEnemyHatredCoef = turretAddEnemyHatredCoef.Value; } if (turretAddEnemyThreatBase.HasValue) { desc.turretAddEnemyThreatBase = turretAddEnemyThreatBase.Value; } if (turretAddEnemyThreatCoef.HasValue) { desc.turretAddEnemyThreatCoef = turretAddEnemyThreatCoef.Value; } if (enemyGenMatter.HasValue) { desc.enemyGenMatter = enemyGenMatter.Value; } if (enemySpMax.HasValue) { desc.enemySpMax = enemySpMax.Value; } if (unitAttackDamage0.HasValue) { desc.unitAttackDamage0 = unitAttackDamage0.Value; } if (unitAttackDamageInc0.HasValue) { desc.unitAttackDamageInc0 = unitAttackDamageInc0.Value; } if (multiLevel.HasValue) { desc.multiLevel = multiLevel.Value; } if (storageCol.HasValue) { desc.storageCol = storageCol.Value; } if (storageRow.HasValue) { desc.storageRow = storageRow.Value; } if (isStorage.HasValue) { desc.isStorage = isStorage.Value; } if (subId.HasValue) { desc.subId = subId.Value; } if (allowBuildInWater.HasValue) { desc.allowBuildInWater = allowBuildInWater.Value; } if (needBuildInWaterTech.HasValue) { desc.needBuildInWaterTech = needBuildInWaterTech.Value; } if (waterTypes != null) { desc.waterTypes = waterTypes; } if (turretMinAttackRange.HasValue) { desc.turretMinAttackRange = turretMinAttackRange.Value; } } } private static readonly Assembly Assembly = Assembly.GetExecutingAssembly(); internal static T[] GetJsonContent(string json) { return JsonConvert.DeserializeObject(new StreamReader(Assembly.GetManifestResourceStream("ProjectOrbitalRing.data." + json + ".json")).ReadToEnd()); } internal static string SerializeObject(object obj) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown return JsonConvert.SerializeObject(obj, (Formatting)1, new JsonSerializerSettings { ReferenceLoopHandling = (ReferenceLoopHandling)1 }); } internal static void ExportAsJson(string path) { File.WriteAllText(path + "/techs.json", SerializeObject(((ProtoSet)(object)LDB.techs).dataArray.Select(TechProtoJson.FromProto))); File.WriteAllText(path + "/items.json", SerializeObject(((ProtoSet)(object)LDB.items).dataArray.Select(ItemProtoJson.FromProto))); File.WriteAllText(path + "/recipes.json", SerializeObject(((ProtoSet)(object)LDB.recipes).dataArray.Select(RecipeProtoJson.FromProto))); } } public static class KvpDeconstruct { public static void Deconstruct(this KeyValuePair pair, out TKey key, out TValue value) { key = pair.Key; value = pair.Value; } } public class SyncSlotsData { public int PlanetId { get; set; } public int EntityId { get; set; } public byte[] SlotsData { get; set; } public SyncSlotsData() { } public SyncSlotsData(int planetId, int entityId, SlotData[] data) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected I4, but got Unknown PlanetId = planetId; EntityId = entityId; IWriterProvider binaryWriter = NebulaModAPI.GetBinaryWriter(); try { BinaryWriter binaryWriter2 = binaryWriter.BinaryWriter; binaryWriter2.Write(data.Length); for (int i = 0; i < data.Length; i++) { binaryWriter2.Write((int)data[i].dir); binaryWriter2.Write(data[i].beltId); binaryWriter2.Write(data[i].storageIdx); binaryWriter2.Write(data[i].counter); } SlotsData = binaryWriter.CloseAndGetBytes(); } finally { ((IDisposable)binaryWriter)?.Dispose(); } } internal static void Sync(int planetId, int entityId, SlotData[] slotsData) { if (NebulaModAPI.IsMultiplayerActive) { NebulaModAPI.MultiplayerSession.Network.SendPacket(new SyncSlotsData(planetId, entityId, slotsData)); } } internal static void OnReceive(int planetId, int entityId, byte[] data) { //IL_0029: 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_0063: 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) IReaderProvider binaryReader = NebulaModAPI.GetBinaryReader(data); SlotData[] array; try { using BinaryReader binaryReader2 = binaryReader.BinaryReader; int num = binaryReader2.ReadInt32(); array = (SlotData[])(object)new SlotData[num]; for (int i = 0; i < num; i++) { array[i] = new SlotData { dir = (IODir)binaryReader2.ReadInt32(), beltId = binaryReader2.ReadInt32(), storageIdx = binaryReader2.ReadInt32(), counter = binaryReader2.ReadInt32() }; } binaryReader.BinaryReader.Close(); } finally { ((IDisposable)binaryReader)?.Dispose(); } MegaAssemblerPatches.SyncSlots((planetId, entityId), array); } } [RegisterPacketProcessor] public class SyncSlotsDataProcessor : BasePacketProcessor { public override void ProcessPacket(SyncSlotsData packet, INebulaConnection conn) { SyncSlotsData.OnReceive(packet.PlanetId, packet.EntityId, packet.SlotsData); } } public class SyncSlotData { public int PlanetId { get; set; } public int SlotId { get; set; } public int EntityId { get; set; } public byte[] SlotData { get; set; } public SyncSlotData() { } public SyncSlotData(int planetId, int slotId, int entityId, SlotData data) { //IL_002f: 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) //IL_003b: Expected I4, but got Unknown //IL_003d: 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_0059: Unknown result type (might be due to invalid IL or missing references) PlanetId = planetId; SlotId = slotId; EntityId = entityId; IWriterProvider binaryWriter = NebulaModAPI.GetBinaryWriter(); try { BinaryWriter binaryWriter2 = binaryWriter.BinaryWriter; binaryWriter2.Write((int)data.dir); binaryWriter2.Write(data.beltId); binaryWriter2.Write(data.storageIdx); binaryWriter2.Write(data.counter); SlotData = binaryWriter.CloseAndGetBytes(); } finally { ((IDisposable)binaryWriter)?.Dispose(); } } internal static void Sync(int planetId, int slotId, int entityId, SlotData slotData) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (NebulaModAPI.IsMultiplayerActive) { NebulaModAPI.MultiplayerSession.Network.SendPacket(new SyncSlotData(planetId, slotId, entityId, slotData)); } } internal static void OnReceive(int planetId, int slotId, int entityId, byte[] data) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_007d: Unknown result type (might be due to invalid IL or missing references) IReaderProvider binaryReader = NebulaModAPI.GetBinaryReader(data); SlotData slotData; try { using BinaryReader binaryReader2 = binaryReader.BinaryReader; SlotData val = default(SlotData); val.dir = (IODir)binaryReader2.ReadInt32(); val.beltId = binaryReader2.ReadInt32(); val.storageIdx = binaryReader2.ReadInt32(); val.counter = binaryReader2.ReadInt32(); slotData = val; binaryReader.BinaryReader.Close(); } finally { ((IDisposable)binaryReader)?.Dispose(); } MegaAssemblerPatches.SyncSlot((planetId, entityId), slotId, slotData); } } [RegisterPacketProcessor] public class SyncSlotDataProcessor : BasePacketProcessor { public override void ProcessPacket(SyncSlotData packet, INebulaConnection conn) { SyncSlotData.OnReceive(packet.PlanetId, packet.SlotId, packet.EntityId, packet.SlotData); } } public class SyncPlanetFocusData { public int PlanetId { get; set; } public int Index { get; set; } public int FocusId { get; set; } public SyncPlanetFocusData() { } public SyncPlanetFocusData(int planetId, int index, int focusId) { PlanetId = planetId; Index = index; FocusId = focusId; } internal static void Sync(int planetId, int index, int focusId) { if (NebulaModAPI.IsMultiplayerActive) { NebulaModAPI.MultiplayerSession.Network.SendPacket(new SyncPlanetFocusData(planetId, index, focusId)); } } internal static void OnReceive(int planetId, int index, int focusId) { PlanetFocusPatches.SyncPlanetFocus(planetId, index, focusId); } } [RegisterPacketProcessor] public class SyncPlanetFocusDataProcessor : BasePacketProcessor { public override void ProcessPacket(SyncPlanetFocusData packet, INebulaConnection conn) { SyncPlanetFocusData.OnReceive(packet.PlanetId, packet.Index, packet.FocusId); } } public class SyncNewQuantumStorageData { public int PlanetId { get; set; } public int StorageId { get; set; } public int OrbitId { get; set; } public SyncNewQuantumStorageData() { } public SyncNewQuantumStorageData(int planetId, int storageId, int orbitId) { PlanetId = planetId; StorageId = storageId; OrbitId = orbitId; } internal static void Sync(int planetId, int storageId, int orbitId) { if (NebulaModAPI.IsMultiplayerActive) { NebulaModAPI.MultiplayerSession.Network.SendPacket(new SyncNewQuantumStorageData(planetId, storageId, orbitId)); } } internal static void OnReceive(int planetId, int storageId, int orbitId) { QuantumStoragePatches.SyncNewQuantumStorage(planetId, storageId, orbitId); } } [RegisterPacketProcessor] public class SyncNewQuantumStorageDataProcessor : BasePacketProcessor { public override void ProcessPacket(SyncNewQuantumStorageData packet, INebulaConnection conn) { SyncNewQuantumStorageData.OnReceive(packet.PlanetId, packet.StorageId, packet.OrbitId); } } public class SyncRemoveQuantumStorageData { public int PlanetId { get; set; } public int StorageId { get; set; } public int OrbitId { get; set; } public SyncRemoveQuantumStorageData() { } public SyncRemoveQuantumStorageData(int planetId, int storageId, int orbitId) { PlanetId = planetId; StorageId = storageId; OrbitId = orbitId; } internal static void Sync(int planetId, int storageId, int orbitId) { if (NebulaModAPI.IsMultiplayerActive) { NebulaModAPI.MultiplayerSession.Network.SendPacket(new SyncRemoveQuantumStorageData(planetId, storageId, orbitId)); } } internal static void OnReceive(int planetId, int storageId, int orbitId) { QuantumStoragePatches.SyncRemoveQuantumStorage(planetId, storageId, orbitId); } } [RegisterPacketProcessor] public class SyncRemoveQuantumStorageDataProcessor : BasePacketProcessor { public override void ProcessPacket(SyncRemoveQuantumStorageData packet, INebulaConnection conn) { SyncRemoveQuantumStorageData.OnReceive(packet.PlanetId, packet.StorageId, packet.OrbitId); } } public class SyncQuantumStorageOrbitChangeData { public int PlanetId { get; set; } public int StorageId { get; set; } public int OrbitId { get; set; } public SyncQuantumStorageOrbitChangeData() { } public SyncQuantumStorageOrbitChangeData(int planetId, int storageId, int orbitId) { PlanetId = planetId; StorageId = storageId; OrbitId = orbitId; } internal static void Sync(int planetId, int storageId, int orbitId) { if (NebulaModAPI.IsMultiplayerActive) { NebulaModAPI.MultiplayerSession.Network.SendPacket(new SyncQuantumStorageOrbitChangeData(planetId, storageId, orbitId)); } } internal static void OnReceive(int planetId, int storageId, int orbitId) { QuantumStoragePatches.SyncQuantumStorageOrbitChange(planetId, storageId, orbitId); } } [RegisterPacketProcessor] public class SyncQuantumStorageOrbitChangeDataProcessor : BasePacketProcessor { public override void ProcessPacket(SyncQuantumStorageOrbitChangeData packet, INebulaConnection conn) { SyncQuantumStorageOrbitChangeData.OnReceive(packet.PlanetId, packet.StorageId, packet.OrbitId); } } public class SyncGlobalPowerSupplyNodeIdData { public int PlanetId { get; set; } public int NodeId { get; set; } public SyncGlobalPowerSupplyNodeIdData() { } public SyncGlobalPowerSupplyNodeIdData(int planetId, int nodeId) { PlanetId = planetId; NodeId = nodeId; } internal static void Sync(int planetId, int nodeId) { if (NebulaModAPI.IsMultiplayerActive) { NebulaModAPI.MultiplayerSession.Network.SendPacket(new SyncGlobalPowerSupplyNodeIdData(planetId, nodeId)); } } internal static void OnReceive(int planetId, int nodeId) { GlobalPowerSupplyPatches.SyncGlobalPowerSupplyNodeId(planetId, nodeId); } } [RegisterPacketProcessor] public class SyncGlobalPowerSupplyNodeIdDataProcessor : BasePacketProcessor { public override void ProcessPacket(SyncGlobalPowerSupplyNodeIdData packet, INebulaConnection conn) { SyncGlobalPowerSupplyNodeIdData.OnReceive(packet.PlanetId, packet.NodeId); } } public class SyncSyncGlobalPowerSupplyRemoveData { public int PlanetId { get; set; } public SyncSyncGlobalPowerSupplyRemoveData() { } public SyncSyncGlobalPowerSupplyRemoveData(int planetId) { PlanetId = planetId; } internal static void Sync(int planetId) { if (NebulaModAPI.IsMultiplayerActive) { NebulaModAPI.MultiplayerSession.Network.SendPacket(new SyncSyncGlobalPowerSupplyRemoveData(planetId)); } } internal static void OnReceive(int planetId) { GlobalPowerSupplyPatches.SyncGlobalPowerSupplyRemoved(planetId); } } [RegisterPacketProcessor] public class SyncSyncGlobalPowerSupplyRemoveDataProcessor : BasePacketProcessor { public override void ProcessPacket(SyncSyncGlobalPowerSupplyRemoveData packet, INebulaConnection conn) { SyncSyncGlobalPowerSupplyRemoveData.OnReceive(packet.PlanetId); } } public class OrbitalRingPlanetLoadRequest { public int PlanetId { get; set; } public OrbitalRingPlanetLoadRequest() { } public OrbitalRingPlanetLoadRequest(int planetId) { PlanetId = planetId; } } [RegisterPacketProcessor] public class OrbitalRingPlanetLoadRequestProcessor : BasePacketProcessor { public override void ProcessPacket(OrbitalRingPlanetLoadRequest packet, INebulaConnection conn) { if (!base.IsClient) { IWriterProvider binaryWriter = NebulaModAPI.GetBinaryWriter(); byte[] data; try { MegaAssemblerPatches.ExportPlanetData(packet.PlanetId, binaryWriter.BinaryWriter); PlanetFocusPatches.ExportPlanetFocus(packet.PlanetId, binaryWriter.BinaryWriter); QuantumStoragePatches.ExportPlanetQuantumStorage(packet.PlanetId, binaryWriter.BinaryWriter); data = binaryWriter.CloseAndGetBytes(); } finally { ((IDisposable)binaryWriter)?.Dispose(); } conn.SendPacket(new OrbitalRingPlanetData(packet.PlanetId, data)); } } } public class OrbitalRingPlanetData { public int PlanetId { get; set; } public byte[] BinaryData { get; set; } public OrbitalRingPlanetData() { } public OrbitalRingPlanetData(int id, byte[] data) { PlanetId = id; BinaryData = data; } } [RegisterPacketProcessor] public class OrbitalRingPlanetDataProcessor : BasePacketProcessor { internal static readonly Dictionary PendingData = new Dictionary(); public override void ProcessPacket(OrbitalRingPlanetData packet, INebulaConnection conn) { if (!base.IsHost) { PendingData.Add(packet.PlanetId, packet.BinaryData); } } public static void ProcessBytesLater(int planetId) { if (!NebulaModAPI.IsMultiplayerActive || NebulaModAPI.MultiplayerSession.LocalPlayer.IsHost || !PendingData.Remove(planetId, out var value)) { return; } IReaderProvider binaryReader = NebulaModAPI.GetBinaryReader(value); try { MegaAssemblerPatches.ImportPlanetData(binaryReader.BinaryReader); PlanetFocusPatches.ImportPlanetFocus(binaryReader.BinaryReader); QuantumStoragePatches.ImportPlanetQuantumStorage(binaryReader.BinaryReader); } finally { ((IDisposable)binaryReader)?.Dispose(); } } } internal static class PlanetThemeUtils { private sealed class CachedPlanetThemeValue { internal int VanillaThemeId { get; } internal CachedPlanetThemeValue(int vanillaThemeId) { VanillaThemeId = vanillaThemeId; } } private const string GS2_GUID = "dsp.galactic-scale.2"; private static readonly Dictionary ThemeNameToVanillaThemeId = new Dictionary { ["Mediterranean"] = 1, ["AshenGelisol"] = 1, ["GasGiant"] = 2, ["GasGiant2"] = 3, ["GasGiant3"] = 2, ["GasGiant4"] = 3, ["IceGiant"] = 4, ["IceGiant2"] = 5, ["IceGiant3"] = 4, ["IceGiant4"] = 5, ["AridDesert"] = 6, ["AridDesert2"] = 6, ["OceanicJungle"] = 8, ["Lava"] = 9, ["IceGelisol"] = 10, ["IceGelisol2"] = 10, ["IceGelisol3"] = 10, ["Barren"] = 11, ["Gobi"] = 12, ["VolcanicAsh"] = 13, ["RedStone"] = 14, ["Prairie"] = 15, ["OceanWorld"] = 16, ["SaltLake"] = 17, ["Sakura"] = 18, ["Hurricane"] = 19, ["IceLake"] = 20, ["GasGiant5"] = 21, ["Savanna"] = 22, ["CrystalDesert"] = 23, ["FrozenTundra"] = 24, ["PandoraSwamp"] = 25, ["PandoraSwamp2"] = 25 }; private static readonly ConcurrentDictionary ResolvedThemeNameCache = new ConcurrentDictionary(); private static readonly ConditionalWeakTable CachedPlanetVanillaThemeIds = new ConditionalWeakTable(); private static readonly object GS2ReflectionLock = new object(); private static readonly BindingFlags AnyStatic = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; private static readonly BindingFlags AnyInstance = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static bool GS2ReflectionInitialized; private static bool GS2ReflectionAvailable; private static MethodInfo GS2GetGSPlanetMethod; private static MemberInfo GSPlanetThemeMember; private static MemberInfo GSPlanetGsThemeMember; private static MemberInfo GSThemeNameMember; private static MemberInfo GSThemeBaseNameMember; private static MemberInfo GSThemeLdbThemeIdMember; private static MemberInfo GSSettingsThemeLibraryMember; internal static int GetVanillaThemeId(PlanetData planet) { if (planet == null) { return 0; } if (!Chainloader.PluginInfos.ContainsKey("dsp.galactic-scale.2")) { return planet.theme; } if (CachedPlanetVanillaThemeIds.TryGetValue(planet, out var value)) { return value.VanillaThemeId; } try { int? vanillaThemeId = GetVanillaThemeIdFromGS2(planet); if (vanillaThemeId.HasValue) { CachedPlanetVanillaThemeIds.GetValue(planet, (PlanetData _) => new CachedPlanetThemeValue(vanillaThemeId.Value)); return vanillaThemeId.Value; } } catch { } return planet.theme; } internal static string GetThemeDebugInfo(PlanetData planet) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (planet == null) { return "planet="; } string gsThemeName = null; string gsBaseName = null; int gsThemeLdbThemeId = -1; string text = null; if (Chainloader.PluginInfos.ContainsKey("dsp.galactic-scale.2")) { try { FillThemeDebugInfoFromGS2(planet, out gsThemeName, out gsBaseName, out gsThemeLdbThemeId); } catch (Exception ex) { text = ex.GetType().Name + ": " + ex.Message; } } return string.Format("planetId={0}, displayName={1}, planet.theme={2}, planet.type={3}, gsTheme={4}, gsBase={5}, gsTheme.LDBThemeId={6}, resolvedVanillaTheme={7}{8}", planet.id, planet.displayName, planet.theme, planet.type, gsThemeName ?? "", gsBaseName ?? "", gsThemeLdbThemeId, GetVanillaThemeId(planet), string.IsNullOrEmpty(text) ? string.Empty : (", gsError=" + text)); } private static int? GetVanillaThemeIdFromGS2(PlanetData planet) { if (!EnsureGS2Reflection()) { return null; } object obj = InvokeGS2GetGSPlanet(planet); if (obj == null) { return null; } string memberValue = GetMemberValue(obj, GSPlanetThemeMember); if (TryResolveVanillaThemeIdFromGS2(memberValue, out var vanillaThemeId)) { return vanillaThemeId; } return null; } private static void FillThemeDebugInfoFromGS2(PlanetData planet, out string gsThemeName, out string gsBaseName, out int gsThemeLdbThemeId) { gsThemeName = null; gsBaseName = null; gsThemeLdbThemeId = -1; if (!EnsureGS2Reflection()) { return; } object obj = InvokeGS2GetGSPlanet(planet); if (obj == null) { return; } gsThemeName = GetMemberValue(obj, GSPlanetThemeMember); object memberValue = GetMemberValue(obj, GSPlanetGsThemeMember); if (memberValue != null) { gsBaseName = GetMemberValue(memberValue, GSThemeBaseNameMember); int? memberValue2 = GetMemberValue(memberValue, GSThemeLdbThemeIdMember); if (memberValue2.HasValue) { gsThemeLdbThemeId = memberValue2.Value; } } } private static bool TryResolveVanillaThemeIdFromGS2(string themeName, out int vanillaThemeId) { vanillaThemeId = 0; if (string.IsNullOrEmpty(themeName)) { return false; } if (ResolvedThemeNameCache.TryGetValue(themeName, out var value)) { if (value.HasValue) { vanillaThemeId = value.Value; return true; } return false; } IDictionary gS2ThemeLibrary = GetGS2ThemeLibrary(); bool flag = TryResolveVanillaThemeIdFromGS2(themeName, new HashSet(), gS2ThemeLibrary, out vanillaThemeId); ResolvedThemeNameCache[themeName] = (flag ? new int?(vanillaThemeId) : null); return flag; } private static bool TryResolveVanillaThemeIdFromGS2(string themeName, HashSet visited, IDictionary themeLibrary, out int vanillaThemeId) { vanillaThemeId = 0; if (string.IsNullOrEmpty(themeName)) { return false; } if (!visited.Add(themeName)) { return false; } if (ThemeNameToVanillaThemeId.TryGetValue(themeName, out vanillaThemeId)) { return true; } if (TryResolveSmolThemeIdFromGS2(themeName, visited, themeLibrary, out vanillaThemeId)) { return true; } if (themeLibrary == null || !themeLibrary.Contains(themeName)) { return false; } object obj = themeLibrary[themeName]; if (obj == null) { return false; } string memberValue = GetMemberValue(obj, GSThemeNameMember); if (!string.IsNullOrEmpty(memberValue) && ThemeNameToVanillaThemeId.TryGetValue(memberValue, out vanillaThemeId)) { return true; } if (!string.IsNullOrEmpty(memberValue) && TryResolveSmolThemeIdFromGS2(memberValue, visited, themeLibrary, out vanillaThemeId)) { return true; } string memberValue2 = GetMemberValue(obj, GSThemeBaseNameMember); if (!string.IsNullOrEmpty(memberValue2)) { return TryResolveVanillaThemeIdFromGS2(memberValue2, visited, themeLibrary, out vanillaThemeId); } return false; } private static bool TryResolveSmolThemeIdFromGS2(string themeName, HashSet visited, IDictionary themeLibrary, out int vanillaThemeId) { vanillaThemeId = 0; if (string.IsNullOrEmpty(themeName)) { return false; } if (!themeName.EndsWith("smol", StringComparison.Ordinal)) { return false; } if (themeName.Length <= 4) { return false; } string text = themeName.Substring(0, themeName.Length - 4); if (string.IsNullOrEmpty(text)) { return false; } if (ThemeNameToVanillaThemeId.TryGetValue(text, out vanillaThemeId)) { return true; } return TryResolveVanillaThemeIdFromGS2(text, visited, themeLibrary, out vanillaThemeId); } private static IDictionary GetGS2ThemeLibrary() { if (!EnsureGS2Reflection()) { return null; } return GetStaticMemberValue(GSSettingsThemeLibraryMember) as IDictionary; } private static bool EnsureGS2Reflection() { if (GS2ReflectionInitialized) { return GS2ReflectionAvailable; } lock (GS2ReflectionLock) { if (GS2ReflectionInitialized) { return GS2ReflectionAvailable; } GS2ReflectionAvailable = InitializeGS2Reflection(); GS2ReflectionInitialized = true; return GS2ReflectionAvailable; } } private static bool InitializeGS2Reflection() { if (!Chainloader.PluginInfos.TryGetValue("dsp.galactic-scale.2", out var value)) { return false; } Assembly assembly = ((object)value.Instance).GetType().Assembly; Type type = assembly.GetType("GalacticScale.GS2"); Type type2 = assembly.GetType("GalacticScale.GSPlanet"); Type type3 = assembly.GetType("GalacticScale.GSTheme"); Type type4 = assembly.GetType("GalacticScale.GSSettings"); if (type == null || type2 == null || type3 == null || type4 == null) { return false; } GS2GetGSPlanetMethod = FindStaticMethod(type, "GetGSPlanet", typeof(PlanetData)); GSPlanetThemeMember = FindMember(type2, "Theme", isStatic: false); GSPlanetGsThemeMember = FindMember(type2, "GsTheme", isStatic: false); GSThemeNameMember = FindMember(type3, "Name", isStatic: false); GSThemeBaseNameMember = FindMember(type3, "BaseName", isStatic: false); GSThemeLdbThemeIdMember = FindMember(type3, "LDBThemeId", isStatic: false); GSSettingsThemeLibraryMember = FindMember(type4, "ThemeLibrary", isStatic: true); return GS2GetGSPlanetMethod != null && GSPlanetThemeMember != null && GSPlanetGsThemeMember != null && GSThemeNameMember != null && GSThemeBaseNameMember != null && GSThemeLdbThemeIdMember != null && GSSettingsThemeLibraryMember != null; } private static MethodInfo FindStaticMethod(Type type, string name, Type parameterType) { MethodInfo[] methods = type.GetMethods(AnyStatic); foreach (MethodInfo methodInfo in methods) { if (!(methodInfo.Name != name)) { ParameterInfo[] parameters = methodInfo.GetParameters(); if (parameters.Length == 1 && !(parameters[0].ParameterType != parameterType)) { return methodInfo; } } } return null; } private static MemberInfo FindMember(Type type, string name, bool isStatic) { BindingFlags bindingAttr = (isStatic ? AnyStatic : AnyInstance); PropertyInfo property = type.GetProperty(name, bindingAttr); if (property != null && property.GetGetMethod(nonPublic: true) != null) { return property; } FieldInfo field = type.GetField(name, bindingAttr); if (field != null) { return field; } return null; } private static object InvokeGS2GetGSPlanet(PlanetData planet) { if (GS2GetGSPlanetMethod == null) { return null; } return GS2GetGSPlanetMethod.Invoke(null, new object[1] { planet }); } private static T GetMemberValue(object instance, MemberInfo member) { if (instance == null || member == null) { return default(T); } object obj = null; if (member is PropertyInfo propertyInfo) { obj = propertyInfo.GetValue(instance, null); } else if (member is FieldInfo fieldInfo) { obj = fieldInfo.GetValue(instance); } if (obj == null) { return default(T); } if (obj is T result) { return result; } Type conversionType = Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T); return (T)Convert.ChangeType(obj, conversionType); } private static T GetStaticMemberValue(MemberInfo member) { if (member == null) { return default(T); } object obj = null; if (member is PropertyInfo propertyInfo) { obj = propertyInfo.GetValue(null, null); } else if (member is FieldInfo fieldInfo) { obj = fieldInfo.GetValue(null); } if (obj == null) { return default(T); } if (obj is T result) { return result; } Type conversionType = Nullable.GetUnderlyingType(typeof(T)) ?? typeof(T); return (T)Convert.ChangeType(obj, conversionType); } } internal static class ProtoID { internal const int I水 = 1000; internal const int I原油 = 1007; internal const int I单极磁石 = 1016; internal const int I沙土 = 1099; internal const int I铁块 = 1101; internal const int I铜块 = 1104; internal const int I可燃冰 = 1011; internal const int I重油 = 1114; internal const int I氢 = 1120; internal const int I重氢 = 1121; internal const int I反物质 = 1122; internal const int I增产剂 = 1143; internal const int I超合金弹箱 = 1603; internal const int I氘核轨道弹 = 1607; internal const int I氢燃料棒 = 1801; internal const int I氘核燃料棒 = 1802; internal const int I反物质燃料棒 = 1803; internal const int I奇异燃料棒 = 1804; internal const int I物流立交 = 2103; internal const int I太空物流港 = 2104; internal const int I轨道采集器 = 2105; internal const int I满蓄电器mk2 = 2207; internal const int I量子化工厂 = 2317; internal const int I物质重组工厂 = 2318; internal const int I负熵熔炉 = 2319; internal const int I重型电浆炮 = 3004; internal const int I太空运输船 = 5002; internal const int I黑雾矩阵 = 5201; internal const int I负熵奇点 = 5204; internal const int I能量碎片 = 5206; internal const int I电气矩阵 = 6001; internal const int I能量矩阵 = 6002; internal const int I结构矩阵 = 6003; internal const int I粒子矩阵 = 6004; internal const int I引力矩阵 = 6005; internal const int I宇宙矩阵 = 6006; internal const int I钨矿 = 6201; internal const int I深层熔岩 = 6202; internal const int I熔融金属 = 6203; internal const int I甲烷 = 6205; internal const int I二氧化碳 = 6206; internal const int I硫磺矿 = 6207; internal const int I激素生长菌群 = 6208; internal const int I高速生长菌群 = 6212; internal const int I朗基努斯之枪 = 6213; internal const int I黑盒 = 6215; internal const int I四氢双环戊二烯燃料棒 = 6216; internal const int I化学燃料罐 = 6217; internal const int I蓄电器mk1 = 6218; internal const int I满蓄电器mk1 = 6219; internal const int I损伤定义护盾 = 6220; internal const int I放射性矿物 = 6222; internal const int I无尽水罐 = 6223; internal const int I量子储物仓 = 6231; internal const int I文明遗物 = 6234; internal const int I空轨 = 6235; internal const int I钚燃料棒 = 6241; internal const int I铀燃料棒 = 6242; internal const int IMOX燃料棒 = 6243; internal const int I奇夸克样本 = 6244; internal const int I菌丝母株 = 6245; internal const int I岩浆 = 6251; internal const int I大型神经网络 = 6252; internal const int I湿件主机 = 6253; internal const int I生态温室 = 6254; internal const int I太空船坞 = 6257; internal const int I太空电梯 = 6258; internal const int I天枢座 = 6259; internal const int ISCP310恒燃之火 = 6260; internal const int I轨道反物质堆核心 = 6261; internal const int I轨道水培舱 = 6264; internal const int I星环对撞机 = 6265; internal const int I深空物流港 = 6267; internal const int I轨道观测站 = 6273; internal const int I信息矩阵 = 6278; internal const int I电磁矩阵 = 6279; internal const int I奇点矩阵 = 6280; internal const int I超空间中继器基座 = 6281; internal const int I燃油燃料棒 = 6217; internal const int I深空货舰 = 6230; internal const int I轨道熔炼站 = 6501; internal const int I轨道反物质堆基座 = 6506; internal const int I空燃料棒 = 6509; internal const int I超空间中继器核心 = 6511; internal const int I重型电磁弹射器 = 6513; internal const int I轨道空投引导站 = 6514; internal const int I轨道连接组件 = 6515; internal const int I粒子加速轨道 = 6516; internal const int I星环电网组件 = 6517; internal const int I星环护盾组件 = 6518; internal const int I气云 = 6519; internal const int I量子虚拟生命 = 6530; internal const int I黑萝卜 = 6531; internal const int I欺骗型广播塔 = 6533; internal const int I氨 = 7002; internal const int I盐酸 = 7014; internal const int I硝酸 = 7017; internal const int I海水 = 7018; internal const int I氧 = 7019; internal const int I种子 = 7021; internal const int I钢芯弹箱 = 7607; internal const int I零素矢 = 7609; internal const int I伺服天穹组件 = 7619; internal const int I智能方尖碑 = 7620; internal const int I亿万械国 = 7621; internal const int I钨块 = 7705; internal const int I石墨矿 = 7706; internal const int I突触凝练机 = 7803; internal const int I乾坤 = 7806; internal const int I乾坤铁 = 7807; internal const int I低温工厂 = 7823; internal const int I组装厂交互塔 = 9512; internal const int R等离子精炼 = 16; internal const int R高效石墨烯 = 32; internal const int R硅石筛选 = 34; internal const int R氦原子提取 = 107; internal const int R增产剂 = 108; internal const int R放射性矿物处理 = 401; internal const int R铀235提纯 = 405; internal const int R物质分解 = 429; internal const int R纳米塑料纤维 = 506; internal const int R催化重整 = 509; internal const int R四氢双环戊二烯 = 512; internal const int R二氧化硫还原 = 548; internal const int R有机晶体活化 = 549; internal const int R有机晶体重组 = 550; internal const int R水电解 = 702; internal const int R盐水电解 = 703; internal const int R合成氨 = 710; internal const int R三氯化铁 = 716; internal const int R氨氧化 = 717; internal const int R羰基合成 = 720; internal const int R聚苯硫醚 = 771; internal const int R聚酰亚胺 = 772; internal const int R钨矿筛选 = 773; internal const int R海水淡化 = 801; internal const int M物流立交 = 49; internal const int M太空物流港 = 50; internal const int M矩阵研究站 = 70; internal const int M射线接收站 = 73; internal const int M负熵熔炉 = 457; internal const int M行星基地 = 292; internal const int M强袭者营地 = 293; internal const int M游骑兵营地 = 294; internal const int M守卫者营地 = 295; internal const int M高能激光塔 = 296; internal const int M等离子哨戒塔 = 297; internal const int M等离子护盾 = 298; internal const int M导轨 = 299; internal const int M强袭者 = 300; internal const int M游骑兵 = 301; internal const int M守卫者 = 302; internal const int M高频激光塔 = 373; internal const int M量子化工厂 = 376; internal const int M自演化研究站 = 455; internal const int M轨道熔炼站 = 801; internal const int M超空间中继器 = 802; internal const int M太空船坞 = 803; internal const int M轨道观测站 = 804; internal const int M太空电梯 = 805; internal const int M深空物流港 = 806; internal const int M轨道反物质堆核心 = 807; internal const int M勘察卫星 = 808; internal const int M同位素温差发电机 = 809; internal const int M轨道水培舱 = 810; internal const int M星环对撞机 = 811; internal const int M蓄电器 = 812; internal const int M启示录聚变弹 = 813; internal const int M轨道反物质堆基座 = 814; internal const int M聚爆加农炮MK2 = 815; internal const int M高频激光塔MK2 = 816; internal const int M战术核导弹 = 817; internal const int M反物质炮弹 = 818; internal const int M深空货舰 = 819; internal const int M天枢座 = 820; internal const int M超空间中继器核心 = 821; internal const int M轨道弹射器 = 822; internal const int M轨道空投站 = 823; internal const int M轨道连接组件 = 824; internal const int M粒子加速轨道 = 825; internal const int M星环电网组件 = 826; internal const int M星环护盾组件 = 827; internal const int M黑盒 = 828; internal const int M空轨 = 829; internal const int M伺服天穹组件 = 830; internal const int M智能方尖碑 = 831; internal const int M亿万械国 = 832; internal const int MSCP310恒燃之火 = 833; internal const int M突触凝练机 = 834; internal const int M生态温室 = 835; internal const int M低温工厂 = 836; internal const int M朗基努斯之枪 = 837; internal const int M欺骗型广播塔 = 838; internal const int M无尽水罐 = 839; internal const int T戴森球计划 = 1; internal const int T电磁学 = 1001; internal const int T流体储存封装 = 1120; internal const int T物品增产 = 1151; internal const int T跃迁航行理论 = 1152; internal const int T工业化生产 = 1415; internal const int T物品仓储 = 1607; internal const int T电磁驱动 = 1701; internal const int T武器系统 = 1801; internal const int T科学理论 = 1900; internal const int T坐标引擎 = 1934; internal const int T行星协调中心 = 1936; internal const int T护盾载波调制 = 1937; internal const int T基础机械组件 = 1941; internal const int T黑雾协调中心 = 1960; internal const int T机甲核心6 = 2106; internal const int T能量回路4 = 2504; internal const int T批量建造1 = 2701; internal const int T批量建造2 = 2702; internal const int T批量建造3 = 2703; internal const int T驱动引擎2 = 2902; internal const int T驱动引擎3 = 2903; internal const int T驱动引擎4 = 2904; internal const int T驱动引擎5 = 2905; internal const int T集装分拣6 = 3316; internal const int T垂直建造3 = 3703; internal const int T垂直建造6 = 3706; internal const int T宇宙探索1 = 4101; internal const int T宇宙探索2 = 4102; internal const int T宇宙探索3 = 4103; internal const int T宇宙探索4 = 4104; } internal static class RandomUtils { public static uint randSeed = (uint)new Random().Next(1, 2147483646); public static double GetRandDouble(ref uint seed) { seed = (uint)((int)((ulong)((long)(seed % 2147483646 + 1) * 48271L) % 2147483647uL) - 1); return (double)seed / 2147483646.0; } public static int GetRandInt(int min, int max) { randSeed = (uint)((int)((ulong)((long)(randSeed % 2147483646 + 1) * 48271L) % 2147483647uL) - 1); double num = (double)randSeed / 2147483646.0; return (int)(num * (double)(max - min)) + min; } public static double GetRandDouble() { randSeed = (uint)((int)((ulong)((long)(randSeed % 2147483646 + 1) * 48271L) % 2147483647uL) - 1); return (double)randSeed / 2147483646.0; } } internal static class TextureHelper { private static readonly Assembly Assembly = Assembly.GetExecutingAssembly(); private static readonly Dictionary Cache = new Dictionary(); internal static Texture2D GetTexture(string name, string type = "texture") { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown if (Cache.TryGetValue(name, out var value)) { return value; } using Stream stream = Assembly.GetManifestResourceStream("ProjectOrbitalRing.assets." + type + "." + name + ".png"); if (stream == null) { ProjectOrbitalRing.LogInfo("Could not find texture for " + name); return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); byte[] array = memoryStream.ToArray(); Texture2D val = new Texture2D(2, 2); if (!ImageConversion.LoadImage(val, array)) { return null; } ((Object)val).name = name; Cache[name] = val; return val; } internal static Sprite GetSprite(string name, int? width = null, int? height = null) { //IL_0062: 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) if (!Cache.TryGetValue(name, out var value)) { value = GetTexture(name, "sprite"); } return Sprite.Create(value, new Rect(0f, 0f, (float)(width ?? ((Texture)value).width), (float)(height ?? ((Texture)value).height)), new Vector2(0.5f, 0.5f)); } } internal static class TranslateUtils { private static readonly Dictionary StringProtoJsons; private static readonly Dictionary StringModProtoJsons; private static readonly bool IsSystemZHCN; static TranslateUtils() { //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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Invalid comparison between Unknown and I4 //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Invalid comparison between Unknown and I4 StringProtoJsons = JsonHelper.GetJsonContent("strings").ToDictionary((JsonHelper.StringProtoJson i) => i.Name); StringModProtoJsons = JsonHelper.GetJsonContent("strings_mod").ToDictionary((JsonHelper.StringProtoJson i) => i.Name); int @int = PlayerPrefs.GetInt("language", 0); if (@int > 2) { IsSystemZHCN = @int == 2052; return; } SystemLanguage systemLanguage = Application.systemLanguage; SystemLanguage val = systemLanguage; if ((int)val == 6 || val - 40 <= 1) { IsSystemZHCN = true; } } internal static void RegisterStrings() { foreach (var (text2, stringProtoJson2) in StringProtoJsons) { LocalizationModule.RegisterTranslation(text2, stringProtoJson2.ENUS, stringProtoJson2.ZHCN, ""); } } public static string TranslateFromJsonSpecial(this string s) { if (string.IsNullOrWhiteSpace(s)) { return ""; } if (!StringModProtoJsons.TryGetValue(s, out var value) && !StringProtoJsons.TryGetValue(s, out value)) { return s; } return IsSystemZHCN ? value.ZHCN : value.ENUS; } public static string TranslateFromJson(this string s) { if (string.IsNullOrWhiteSpace(s)) { return ""; } if (!StringModProtoJsons.TryGetValue(s, out var value) && !StringProtoJsons.TryGetValue(s, out value)) { return s; } return Localization.isZHCN ? value.ZHCN : value.ENUS; } } public static class TranspilerLogUtils { public static void LogInstructionEnumeration(this CodeMatcher matcher) { foreach (CodeInstruction item in matcher.InstructionEnumeration()) { ProjectOrbitalRing.logger.LogInfo((object)((object)item).ToString()); } } public static void LogInstructionEnumerationWhenChecking(this CodeMatcher matcher) { foreach (CodeInstruction item in matcher.InstructionEnumeration()) { InstallationCheckPlugin.logger.LogInfo((object)((object)item).ToString()); } } } } namespace ProjectOrbitalRing.Patches { public static class DysonSpherePatches { [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyTranspiler] public static IEnumerable DysonFrame_segCount_Transpiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_2, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null) }); val.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop, (object)null)); return val.InstructionEnumeration(); } [HarmonyPatch(typeof(DysonShell), "GenerateGeometry")] [HarmonyPatch(typeof(DysonShell), "Import")] [HarmonyTranspiler] public static IEnumerable DysonShell_cpPerVertex_Transpiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_2, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(DysonShell), "cpPerVertex"), (string)null) }); val.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Ldc_I4_1, (object)null)).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Div, (object)null)); return val.InstructionEnumeration(); } [HarmonyPatch(typeof(DysonSphere), "Init")] [HarmonyTranspiler] public static IEnumerable DysonSphere_Init_Transpiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Expected O, but got Unknown //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Expected O, but got Unknown //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(DysonSphere), "energyGenPerSail"), (string)null) }); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldc_I4, (object)10), new CodeInstruction(OpCodes.Conv_I8, (object)null), new CodeInstruction(OpCodes.Mul, (object)null) }); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(DysonSphere), "energyGenPerNode"), (string)null) }); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldc_I4_2, (object)null), new CodeInstruction(OpCodes.Conv_I8, (object)null), new CodeInstruction(OpCodes.Mul, (object)null) }); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(DysonSphere), "energyGenPerFrame"), (string)null) }); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldc_I4_2, (object)null), new CodeInstruction(OpCodes.Conv_I8, (object)null), new CodeInstruction(OpCodes.Mul, (object)null) }); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(DysonSphere), "energyGenPerShell"), (string)null) }); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldc_I4, (object)10), new CodeInstruction(OpCodes.Conv_I8, (object)null), new CodeInstruction(OpCodes.Mul, (object)null) }); return val.InstructionEnumeration(); } [HarmonyPatch(typeof(PowerGeneratorComponent), "RequiresCurrent_Gamma")] [HarmonyPatch(typeof(PowerGeneratorComponent), "MaxOutputCurrent_Gamma")] [HarmonyPatch(typeof(PowerGeneratorComponent), "EnergyCap_Gamma_Req")] [HarmonyTranspiler] public static IEnumerable EnergyCap_Gamma_Req_Transpiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)8f, (string)null) }); val.SetOperandAndAdvance((object)1f); return val.InstructionEnumeration(); } } public static class ResourcesPatches { [HarmonyPatch(typeof(Resources), "Load", new Type[] { typeof(string), typeof(Type) })] [HarmonyBefore(new string[] { "dsp.common-api.CommonAPI" })] [HarmonyPrefix] public static bool GetAssemblyManifestResource(ref string path, Type systemTypeInstance, ref Object __result) { if (!path.StartsWith("Assets/texpack/")) { return true; } string name = path.Substring("Assets/texpack/".Length); if (systemTypeInstance == typeof(Texture2D)) { __result = (Object)(object)TextureHelper.GetTexture(name); return __result == (Object)null; } if (systemTypeInstance == typeof(Sprite)) { __result = (Object)(object)TextureHelper.GetSprite(name); return __result == (Object)null; } return true; } } public static class UITutorialWindowPatches { [HarmonyPatch(typeof(UITutorialWindow), "OnTutorialChange")] [HarmonyTranspiler] public static IEnumerable UITutorialWindow_Transpiler(IEnumerable instructions, ILGenerator ilGenerator) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, ilGenerator); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null) }); Label label = default(Label); val.CreateLabelAt(val.Pos, ref label); val.MatchBack(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)AccessTools.Field(typeof(UITutorialWindow), "textFolder"), (string)null) }); Label label2 = default(Label); val.CreateLabelAt(val.Pos, ref label2); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[4] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(UITutorialWindow), "tutorialProto")), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(UITutorialWindowPatches), "IsOrbitalRingLayout", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Brfalse_S, (object)label2) }); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[4] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(UITutorialWindow), "tutorialProto")), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(UITutorialWindowPatches), "GetOrbitalRingLayoutStr", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Br_S, (object)label) }); return val.InstructionEnumeration(); } public static bool IsOrbitalRingLayout(TutorialProto proto) { string layoutFileName = proto.LayoutFileName; return !string.IsNullOrEmpty(layoutFileName) && layoutFileName.StartsWith("orbitalring-tutorials-"); } public static string GetOrbitalRingLayoutStr(TutorialProto proto) { string name = ((Proto)proto).Name; if (!name.EndsWith("标题")) { return string.Empty; } string s = name.Replace("标题", "前字"); return "{$Text|fontsize=16;linespacing=1.1;textalignment=0,1;color=#FFFFFF52;material=UI/Materials/widget-text-alpha-5x-thick;margins=20,20,20,30}\n" + name.TranslateFromJson() + "{$Text|fontsize=14;linespacing=1.1;textalignment=0,1;color=#FFFFFF52;material=UI/Materials/widget-text-alpha-5x-thick;margins=20,20,20,20}\n" + s.TranslateFromJson(); } } } namespace ProjectOrbitalRing.Patches.UI { public static class AdvancedLaserPatches { private static readonly DataPoolRenderer _turretAdvancedLaserContinuous = new DataPoolRenderer(); private static RenderableObjectDesc _combatTurretAdvancedLaserContinuousDesc; private static readonly FieldInfo TurretComponent_projectileId_Field = AccessTools.Field(typeof(TurretComponent), "projectileId"); [HarmonyPatch(typeof(SkillSystem), "Init")] [HarmonyPostfix] public static void SkillSystem_Init() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0077: 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_0091: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_combatTurretAdvancedLaserContinuousDesc)) { RenderableObjectDesc turretLaserContinuousDesc = Configs.combat.turretLaserContinuousDesc; _combatTurretAdvancedLaserContinuousDesc = ((Component)turretLaserContinuousDesc).gameObject.AddComponent(); _combatTurretAdvancedLaserContinuousDesc.gpuWorkType = (EGpuWorkEntry)21; _combatTurretAdvancedLaserContinuousDesc.meshProcedured = turretLaserContinuousDesc.meshProcedured; Material val = new Material(turretLaserContinuousDesc.materials[0]); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.8471f, 0.6078f, 1f); val.SetColor("_BeamColor1", val2); val.SetColor("_MuzzleWaveColor", val2); val.SetColor("_PulseColor", val2); val.SetColor("_ShortWaveColor", val2); ((Color)(ref val2))..ctor(0.6118f, 0f, 1f); val.SetColor("_BeamColor2", val2); ((Color)(ref val2))..ctor(0.7922f, 0.4627f, 1f); val.SetColor("_LongWaveColor", val2); ((Color)(ref val2))..ctor(0.7569f, 0.4078f, 1f); val.SetColor("_MuzzleFlareColor", val2); _combatTurretAdvancedLaserContinuousDesc.materials = (Material[])(object)new Material[1] { val }; } _turretAdvancedLaserContinuous.InitRenderer(_combatTurretAdvancedLaserContinuousDesc); } [HarmonyPatch(typeof(TurretComponent), "StopContinuousSkill")] [HarmonyTranspiler] public static IEnumerable TurretComponent_StopContinuousSkill_Transpiler(IEnumerable instructions, ILGenerator generator) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected O, but got Unknown //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Expected O, but got Unknown //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Expected O, but got Unknown //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, generator); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)TurretComponent_projectileId_Field, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null) }); val.Advance(1).SetOpcodeAndAdvance(OpCodes.Beq_S); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldarg_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(SkillSystem), "turretLaserContinuous"), (string)null) }); Label label = default(Label); val.Advance(1).CreateLabel(ref label); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Br, (object)label) }); val.Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(AdvancedLaserPatches), "Patch_Result_Method", (Type[])null, (Type[])null)) }); Label label2 = default(Label); val.CreateLabel(ref label2); val.Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[5] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)TurretComponent_projectileId_Field), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(AdvancedLaserPatches), "Set_ProjectileId_Method", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Stfld, (object)TurretComponent_projectileId_Field) }); val.Advance(-9).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[4] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)TurretComponent_projectileId_Field), new CodeInstruction(OpCodes.Ldc_I4_0, (object)null), new CodeInstruction(OpCodes.Blt, (object)label2) }); return val.InstructionEnumeration(); } public static int Set_ProjectileId_Method(int index) { return -index; } [HarmonyPatch(typeof(TurretComponent), "InternalUpdate")] [HarmonyTranspiler] public static IEnumerable InternalUpdate_Transpiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)TurretComponent_projectileId_Field, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null) }); val.Advance(1).SetOpcodeAndAdvance(OpCodes.Beq_S); return val.InstructionEnumeration(); } private static bool Patch_Condition_Method(PlanetFactory factory, ref TurretComponent component) { return factory.entityPool[component.entityId].modelIndex == 816; } public static int Patch_ProjectileId_Method(int index, PlanetFactory factory, ref TurretComponent component) { return Patch_Condition_Method(factory, ref component) ? (-index) : index; } public static DataPoolRenderer Patch_Result_Method() { return _turretAdvancedLaserContinuous; } [HarmonyPatch(typeof(SkillSystem), "GameTick")] [HarmonyPostfix] public static void SkillSystem_GameTick(SkillSystem __instance) { PlanetFactory[] factories = __instance.gameData.factories; int cursor = _turretAdvancedLaserContinuous.cursor; LocalLaserContinuous[] buffer = _turretAdvancedLaserContinuous.buffer; for (int i = 1; i < cursor; i++) { if (buffer[i].id == i) { ((LocalLaserContinuous)(ref buffer[i])).TickSkillLogic(__instance, factories); if ((double)buffer[i].fade == 0.0) { _turretAdvancedLaserContinuous.Remove(i); } } } if (_turretAdvancedLaserContinuous.count == 0 && _turretAdvancedLaserContinuous.capacity > 256) { _turretAdvancedLaserContinuous.Flush(); } } [HarmonyPatch(typeof(SkillSystem), "RendererDraw")] [HarmonyPostfix] public static void SkillSystem_RendererDraw(SkillSystem __instance) { if (__instance.gameData.localPlanet != null) { _turretAdvancedLaserContinuous.Render(); } } [HarmonyPatch(typeof(SkillSystem), "Free")] [HarmonyPostfix] public static void SkillSystem_Free() { if (_turretAdvancedLaserContinuous != null) { _turretAdvancedLaserContinuous.FreeRenderer(); } } [HarmonyPatch(typeof(SkillSystem), "SetForNewGame")] [HarmonyPostfix] public static void SkillSystem_SetForNewGame() { ReInitAll(); } [HarmonyPatch(typeof(PlanetFactory), "UpgradeEntityWithComponents")] [HarmonyPostfix] public static void PlanetFactory_UpgradeEntityWithComponents_Postfix(PlanetFactory __instance, int entityId, ItemProto newProto) { if (entityId != 0 && __instance.entityPool[entityId].id != 0) { int turretId = __instance.entityPool[entityId].turretId; if (turretId > 0 && (newProto.ModelIndex == 816 || newProto.ModelIndex == 373)) { PlanetFactory factory = __instance.planet.factory; ((TurretComponent)(ref factory.defenseSystem.turrets.buffer[turretId])).StopContinuousSkill(factory.skillSystem, false); } } } internal static void Import(BinaryReader r) { ReInitAll(); try { _turretAdvancedLaserContinuous.Import(r); } catch (EndOfStreamException) { } } internal static void Export(BinaryWriter w) { lock (_turretAdvancedLaserContinuous) { _turretAdvancedLaserContinuous.Flush(); _turretAdvancedLaserContinuous.Export(w); } } internal static void IntoOtherSave() { ReInitAll(); } private static void ReInitAll() { _turretAdvancedLaserContinuous.ResetPool(); } } public static class ChemicalRecipeFcolPatches { private static readonly Dictionary RecipeIdPos = new Dictionary { { 509, 432 }, { 512, 433 }, { 550, 434 }, { 702, 435 }, { 703, 436 }, { 710, 437 }, { 716, 438 }, { 717, 439 }, { 720, 440 }, { 506, 441 }, { 772, 442 }, { 773, 443 }, { 801, 444 }, { 549, 445 }, { 548, 446 }, { 108, 447 }, { 107, 448 }, { 34, 449 } }; private static readonly Dictionary ItemColors = new Dictionary { { 1117, new Color32((byte)153, (byte)163, (byte)87, byte.MaxValue) }, { 7101, new Color32((byte)244, (byte)244, (byte)244, byte.MaxValue) }, { 1114, new Color32((byte)244, (byte)244, (byte)244, byte.MaxValue) }, { 7020, new Color32((byte)58, (byte)97, (byte)164, byte.MaxValue) }, { 1014, new Color32((byte)229, (byte)153, byte.MaxValue, byte.MaxValue) }, { 1124, new Color32((byte)121, (byte)110, (byte)114, byte.MaxValue) }, { 1123, new Color32((byte)150, (byte)161, (byte)174, byte.MaxValue) }, { 6201, new Color32((byte)54, (byte)54, (byte)54, byte.MaxValue) }, { 7708, new Color32((byte)210, (byte)190, (byte)144, byte.MaxValue) }, { 7709, new Color32((byte)21, (byte)21, (byte)21, byte.MaxValue) }, { 1000, new Color32((byte)165, (byte)198, (byte)208, byte.MaxValue) }, { 1003, new Color32((byte)55, (byte)179, (byte)114, byte.MaxValue) }, { 1004, new Color32((byte)195, (byte)220, (byte)250, byte.MaxValue) }, { 1005, new Color32((byte)137, (byte)145, (byte)165, byte.MaxValue) }, { 1143, new Color32((byte)21, (byte)175, (byte)251, byte.MaxValue) } }; private static readonly Dictionary InputIndexMap = new Dictionary { { 1, new int[1][] { new int[5] { 8, 7, 5, 4, 3 } } }, { 2, new int[2][] { new int[3] { 8, 5, 4 }, new int[2] { 7, 3 } } }, { 3, new int[3][] { new int[2] { 8, 5 }, new int[2] { 7, 4 }, new int[1] { 3 } } } }; [HarmonyPatch(typeof(FactorySystem), "GameTick", new Type[] { typeof(long), typeof(bool) })] [HarmonyTranspiler] public static IEnumerable FactorySystem_GameTick_Transpiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(AssemblerComponent), "recipeType"), (string)null) }); val.Advance(1).SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ChemicalRecipeFcolPatches), "ChemicalRecipeTypePatch", (Type[])null, (Type[])null))).SetOpcodeAndAdvance(OpCodes.Brfalse_S); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(AssemblerComponent), "recipeId"), (string)null), new CodeMatch((OpCode?)OpCodes.Conv_R4, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(AnimData), "working_length"), (string)null) }); val.Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ChemicalRecipeFcolPatches), "ChemicalRecipeFcolPatch", (Type[])null, (Type[])null)) }); return val.InstructionEnumeration(); } private static bool ChemicalRecipeTypePatch(int recipeType) { return recipeType == 2 || recipeType == 16; } private static int ChemicalRecipeFcolPatch(int recipeId) { return CollectionExtensions.GetValueOrDefault((IReadOnlyDictionary)RecipeIdPos, recipeId, recipeId); } internal static void SetChemicalRecipeFcol() { Texture texture = (Texture)(object)TextureHelper.GetTexture("chemical-plant-recipe-fcol"); int num = Shader.PropertyToID("_FluidTex"); ref PrefabDesc prefabDesc = ref ((ProtoSet)(object)LDB.models).Select(64).prefabDesc; prefabDesc.lodMaterials[0][1].SetTexture(num, texture); prefabDesc.lodMaterials[1][1].SetTexture(num, texture); prefabDesc = ref ((ProtoSet)(object)LDB.models).Select(376).prefabDesc; prefabDesc.lodMaterials[0][1].SetTexture(num, texture); prefabDesc.lodMaterials[1][1].SetTexture(num, texture); } private static Color32 GetItemColor(int itemId) { //IL_0012: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (ItemColors.TryGetValue(itemId, out var value)) { return value; } IconDescUtils.ModIconDesc value2; return Color32.op_Implicit(IconDescUtils.IconDescs.TryGetValue(itemId, out value2) ? value2.Color : IconDescUtils.ExportIconDesc(itemId).faceColor); } private static void SetDefaultColors(Texture2D texture, int column) { //IL_0015: 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) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Color element = Color32.op_Implicit(new Color32((byte)165, (byte)198, (byte)208, byte.MaxValue)); Color[] array = Enumerable.Repeat(element, 16).ToArray(); texture.SetPixels(column, 0, 1, 16, array); } private static void ApplyColors(Texture2D texture, int column, Color32 color, int[] positions) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) foreach (int num in positions) { texture.SetPixel(column, num, Color32.op_Implicit(color)); } } private static void ApplyRecipeColors(Texture2D texture, int column, RecipeProto proto) { //IL_000b: 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) ApplyColors(texture, column, GetItemColor(proto.Results[0]), new int[5] { 9, 6, 2, 1, 0 }); if (InputIndexMap.TryGetValue(proto.Items.Length, out var value)) { for (int i = 0; i < value.Length; i++) { ApplyColors(texture, column, GetItemColor(proto.Items[i]), value[i]); } } } internal static void GenerateRecipeTexture(string outputFilePath) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Invalid comparison between Unknown and I4 //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Invalid comparison between Unknown and I4 int[] array = new int[0]; int[] array2 = array.Select((int i) => RecipeIdPos[i]).ToArray(); Texture2D texture = TextureHelper.GetTexture("化工厂渲染索引"); for (int j = 0; j < array.Length; j++) { int column = array2[j]; SetDefaultColors(texture, column); RecipeProto val = ((ProtoSet)(object)LDB.recipes).Select(array[j]); if (val != null && ((int)val.Type == 2 || (int)val.Type == 16)) { ApplyRecipeColors(texture, column, val); } } texture.Apply(); File.WriteAllBytes(outputFilePath, ImageConversion.EncodeToPNG(texture)); } } public static class FactoryModelPatches { } internal static class FluidColorPatches { [HarmonyPatch(typeof(UITankWindow), "_OnUpdate")] [HarmonyPostfix] public static void UITankWindow_OnUpdate(UITankWindow __instance) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) int tankId = __instance.tankId; TankComponent val = __instance.storage.tankPool[tankId]; if (val.id == tankId) { int fluidId = val.fluidId; if (IconDescUtils.IconDescs.TryGetValue(fluidId, out var value)) { __instance.exchangeAndColoring(value.Color); } } } } public static class UISignalTagPickerPatches { private static List _customTabBtns; [HarmonyPatch(typeof(UISignalTagPicker), "_OnCreate")] [HarmonyPostfix] public static void Create(UISignalTagPicker __instance) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_006e: Expected O, but got Unknown //IL_0070: 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) TabData[] allTabs = TabSystem.GetAllTabs(); _customTabBtns = new List(); Vector2 anchoredPosition = ((RectTransform)((Component)__instance.upgradeTab2Btn).transform).anchoredPosition; TabData[] array = allTabs; foreach (TabData val in array) { if (val != null) { GameObject val2 = Object.Instantiate(((Component)__instance.upgradeTab2Btn).gameObject, (Transform)(object)__instance.pickerTrans, false); RectTransform val3 = (RectTransform)val2.transform; val3.anchoredPosition = new Vector2(anchoredPosition.x + (float)((val.tabIndex - 5) * 48), anchoredPosition.y); UIButton component = val2.GetComponent(); component.data = val.tabIndex + 6; Image component2 = ((Component)val2.transform.Find("icon")).GetComponent(); component2.sprite = Resources.Load(val.tabIconPath); _customTabBtns.Add(component); } } ((Component)__instance.upgradeTab2Btn).gameObject.SetActive(false); ((Component)__instance.upgradeTab1Btn).gameObject.SetActive(false); ((Component)__instance.techTabBtn).gameObject.SetActive(false); } [HarmonyPatch(typeof(UISignalTagPicker), "_OnRegEvent")] [HarmonyPostfix] public static void OnRegEvent(UISignalTagPicker __instance) { if (_customTabBtns == null) { return; } foreach (UIButton customTabBtn in _customTabBtns) { customTabBtn.onClick += __instance.OnTypeButtonClick; } } [HarmonyPatch(typeof(UISignalTagPicker), "_OnUnregEvent")] [HarmonyPostfix] public static void OnUnregEvent(UISignalTagPicker __instance) { if (_customTabBtns == null) { return; } foreach (UIButton customTabBtn in _customTabBtns) { customTabBtn.onClick -= __instance.OnTypeButtonClick; } } [HarmonyPatch(typeof(UISignalTagPicker), "RefreshIcons")] [HarmonyPostfix] public static void RefreshIcons(UISignalTagPicker __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_006c: 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: Invalid comparison between I4 and Unknown if ((int)__instance.currentType <= 8) { return; } IconSet iconSet = GameMain.iconSet; ItemProto[] dataArray = ((ProtoSet)(object)LDB.items).dataArray; GameHistoryData history = GameMain.history; ItemProto[] array = dataArray; foreach (ItemProto val in array) { if (val.GridIndex < 1101) { continue; } int num = val.GridIndex / 1000; if (num != __instance.currentType - 6) { continue; } int num2 = (val.GridIndex - num * 1000) / 100 - 1; int num3 = val.GridIndex % 100 - 1; if (num2 >= 0 && num3 >= 0 && num2 < 10 && num3 < 14) { int num4 = num2 * 14 + num3; if (num4 >= 0 && num4 < __instance.indexArray.Length && (UISignalTagPicker.showUnlock || history.ItemUnlocked(((Proto)val).ID))) { int num5 = SignalProtoSet.SignalId((ESignalType)1, ((Proto)val).ID); __instance.indexArray[num4] = iconSet.signalIconIndex[num5]; __instance.signalArray[num4] = num5; } } } } [HarmonyPatch(typeof(UISignalTagPicker), "OnTypeButtonClick")] [HarmonyPostfix] public static void OnTypeButtonClick_Postfix(UISignalTagPicker __instance, int type) { if (_customTabBtns == null) { return; } foreach (UIButton customTabBtn in _customTabBtns) { bool flag = (customTabBtn.highlighted = customTabBtn.data == type); ((Selectable)customTabBtn.button).interactable = !flag; } } } internal class HarmonyLogListener : ILogListener, IDisposable { internal static readonly List LogData = new List(); public void LogEvent(object sender, LogEventArgs eventArgs) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 string text = eventArgs.Data.ToString(); if ((eventArgs.Source.SourceName == "HarmonyX" || text.Contains("InvalidProgramException")) && (int)eventArgs.Level == 2) { LogData.Add(text); } } public void Dispose() { } } public static class HarmonyLogPatches { private static bool _finished; [HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")] [HarmonyPostfix] public static void InvokeOnLoadWorkEnded() { if (!_finished) { while (HarmonyLogListener.LogData.Count > 0) { string text = HarmonyLogListener.LogData[0]; HarmonyLogListener.LogData.RemoveAt(0); UIFatalErrorTip.instance.ShowError("Harmony throws an error when patching!", text); } _finished = true; } } } public static class IconSetPatches { [HarmonyPatch(typeof(IconSet), "Create")] [HarmonyTranspiler] public static IEnumerable IconSet_Create_Transpiler(IEnumerable instructions) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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 CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.PropertyGetter(typeof(TechProto), "iconSprite"), (string)null) }); object operand = val.Clone().Advance(5).Operand; object operand2 = val.Clone().Advance(-1).Operand; val.Advance(6).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldloc, operand2), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(IconSetPatches), "IsInvalidTech", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Brtrue, operand) }); return val.InstructionEnumeration(); } public static bool IsInvalidTech(TechProto proto) { if (proto == null) { return false; } if (((Proto)proto).ID > 2100 && ((Proto)proto).ID < 2106) { return false; } switch (((Proto)proto).ID) { case 2701: case 2902: case 2904: case 3508: case 3509: case 3510: return false; default: return ((Proto)proto).ID > 2000; } } } internal static class UIAssemblerWindowPatch { private static GameObject _obj; private static GameObject _iconObj; private static Text _text; private static Text _count; private static Image _icon; private static UIButton _uiButton; private static Button _button; private static Sprite _tagNotSelectedSprite; public static bool ShouldModuleButtonActive(ERecipeType recipeType, int recipeId, int speed) { //IL_0030: 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) //IL_0033: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 if (!GameMain.history.TechUnlocked(1311)) { return false; } if (speed >= 40000) { return false; } if ((int)recipeType == 4 || (int)recipeType == 10 || (int)recipeType == 12) { return true; } switch (recipeId) { case 775: case 778: case 784: case 847: case 848: return true; default: return false; } } [HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")] [HarmonyPostfix] [HarmonyPriority(0)] public static void VFPreload_InvokeOnLoadWorkEnded_Postfix() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0086: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Expected O, but got Unknown if ((Object)(object)_obj == (Object)null) { Transform transform = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Assembler Window/produce").transform; _obj = new GameObject { name = "lithography" }; _obj.transform.SetParent(transform, false); _obj.AddComponent(); Image component = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Power Generator Window/produce-2/fuel").GetComponent(); Image component2 = _obj.GetComponent(); component2.sprite = component.sprite; ((Graphic)component2).color = ((Graphic)component).color; _obj.GetComponent().sizeDelta = new Vector2(68f, 68f); _obj.transform.localScale = new Vector3(0.75f, 0.75f, 0.75f); _obj.transform.localPosition = new Vector3(15f, -120f, 0f); Transform transform2 = _obj.transform; GameObject val = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Power Generator Window/ray-receiver/catalytic/eff-text"); GameObject val2 = Object.Instantiate(val, transform2); val2.transform.localScale = Vector3.one; val2.transform.localPosition = new Vector3(0f, -48f, 0f); _text = ((Component)val2.transform).GetComponent(); Object.DestroyImmediate((Object)(object)val2.GetComponent()); _text.text = "伺服器".TranslateFromJson(); _text.fontSize = 16; val = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Power Generator Window/produce-2/fuel/fuel-icon"); _iconObj = Object.Instantiate(val, transform2); _iconObj.transform.localScale = Vector3.one; _icon = _iconObj.GetComponent(); _tagNotSelectedSprite = _icon.sprite; GameObject val3 = GameObject.Find("UI Root/Overlay Canvas/In Game/Windows/Power Generator Window/produce-2/fuel/button"); GameObject val4 = Object.Instantiate(val3, transform2); val4.transform.localScale = Vector3.one; _uiButton = val4.GetComponent(); _uiButton.tips.itemCount = 0; _uiButton.tips.itemInc = 0; _uiButton.tips.type = (ItemTipType)3; _button = val4.GetComponent