using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Text; using System.Xml; using BepInEx; using BepInEx.Logging; using DSPAddPlanet.Extensions; using HarmonyLib; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("DSPAddPlanet-moon^2-patch")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Zincon")] [assembly: AssemblyProduct("DSPAddPlanet-moon^2-patch")] [assembly: AssemblyCopyright("Copyright © Zincon 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("67157a1a-8f83-4b4b-a8b1-a279edb9947d")] [assembly: AssemblyFileVersion("3.0.15.0")] [assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")] [assembly: AssemblyVersion("3.0.15.0")] namespace DSPAddPlanet { internal struct AdditionalPlanetConfig { public struct VeinConfig { public struct CustomValue { public enum CustomType { Default, Random, Accurate } public CustomType Type; public int AccurateValue; public int RandomBaseValue; public float RandomCoef; public float RandomMulOffset; public int RandomAddOffset; public int GetRandomResult(DotNet35Random random) { float num = (float)RandomBaseValue * RandomCoef; float num2 = num * RandomMulOffset; float num3 = num - num2; if (num3 < 0f) { num3 = 0f; } float num4 = num + num2; int num5 = random.Next((int)num3, (int)num4); int num6 = num5 - RandomAddOffset; if (num6 < 0) { num6 = 0; } int num7 = num5 + RandomAddOffset; return random.Next(num6, num7); } } public CustomValue VeinGroupCount; public CustomValue VeinSpotCount; public CustomValue VeinAmount; public const int DEFAULT_VEIN_GROUP_COUNT_RANDOM_BASE_VALUE = 8; public const float DEFAULT_VEIN_GROUP_COUNT_RANDOM_COEF = 1f; public const float DEFAULT_VEIN_GROUP_COUNT_RANDOM_MUL_OFFSET = 0f; public const int DEFAULT_VEIN_GROUP_COUNT_RANDOM_ADD_OFFSET = 2; public const int DEFAULT_VEIN_SPOT_COUNT_RANDOM_BASE_VALUE = 15; public const float DEFAULT_VEIN_SPOT_COUNT_RANDOM_COEF = 1f; public const float DEFAULT_VEIN_SPOT_COUNT_RANDOM_MUL_OFFSET = 0f; public const int DEFAULT_VEIN_SPOT_COUNT_RANDOM_ADD_OFFSET = 5; public const int DEFAULT_VEIN_AMOUNT_RANDOM_BASE_VALUE = 100000; public const float DEFAULT_VEIN_AMOUNT_RANDOM_COEF = 1f; public const float DEFAULT_VEIN_AMOUNT_RANDOM_MUL_OFFSET = 0f; public const int DEFAULT_VEIN_AMOUNT_RANDOM_ADD_OFFSET = 50000; } public int Index; public int OrbitAround; public bool _HasOrbitAroundIndex; public int OrbitAroundIndex; public int OrbitIndex; public int Number; public bool GasGiant; public int InfoSeed; public int GenSeed; public float Radius; public float OrbitalPeriod; public float RotationPeriod; public bool IsTidalLocked; public float OrbitInclination; public float Obliquity; public bool DontGenerateVein; public bool _HasThemeId; public int ThemeId; public string ThemeName; public bool _HasOrbitLongitude; public float OrbitLongitude; public bool _HasVeinCustom; public Dictionary VeinCustom; public bool _HasReplaceAllVeinsTo; public EVeinType ReplaceAllVeinsTo; public bool IsBirthPoint; public override string ToString() { //IL_08ca: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder("AdditionalPlanetConfig:\r\n"); stringBuilder.Append(" ").Append("Index: ").Append(Index) .Append("\r\n"); stringBuilder.Append(" ").Append("OrbitAround: ").Append(OrbitAround) .Append("\r\n"); stringBuilder.Append(" ").Append("_HasOrbitAroundIndex: ").Append(_HasOrbitAroundIndex) .Append("\r\n"); stringBuilder.Append(" ").Append("OrbitAroundIndex: ").Append(OrbitAroundIndex) .Append("\r\n"); stringBuilder.Append(" ").Append("OrbitIndex: ").Append(OrbitIndex) .Append("\r\n"); stringBuilder.Append(" ").Append("Number: ").Append(Number) .Append("\r\n"); stringBuilder.Append(" ").Append("GasGiant: ").Append(GasGiant) .Append("\r\n"); stringBuilder.Append(" ").Append("InfoSeed: ").Append(InfoSeed) .Append("\r\n"); stringBuilder.Append(" ").Append("GenSeed: ").Append(GenSeed) .Append("\r\n"); stringBuilder.Append(" ").Append("Radius: ").Append(Radius) .Append("\r\n"); stringBuilder.Append(" ").Append("OrbitalPeriod: ").Append(OrbitalPeriod) .Append("\r\n"); stringBuilder.Append(" ").Append("RotationPeriod: ").Append(RotationPeriod) .Append("\r\n"); stringBuilder.Append(" ").Append("IsTidalLocked: ").Append(IsTidalLocked) .Append("\r\n"); stringBuilder.Append(" ").Append("OrbitInclination: ").Append(OrbitInclination) .Append("\r\n"); stringBuilder.Append(" ").Append("Obliquity: ").Append(Obliquity) .Append("\r\n"); stringBuilder.Append(" ").Append("DontGenerateVein: ").Append(DontGenerateVein) .Append("\r\n"); stringBuilder.Append(" ").Append("_HasThemeId: ").Append(_HasThemeId) .Append("\r\n"); stringBuilder.Append(" ").Append("ThemeId: ").Append(ThemeId) .Append("\r\n"); stringBuilder.Append(" ").Append("ThemeName: ").Append(ThemeName) .Append("\r\n"); stringBuilder.Append(" ").Append("_HasOrbitLongitude: ").Append(_HasOrbitLongitude) .Append("\r\n"); stringBuilder.Append(" ").Append("OrbitLongitude: ").Append(OrbitLongitude) .Append("\r\n"); stringBuilder.Append(" ").Append("_HasVeinCustom: ").Append(_HasVeinCustom) .Append("\r\n"); stringBuilder.Append(" ").Append("VeinCustom: ").Append("\r\n"); if (_HasVeinCustom) { foreach (KeyValuePair item in VeinCustom) { stringBuilder.Append(" ").Append("VeinType: ").Append(item.Key) .Append("\r\n"); stringBuilder.Append(" ").Append("VeinGroupCount:").Append("\r\n"); stringBuilder.Append(" ").Append("Type: ").Append(item.Value.VeinGroupCount.Type) .Append("\r\n"); stringBuilder.Append(" ").Append("AccurateValue: ").Append(item.Value.VeinGroupCount.AccurateValue) .Append("\r\n"); stringBuilder.Append(" ").Append("RandomBaseValue: ").Append(item.Value.VeinGroupCount.RandomBaseValue) .Append("\r\n"); stringBuilder.Append(" ").Append("RandomCoef: ").Append(item.Value.VeinGroupCount.RandomCoef) .Append("\r\n"); stringBuilder.Append(" ").Append("RandomMulOffset: ").Append(item.Value.VeinGroupCount.RandomMulOffset) .Append("\r\n"); stringBuilder.Append(" ").Append("RandomAddOffset: ").Append(item.Value.VeinGroupCount.RandomAddOffset) .Append("\r\n"); stringBuilder.Append(" ").Append("VeinSpotCount:").Append("\r\n"); stringBuilder.Append(" ").Append("Type: ").Append(item.Value.VeinSpotCount.Type) .Append("\r\n"); stringBuilder.Append(" ").Append("AccurateValue: ").Append(item.Value.VeinSpotCount.AccurateValue) .Append("\r\n"); stringBuilder.Append(" ").Append("RandomBaseValue: ").Append(item.Value.VeinSpotCount.RandomBaseValue) .Append("\r\n"); stringBuilder.Append(" ").Append("RandomCoef: ").Append(item.Value.VeinSpotCount.RandomCoef) .Append("\r\n"); stringBuilder.Append(" ").Append("RandomMulOffset: ").Append(item.Value.VeinSpotCount.RandomMulOffset) .Append("\r\n"); stringBuilder.Append(" ").Append("RandomAddOffset: ").Append(item.Value.VeinSpotCount.RandomAddOffset) .Append("\r\n"); stringBuilder.Append(" ").Append("VeinAmount:").Append("\r\n"); stringBuilder.Append(" ").Append("Type: ").Append(item.Value.VeinAmount.Type) .Append("\r\n"); stringBuilder.Append(" ").Append("AccurateValue: ").Append(item.Value.VeinAmount.AccurateValue) .Append("\r\n"); stringBuilder.Append(" ").Append("RandomBaseValue: ").Append(item.Value.VeinAmount.RandomBaseValue) .Append("\r\n"); stringBuilder.Append(" ").Append("RandomCoef: ").Append(item.Value.VeinAmount.RandomCoef) .Append("\r\n"); stringBuilder.Append(" ").Append("RandomMulOffset: ").Append(item.Value.VeinAmount.RandomMulOffset) .Append("\r\n"); stringBuilder.Append(" ").Append("RandomAddOffset: ").Append(item.Value.VeinAmount.RandomAddOffset) .Append("\r\n"); } } stringBuilder.Append(" ").Append("_HasReplaceAllVeinsTo: ").Append(_HasReplaceAllVeinsTo) .Append("\r\n"); stringBuilder.Append(" ").Append("ReplaceAllVeinsTo: ").Append(ReplaceAllVeinsTo) .Append("\r\n"); stringBuilder.Append(" ").Append("IsBirthPoint: ").Append(IsBirthPoint) .Append("\r\n"); return stringBuilder.ToString(); } } internal static class ConfigUtility { public const string MOD_DATA_DIR = "modData/IndexOutOfRange.DSPAddPlanet/"; public const string XML_CONFIG_FILE = "config.xml"; public const string TEXT_CONFIG_FILE = "config.txt"; public const bool DEFAULT_IS_BIRTH_POINT = false; public const bool DEFAULT_GAS_GIANT = false; public const int DEFAULT_INFO_SEED = 0; public const int DEFAULT_GEN_SEED = 0; public const bool DEFAULT_FORCE_PLANET_RADIUS = false; public const int DEFAULT_RADIUS = 200; public const int MIN_RADIUS = 50; public const int MAX_RADIUS = 600; public const int DEFAULT_ORBITAL_PERIOD = 3600; public const int DEFAULT_ROTATION_PERIOD = 3600; public const bool DEFAULT_IS_TIDAL_LOCKED = true; public const float DEFAULT_ORBIT_INCLINATION = 0f; public const float DEFAULT_OBLIQUITY = 0f; public const bool DEFAULT_DONT_GENERATE_VEIN = true; public const bool DEFAULT_ENABLE_GALACTIC_SCALE_THEMES_IN_RANDOM_GENERATION = false; public static bool EnableGalacticScaleThemesInRandomGeneration { get; private set; } public static void ReadConfig(Dictionary> globalPlanetConfig, Dictionary> gameNameSpecificConfig) { globalPlanetConfig.Clear(); gameNameSpecificConfig.Clear(); EnableGalacticScaleThemesInRandomGeneration = false; string text = GameConfig.gameSaveFolder + "modData/IndexOutOfRange.DSPAddPlanet/"; if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } string text2 = text + "config.xml"; string text3 = text + "config.txt"; if (File.Exists(text2)) { try { ReadXmlConfig(text2, globalPlanetConfig, gameNameSpecificConfig); } catch (Exception ex) { Plugin.Instance.Logger.LogError((object)ex.Message); Plugin.Instance.Logger.LogError((object)ex.StackTrace); globalPlanetConfig.Clear(); gameNameSpecificConfig.Clear(); } } else if (File.Exists(text3)) { try { ReadTextConfig(text3, gameNameSpecificConfig); } catch (Exception ex2) { Plugin.Instance.Logger.LogError((object)ex2.Message); Plugin.Instance.Logger.LogError((object)ex2.Message); gameNameSpecificConfig.Clear(); } } else { CreateExampleXmlConfigFile(text2); } foreach (KeyValuePair> item in globalPlanetConfig) { item.Value.Sort((AdditionalPlanetConfig a, AdditionalPlanetConfig b) => a.Index - b.Index); } foreach (KeyValuePair> item2 in gameNameSpecificConfig) { item2.Value.Sort((AdditionalPlanetConfig a, AdditionalPlanetConfig b) => a.Index - b.Index); } } private static void ReadXmlConfig(string filePath, Dictionary> globalPlanetConfig, Dictionary> gameNameSpecificConfig) { //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) XmlDocument val = new XmlDocument(); val.Load(filePath); XmlNode val2 = ((XmlNode)val).SelectSingleNode("Config"); if (val2 == null) { return; } EnableGalacticScaleThemesInRandomGeneration = ReadBoolNode(val2, "EnableGalacticScaleThemesInRandomGeneration", required: false, defaultValue: false); GalacticScaleThemeRegistry.SetRandomGenerationEnabled(EnableGalacticScaleThemesInRandomGeneration); XmlNode val3 = val2.SelectSingleNode("Global"); if (val3 != null) { XmlNode val4 = val3.SelectSingleNode("Planets"); if (val4 != null) { Plugin.Instance.Logger.LogInfo((object)"Reading global planet config..."); ReadPlanetNodes(val4, globalPlanetConfig, isGameNameRequired: false); Plugin.Instance.Logger.LogInfo((object)("Global planet config size: " + globalPlanetConfig.Count)); } } XmlNode val5 = val2.SelectSingleNode("GameNameSpecific"); if (val5 != null) { XmlNode val6 = val5.SelectSingleNode("Planets"); if (val6 != null) { Plugin.Instance.Logger.LogInfo((object)"Reading game name specific planet config..."); ReadPlanetNodes(val6, gameNameSpecificConfig, isGameNameRequired: true); Plugin.Instance.Logger.LogInfo((object)("Config size: " + gameNameSpecificConfig.Count)); } } } private static void ReadPlanetNodes(XmlNode parent, Dictionary> planetConfig, bool isGameNameRequired) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Invalid comparison between Unknown and I4 //IL_048b: 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_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Invalid comparison between Unknown and I4 //IL_0659: Unknown result type (might be due to invalid IL or missing references) GalacticScaleThemeRegistry.EnsureRegistered(); List list = new List(); ThemeProto[] dataArray = ((ProtoSet)(object)LDB.themes).dataArray; foreach (ThemeProto val in dataArray) { list.Add(((Proto)val).ID); } XmlNodeList childNodes = parent.ChildNodes; for (int j = 0; j < childNodes.Count; j++) { XmlNode val2 = childNodes.Item(j); if ((int)val2.NodeType != 1) { continue; } string text = ReadUniqueStarId(val2, isGameNameRequired); Plugin.Instance.Logger.LogInfo((object)text); AdditionalPlanetConfig config = default(AdditionalPlanetConfig); config.IsBirthPoint = ReadBoolNode(val2, "IsBirthPoint", required: false, defaultValue: false); config.Index = ReadIntNode(val2, "Index", required: true, 0, 0); config.OrbitAround = ReadIntNode(val2, "OrbitAround", required: true, 0, 0); config._HasOrbitAroundIndex = val2.SelectSingleNode("OrbitAroundIndex") != null; if (config._HasOrbitAroundIndex) { config.OrbitAroundIndex = ReadIntNode(val2, "OrbitAroundIndex", required: true, 0, 0); if (config.OrbitAroundIndex == config.Index) { throw new Exception($"Parameter 'OrbitAroundIndex' cannot point to the planet itself, index: {config.Index}"); } } config.OrbitIndex = ReadIntNode(val2, "OrbitIndex", required: true, 0, 0); config.Number = ReadIntNode(val2, "Number", required: true, 0, 1); config.GasGiant = ReadBoolNode(val2, "GasGiant", required: false, defaultValue: false); config.InfoSeed = ReadIntNode(val2, "InfoSeed", required: false, 0); config.GenSeed = ReadIntNode(val2, "GenSeed", required: false, 0); if (ReadBoolNode(val2, "ForcePlanetRadius", required: false, defaultValue: false)) { config.Radius = ReadIntNode(val2, "Radius", required: false, 200, 1); } else { config.Radius = ReadIntNode(val2, "Radius", required: false, 200, 50, 600); } config.OrbitalPeriod = ReadIntNode(val2, "OrbitalPeriod", required: false, 3600, 1); config.RotationPeriod = ReadIntNode(val2, "RotationPeriod", required: false, 3600, 1); config.IsTidalLocked = ReadBoolNode(val2, "IsTidalLocked", required: false, defaultValue: true); config.OrbitInclination = ReadFloatNode(val2, "OrbitInclination", required: false, 0f, 0f, 360f); config.Obliquity = ReadFloatNode(val2, "Obliquity", required: false, 0f, 0f, 360f); config.DontGenerateVein = ReadBoolNode(val2, "DontGenerateVein", required: false, defaultValue: true); XmlNode val3 = val2.SelectSingleNode("ThemeId"); XmlNode val4 = val2.SelectSingleNode("ThemeName"); if (val3 != null && val4 != null) { throw new Exception("Use either 'ThemeId' or 'ThemeName', not both"); } config._HasThemeId = val3 != null || val4 != null; if (val3 != null) { config.ThemeId = ReadIntNode(val2, "ThemeId", required: true, 0, list); } else if (val4 != null) { config.ThemeName = ReadStringNode(val2, "ThemeName", required: true, null); if (!GalacticScaleThemeRegistry.TryResolveThemeName(config.ThemeName, out config.ThemeId)) { throw new Exception("Invalid parameter 'ThemeName', theme '" + config.ThemeName + "' was not found. Known themes: " + GalacticScaleThemeRegistry.GetKnownThemeNames()); } } config._HasOrbitLongitude = val2.SelectSingleNode("OrbitLongitude") != null; if (config._HasOrbitLongitude) { config.OrbitLongitude = ReadFloatNode(val2, "OrbitLongitude", required: true, 0f, 0f, 360f); } config._HasReplaceAllVeinsTo = val2.SelectSingleNode("ReplaceAllVeinsTo") != null; if (config._HasReplaceAllVeinsTo) { config.ReplaceAllVeinsTo = ReadEnumNode(val2, "ReplaceAllVeinsTo", required: true, (EVeinType)0); } config._HasVeinCustom = val2.SelectSingleNode("VeinCustom") != null; if (config._HasVeinCustom) { Dictionary dictionary = new Dictionary(); XmlNodeList childNodes2 = val2.SelectSingleNode("VeinCustom").ChildNodes; for (int k = 0; k < childNodes2.Count; k++) { XmlNode val5 = childNodes2.Item(k); if ((int)val5.NodeType != 1) { continue; } if (!Enum.TryParse(val5.Name.Trim(), out EVeinType result)) { throw new Exception("Invalid vein type '" + val5.Name + "' in "); } AdditionalPlanetConfig.VeinConfig value = default(AdditionalPlanetConfig.VeinConfig); AdditionalPlanetConfig.VeinConfig.CustomValue veinGroupCount = default(AdditionalPlanetConfig.VeinConfig.CustomValue); XmlNode val6 = val5.SelectSingleNode("VeinGroupCount"); if (val6 == null) { veinGroupCount.Type = AdditionalPlanetConfig.VeinConfig.CustomValue.CustomType.Default; } else { try { veinGroupCount = ReadVeinCustomValue(val6, 8, 1f, 0f, 2); } catch (Exception ex) { throw new Exception("Error in : " + ex.Message); } } value.VeinGroupCount = veinGroupCount; AdditionalPlanetConfig.VeinConfig.CustomValue veinSpotCount = default(AdditionalPlanetConfig.VeinConfig.CustomValue); XmlNode val7 = val5.SelectSingleNode("VeinSpotCount"); if (val7 == null) { veinSpotCount.Type = AdditionalPlanetConfig.VeinConfig.CustomValue.CustomType.Default; } else { try { veinSpotCount = ReadVeinCustomValue(val7, 15, 1f, 0f, 5); } catch (Exception ex2) { throw new Exception("Error in : " + ex2.Message); } } value.VeinSpotCount = veinSpotCount; AdditionalPlanetConfig.VeinConfig.CustomValue veinAmount = default(AdditionalPlanetConfig.VeinConfig.CustomValue); XmlNode val8 = val5.SelectSingleNode("VeinAmount"); if (val8 == null) { veinAmount.Type = AdditionalPlanetConfig.VeinConfig.CustomValue.CustomType.Default; } else { try { veinAmount = ReadVeinCustomValue(val8, 100000, 1f, 0f, 50000); } catch (Exception ex3) { throw new Exception("Error in : " + ex3.Message); } } value.VeinAmount = veinAmount; dictionary.Add(result, value); } config.VeinCustom = dictionary; } if (planetConfig.ContainsKey(text)) { List list2 = planetConfig[text]; if (list2.FindIndex((AdditionalPlanetConfig c) => c.Index == config.Index) != -1) { throw new Exception($"Duplicate index '{config.Index}' in <{text}>"); } list2.Add(config); } else { planetConfig.Add(text, new List { config }); } Plugin.Instance.Logger.LogInfo((object)$"Found new planet at {text}\r\n{config}"); } } private static void CreateExampleXmlConfigFile(string filePath) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("\r\n").Append(" false\r\n").Append(" \r\n") .Append(" \r\n") .Append(" \r\n") .Append(" \r\n") .Append(" The cluster string\r\n") .Append(" 1\r\n") .Append(" \r\n") .Append(" false\r\n") .Append(" 4\r\n") .Append(" 0\r\n") .Append(" 2\r\n") .Append(" 3\r\n") .Append(" false\r\n") .Append(" 0\r\n") .Append(" 0\r\n") .Append(" false\r\n") .Append(" 200\r\n") .Append(" 3600\r\n") .Append(" 3600\r\n") .Append(" true\r\n") .Append(" 0\r\n") .Append(" 0\r\n") .Append(" true\r\n") .Append(" 0\r\n") .Append(" 0\r\n") .Append(" \r\n") .Append(" \r\n") .Append(" \r\n") .Append(" Accurate\r\n") .Append(" 10\r\n") .Append(" \r\n") .Append(" \r\n") .Append(" Random\r\n") .Append(" 100000\r\n") .Append(" 1\r\n") .Append(" 0\r\n") .Append(" 5\r\n") .Append(" \r\n") .Append(" \r\n") .Append(" Default\r\n") .Append(" \r\n") .Append(" \r\n") .Append(" \r\n") .Append(" Copper\r\n") .Append(" \r\n") .Append(" \r\n") .Append(" \r\n") .Append(" \r\n") .Append(" \r\n") .Append(" \r\n") .Append(" \r\n") .Append(" The game name of your save file\r\n") .Append(" The cluster string\r\n") .Append(" 1\r\n") .Append(" \r\n") .Append(" false\r\n") .Append(" 4\r\n") .Append(" 0\r\n") .Append(" 2\r\n") .Append(" 3\r\n") .Append(" false\r\n") .Append(" 0\r\n") .Append(" 0\r\n") .Append(" false\r\n") .Append(" 200\r\n") .Append(" 3600\r\n") .Append(" 3600\r\n") .Append(" true\r\n") .Append(" 0\r\n") .Append(" 0\r\n") .Append(" true\r\n") .Append(" 0\r\n") .Append(" 0\r\n") .Append(" \r\n") .Append(" \r\n") .Append(" \r\n") .Append(" Accurate\r\n") .Append(" 10\r\n") .Append(" \r\n") .Append(" \r\n") .Append(" Random\r\n") .Append(" 100000\r\n") .Append(" 1\r\n") .Append(" 0\r\n") .Append(" 5\r\n") .Append(" \r\n") .Append(" \r\n") .Append(" Default\r\n") .Append(" \r\n") .Append(" \r\n") .Append(" \r\n") .Append(" Copper\r\n") .Append(" \r\n") .Append(" \r\n") .Append(" \r\n") .Append("\r\n"); StreamWriter streamWriter = File.CreateText(filePath); streamWriter.Write((object?)stringBuilder); streamWriter.Flush(); streamWriter.Dispose(); } private static void ReadTextConfig(string filePath, Dictionary> planetConfig) { //IL_06ef: Unknown result type (might be due to invalid IL or missing references) string[] array = File.ReadAllLines(filePath); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (Utility.IsNullOrWhiteSpace(text) || text.StartsWith("#") || text.StartsWith("(EXAMPLE)")) { continue; } Dictionary dictionary = Utility.ParseQueryString(text); string valueSafe = GeneralExtensions.GetValueSafe(dictionary, "uniqueStarId"); valueSafe = valueSafe.Substring(0, valueSafe.IndexOf('-')) + "." + valueSafe.Substring(valueSafe.IndexOf('-') + 1, valueSafe.LastIndexOf('-')) + "." + valueSafe.Substring(valueSafe.LastIndexOf('-') + 1); if (string.IsNullOrWhiteSpace(valueSafe)) { throw new Exception("Missing parameter 'uniqueStarId'"); } if (!int.TryParse(GeneralExtensions.GetValueSafe(dictionary, "index"), out var result)) { throw new Exception("Missing parameter 'index'"); } if (!int.TryParse(GeneralExtensions.GetValueSafe(dictionary, "orbitAround"), out var result2)) { throw new Exception("Missing parameter 'orbitAround'"); } bool hasOrbitAroundIndex = false; int result3 = 0; if (dictionary.ContainsKey("orbitAroundIndex")) { if (!int.TryParse(GeneralExtensions.GetValueSafe(dictionary, "orbitAroundIndex"), out result3)) { throw new Exception("Invalid parameter 'orbitAroundIndex', this parameter must be a non-negative integer"); } if (result3 == result) { throw new Exception($"Parameter 'orbitAroundIndex' cannot point to the planet itself, index: {result}"); } hasOrbitAroundIndex = true; } if (!int.TryParse(GeneralExtensions.GetValueSafe(dictionary, "orbitIndex"), out var result4)) { throw new Exception("Missing parameter 'orbitIndex'"); } if (!int.TryParse(GeneralExtensions.GetValueSafe(dictionary, "number"), out var result5)) { throw new Exception("Missing parameter 'number'"); } if (!bool.TryParse(GeneralExtensions.GetValueSafe(dictionary, "gasGiant"), out var result6)) { Plugin.Instance.Logger.LogInfo((object)$"Missing parameter 'gasGiant', pick default value: {false}"); result6 = false; } if (!int.TryParse(GeneralExtensions.GetValueSafe(dictionary, "info_seed"), out var result7)) { Plugin.Instance.Logger.LogInfo((object)$"Missing parameter 'info_seed', pick default value: {0}"); result7 = 0; } if (!int.TryParse(GeneralExtensions.GetValueSafe(dictionary, "gen_seed"), out var result8)) { Plugin.Instance.Logger.LogInfo((object)$"Missing parameter 'gen_seed', pick default value: {0}"); result8 = 0; } if (!bool.TryParse(GeneralExtensions.GetValueSafe(dictionary, "forcePlanetRadius"), out var result9)) { Plugin.Instance.Logger.LogInfo((object)$"Missing parameter 'forcePlanetRadius', pick default value: {false}"); result9 = false; } if (!float.TryParse(GeneralExtensions.GetValueSafe(dictionary, "planetRadius"), out var result10)) { Plugin.Instance.Logger.LogInfo((object)$"Missing parameter 'planetRadius', pick default value: {200}"); result10 = 200f; } if (result10 > 600f) { if (!result9) { throw new Exception($"Current max planet radius is {600}, use 'forcePlanetRadius=true' to override this"); } Plugin.Instance.Logger.LogWarning((object)$"Force planet radius: {result10}"); } if (!float.TryParse(GeneralExtensions.GetValueSafe(dictionary, "orbitalPeriod"), out var result11)) { Plugin.Instance.Logger.LogInfo((object)$"Missing parameter 'orbitalPeriod', pick default value: {3600}"); result11 = 3600f; } if (!float.TryParse(GeneralExtensions.GetValueSafe(dictionary, "rotationPeriod"), out var result12)) { Plugin.Instance.Logger.LogInfo((object)$"Missing parameter 'rotationPeriod', pick default value: {3600}"); result12 = 3600f; } if (!bool.TryParse(GeneralExtensions.GetValueSafe(dictionary, "isTidalLocked"), out var result13)) { Plugin.Instance.Logger.LogInfo((object)$"Missing parameter 'isTidalLocked', pick default value: {true}"); result13 = true; } if (!float.TryParse(GeneralExtensions.GetValueSafe(dictionary, "orbitInclination"), out var result14)) { Plugin.Instance.Logger.LogInfo((object)$"Missing parameter 'orbitInclination', pick default value: {0f}"); result14 = 0f; } if (!float.TryParse(GeneralExtensions.GetValueSafe(dictionary, "obliquity"), out var result15)) { Plugin.Instance.Logger.LogInfo((object)$"Missing parameter 'obliquity', pick default value: {0f}"); result15 = 0f; } if (!bool.TryParse(GeneralExtensions.GetValueSafe(dictionary, "dontGenerateVein"), out var result16)) { Plugin.Instance.Logger.LogInfo((object)$"Missing parameter 'dontGenerateVein', pick default value: {true}"); result16 = true; } int themeId = 0; string text2 = null; bool hasThemeId = false; if (dictionary.ContainsKey("theme") && dictionary.ContainsKey("themeName")) { throw new Exception("Use either 'theme' or 'themeName', not both"); } if (dictionary.ContainsKey("theme")) { if (!int.TryParse(GeneralExtensions.GetValueSafe(dictionary, "theme"), out themeId)) { throw new Exception("Invalid parameter 'theme', this parameter must be a positive integer"); } if (!((ProtoSet)(object)LDB.themes).Exist(themeId)) { throw new Exception($"Fail to find theme #{themeId} in game data"); } if (((ProtoSet)(object)LDB.themes).Select(themeId) == null) { throw new Exception($"Theme exists but is null, theme id: {themeId}"); } hasThemeId = true; } else if (dictionary.ContainsKey("themeName")) { text2 = GeneralExtensions.GetValueSafe(dictionary, "themeName"); if (!GalacticScaleThemeRegistry.TryResolveThemeName(text2, out themeId)) { throw new Exception("Invalid parameter 'themeName', theme '" + text2 + "' was not found. Known themes: " + GalacticScaleThemeRegistry.GetKnownThemeNames()); } hasThemeId = true; } float num = 0f; bool hasOrbitLongitude = false; if (dictionary.ContainsKey("orbitLongitude")) { string text3 = dictionary["orbitLongitude"]; if (string.IsNullOrWhiteSpace(text3)) { throw new Exception("Parameter 'orbitLongitude' has invalid value, correct format is 'DEGREE,MINUTE', e.g. '60,60'"); } string[] array2 = text3.Split(','); if (array2.Length != 2) { throw new Exception("Parameter 'orbitLongitude' has invalid value, correct format is 'DEGREE,MINUTE', e.g. '60,60'"); } if (!float.TryParse(array2[0].Trim(), out var result17)) { throw new Exception("Parameter 'orbitLongitude' has invalid value, correct format is 'DEGREE,MINUTE', e.g. '60,60'"); } if (!float.TryParse(array2[1].Trim(), out var result18)) { throw new Exception("Parameter 'orbitLongitude' has invalid value, correct format is 'DEGREE,MINUTE', e.g. '60,60'"); } num = result17 + result18 / 60f; if (num >= 360f) { num = Mathf.Repeat(num, 360f); } else if (num < 0f) { throw new Exception("Parameter 'orbitLongitude' must be positive"); } hasOrbitLongitude = true; } AdditionalPlanetConfig additionalPlanetConfig = new AdditionalPlanetConfig { Index = result, OrbitAround = result2, _HasOrbitAroundIndex = hasOrbitAroundIndex, OrbitAroundIndex = result3, OrbitIndex = result4, Number = result5, GasGiant = result6, InfoSeed = result7, GenSeed = result8, Radius = result10, OrbitalPeriod = result11, RotationPeriod = result12, IsTidalLocked = result13, OrbitInclination = result14, Obliquity = result15, DontGenerateVein = result16, _HasThemeId = hasThemeId, ThemeId = themeId, ThemeName = text2, _HasOrbitLongitude = hasOrbitLongitude, OrbitLongitude = num, _HasVeinCustom = false, VeinCustom = null, _HasReplaceAllVeinsTo = false, ReplaceAllVeinsTo = (EVeinType)0 }; if (!planetConfig.ContainsKey(valueSafe)) { planetConfig[valueSafe] = new List(); } planetConfig[valueSafe].Add(additionalPlanetConfig); Plugin.Instance.Logger.LogInfo((object)$"Found new planet at {valueSafe}\r\n{additionalPlanetConfig}"); } } private static string ReadStringNode(XmlNode parent, string childName, bool required, string defaultValue) { XmlNode val = parent.SelectSingleNode(childName); if (val == null) { if (required) { throw new Exception("Missing parameter '" + childName + "'"); } return defaultValue; } return val.InnerText.Trim(); } private static int ReadIntNode(XmlNode parent, string childName, bool required, int defaultValue, int min = int.MinValue, int max = int.MaxValue) { XmlNode val = parent.SelectSingleNode(childName); if (val == null) { if (required) { throw new Exception("Missing parameter '" + childName + "'"); } return defaultValue; } if (!int.TryParse(val.InnerText.Trim(), out var result)) { throw new Exception("Invalid parameter '" + childName + "', '" + childName + "' must be an integer, current value: " + val.InnerText); } if (result < min || result > max) { throw new Exception($"Invalid parameter '{childName}', '{childName}' must be in range [{min}, {max}], current value: {val.InnerText}"); } return result; } private static int ReadIntNode(XmlNode parent, string childName, bool required, int defaultValue, IEnumerable set) { XmlNode val = parent.SelectSingleNode(childName); if (val == null) { if (required) { throw new Exception("Missing parameter '" + childName + "'"); } return defaultValue; } if (!int.TryParse(val.InnerText.Trim(), out var result)) { throw new Exception("Invalid parameter '" + childName + "', '" + childName + "' must be an integer, current value: " + val.InnerText); } if (!set.Contains(result)) { throw new Exception("Invalid parameter '" + childName + "', '" + childName + "' must be in set {" + GeneralExtensions.Join(set, (Func)null, ", ") + "}, current value: " + val.InnerText); } return result; } private static float ReadFloatNode(XmlNode parent, string childName, bool required, float defaultValue, float min = float.MinValue, float max = float.MaxValue) { XmlNode val = parent.SelectSingleNode(childName); if (val == null) { if (required) { throw new Exception("Missing parameter '" + childName + "'"); } return defaultValue; } if (!float.TryParse(val.InnerText.Trim(), out var result)) { throw new Exception("Invalid parameter '" + childName + "', '" + childName + "' must be an integer, current value: " + val.InnerText); } if (result < min || result > max) { throw new Exception($"Invalid parameter '{childName}', '{childName}' must be in range [{min}, {max}], current value: {val.InnerText}"); } return result; } private static bool ReadBoolNode(XmlNode parent, string childName, bool required, bool defaultValue) { XmlNode val = parent.SelectSingleNode(childName); if (val == null) { if (required) { throw new Exception("Missing parameter '" + childName + "'"); } return defaultValue; } if (!bool.TryParse(val.InnerText.Trim(), out var result)) { throw new Exception("Invalid parameter '" + childName + "', '" + childName + "' must be 'true' or 'false', current value: " + val.InnerText); } return result; } private static T ReadEnumNode(XmlNode parent, string childName, bool required, T defaultValue) where T : Enum { XmlNode val = parent.SelectSingleNode(childName); if (val == null) { if (required) { throw new Exception("Missing parameter '" + childName + "'"); } return defaultValue; } try { return (T)Enum.Parse(typeof(T), val.InnerText.Trim()); } catch (Exception) { throw new Exception("Invalid parameter '" + childName + "', '" + childName + "' must be in set {" + Utility.EnumValuesJoin() + "}, current value: " + val.InnerText); } } private static AdditionalPlanetConfig.VeinConfig.CustomValue ReadVeinCustomValue(XmlNode parent, int defaultRandomBaseValue, float defaultRandomCoef, float defaultRandomMulOffset, int defaultRandomAddOffset) { if (!Enum.TryParse((parent.SelectSingleNode("Type") ?? throw new Exception("Missing parameter 'Type'")).InnerText.Trim(), out var result)) { throw new Exception("'Type' must be in set {" + Utility.EnumValuesJoin() + "}"); } AdditionalPlanetConfig.VeinConfig.CustomValue result2 = default(AdditionalPlanetConfig.VeinConfig.CustomValue); switch (result) { case AdditionalPlanetConfig.VeinConfig.CustomValue.CustomType.Default: result2.Type = result; return result2; case AdditionalPlanetConfig.VeinConfig.CustomValue.CustomType.Random: { int randomBaseValue = ReadIntNode(parent, "RandomBaseValue", required: false, defaultRandomBaseValue, 0); float randomCoef = ReadFloatNode(parent, "RandomCoef", required: false, defaultRandomCoef, 0f); float randomMulOffset = ReadFloatNode(parent, "RandomMulOffset", required: false, defaultRandomMulOffset, 0f); int randomAddOffset = ReadIntNode(parent, "RandomAddOffset", required: false, defaultRandomAddOffset, 0); result2.Type = result; result2.RandomBaseValue = randomBaseValue; result2.RandomCoef = randomCoef; result2.RandomMulOffset = randomMulOffset; result2.RandomAddOffset = randomAddOffset; return result2; } case AdditionalPlanetConfig.VeinConfig.CustomValue.CustomType.Accurate: { int accurateValue = ReadIntNode(parent, "AccurateValue", required: true, 0, 0); result2.Type = result; result2.AccurateValue = accurateValue; return result2; } default: throw new Exception("Unrecognizable CustomType: " + result); } } private static string ReadUniqueStarId(XmlNode parent, bool isGameNameRequired) { XmlNode val = parent.SelectSingleNode("UniqueStarId"); if (val == null) { throw new Exception("Missing paremeter 'UniqueStarId'"); } string text = ReadStringNode(val, "ClusterString", required: true, null).Trim(); if (string.IsNullOrWhiteSpace(text)) { throw new Exception("Parameter 'ClusterString' can not be empty"); } bool flag = val.SelectSingleNode("StarId") != null; int starId = 0; string text2 = null; if (flag) { starId = ReadIntNode(val, "StarId", required: true, 0, 1); } else { text2 = ReadStringNode(val, "Star", required: true, null).Trim(); if (string.IsNullOrWhiteSpace(text2)) { throw new Exception("Parameter 'Star' can not be empty"); } } if (!isGameNameRequired) { if (!flag) { return Utility.UniqueStarIdWithoutGameName(text, text2); } return Utility.UniqueStarIdWithoutGameName(text, starId); } string text3 = ReadStringNode(val, "GameName", required: true, null).Trim(); if (string.IsNullOrWhiteSpace(text3)) { throw new Exception("Parameter 'GameName' can not be empty when required"); } if (!flag) { return Utility.UniqueStarIdWithGameName(text3, text, text2); } return Utility.UniqueStarIdWithGameName(text3, text, starId); } } internal static class GalacticScaleThemeRegistry { private enum MaterialRole { Terrain, Ocean, Atmosphere, Thumb, Minimap } private class ThemeSpec { public string Name; public string DisplayName; public int BaseThemeId; public int? TerrainThemeId; public int? OceanThemeId; public int? AtmosphereThemeId; public int? AmbientThemeId; public int? Algo; public EPlanetType? PlanetType; public float? Temperature; public int[] Vegetables0; public int[] Vegetables1; public int[] Vegetables2; public int[] Vegetables3; public int[] Vegetables4; public int[] Vegetables5; public int[] VeinSpot; public float[] VeinCount; public float[] VeinOpacity; public int[] RareVeins; public float[] RareSettings; public int[] GasItems; public float[] GasSpeeds; public float? Wind; public float? IonHeight; public float? WaterHeight; public int? WaterItemId; public string SFXPath; public bool IncludeInRandomGeneration = true; public EThemeDistribute? RandomDistribute; public int RandomWeight = 1; public int[] ExtraRandomThemeIds; public Color? TerrainTint; public Color? OceanTint; public Color? AtmosphereTint; public float? AmbientLutContribution; public Color? AmbientReflectionColor; public Action AmbientOverride; public Dictionary TerrainColors; public Dictionary OceanColors; public Dictionary AtmosphereColors; public Dictionary TerrainParams; public Dictionary OceanParams; public Dictionary AtmosphereParams; public ThemeTerrainSettings TerrainSettings; public ThemeVeinSettings VeinSettings; public bool UseSingleMaterial = true; public ThemeSpec Clone() { return (ThemeSpec)MemberwiseClone(); } } private class ThemeTerrainSettings { public string Algorithm = "Vanilla"; public double BaseHeight; public double BiomeHeightModifier; public double BiomeHeightMulti = 1.0; public double HeightMulti = 1.0; public double LandModifier; public double RandomFactor = 1.0; public double xFactor; public double yFactor; public double zFactor; } private class ThemeVeinSettings { public string Algorithm = "Vanilla"; public float VeinPadding = 1f; public List VeinTypes = new List(); } private class ThemeVeinType { public EVeinType Type; public bool Rare; public List Veins = new List(); public static ThemeVeinType Generate(EVeinType type, int min, int max, float minRichness, float maxRichness, int minPatchSize, int maxPatchSize, bool rare, int seed) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) DotNet35Random val = new DotNet35Random(seed); ThemeVeinType themeVeinType = new ThemeVeinType { Type = type, Rare = rare }; int num = Mathf.RoundToInt((float)Mathf.Clamp(val.Next(min, max + 1), 0, 3000)); for (int i = 0; i < num; i++) { themeVeinType.Veins.Add(new ThemeVein { Count = val.Next(minPatchSize, maxPatchSize + 1), Richness = Mathf.Lerp(minRichness, maxRichness, (float)val.NextDouble()) }); } return themeVeinType; } } private class ThemeVein { public int Count; public float Richness; } private struct VeinDescriptor { public int Count; public EVeinType Type; public Vector3 Position; public bool Rare; public float Richness; } private class RegisteredThemeInfo { public int Id; public bool IncludeInRandomGeneration; public int RandomWeight; public EThemeDistribute RandomDistribute; public int[] ExtraRandomThemeIds; } private const int MEDITERRANEAN = 1; private const int GAS_GIANT = 2; private const int ICE_GIANT = 4; private const int LAVA = 9; private const int ICE_GELISOL = 10; private const int BARREN = 11; private const int GOBI = 12; private const int VOLCANIC_ASH = 13; private const int RED_STONE = 14; private const int SAVANNA = 22; private const int OCEAN_WORLD = 16; private const int OCEANIC_JUNGLE = 8; private const int PANDORA_SWAMP = 25; private static bool registered; private static readonly Dictionary themeNameToId = new Dictionary(); private static readonly Dictionary themeSpecsById = new Dictionary(); private static readonly Dictionary themeSpecsByName = new Dictionary(); private static readonly List registeredThemeInfos = new List(); private static readonly HashSet materialReapplyLogged = new HashSet(); private static readonly HashSet materialDiagnosticLogged = new HashSet(); public static IReadOnlyDictionary ThemeNameToId => themeNameToId; public static bool IsGiganticForestTheme(int themeId) { EnsureRegistered(); ThemeProto val = ((ProtoSet)(object)LDB.themes).Select(themeId); if (val == null) { return false; } string text = NormalizeName(((Proto)val).Name); if (!(text == "giganticforest")) { return text == "giganticforestcold"; } return true; } public static bool IsBeachTheme(int themeId) { EnsureRegistered(); ThemeProto val = ((ProtoSet)(object)LDB.themes).Select(themeId); if (val == null) { return false; } string text = NormalizeName(((Proto)val).Name); if (!(text == "beach")) { return text == "beachcold"; } return true; } public static bool TryGenerateGalacticScaleVeins(PlanetData planet) { EnsureRegistered(); if (planet == null || planet.data == null) { return false; } ThemeSpec specForThemeId = GetSpecForThemeId(planet.theme); if (specForThemeId == null || specForThemeId.VeinSettings == null) { return false; } if (!string.Equals(specForThemeId.VeinSettings.Algorithm, "GS2", StringComparison.OrdinalIgnoreCase)) { return false; } GenerateGs2Veins(planet, specForThemeId.VeinSettings); return true; } public static bool UsesGalacticScaleTerrain(int themeId) { EnsureRegistered(); ThemeSpec specForThemeId = GetSpecForThemeId(themeId); if (specForThemeId != null && specForThemeId.TerrainSettings != null && !string.IsNullOrWhiteSpace(specForThemeId.TerrainSettings.Algorithm)) { return !string.Equals(specForThemeId.TerrainSettings.Algorithm, "Vanilla", StringComparison.OrdinalIgnoreCase); } return false; } public static bool TryGenerateGalacticScaleTerrain(PlanetData planet, double modX, double modY) { EnsureRegistered(); if (planet == null || planet.data == null) { return false; } ThemeSpec specForThemeId = GetSpecForThemeId(planet.theme); if (specForThemeId == null || specForThemeId.TerrainSettings == null) { return false; } string a = specForThemeId.TerrainSettings.Algorithm ?? ""; if (string.Equals(a, "GSTA1", StringComparison.OrdinalIgnoreCase)) { GenerateTerrain1(planet, specForThemeId.TerrainSettings); return true; } if (string.Equals(a, "GSTA3", StringComparison.OrdinalIgnoreCase)) { GenerateTerrain3(planet, specForThemeId.TerrainSettings); return true; } if (string.Equals(a, "GSTA6", StringComparison.OrdinalIgnoreCase)) { GenerateTerrain6(planet, specForThemeId.TerrainSettings); return true; } return false; } private static ThemeSpec GetSpecForThemeId(int themeId) { if (themeSpecsById.TryGetValue(themeId, out var value)) { return value; } ThemeProto val = ((ProtoSet)(object)LDB.themes).Select(themeId); if (val == null) { return null; } if (themeSpecsByName.TryGetValue(NormalizeName(((Proto)val).Name), out value) || themeSpecsByName.TryGetValue(NormalizeName(((Proto)val).name), out value) || themeSpecsByName.TryGetValue(NormalizeName(val.DisplayName), out value) || themeSpecsByName.TryGetValue(NormalizeName(val.displayName), out value)) { return value; } return null; } private static void GenerateTerrain1(PlanetData planet, ThemeTerrainSettings terrainSettings) { //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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown PlanetRawData data = planet.data; if (data != null && data.vertices != null && data.heightData != null && data.biomoData != null) { DotNet35Random val = new DotNet35Random(planet.seed); SimplexNoise val2 = new SimplexNoise(val.Next()); SimplexNoise val3 = new SimplexNoise(val.Next()); for (int i = 0; i < data.dataLength; i++) { double num = (double)data.vertices[i].x * (double)planet.radius; double num2 = (double)data.vertices[i].y * (double)planet.radius; double num3 = (double)data.vertices[i].z * (double)planet.radius; double num4 = val2.Noise3DFBM(num * (terrainSettings.xFactor + 0.01), num2 * (terrainSettings.yFactor + 0.012), num3 * (terrainSettings.zFactor + 0.01), 6, 0.5, 2.0) * 3.0 * terrainSettings.HeightMulti + (-0.2 + terrainSettings.BaseHeight); double num5 = val3.Noise3DFBM(num * 0.0025, num2 * 0.0025, num3 * 0.0025, 3, 0.5, 2.0) * 3.0 * terrainSettings.HeightMulti * (terrainSettings.RandomFactor + 0.9) + (terrainSettings.LandModifier + 0.5); num5 = ((num5 <= 0.0) ? num5 : (num5 * 0.5)); double num6 = num4 + num5; double num7 = ((num6 <= 0.0) ? (num6 * 1.6) : (num6 * 0.5)); double num8 = ((num7 <= 0.0) ? Maths.Levelize2(num7, 0.5, 0.0) : Maths.Levelize3(num7, 0.7, 0.0)); double num9 = val3.Noise3DFBM(num * (terrainSettings.xFactor + 0.01) * 2.5, num2 * (terrainSettings.yFactor + 0.012) * 8.0, num3 * (terrainSettings.zFactor + 0.01) * 2.5, 2, 0.5, 2.0) * 0.6 - 0.3; double num10 = num7 * terrainSettings.BiomeHeightMulti + num9 + terrainSettings.BiomeHeightModifier * 2.5 + 0.3; double num11 = ((num10 >= 1.0) ? ((num10 - 1.0) * 0.8 + 1.0) : num10); int num12 = (int)(((double)planet.radius + num8 + 0.2) * 100.0); data.heightData[i] = (ushort)Mathf.Clamp(num12, 0, 65535); data.biomoData[i] = (byte)Mathf.Clamp((float)(num11 * 100.0), 0f, 200f); } } } private static void GenerateTerrain3(PlanetData planet, ThemeTerrainSettings terrainSettings) { //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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown PlanetRawData data = planet.data; if (data == null || data.vertices == null || data.heightData == null || data.biomoData == null) { return; } DotNet35Random val = new DotNet35Random(planet.seed); SimplexNoise val2 = new SimplexNoise(val.Next()); SimplexNoise val3 = new SimplexNoise(val.Next()); for (int i = 0; i < data.dataLength; i++) { double num = (double)data.vertices[i].x * (double)planet.radius; double num2 = (double)data.vertices[i].y * (double)planet.radius; double num3 = (double)data.vertices[i].z * (double)planet.radius; double num4 = num + Math.Sin(num2 * 0.15) * 3.0; double num5 = num2 + Math.Sin(num3 * 0.15) * 3.0; double num6 = num3 + Math.Sin(num4 * 0.15) * 3.0; double num7 = val2.Noise3DFBM(num4 * 0.007, num5 * 0.0077, num6 * 0.007, 6, 0.5, 1.8); double num8 = val3.Noise3DFBM(num4 * 0.0091 + 0.5, num5 * 0.0196 + 0.2, num6 * 0.0091 + 0.7, 3, 0.5, 2.0) * 2.0; double num9 = val3.Noise3DFBM(num4 * 0.042, num5 * 0.084, num6 * 0.042, 2, 0.5, 2.0) * 2.0; double num10 = val3.Noise3DFBM(num4 * 0.0056, num5 * 0.0056, num6 * 0.0056, 2, 0.5, 2.0) * 2.0; double num11 = num7 * 2.0 + 0.92 + (double)Mathf.Clamp01((float)(num8 * (double)Mathf.Abs((float)num10 + 0.5f) - 0.35) * 1f); if (num11 < 0.0) { num11 *= 2.0; } double num12 = Maths.Levelize2(num11, 1.0, 0.0); if (num12 > 0.0) { num12 = Maths.Levelize4(Maths.Levelize2(num11, 1.0, 0.0), 1.0, 0.0); } double num13 = ((num12 <= 0.0) ? ((double)Mathf.Lerp(-4f, 0f, (float)num12 + 1f)) : ((num12 <= 1.0) ? ((double)Mathf.Lerp(0f, 0.3f, (float)num12) + num9 * 0.1) : ((num12 <= 2.0) ? ((double)Mathf.Lerp(0.3f, 1.4f, (float)num12 - 1f) + num9 * 0.12) : ((double)Mathf.Lerp(1.4f, 2.7f, (float)num12 - 2f) + num9 * 0.12)))); if (num11 < 0.0) { num11 *= 2.0; } if (num11 < 1.0) { num11 = Maths.Levelize(num11, 1.0, 0.0); } double num14 = Mathf.Abs((float)num11); double num15 = ((num14 <= 0.0) ? 0.0 : ((num14 <= 2.0) ? num14 : 2.0)); double num16 = num15 + ((num15 <= 1.8) ? (num9 * 0.2) : ((0.0 - num9) * 0.8)); int num17 = (int)(((double)planet.radius + num13 * terrainSettings.HeightMulti + 0.2 + terrainSettings.BaseHeight) * 100.0); data.heightData[i] = (ushort)Mathf.Clamp(num17, 0, 65535); data.biomoData[i] = (byte)Mathf.Clamp((float)(num16 * 100.0 * terrainSettings.BiomeHeightMulti + terrainSettings.BiomeHeightModifier), 0f, 200f); } } private static void GenerateTerrain6(PlanetData planet, ThemeTerrainSettings terrainSettings) { //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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown PlanetRawData data = planet.data; if (data == null || data.vertices == null || data.heightData == null || data.biomoData == null) { return; } DotNet35Random val = new DotNet35Random(planet.seed); SimplexNoise val2 = new SimplexNoise(val.Next()); SimplexNoise val3 = new SimplexNoise(val.Next()); for (int i = 0; i < data.dataLength; i++) { double num = (double)data.vertices[i].x * (double)planet.radius; double num2 = (double)data.vertices[i].y * (double)planet.radius; double num3 = (double)data.vertices[i].z * (double)planet.radius; double num4 = Maths.Levelize(num * 0.007, 1.0, 0.0); double num5 = Maths.Levelize(num2 * 0.007, 1.0, 0.0); double num6 = Maths.Levelize(num3 * 0.007, 1.0, 0.0); double num7 = num4 + val2.Noise(num * terrainSettings.xFactor, num2 * terrainSettings.xFactor, num3 * terrainSettings.xFactor) * 0.04 * terrainSettings.RandomFactor; double num8 = num5 + val2.Noise(num2 * terrainSettings.yFactor, num3 * terrainSettings.yFactor, num * terrainSettings.yFactor) * 0.04 * terrainSettings.RandomFactor; double num9 = num6 + val2.Noise(num3 * terrainSettings.zFactor, num * terrainSettings.zFactor, num2 * terrainSettings.zFactor) * 0.04 * terrainSettings.RandomFactor; double num10 = Math.Abs(val3.Noise(num7, num8, num9)); double num11 = (0.16 - num10) * 10.0 * (1.0 + terrainSettings.LandModifier); double num12 = ((num11 <= 0.0) ? 0.0 : ((num11 <= 1.0) ? num11 : 1.0)); double num13 = num12 * num12; double num14 = (val2.Noise3DFBM(num2 * 0.005, num3 * 0.005, num * 0.005, 4, 0.5, 2.0) + 0.22) * 5.0; double num15 = ((num14 <= 0.0) ? 0.0 : ((num14 <= 1.0) ? num14 : 1.0)); double num16 = Math.Abs(val3.Noise3DFBM(num7 * 1.5, num8 * 1.5, num9 * 1.5, 2, 0.5, 2.0)); double num17 = 0.0 - num13 * 1.2 * num15; if (num17 >= 0.0) { num17 += num10 * 0.25 + num16 * 0.6; } double num18 = num17 - 0.1; double num19 = -0.3 - num18; if (num19 > 0.0) { double num20 = ((num19 <= 1.0) ? num19 : 1.0); num18 = -0.3 - (3.0 - num20 - num20) * num20 * num20 * 3.70000004768372; } double num21 = Maths.Levelize((num13 <= 0.300000011920929) ? 0.300000011920929 : num13, 0.7, 0.0); double num22 = ((num18 <= -0.800000011920929) ? ((0.0 - num21 - num10) * 0.899999976158142) : num18); double num23 = ((num22 <= -1.20000004768372) ? (-1.20000004768372) : num22); num23 = num23 * terrainSettings.HeightMulti + terrainSettings.BaseHeight; double num24 = num23 * num13 + (num10 * 2.1 * terrainSettings.BiomeHeightMulti + 0.800000011920929 + terrainSettings.BiomeHeightModifier); if (num24 > 1.70000004768372 && num24 < 2.0) { num24 = 2.0; } int num25 = (int)(((double)planet.radius + num23 + 0.2) * 100.0); data.heightData[i] = (ushort)Mathf.Clamp(num25, 0, 65535); data.biomoData[i] = (byte)Mathf.Clamp((float)(num24 * 100.0), 0f, 200f); } } private static void GenerateGs2Veins(PlanetData planet, ThemeVeinSettings veinSettings) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Invalid comparison between Unknown and I4 //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) if (planet.data == null) { return; } DotNet35Random val = new DotNet35Random(planet.seed); List list = BuildGs2VeinDescriptors(veinSettings, val); if (list.Count == 0) { planet.data.veinCursor = 1; planet.veinGroups = (VeinGroup[])(object)new VeinGroup[1]; ((VeinGroup)(ref planet.veinGroups[0])).SetNull(); return; } double num = 0.5 + val.NextDouble() / 2.0; float num2 = (float)Math.Pow(2.1 / (double)Math.Max(planet.radius, 0.0001f), 2.0); Vector3 val2 = RandomDirection(val); ((Vector3)(ref val2)).Normalize(); val2 *= (float)(val.NextDouble() * 0.4 + 0.2); Dictionary dictionary = new Dictionary(); for (int i = 0; i < list.Count; i++) { VeinDescriptor value = list[i]; if ((val.NextDouble() > num && dictionary.ContainsKey(value.Type)) || (value.Rare && planet.star != null && (double)planet.star.level + 0.1 < val.NextDouble() * val.NextDouble())) { continue; } bool flag = (int)value.Type != 7; bool flag2 = false; Vector3 val3 = Vector3.zero; for (int j = 0; j < 99; j++) { val3 = RandomDirection(val); if (flag) { val3 += val2; } ((Vector3)(ref val3)).Normalize(); float num3 = planet.data.QueryHeight(val3); if (!(num3 < planet.radius) && (flag || !(num3 < planet.radius + 0.5f))) { float padding = num2 * (flag ? (veinSettings.VeinPadding * 196f) : 100f); if (!SurfaceVectorCollision(val3, list, i, padding)) { flag2 = true; break; } } } if (flag2) { if (!dictionary.ContainsKey(value.Type)) { dictionary.Add(value.Type, 1); } else { dictionary[value.Type]++; } value.Position = val3; list[i] = value; } } List list2 = list.Where((VeinDescriptor group) => group.Position != Vector3.zero).ToList(); InitializePlanetVeins(planet, list2.Count); for (int num4 = 0; num4 < list2.Count; num4++) { AddGs2VeinGroupToPlanet(planet, list2[num4], (short)num4, val); } } private static List BuildGs2VeinDescriptors(ThemeVeinSettings veinSettings, DotNet35Random random) { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) List veinTypes = new List(veinSettings.VeinTypes ?? new List()); CutVeinTypes(ref veinTypes, random); int num = ((veinTypes.Count != 0) ? veinTypes.Max((ThemeVeinType type) => type.Veins.Count) : 0); List list = new List(); for (int num2 = 0; num2 < num; num2++) { foreach (ThemeVeinType item in veinTypes) { if (item.Veins.Count > num2) { ThemeVein themeVein = item.Veins[num2]; list.Add(new VeinDescriptor { Count = ((themeVein.Count < 0) ? random.Next(5, 25) : themeVein.Count), Type = item.Type, Position = Vector3.zero, Rare = item.Rare, Richness = ((themeVein.Richness < 0f) ? ((float)random.NextDouble()) : themeVein.Richness) }); } } } return list; } private static void AddGs2VeinGroupToPlanet(PlanetData planet, VeinDescriptor veinGroup, short groupIndex, DotNet35Random random) { //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_000d: 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_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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_002e: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Invalid comparison between Unknown and I4 //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Invalid comparison between Unknown and I4 //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Invalid comparison between Unknown and I4 //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Invalid comparison between Unknown and I4 //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) Vector3 normalized = ((Vector3)(ref veinGroup.Position)).normalized; Quaternion val = Quaternion.FromToRotation(Vector3.up, normalized); Vector3 val2 = val * Vector3.right; Vector3 val3 = val * Vector3.forward; List obj = new List { Vector2.zero }; int maxCount = (((int)veinGroup.Type == 7) ? 1 : Mathf.Max(1, veinGroup.Count)); GenerateNodeVectors(obj, maxCount, random); int num = Mathf.RoundToInt(veinGroup.Richness * 100000f * (planet.star?.resourceCoef ?? 1f)); num = (int)((double)num * (random.NextDouble() + 0.5)); if ((int)veinGroup.Type == 7) { num *= 2; } if (num < 20) { num = 20; } if ((int)veinGroup.Type != 7) { num = Mathf.RoundToInt((float)num * DSPGame.GameDesc.resourceMultiplier); } if (DSPGame.GameDesc.resourceMultiplier >= 99.5f && (int)veinGroup.Type != 7) { num = 1000000000; } InitializeVeinGroup(planet, groupIndex, veinGroup.Type, normalized); float num2 = 2.1f / Math.Max(planet.radius, 0.0001f); foreach (Vector2 item in obj) { Vector3 val4 = normalized + (item.x * val2 + item.y * val3) * num2; planet.data.EraseVegetableAtPoint(val4); val4 = ((Vector3)(ref val4)).normalized * planet.data.QueryHeight(val4); AddVeinToPlanet(planet, num, veinGroup.Type, val4, groupIndex, random); } } private static void InitializePlanetVeins(PlanetData planet, int veinVectorCount) { planet.data.veinCursor = 1; planet.veinGroups = (VeinGroup[])(object)new VeinGroup[veinVectorCount + 1]; ((VeinGroup)(ref planet.veinGroups[0])).SetNull(); } private static void InitializeVeinGroup(PlanetData planet, short groupIndex, EVeinType veinType, Vector3 position) { //IL_0010: 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_0022: 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) int num = groupIndex + 1; planet.veinGroups[num].type = veinType; planet.veinGroups[num].pos = position; planet.veinGroups[num].count = 0; planet.veinGroups[num].amount = 0L; } private static void AddVeinToPlanet(PlanetData planet, int amount, EVeinType veinType, Vector3 position, short groupIndex, DotNet35Random random) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Expected I4, but got Unknown //IL_001a: 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_002b: 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_0069: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) int num = (int)veinType; int num2 = PlanetModelingManager.veinModelIndexs[num]; int num3 = PlanetModelingManager.veinModelCounts[num]; short num4 = (short)(groupIndex + 1); VeinData val = new VeinData { amount = amount, pos = position, type = veinType, groupIndex = num4, minerCount = 0, modelIndex = (short)random.Next(num2, num2 + num3), productId = PlanetModelingManager.veinProducts[num] }; planet.veinGroups[num4].count++; planet.veinGroups[num4].amount += val.amount; planet.data.AddVeinData(val); } private static void GenerateNodeVectors(List nodeVectors, int maxCount, DotNet35Random random) { //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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) int num = 0; Vector2 val2 = default(Vector2); while (num++ < 20) { int count = nodeVectors.Count; for (int i = 0; i < count; i++) { if (nodeVectors.Count >= maxCount) { break; } Vector2 val = nodeVectors[i]; if (!(((Vector2)(ref val)).sqrMagnitude > 36f)) { double num2 = random.NextDouble() * Math.PI * 2.0; ((Vector2)(ref val2))..ctor((float)Math.Cos(num2), (float)Math.Sin(num2)); val2 += nodeVectors[i] * 0.2f; ((Vector2)(ref val2)).Normalize(); Vector2 candidate = nodeVectors[i] + val2; if (!nodeVectors.Any(delegate(Vector2 existing) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_000c: Unknown result type (might be due to invalid IL or missing references) Vector2 val3 = existing - candidate; return ((Vector2)(ref val3)).sqrMagnitude < 0.85f; })) { nodeVectors.Add(candidate); } } } if (nodeVectors.Count >= maxCount) { break; } } } private static Vector3 RandomDirection(DotNet35Random random) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) return new Vector3((float)random.NextDouble() * 2f - 1f, (float)random.NextDouble() * 2f - 1f, (float)random.NextDouble() * 2f - 1f); } private static bool SurfaceVectorCollision(Vector3 vector, List vectors, int processedVectorCount, float padding) { //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_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) for (int i = 0; i < processedVectorCount; i++) { if (vectors[i].Position != Vector3.zero) { Vector3 val = vectors[i].Position - vector; if (((Vector3)(ref val)).sqrMagnitude < padding) { return true; } } } return false; } private static void CutVeinTypes(ref List veinTypes, DotNet35Random random) { if (veinTypes.Count >= 1) { int num = random.Next(veinTypes.Count); List list = new List(); for (int i = num; i < veinTypes.Count; i++) { list.Add(veinTypes[i]); } for (int j = 0; j < num; j++) { list.Add(veinTypes[j]); } veinTypes = list; } } public static void EnsureRegistered() { if (registered || (Object)(object)LDB.themes == (Object)null || ((ProtoSet)(object)LDB.themes).dataArray == null || ((ProtoSet)(object)LDB.themes).dataArray.Length == 0) { return; } try { ThemeSpec themeSpec = CreateGiganticForest(); ThemeSpec themeSpec2 = CreateRedForest(); ThemeSpec themeSpec3 = CreateBeach(); ThemeSpec themeSpec4 = CreatePandora(); RegisterTheme(themeSpec); RegisterTheme(themeSpec2); RegisterTheme(CreateSulfurSea()); RegisterTheme(CreateMoltenWorld()); RegisterTheme(themeSpec3); RegisterTheme(themeSpec4); RegisterTheme(CreateObsidian()); RegisterTheme(CreateHotObsidian()); RegisterHiddenTheme(CreateRemovedSmallPlanetSlot("RemovedSmallPlanetTheme34", 11)); RegisterHiddenTheme(CreateRemovedSmallPlanetSlot("RemovedSmallPlanetTheme35", 11)); RegisterHiddenTheme(CreateRemovedSmallPlanetSlot("RemovedSmallPlanetTheme36", 10)); RegisterTheme(CreateInferno()); RegisterTheme(CreateOilGiant()); RegisterTheme(CreateColdVariant(themeSpec, "GiganticForestCold")); RegisterTheme(CreateColdVariant(themeSpec2, "RedForestCold")); RegisterTheme(CreateColdVariant(themeSpec3, "BeachCold")); RegisterTheme(CreateColdVariant(themeSpec4, "PandoraCold")); registered = true; SetRandomGenerationEnabled(ConfigUtility.EnableGalacticScaleThemesInRandomGeneration); Plugin.Instance.Logger.LogInfo((object)$"Registered {themeNameToId.Count} GalacticScale-style themes"); } catch (Exception ex) { Plugin.Instance.Logger.LogError((object)("Failed to register GalacticScale-style themes: " + ex.Message)); Plugin.Instance.Logger.LogError((object)ex.StackTrace); } } public static bool TryResolveThemeName(string name, out int themeId) { EnsureRegistered(); string text = NormalizeName(name); if (themeNameToId.TryGetValue(text, out themeId)) { return true; } ThemeProto[] dataArray = ((ProtoSet)(object)LDB.themes).dataArray; foreach (ThemeProto val in dataArray) { if (val != null && (NormalizeName(((Proto)val).Name) == text || NormalizeName(((Proto)val).name) == text || NormalizeName(val.DisplayName) == text || NormalizeName(val.displayName) == text)) { themeId = ((Proto)val).ID; return true; } } themeId = 0; return false; } public static string GetKnownThemeNames() { EnsureRegistered(); List list = new List(); ThemeProto[] dataArray = ((ProtoSet)(object)LDB.themes).dataArray; foreach (ThemeProto val in dataArray) { if (val != null && !string.IsNullOrWhiteSpace(((Proto)val).Name) && !((Proto)val).Name.StartsWith("RemovedSmallPlanetTheme", StringComparison.OrdinalIgnoreCase)) { list.Add(((Proto)val).Name); } } list.Sort(StringComparer.OrdinalIgnoreCase); return string.Join(", ", list.ToArray()); } public static void SetRandomGenerationEnabled(bool enabled) { //IL_0043: 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) EnsureRegistered(); foreach (RegisteredThemeInfo registeredThemeInfo in registeredThemeInfos) { ThemeProto val = ((ProtoSet)(object)LDB.themes).Select(registeredThemeInfo.Id); if (val != null) { val.Distribute = (EThemeDistribute)((!enabled || !registeredThemeInfo.IncludeInRandomGeneration) ? 3 : ((int)registeredThemeInfo.RandomDistribute)); } } } public static void ApplyRandomGenerationToGameDesc(GameDesc gameDesc, bool enabled) { EnsureRegistered(); SetRandomGenerationEnabled(enabled); if (gameDesc == null || gameDesc.savedThemeIds == null) { return; } HashSet hashSet = new HashSet(registeredThemeInfos.Select((RegisteredThemeInfo info) => info.Id)); HashSet hashSet2 = new HashSet(registeredThemeInfos.Where((RegisteredThemeInfo info) => info.ExtraRandomThemeIds != null).SelectMany((RegisteredThemeInfo info) => info.ExtraRandomThemeIds)); HashSet hashSet3 = new HashSet(); List list = new List(); int[] savedThemeIds = gameDesc.savedThemeIds; foreach (int item in savedThemeIds) { if (!hashSet.Contains(item) && (!hashSet2.Contains(item) || hashSet3.Add(item))) { list.Add(item); } } if (enabled) { foreach (RegisteredThemeInfo registeredThemeInfo in registeredThemeInfos) { if (registeredThemeInfo.IncludeInRandomGeneration) { if (registeredThemeInfo.ExtraRandomThemeIds != null) { list.AddRange(registeredThemeInfo.ExtraRandomThemeIds); } for (int num2 = 0; num2 < Math.Max(1, registeredThemeInfo.RandomWeight); num2++) { list.Add(registeredThemeInfo.Id); } } } } gameDesc.savedThemeIds = list.ToArray(); } public static bool ReapplyRegisteredThemeMaterials(ThemeProto proto) { if (proto == null || !TryGetRegisteredThemeSpec(proto, out var spec)) { return false; } try { ApplySpecAssets(proto, spec); if (materialReapplyLogged.Add(((Proto)proto).ID)) { Plugin.Instance.Logger.LogInfo((object)$"Applied GalacticScale-style material fix for theme {((Proto)proto).ID}: {((Proto)proto).Name}"); } return true; } catch (Exception ex) { Plugin.Instance.Logger.LogWarning((object)("Failed to reapply GalacticScale-style theme materials for " + ((Proto)proto).Name + ": " + ex.Message)); return false; } } public static bool ApplyRegisteredThemeToPlanet(PlanetData planet) { if (planet == null || !TryGetRegisteredThemeSpec(planet.theme, out var spec)) { return false; } ThemeProto val = ((ProtoSet)(object)LDB.themes).Select(planet.theme); if (val == null) { return false; } try { ApplySpecAssets(val, spec); ApplyThemeProtoToPlanetMaterials(planet, val, spec); return true; } catch (Exception ex) { Plugin.Instance.Logger.LogWarning((object)("Failed to apply GalacticScale-style planet materials for " + planet.displayName + ": " + ex.Message)); return false; } } public static bool PrepareRegisteredThemeForPlanet(PlanetData planet) { if (planet == null || !TryGetRegisteredThemeSpec(planet.theme, out var _)) { return false; } return ReapplyRegisteredThemeMaterials(((ProtoSet)(object)LDB.themes).Select(planet.theme)); } public static bool ApplyRegisteredThemeToLoadedPlanet(PlanetData planet) { if (!ApplyRegisteredThemeToPlanet(planet)) { return false; } SyncPlanetSimulatorMaterials(planet); return true; } public static void RefreshRegisteredThemeSimulator(PlanetSimulator simulator, Transform lookCamera, StarSimulator star) { //IL_009e: 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_00a4: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: 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_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0335: 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_0323: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)simulator == (Object)null || simulator.planetData == null || !IsRegisteredTheme(simulator.planetData.theme)) { return; } PlanetData planetData = simulator.planetData; if (planetData.loading || planetData.factoryLoading || (Object)(object)simulator.atmoTrans0 == (Object)null || (Object)(object)simulator.atmoTrans1 == (Object)null || (Object)(object)simulator.atmoMat == (Object)null || (Object)(object)simulator.atmoMatLate == (Object)null || (Object)(object)lookCamera == (Object)null) { return; } Camera main = GameCamera.main; if ((Object)(object)main == (Object)null) { return; } PlanetData localPlanet = GameMain.localPlanet; Quaternion val = localPlanet?.runtimeRotation ?? Quaternion.identity; Quaternion val2 = Quaternion.Inverse(val); VectorLF3 val3 = planetData.star.uPosition - planetData.uPosition; Vector3 sunDir = val2 * VectorLF3.op_Implicit(((VectorLF3)(ref val3)).normalized); if (FactoryModel.whiteMode0 && (Object)(object)GameCamera.instance?.camLight != (Object)null) { sunDir = -((Component)GameCamera.instance.camLight).transform.forward; } simulator.atmoTrans0.rotation = lookCamera.localRotation; Vector4 localPos = (((Object)(object)GameCamera.generalTarget == (Object)null) ? Vector4.zero : Vector4.op_Implicit(GameCamera.generalTarget.position)); Vector3 position = ((Component)main).transform.position; if (((Vector4)(ref localPos)).sqrMagnitude == 0f) { if (!GameCamera.instance.isPlanetMode && GameMain.mainPlayer != null) { localPos = Vector4.op_Implicit(GameMain.mainPlayer.position); } else { Vector4 val4 = Vector4.op_Implicit(position + ((Component)main).transform.forward * 30f); localPos = ((Vector4)(ref val4)).normalized * planetData.realRadius; } } Vector3 val5 = lookCamera.localPosition - ((Component)simulator).transform.localPosition; float num = Mathf.Max(((Vector3)(ref val5)).magnitude, 0.0001f); VectorLF3 val6 = planetData.uPosition; if (localPlanet != null) { val = localPlanet.runtimeRotation; if (localPlanet == planetData) { val6 = VectorLF3.zero; } else { val6 -= localPlanet.uPosition; val6 = Maths.QInvRotateLF(val, val6); } } else if (GameMain.mainPlayer != null) { val6 -= GameMain.mainPlayer.uPosition; } Vector3 val7 = default(Vector3); float num2 = default(float); UniverseSimulator.VirtualMapping(val6.x, val6.y, val6.z, position, ref val7, ref num2, 10000.0); float planetScaleFactor = GetPlanetScaleFactor(planetData); simulator.atmoTrans1.localPosition = new Vector3(0f, 0f, Mathf.Clamp(Vector3.Dot(val5, lookCamera.forward) + 10f / planetScaleFactor, 0f, Math.Max(320f, 320f * planetScaleFactor))); float fieldOfView = main.fieldOfView; float aspect = main.aspect; float num3 = Mathf.Atan(Mathf.Tan(fieldOfView * 0.5f * ((float)Math.PI / 180f)) * aspect) * 2f * 57.29578f; if (num3 > 90f) { simulator.atmoTrans1.localScale = Vector3.one * (planetData.realRadius * 5f * Mathf.Tan(num3 * 0.5f * ((float)Math.PI / 180f))); } else if (!Mathf.Approximately(simulator.atmoTrans1.localScale.x, planetData.realRadius * 5f)) { simulator.atmoTrans1.localScale = Vector3.one * (planetData.realRadius * 5f); } float intensityControl = Mathf.Clamp01(8000f / num); float num4 = Mathf.Clamp01(4000f / num); float distanceControl = Mathf.Max(0f, num / 6000f - 1f); Vector4 atmoMatRadiusParam = simulator.atmoMatRadiusParam; atmoMatRadiusParam.z = atmoMatRadiusParam.x + (atmoMatRadiusParam.z - atmoMatRadiusParam.x) * (2.7f - num4 * 1.7f); atmoMatRadiusParam *= num2 * planetScaleFactor; object obj = star; if (obj == null) { UniverseSimulator universeSimulator = GameMain.universeSimulator; obj = ((universeSimulator != null) ? universeSimulator.FindStarSimulator(planetData.star) : null); } StarSimulator val8 = (StarSimulator)obj; Color sunAtmosColor = (((Object)(object)val8 != (Object)null) ? val8.sunAtmosColor : Color.white); Color sunriseAtmosColor = (((Object)(object)val8 != (Object)null) ? val8.sunriseAtmosColor : Color.white); float scatterPower = Mathf.Max(60f * planetScaleFactor, (num - planetData.realRadius * 2f) * 0.18f); RefreshAtmosphereMaterial(simulator.atmoMat, ((Component)simulator).transform.localPosition, sunDir, atmoMatRadiusParam, sunAtmosColor, sunriseAtmosColor, localPos, scatterPower, intensityControl, distanceControl); RefreshAtmosphereMaterial(simulator.atmoMatLate, ((Component)simulator).transform.localPosition, sunDir, atmoMatRadiusParam, sunAtmosColor, sunriseAtmosColor, localPos, scatterPower, intensityControl, distanceControl); simulator.atmoMat.renderQueue = ((planetData == localPlanet) ? 2991 : 2989); if (planetData == localPlanet) { simulator.atmoMatLate.renderQueue = 3200; SetIntIfExists(simulator.atmoMatLate, "_StencilRef", 2); SetIntIfExists(simulator.atmoMatLate, "_StencilComp", 3); } else { simulator.atmoMatLate.renderQueue = 2989; SetIntIfExists(simulator.atmoMatLate, "_StencilRef", 0); SetIntIfExists(simulator.atmoMatLate, "_StencilComp", 1); } } public static bool IsRegisteredTheme(int themeId) { EnsureRegistered(); ThemeSpec spec; return TryGetRegisteredThemeSpec(themeId, out spec); } private static ThemeSpec CreateGiganticForest() { ThemeSpec themeSpec = new ThemeSpec(); themeSpec.Name = "GiganticForest"; themeSpec.DisplayName = "Gigantic Forest"; themeSpec.BaseThemeId = 8; themeSpec.OceanThemeId = 1; themeSpec.Algo = 1; themeSpec.Vegetables1 = new int[64] { 42, 42, 42, 46, 101, 101, 101, 101, 101, 101, 102, 102, 102, 102, 102, 102, 103, 103, 103, 103, 103, 103, 104, 104, 104, 104, 104, 104, 125, 125, 125, 125, 125, 125, 601, 601, 601, 601, 601, 601, 602, 602, 602, 602, 602, 602, 603, 603, 603, 603, 603, 603, 604, 604, 604, 604, 604, 604, 605, 605, 605, 605, 605, 605 }; themeSpec.Vegetables2 = new int[6] { 1001, 1002, 1003, 1005, 1006, 1007 }; themeSpec.Vegetables3 = new int[12] { 43, 46, 47, 47, 101, 102, 103, 104, 106, 601, 602, 604 }; themeSpec.Vegetables4 = new int[0]; themeSpec.Vegetables5 = new int[82] { 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43, 43, 43, 43, 43, 43, 46, 46, 47, 47, 47, 47, 47, 47, 47, 102, 103, 103, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 125, 125, 125, 125, 125, 125, 125, 604, 604, 604, 604, 604, 604, 604, 605, 605, 605, 605, 605, 605, 605, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002 }; themeSpec.Wind = 1.15f; themeSpec.Temperature = 0f; themeSpec.WaterHeight = 0f; themeSpec.WaterItemId = 1000; themeSpec.TerrainSettings = new ThemeTerrainSettings { Algorithm = "GSTA6" }; return themeSpec; } private static ThemeSpec CreateRedForest() { //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) ThemeProto val = ((ProtoSet)(object)LDB.themes).Select(14); ThemeSpec themeSpec = new ThemeSpec(); themeSpec.Name = "RedForest"; themeSpec.DisplayName = "Red Forest"; themeSpec.BaseThemeId = 8; themeSpec.Algo = 1; themeSpec.Vegetables0 = new int[5] { 26, 26, 45, 603, 604 }; themeSpec.Vegetables1 = new int[9] { 1001, 1001, 1001, 1001, 1001, 1001, 45, 26, 26 }; themeSpec.Vegetables2 = new int[1] { 1001 }; themeSpec.Vegetables3 = new int[8] { 26, 26, 26, 26, 45, 602, 603, 604 }; themeSpec.Vegetables4 = new int[5] { 1001, 26, 602, 603, 604 }; themeSpec.Vegetables5 = new int[6] { 25, 32, 36, 37, 39, 41 }; themeSpec.VeinSpot = Clone(val.VeinSpot); themeSpec.VeinCount = Clone(val.VeinCount); themeSpec.VeinOpacity = Clone(val.VeinOpacity); themeSpec.RareVeins = Clone(val.RareVeins); themeSpec.RareSettings = Clone(val.RareSettings); themeSpec.TerrainTint = new Color(0.35f, 0.08f, 0.06f, 1f); themeSpec.AtmosphereTint = new Color(0.45f, 0.12f, 0.1f, 0.75f); themeSpec.OceanTint = new Color(0.45f, 0.03f, 0.02f, 0.4f); themeSpec.Wind = 1f; themeSpec.Temperature = 0f; themeSpec.WaterHeight = 0f; themeSpec.WaterItemId = 1000; themeSpec.TerrainSettings = new ThemeTerrainSettings { Algorithm = "GSTA1", BaseHeight = -0.7, xFactor = 0.01, yFactor = 0.012, zFactor = 0.01, HeightMulti = 1.2, LandModifier = 1.3, RandomFactor = 0.3, BiomeHeightMulti = 2.0, BiomeHeightModifier = 0.2 }; return themeSpec; } private static ThemeSpec CreateSulfurSea() { //IL_0189: Unknown result type (might be due to invalid IL or missing references) ThemeSpec themeSpec = new ThemeSpec(); themeSpec.Name = "SulfurSea"; themeSpec.DisplayName = "Sulfurous Sea"; themeSpec.BaseThemeId = 16; themeSpec.TerrainThemeId = 12; themeSpec.OceanThemeId = 13; themeSpec.AtmosphereThemeId = 13; themeSpec.Algo = 7; themeSpec.PlanetType = (EPlanetType)2; themeSpec.Vegetables0 = new int[0]; themeSpec.Vegetables1 = new int[0]; themeSpec.Vegetables2 = new int[0]; themeSpec.Vegetables3 = new int[5] { 601, 602, 603, 604, 605 }; themeSpec.Vegetables4 = new int[5] { 601, 602, 603, 604, 605 }; themeSpec.Vegetables5 = new int[0]; themeSpec.AmbientThemeId = 13; themeSpec.OceanParams = new Dictionary { ["_GIGloss"] = 1f, ["_GISaturate"] = 0.8f, ["_GIStrengthDay"] = 1f, ["_GIStrengthNight"] = 0f }; themeSpec.Wind = 1f; themeSpec.IonHeight = 60f; themeSpec.Temperature = 1f; themeSpec.WaterHeight = -1.3f; themeSpec.WaterItemId = 1116; themeSpec.SFXPath = "SFX/sfx-amb-lava-1"; themeSpec.AtmosphereTint = new Color(0.3f, 0.3f, 0f, 1f); themeSpec.TerrainColors = SulfurSeaTerrainColors(); themeSpec.TerrainParams = SulfurSeaTerrainParams(); themeSpec.OceanColors = SulfurSeaOceanColors(); themeSpec.TerrainSettings = new ThemeTerrainSettings { Algorithm = "GSTA1", HeightMulti = 1.0, BaseHeight = -1.3, LandModifier = -0.7, RandomFactor = 0.1, BiomeHeightMulti = 2.9, BiomeHeightModifier = 1.0 }; return themeSpec; } private static Dictionary SulfurSeaTerrainColors() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) return new Dictionary { ["_AmbientColor0"] = new Color(0.18f, 0.145f, 0.08f, 1f), ["_AmbientColor1"] = new Color(0.105f, 0.085f, 0.055f, 1f), ["_AmbientColor2"] = new Color(0.045f, 0.043f, 0.035f, 1f), ["_Color"] = new Color(0.62f, 0.54f, 0.36f, 1f), ["_EmissionColor"] = new Color(0f, 0f, 0f, 1f), ["_HeightEmissionColor"] = new Color(0f, 0f, 0f, 0f), ["_LightColorScreen"] = new Color(0.12f, 0.1f, 0.06f, 1f), ["_SpeclColor"] = new Color(0.12f, 0.1f, 0.08f, 1f), ["_Rotation"] = new Color(0f, 0f, 0f, 1f), ["_SunDir"] = new Color(0.6943676f, -0.1823572f, 0.6961318f, 0f) }; } private static Dictionary SulfurSeaTerrainParams() { return new Dictionary { ["_AmbientInc"] = 0.25f, ["_BioFuzzMask"] = 1f, ["_BioFuzzStrength"] = 0f, ["_BumpScale"] = 1f, ["_Cutoff"] = 0.5f, ["_DetailNormalMapScale"] = 1f, ["_Distance"] = 290.6332f, ["_DstBlend"] = 0f, ["_EmissionStrength"] = 0f, ["_GlossMapScale"] = 1f, ["_Glossiness"] = 0.5f, ["_GlossyReflections"] = 1f, ["_HeightEmissionRadius"] = 50f, ["_Metallic"] = 0f, ["_Mode"] = 0f, ["_Multiplier"] = 0.8f, ["_NormalStrength"] = 0.55f, ["_OcclusionStrength"] = 1f, ["_Parallax"] = 0.02f, ["_Radius"] = 200f, ["_SmoothnessTextureChannel"] = 0f, ["_SpecularHighlights"] = 0f, ["_SrcBlend"] = 1f, ["_StepBlend"] = 0.35f, ["_UVSec"] = 0f, ["_ZWrite"] = 1f }; } private static Dictionary SulfurSeaOceanColors() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0217: 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_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_052f: Unknown result type (might be due to invalid IL or missing references) return new Dictionary { ["_BumpDirection"] = new Color(1f, 1f, -1f, 1f), ["_BumpTiling"] = new Color(1f, 1f, -2f, 3f), ["_CausticsColor"] = new Color(0.3867925f, 0.3267751f, 0.08940012f, 1f), ["_Color"] = new Color(79f / 106f, 0.6000856f, 0.4745906f, 1f), ["_Color0"] = new Color(0f, 0.1574037f, 0.2352941f, 1f), ["_Color1"] = new Color(77f / 106f, 77f / 106f, 77f / 106f, 1f), ["_Color2"] = new Color(0.6763465f, 0.6792453f, 0.6183695f, 1f), ["_Color3"] = new Color(0.6037736f, 0.523596f, 0.4243503f, 1f), ["_DensityParams"] = new Color(0.02f, 0.1f, 0f, 0f), ["_DepthColor"] = new Color(0f, 0.06095791f, 0.1132075f, 1f), ["_DepthFactor"] = new Color(0.4f, 0.4f, 0.5f, 0.1f), ["_Foam"] = new Color(15f, 1f, 5f, 1.5f), ["_FoamColor"] = new Color(0.3925616f, 0.4150942f, 0.2581885f, 1f), ["_FoamParams"] = new Color(12f, 0.2f, 0.15f, 0.7f), ["_FresnelColor"] = new Color(0.383585f, 0.2812832f, 0.4056602f, 1f), ["_InvFadeParemeter"] = new Color(0.9f, 0.25f, 0.5f, 0.08f), ["_PLColor1"] = new Color(0f, 0f, 0f, 1f), ["_PLColor2"] = new Color(0f, 0f, 0f, 1f), ["_PLColor3"] = new Color(1f, 1f, 1f, 1f), ["_PLParam1"] = new Color(0f, 0f, 0f, 0f), ["_PLParam2"] = new Color(0f, 0f, 0f, 0f), ["_PLPos1"] = new Color(0f, 0f, 0f, 0f), ["_PLPos2"] = new Color(0f, 0f, 0f, 0f), ["_PLPos3"] = new Color(0f, 0.1f, -0.5f, 0f), ["_Paremeters1"] = new Color(0.02f, 0.1f, 0f, 0f), ["_PointAtten"] = new Color(0f, 0.1f, -0.5f, 0f), ["_PointLightPos"] = new Color(0f, 0.1f, -0.5f, 0f), ["_ReflectionColor"] = new Color(0.1933962f, 0.5064065f, 1f, 1f), ["_SLColor1"] = new Color(1f, 1f, 1f, 1f), ["_SLDir1"] = new Color(0f, 0.1f, -0.5f, 0f), ["_SLPos1"] = new Color(0f, 0.1f, -0.5f, 0f), ["_SpecColor"] = new Color(1f, 1f, 1f, 1f), ["_SpeclColor"] = new Color(0.4100249f, 0.4411012f, 0.497f, 1f), ["_SpeclColor1"] = new Color(0.5257207f, 0.5331763f, 0.6226414f, 1f), ["_Specular"] = new Color(0.9573934f, 0.8672858f, 0.5744361f, 0.9573934f), ["_SunDirection"] = new Color(-0.6f, 0.8f, 0f, 0f), ["_WorldLightDir"] = new Color(-0.6525278f, -0.6042119f, -0.4573132f, 0f) }; } private static ThemeSpec CreateMoltenWorld() { ThemeSpec themeSpec = new ThemeSpec(); themeSpec.Name = "MoltenWorld"; themeSpec.DisplayName = "Molten World"; themeSpec.BaseThemeId = 9; themeSpec.Algo = 3; themeSpec.ExtraRandomThemeIds = new int[4] { 9, 9, 9, 9 }; themeSpec.AmbientThemeId = 9; themeSpec.WaterHeight = -1.5f; themeSpec.WaterItemId = 1116; themeSpec.Wind = 0.8f; themeSpec.IonHeight = 70f; themeSpec.SFXPath = "SFX/sfx-amb-lava-1"; themeSpec.TerrainSettings = new ThemeTerrainSettings { Algorithm = "GSTA1", BaseHeight = -1.5, xFactor = 0.01, yFactor = 0.012, zFactor = 0.01, HeightMulti = 0.4, LandModifier = -0.9, RandomFactor = -1.0, BiomeHeightMulti = 2.0, BiomeHeightModifier = 1.2 }; return themeSpec; } private static ThemeSpec CreateBeach() { ThemeSpec themeSpec = new ThemeSpec(); themeSpec.Name = "Beach"; themeSpec.DisplayName = "Beach"; themeSpec.BaseThemeId = 16; themeSpec.Algo = 1; themeSpec.RandomDistribute = (EThemeDistribute)2; themeSpec.RandomWeight = 3; themeSpec.Vegetables0 = new int[0]; themeSpec.Vegetables1 = new int[0]; themeSpec.Vegetables2 = new int[3] { 1001, 1002, 1003 }; themeSpec.Vegetables3 = new int[3] { 1001, 1002, 1003 }; themeSpec.Vegetables4 = new int[1] { 1004 }; themeSpec.Vegetables5 = new int[0]; themeSpec.Temperature = 0.4f; themeSpec.WaterHeight = 0f; themeSpec.WaterItemId = 1000; themeSpec.Wind = 1.1f; themeSpec.AmbientLutContribution = 0.25f; themeSpec.AmbientOverride = ApplyGsOceanWorldAmbient; themeSpec.TerrainColors = GsOceanWorldTerrainColors(); themeSpec.TerrainParams = GsOceanWorldTerrainParams(); themeSpec.OceanColors = GsOceanWorldOceanColors(); themeSpec.OceanParams = GsOceanWorldOceanParams(); themeSpec.AtmosphereColors = GsOceanWorldAtmosphereColors(); themeSpec.AtmosphereParams = GsOceanWorldAtmosphereParams(); themeSpec.TerrainSettings = new ThemeTerrainSettings { Algorithm = "GSTA1" }; themeSpec.VeinSettings = CreateBeachVeinSettings(); return themeSpec; } private static ThemeVeinSettings CreateBeachVeinSettings() { return new ThemeVeinSettings { Algorithm = "GS2", VeinPadding = 1f, VeinTypes = new List { ThemeVeinType.Generate((EVeinType)3, 10, 30, 1f, 10f, 5, 25, rare: false, 1001), ThemeVeinType.Generate((EVeinType)13, 2, 6, 1f, 10f, 5, 25, rare: true, 1002), ThemeVeinType.Generate((EVeinType)10, 2, 6, 1f, 10f, 5, 25, rare: false, 1003), ThemeVeinType.Generate((EVeinType)12, 2, 6, 1f, 10f, 5, 25, rare: false, 1004) } }; } private static Dictionary GsOceanWorldTerrainColors() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) return new Dictionary { ["_AmbientColor0"] = new Color(0.1098038f, 0.1415093f, 0.1333332f, 1f), ["_AmbientColor1"] = new Color(0.06666655f, 0.03519787f, 0.03137255f, 1f), ["_AmbientColor2"] = new Color(0.03921569f, 0.03921569f, 0.1764704f, 1f), ["_Color"] = new Color(1f, 1f, 1f, 1f), ["_EmissionColor"] = new Color(0f, 0f, 0f, 1f), ["_HeightEmissionColor"] = new Color(0f, 0f, 0f, 0f), ["_LightColorScreen"] = new Color(0f, 0f, 0f, 1f), ["_Rotation"] = new Color(0f, 0f, 0f, 1f), ["_SunDir"] = new Color(0.3786571f, 0.01833941f, 0.9253553f, 0f) }; } private static void ApplyGsOceanWorldAmbient(AmbientDesc ambient) { //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_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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) ambient.ambientColor0 = new Color(0.1098039f, 0.1415094f, 0.1333333f, 1f); ambient.ambientColor1 = new Color(0.03137255f, 0.05890403f, 1f / 15f, 1f); ambient.ambientColor2 = new Color(0.03921569f, 0.03921569f, 0.1764706f, 1f); ambient.waterAmbientColor0 = new Color(0f, 0f, 0f, 1f); ambient.waterAmbientColor1 = new Color(0.1354839f, 0.1806452f, 0.2f, 1f); ambient.waterAmbientColor2 = new Color(0.03888888f, 0.1444444f, 0.2f, 1f); ambient.biomoColor0 = new Color(0.8745098f, 0.6923354f, 0.3960784f, 1f); ambient.biomoColor1 = new Color(0.8745098f, 0.6941177f, 0.3960784f, 1f); ambient.biomoColor2 = new Color(0.8745098f, 0.6941177f, 0.3960784f, 1f); ambient.biomoDustColor0 = new Color(1f, 0.8645418f, 0.6812749f, 1f); ambient.biomoDustColor1 = new Color(1f, 0.8627452f, 0.682353f, 1f); ambient.biomoDustColor2 = new Color(1f, 0.8627452f, 0.682353f, 1f); ambient.biomoDustStrength0 = 4f; ambient.biomoDustStrength1 = 4f; ambient.biomoDustStrength2 = 4f; ambient.biomoSound0 = 0; ambient.biomoSound1 = 0; ambient.biomoSound2 = 0; ambient.lutContribution = 0.25f; } private static Dictionary GsOceanWorldTerrainParams() { return new Dictionary { ["_AmbientInc"] = 0.9f, ["_BioFuzzMask"] = 1f, ["_BioFuzzStrength"] = 0.1f, ["_BumpScale"] = 1f, ["_Cutoff"] = 0.5f, ["_DetailNormalMapScale"] = 1f, ["_Distance"] = 314.7685f, ["_DstBlend"] = 0f, ["_EmissionStrength"] = 0f, ["_GlossMapScale"] = 1f, ["_Glossiness"] = 0.5f, ["_GlossyReflections"] = 1f, ["_HeightEmissionRadius"] = 50f, ["_Metallic"] = 0f, ["_Mode"] = 0f, ["_Multiplier"] = 1.6f, ["_NormalStrength"] = 1f, ["_OcclusionStrength"] = 1f, ["_Parallax"] = 0.02f, ["_Radius"] = 200f, ["_SmoothnessTextureChannel"] = 0f, ["_SpecularHighlights"] = 1f, ["_SrcBlend"] = 1f, ["_StepBlend"] = 0.55f, ["_UVSec"] = 0f, ["_ZWrite"] = 1f }; } private static Dictionary GsOceanWorldOceanColors() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0217: 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_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_052f: Unknown result type (might be due to invalid IL or missing references) return new Dictionary { ["_BumpDirection"] = new Color(1f, 1f, -1f, 1f), ["_BumpTiling"] = new Color(1f, 1f, -2f, 3f), ["_CausticsColor"] = new Color(0.5506853f, 0.7075471f, 0.6751246f, 1f), ["_Color"] = new Color(1f, 82f / 85f, 0.7686275f, 1f), ["_Color0"] = new Color(0f, 0.1574037f, 0.2352941f, 1f), ["_Color1"] = new Color(49f / 85f, 0.8313726f, 0.7921569f, 1f), ["_Color2"] = new Color(0.3551085f, 0.6892567f, 0.7169812f, 1f), ["_Color3"] = new Color(0.2731398f, 0.504477f, 0.5849056f, 1f), ["_DensityParams"] = new Color(0.02f, 0.1f, 0f, 0f), ["_DepthColor"] = new Color(0f, 0.06095791f, 0.1132075f, 1f), ["_DepthFactor"] = new Color(0.4f, 0.35f, 0.15f, 0.1f), ["_Foam"] = new Color(15f, 1f, 5f, 1.5f), ["_FoamColor"] = new Color(1f, 1f, 1f, 1f), ["_FoamParams"] = new Color(12f, 0.2f, 0.15f, 0.7f), ["_FresnelColor"] = new Color(0.2470588f, 0.6588235f, 0.8862746f, 1f), ["_InvFadeParemeter"] = new Color(0.9f, 0.25f, 0.5f, 0.08f), ["_PLColor1"] = new Color(0f, 0f, 0f, 1f), ["_PLColor2"] = new Color(0f, 0f, 0f, 1f), ["_PLColor3"] = new Color(1f, 1f, 1f, 1f), ["_PLParam1"] = new Color(0f, 0f, 0f, 0f), ["_PLParam2"] = new Color(0f, 0f, 0f, 0f), ["_PLPos1"] = new Color(0f, 0f, 0f, 0f), ["_PLPos2"] = new Color(0f, 0f, 0f, 0f), ["_PLPos3"] = new Color(0f, 0.1f, -0.5f, 0f), ["_Paremeters1"] = new Color(0.02f, 0.1f, 0f, 0f), ["_PointAtten"] = new Color(0f, 0.1f, -0.5f, 0f), ["_PointLightPos"] = new Color(0f, 0.1f, -0.5f, 0f), ["_ReflectionColor"] = new Color(0.1933962f, 0.5064065f, 1f, 1f), ["_SLColor1"] = new Color(1f, 1f, 1f, 1f), ["_SLDir1"] = new Color(0f, 0.1f, -0.5f, 0f), ["_SLPos1"] = new Color(0f, 0.1f, -0.5f, 0f), ["_SpecColor"] = new Color(1f, 1f, 1f, 1f), ["_SpeclColor"] = new Color(1f, 1f, 1f, 1f), ["_SpeclColor1"] = new Color(95f / 106f, 0.614061f, 0.1733267f, 1f), ["_Specular"] = new Color(0.9573934f, 0.8672858f, 0.5744361f, 0.9573934f), ["_SunDirection"] = new Color(-0.6f, 0.8f, 0f, 0f), ["_WorldLightDir"] = new Color(-0.6525278f, -0.6042119f, -0.4573132f, 0f) }; } private static Dictionary GsOceanWorldOceanParams() { return new Dictionary { ["_CausticsTiling"] = 0.03f, ["_DistortionStrength"] = 1f, ["_FoamInvThickness"] = 6f, ["_FoamSpeed"] = 0.15f, ["_FoamSync"] = 4f, ["_GIGloss"] = 0.6f, ["_GISaturate"] = 1f, ["_GIStrengthDay"] = 1f, ["_GIStrengthNight"] = 0.03f, ["_NormalSpeed"] = 0.6f, ["_NormalStrength"] = 0.4f, ["_NormalTiling"] = 0.06f, ["_PLEdgeAtten"] = 0.5f, ["_PLIntensity2"] = 0f, ["_PLIntensity3"] = 0f, ["_PLRange2"] = 10f, ["_PLRange3"] = 10f, ["_PointLightK"] = 0.01f, ["_PointLightRange"] = 10f, ["_Radius"] = 200f, ["_ReflectionBlend"] = 0.86f, ["_ReflectionTint"] = 0f, ["_RefractionAmt"] = 1000f, ["_RefractionStrength"] = 0.3f, ["_SLCosCutoff1"] = 0.3f, ["_SLIntensity1"] = 1f, ["_SLRange1"] = 10f, ["_Shininess"] = 40f, ["_ShoreIntens"] = 1.4f, ["_SpeclColorDayStrength"] = 0f, ["_SpotExp"] = 2f, ["_Tile"] = 0.05f }; } private static Dictionary GsOceanWorldAtmosphereColors() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0217: 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_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) return new Dictionary { ["_Color"] = new Color(0.3443396f, 0.734796f, 1f, 1f), ["_Color0"] = new Color(33f / 85f, 0.7017767f, 1f, 1f), ["_Color1"] = new Color(0.28854f, 0.7906604f, 0.916f, 1f), ["_Color2"] = new Color(0.4466639f, 0.84536f, 0.888f, 1f), ["_Color3"] = new Color(0.7357877f, 0.923f, 0.9083642f, 1f), ["_Color4"] = new Color(1f, 0.7438396f, 0.4147364f, 1f), ["_Color5"] = new Color(0.2392156f, 0.8758385f, 1f, 1f), ["_Color6"] = new Color(0.3529411f, 0.7509555f, 1f, 1f), ["_Color7"] = new Color(0.2078431f, 0.4966022f, 0.6980392f, 1f), ["_Color8"] = new Color(1f, 1f, 1f, 1f), ["_ColorF"] = new Color(0.4669811f, 0.9485019f, 1f, 1f), ["_EmissionColor"] = new Color(0f, 0f, 0f, 1f), ["_LocalPos"] = new Color(78.1805f, 142.5101f, 140.7908f, 0f), ["_PlanetPos"] = new Color(0f, 0f, 0f, 0f), ["_PlanetRadius"] = new Color(200f, 199.98f, 270f, 0f), ["_Sky0"] = new Color(0.4198112f, 0.6650285f, 1f, 0.1607843f), ["_Sky1"] = new Color(0.485849f, 0.5557498f, 1f, 5f / 51f), ["_Sky2"] = new Color(0.839f, 1f, 0.9984235f, 0.9176471f), ["_Sky3"] = new Color(0.2666666f, 0.7909663f, 1f, 0.6705883f), ["_Sky4"] = new Color(1f, 0.7368349f, 0.3171324f, 1f) }; } private static Dictionary GsOceanWorldAtmosphereParams() { return new Dictionary { ["_AtmoDensity"] = 1f, ["_AtmoThickness"] = 70f, ["_BumpScale"] = 1f, ["_Cutoff"] = 0.5f, ["_Density"] = 0.005f, ["_DetailNormalMapScale"] = 1f, ["_DistanceControl"] = 0f, ["_DstBlend"] = 0f, ["_FarFogDensity"] = 0.03f, ["_FogDensity"] = 0.3f, ["_FogSaturate"] = 1.5f, ["_GlossMapScale"] = 1f, ["_Glossiness"] = 0.5f, ["_GlossyReflections"] = 1f, ["_GroundAtmosPower"] = 3f, ["_Intensity"] = 1f, ["_IntensityControl"] = 1f, ["_Metallic"] = 0f, ["_Mode"] = 0f, ["_OcclusionStrength"] = 1f, ["_Parallax"] = 0.02f, ["_RimFogExp"] = 1.35f, ["_RimFogPower"] = 3.2f, ["_SkyAtmosPower"] = 7f, ["_SmoothnessTextureChannel"] = 0f, ["_SpecularHighlights"] = 1f, ["_SrcBlend"] = 1f, ["_StencilComp"] = 8f, ["_StencilRef"] = 0f, ["_SunColorAdd"] = 0f, ["_SunColorSkyUse"] = 0.2f, ["_SunColorUse"] = 0.6f, ["_SunRiseScatterPower"] = 60f, ["_UVSec"] = 0f, ["_ZWrite"] = 1f }; } private static ThemeSpec CreatePandora() { //IL_0051: 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) return new ThemeSpec { Name = "Pandora", DisplayName = "Pandora", BaseThemeId = 25, OceanThemeId = 1, Algo = 13, OceanTint = new Color(0.15f, 0f, 0.3f, 0.5f), AtmosphereTint = new Color(0.25f, 0.05f, 0.4f, 0.65f), Temperature = 0f, WaterHeight = 0f, WaterItemId = 1000, Wind = 1f, TerrainSettings = new ThemeTerrainSettings { Algorithm = "Vanilla" } }; } private static ThemeSpec CreateObsidian() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) return new ThemeSpec { Name = "Obsidian", DisplayName = "Obsidian", BaseThemeId = 10, Algo = 2, PlanetType = (EPlanetType)4, RandomDistribute = (EThemeDistribute)2, RandomWeight = 3, TerrainTint = new Color(0.15f, 0.15f, 0.15f, 1f), OceanTint = new Color(0f, 0f, 0f, 0.5f), AtmosphereTint = new Color(0f, 0f, 0f, 1f), AmbientThemeId = 10, AmbientLutContribution = 1f, AmbientReflectionColor = new Color(0f, 0f, 0f, 1f), TerrainParams = new Dictionary { ["_AmbientInc"] = 0f, ["_GISaturate"] = 0f, ["_GIStrengthDay"] = 0.01505f, ["_GIStrengthNight"] = 0.013f, ["_Multiplier"] = 0.0018f, ["_NormalStrength"] = 0.2101f, ["_SpecularHighlights"] = 110.1f }, TerrainColors = new Dictionary { ["_SpeclColor"] = new Color(0.14f, 0.14f, 0.14f, 1f) }, AtmosphereColors = new Dictionary { ["_Color"] = new Color(1f, 1f, 1f, 1f) }, Temperature = 2f, Wind = 0.4f, TerrainSettings = new ThemeTerrainSettings { Algorithm = "GSTA3", BiomeHeightMulti = 0.0, BiomeHeightModifier = -111.0, HeightMulti = 1.0, RandomFactor = 1.0 } }; } private static ThemeSpec CreateHotObsidian() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) return new ThemeSpec { Name = "HotObsidian", DisplayName = "Hot Obsidian", BaseThemeId = 10, Algo = 2, PlanetType = (EPlanetType)4, RandomDistribute = (EThemeDistribute)2, RandomWeight = 2, TerrainTint = new Color(0.2f, 0.05f, 0.05f, 1f), OceanTint = new Color(0f, 0f, 0f, 0.5f), AtmosphereTint = new Color(0f, 0f, 0f, 1f), AmbientThemeId = 10, AmbientLutContribution = 1f, AmbientReflectionColor = new Color(0f, 0f, 0f, 1f), TerrainParams = ObsidianTerrainParams(), TerrainColors = new Dictionary { ["_SpeclColor"] = new Color(0.14f, 0.14f, 0.14f, 1f) }, AtmosphereColors = new Dictionary { ["_Color"] = new Color(1f, 1f, 1f, 1f) }, Temperature = 5f, Wind = 0.3f, TerrainSettings = new ThemeTerrainSettings { Algorithm = "GSTA3", BiomeHeightMulti = 0.0, BiomeHeightModifier = -111.0, HeightMulti = 1.0, RandomFactor = 1.0 } }; } private static Dictionary ObsidianTerrainParams() { return new Dictionary { ["_AmbientInc"] = 0f, ["_GISaturate"] = 0f, ["_GIStrengthDay"] = 0.01505f, ["_GIStrengthNight"] = 0.013f, ["_Multiplier"] = 0.0018f, ["_NormalStrength"] = 0.2101f, ["_SpecularHighlights"] = 110.1f }; } private static ThemeSpec CreateInferno() { //IL_00a0: 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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) ThemeSpec themeSpec = new ThemeSpec(); themeSpec.Name = "Inferno"; themeSpec.DisplayName = "Infernal Gas Giant"; themeSpec.BaseThemeId = 2; themeSpec.TerrainThemeId = 2; themeSpec.OceanThemeId = 2; themeSpec.Algo = 0; themeSpec.PlanetType = (EPlanetType)5; themeSpec.GasItems = new int[2] { 1120, 1121 }; themeSpec.GasSpeeds = new float[2] { 0.3f, 0.15f }; themeSpec.TerrainTint = new Color(1f, 0.45f, 0.04f, 0.75f); themeSpec.OceanTint = new Color(1f, 0.2f, 0.03f, 0.7f); themeSpec.AmbientThemeId = 1; themeSpec.TerrainParams = new Dictionary { ["_SkyAtmosPower"] = 10f, ["_Intensity"] = 0.5f, ["_Multiplier"] = 0.5f, ["_AtmoThickness"] = 3f }; themeSpec.TerrainColors = new Dictionary { ["_Color1"] = new Color(0f, 0f, 0f, 1f), ["_Color2"] = new Color(0f, 0f, 0f, 1f), ["_Color3"] = new Color(0f, 0f, 0f, 1f), ["_Color4"] = new Color(0f, 0f, 0f, 1f) }; themeSpec.OceanColors = new Dictionary { ["_Color"] = new Color(0.288f, 0.14f, 0.03f, 1f) }; themeSpec.Temperature = 4f; themeSpec.WaterItemId = 1000; themeSpec.SFXPath = "SFX/sfx-amb-massive"; return themeSpec; } private static ThemeSpec CreateOilGiant() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) ThemeSpec themeSpec = new ThemeSpec(); themeSpec.Name = "OilGiant"; themeSpec.DisplayName = "Oil Giant"; themeSpec.BaseThemeId = 4; themeSpec.Algo = 0; themeSpec.PlanetType = (EPlanetType)5; themeSpec.GasItems = new int[2] { 1114, 1120 }; themeSpec.GasSpeeds = new float[2] { 0.1f, 10f }; themeSpec.TerrainTint = new Color(0.08f, 0.08f, 0.08f, 0.95f); themeSpec.AtmosphereTint = new Color(0f, 0f, 0f, 0.85f); themeSpec.Temperature = -1f; themeSpec.WaterItemId = 0; themeSpec.SFXPath = "SFX/sfx-amb-massive"; return themeSpec; } private static ThemeSpec CreateColdVariant(ThemeSpec source, string name) { ThemeSpec themeSpec = source.Clone(); themeSpec.Name = name; themeSpec.PlanetType = (EPlanetType)4; themeSpec.Temperature = -1f; return themeSpec; } private static ThemeSpec CreateRemovedSmallPlanetSlot(string name, int baseThemeId) { return new ThemeSpec { Name = name, DisplayName = "Removed Small Planet Theme", BaseThemeId = baseThemeId, IncludeInRandomGeneration = false, RandomWeight = 0 }; } private static void RegisterTheme(ThemeSpec spec) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_005c: 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_00ab: Unknown result type (might be due to invalid IL or missing references) if (TryResolveAlreadyRegistered(spec.Name, out var themeId)) { AddAliases(spec, themeId); int id = themeId; ThemeProto obj = ((ProtoSet)(object)LDB.themes).Select(themeId); RememberRegisteredTheme(spec, id, (EThemeDistribute)((obj == null) ? 2 : ((int)obj.Distribute))); return; } ThemeProto val = BuildThemeProto(spec); EThemeDistribute randomDistribute = (EThemeDistribute)(((??)spec.RandomDistribute) ?? val.Distribute); val.Distribute = (EThemeDistribute)3; ThemeProtoSet themes = LDB.themes; int num = ((ProtoSet)(object)themes).dataArray.Length; Array.Resize(ref ((ProtoSet)(object)themes).dataArray, num + 1); int id2 = (((Proto)val).ID = ((ProtoSet)(object)themes).dataArray.Length); ((ProtoSet)(object)themes).dataArray[num] = val; ((ProtoSet)(object)themes).OnAfterDeserialize(); AddAliases(spec, id2); RememberRegisteredTheme(spec, id2, randomDistribute); } private static void RegisterHiddenTheme(ThemeSpec spec) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (TryResolveAlreadyRegistered(spec.Name, out var themeId)) { int id = themeId; ThemeProto obj = ((ProtoSet)(object)LDB.themes).Select(themeId); RememberRegisteredTheme(spec, id, (EThemeDistribute)((obj == null) ? 3 : ((int)obj.Distribute))); return; } ThemeProto val = BuildThemeProto(spec); EThemeDistribute randomDistribute = (EThemeDistribute)(((??)spec.RandomDistribute) ?? val.Distribute); val.Distribute = (EThemeDistribute)3; ThemeProtoSet themes = LDB.themes; int num = ((ProtoSet)(object)themes).dataArray.Length; Array.Resize(ref ((ProtoSet)(object)themes).dataArray, num + 1); int id2 = (((Proto)val).ID = ((ProtoSet)(object)themes).dataArray.Length); ((ProtoSet)(object)themes).dataArray[num] = val; ((ProtoSet)(object)themes).OnAfterDeserialize(); RememberRegisteredTheme(spec, id2, randomDistribute); } private static bool TryResolveAlreadyRegistered(string name, out int themeId) { string text = NormalizeName(name); ThemeProto[] dataArray = ((ProtoSet)(object)LDB.themes).dataArray; foreach (ThemeProto val in dataArray) { if (val != null && (NormalizeName(((Proto)val).Name) == text || NormalizeName(((Proto)val).name) == text)) { themeId = ((Proto)val).ID; return true; } } themeId = 0; return false; } private static void AddAliases(ThemeSpec spec, int id) { AddAlias(spec.Name, id); AddAlias(spec.DisplayName, id); } private static void AddAlias(string name, int id) { string text = NormalizeName(name); if (!string.IsNullOrWhiteSpace(text) && !themeNameToId.ContainsKey(text)) { themeNameToId[text] = id; } } private static void RememberRegisteredTheme(ThemeSpec spec, int id, EThemeDistribute randomDistribute) { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) themeSpecsById[id] = spec; string text = NormalizeName(spec.Name); if (!string.IsNullOrWhiteSpace(text)) { themeSpecsByName[text] = spec; } string text2 = NormalizeName(spec.DisplayName); if (!string.IsNullOrWhiteSpace(text2)) { themeSpecsByName[text2] = spec; } if (!registeredThemeInfos.Any((RegisteredThemeInfo info) => info.Id == id)) { registeredThemeInfos.Add(new RegisteredThemeInfo { Id = id, IncludeInRandomGeneration = spec.IncludeInRandomGeneration, RandomWeight = spec.RandomWeight, RandomDistribute = randomDistribute, ExtraRandomThemeIds = Clone(spec.ExtraRandomThemeIds) }); } } private static bool TryGetRegisteredThemeSpec(ThemeProto proto, out ThemeSpec spec) { if (themeSpecsById.TryGetValue(((Proto)proto).ID, out spec)) { return true; } if (themeSpecsByName.TryGetValue(NormalizeName(((Proto)proto).Name), out spec) || themeSpecsByName.TryGetValue(NormalizeName(((Proto)proto).name), out spec) || themeSpecsByName.TryGetValue(NormalizeName(proto.DisplayName), out spec) || themeSpecsByName.TryGetValue(NormalizeName(proto.displayName), out spec)) { return true; } spec = null; return false; } private static bool TryGetRegisteredThemeSpec(int themeId, out ThemeSpec spec) { EnsureRegistered(); if (themeSpecsById.TryGetValue(themeId, out spec)) { return true; } ThemeProto val = ((ProtoSet)(object)LDB.themes).Select(themeId); if (val != null) { return TryGetRegisteredThemeSpec(val, out spec); } spec = null; return false; } private static ThemeProto BuildThemeProto(ThemeSpec spec) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) ThemeProto val = RequireTheme(spec.BaseThemeId); EnsureThemePreloaded(val); ThemeProto val2 = new ThemeProto(); ((Proto)val2).name = spec.Name; ((Proto)val2).Name = spec.Name; ((Proto)val2).sid = ""; ((Proto)val2).SID = ""; val2.PlanetType = (EPlanetType)(((??)spec.PlanetType) ?? val.PlanetType); val2.DisplayName = spec.DisplayName; val2.displayName = spec.DisplayName; val2.Algos = new int[1] { spec.Algo ?? FirstAlgo(val) }; val2.MaterialPath = val.MaterialPath; val2.Temperature = spec.Temperature ?? val.Temperature; val2.Distribute = val.Distribute; val2.ModX = val.ModX; val2.ModY = val.ModY; val2.Vegetables0 = spec.Vegetables0 ?? Clone(val.Vegetables0); val2.Vegetables1 = spec.Vegetables1 ?? Clone(val.Vegetables1); val2.Vegetables2 = spec.Vegetables2 ?? Clone(val.Vegetables2); val2.Vegetables3 = spec.Vegetables3 ?? Clone(val.Vegetables3); val2.Vegetables4 = spec.Vegetables4 ?? Clone(val.Vegetables4); val2.Vegetables5 = spec.Vegetables5 ?? Clone(val.Vegetables5); val2.VeinSpot = spec.VeinSpot ?? Clone(val.VeinSpot); val2.VeinCount = spec.VeinCount ?? Clone(val.VeinCount); val2.VeinOpacity = spec.VeinOpacity ?? Clone(val.VeinOpacity); val2.RareVeins = spec.RareVeins ?? Clone(val.RareVeins); val2.RareSettings = spec.RareSettings ?? Clone(val.RareSettings); val2.GasItems = spec.GasItems ?? Clone(val.GasItems); val2.GasSpeeds = spec.GasSpeeds ?? Clone(val.GasSpeeds); val2.UseHeightForBuild = val.UseHeightForBuild; val2.Wind = spec.Wind ?? val.Wind; val2.IonHeight = spec.IonHeight ?? val.IonHeight; val2.WaterHeight = spec.WaterHeight ?? val.WaterHeight; val2.WaterItemId = spec.WaterItemId ?? val.WaterItemId; val2.IceFlag = val.IceFlag; val2.Musics = Clone(val.Musics); val2.SFXPath = spec.SFXPath ?? val.SFXPath; val2.SFXVolume = val.SFXVolume; val2.CullingRadius = val.CullingRadius; ThemeProto val3 = val2; ApplySpecVeinArrays(val3, spec); CopyOptionalField(val, val3, "BriefIntroduction", spec.DisplayName + ";" + spec.DisplayName); CopyOptionalField(val, val3, "EigenBit", null); CloneOptionalObjectArrayField(val, val3, "uiIconSprite"); CloneOptionalObjectArrayField(val, val3, "uiScifiDecoTex"); ApplySpecAssets(val3, spec); return val3; } private static void ApplySpecVeinArrays(ThemeProto proto, ThemeSpec spec) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected I4, but got Unknown if (proto == null || spec == null || spec.VeinSettings == null || spec.VeinSettings.VeinTypes == null) { return; } int num = ((PlanetModelingManager.veinProtos != null) ? PlanetModelingManager.veinProtos.Length : 15); proto.VeinSpot = new int[num]; proto.VeinOpacity = new float[num]; proto.VeinCount = new float[num]; List list = new List(); List list2 = new List(); foreach (ThemeVeinType veinType in spec.VeinSettings.VeinTypes) { if (veinType == null || veinType.Veins == null || veinType.Veins.Count == 0) { continue; } int num2 = (int)veinType.Type; if (num2 <= 0 || num2 >= num) { continue; } int count = veinType.Veins.Count; float num3 = 0f; float num4 = 0f; foreach (ThemeVein vein in veinType.Veins) { num3 += (float)vein.Count; num4 += vein.Richness; } if (veinType.Rare) { list.Add(num2); list2.Add(0f); list2.Add(1f); list2.Add((float)count / 25f); list2.Add(num4 / (float)count); } else { proto.VeinSpot[num2 - 1] = count; proto.VeinCount[num2 - 1] = num3 / 25f / (float)count; proto.VeinOpacity[num2 - 1] = num4 / (float)count; } } proto.RareVeins = list.ToArray(); proto.RareSettings = list2.ToArray(); } private static void ApplySpecAssets(ThemeProto proto, ThemeSpec spec) { ThemeProto val = RequireTheme(spec.BaseThemeId); ThemeProto val2 = SelectThemeOrDefault(spec.TerrainThemeId, val); ThemeProto val3 = SelectThemeOrDefault(spec.OceanThemeId, val); ThemeProto val4 = SelectThemeOrDefault(spec.AtmosphereThemeId, val); ThemeProto val5 = SelectThemeOrDefault(spec.AmbientThemeId, val); EnsureThemePreloaded(val); EnsureThemePreloaded(val2); EnsureThemePreloaded(val3); EnsureThemePreloaded(val4); EnsureThemePreloaded(val5); proto.terrainMat = CloneThemeMaterials(val2.terrainMat, spec); proto.oceanMat = CloneThemeMaterials(val3.oceanMat, spec); proto.atmosMat = CloneThemeMaterials(val4.atmosMat, spec); proto.nephogramMat = CloneThemeMaterials(val4.nephogramMat, spec); proto.cloudMat = CloneThemeMaterials(val4.cloudMat, spec); proto.lowMat = CloneThemeMaterials(val2.lowMat, spec); proto.thumbMat = CloneThemeMaterials(val.thumbMat, spec); proto.minimapMat = CloneThemeMaterials(val.minimapMat, spec); proto.ambientDesc = CloneThemeObjects(val5.ambientDesc, spec); proto.ambientSfx = CloneThemeObjects(val.ambientSfx, spec); EnsureUsableMaterials(proto, val); EnsureThemeText(proto, spec); ApplyAmbientOverrides(proto.ambientDesc, spec); ApplyTint(proto.terrainMat, spec.TerrainTint, MaterialRole.Terrain); ApplyTint(proto.oceanMat, spec.OceanTint, MaterialRole.Ocean); ApplyTint(proto.atmosMat, spec.AtmosphereTint, MaterialRole.Atmosphere); ApplyTint(proto.thumbMat, spec.TerrainTint, MaterialRole.Thumb); ApplyTint(proto.minimapMat, spec.TerrainTint, MaterialRole.Minimap); ApplyColors(proto.terrainMat, spec.TerrainColors); ApplyColors(proto.oceanMat, spec.OceanColors); ApplyColors(proto.atmosMat, spec.AtmosphereColors); ApplyParams(proto.terrainMat, spec.TerrainParams); ApplyParams(proto.oceanMat, spec.OceanParams); ApplyParams(proto.atmosMat, spec.AtmosphereParams); } private static void ApplyThemeProtoToPlanetMaterials(PlanetData planet, ThemeProto proto, ThemeSpec spec) { int num = Math.Abs(planet.style); planet.terrainMaterial = CopyStyleMaterial(proto.terrainMat, num, planet.terrainMaterial, planet.displayName + " Terrain"); planet.oceanMaterial = CopyStyleMaterial(proto.oceanMat, num, planet.oceanMaterial, planet.displayName + " Ocean"); planet.atmosMaterial = CopyStyleMaterial(proto.atmosMat, num, planet.atmosMaterial, planet.displayName + " Atmos"); planet.atmosMaterialLate = CopyStyleMaterial(proto.atmosMat, num, planet.atmosMaterialLate, planet.displayName + " Atmos Late"); planet.nephogramMaterial = CopyStyleMaterial(proto.nephogramMat, num, planet.nephogramMaterial, planet.displayName + " Nephogram"); planet.cloudMaterial = CopyStyleMaterial(proto.cloudMat, num, planet.cloudMaterial, planet.displayName + " Cloud"); planet.minimapMaterial = CopyStyleMaterial(proto.minimapMat, num, planet.minimapMaterial, planet.displayName + " Minimap"); if (HasUsable(proto.ambientDesc)) { AmbientDesc val = proto.ambientDesc[num % proto.ambientDesc.Length]; if ((Object)(object)val != (Object)null) { planet.ambientDesc = Object.Instantiate(val); ApplyAmbientOverrides((AmbientDesc[])(object)new AmbientDesc[1] { planet.ambientDesc }, spec); } } if (HasUsable(proto.ambientSfx)) { planet.ambientSfx = proto.ambientSfx[num % proto.ambientSfx.Length]; } ApplyPlanetMaterialRuntimeValues(planet); LogMaterialDiagnosticsOnce(planet, spec); } private static Material CopyStyleMaterial(Material[] materials, int style, Material current, string name) { if (!HasUsable(materials)) { return current; } Material val = materials[Math.Abs(style) % materials.Length]; if ((Object)(object)val == (Object)null) { val = FirstUsable(materials); } if ((Object)(object)val == (Object)null) { return current; } if ((Object)(object)current == (Object)null) { Material obj = Object.Instantiate(val); ((Object)obj).name = name; return obj; } current.shader = val.shader; current.CopyPropertiesFromMaterial(val); current.renderQueue = val.renderQueue; ((Object)current).name = name; return current; } private static void ApplyPlanetMaterialRuntimeValues(PlanetData planet) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (planet != null) { SetRadius(planet.terrainMaterial, planet.realRadius); SetRadius(planet.oceanMaterial, planet.realRadius); SetRadius(planet.minimapMaterial, planet.realRadius); if ((Object)(object)planet.minimapMaterial != (Object)null && (Object)(object)planet.heightmap != (Object)null && planet.minimapMaterial.HasProperty("_HeightMap")) { planet.minimapMaterial.SetTexture("_HeightMap", (Texture)(object)planet.heightmap); } if ((Object)(object)planet.terrainMaterial != (Object)null && planet.terrainMaterial.HasProperty("_LightColorScreen")) { planet.groundScreenColor = planet.terrainMaterial.GetColor("_LightColorScreen"); } } } private static void SetRadius(Material material, float radius) { if ((Object)(object)material != (Object)null && material.HasProperty("_Radius")) { material.SetFloat("_Radius", radius); } } private static float GetPlanetScaleFactor(PlanetData planet) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 if (planet == null) { return 1f; } if ((int)planet.type != 5) { return Mathf.Max(planet.radius / 200f, 0.0001f); } return Mathf.Max(planet.radius / 80f, 0.0001f); } private static void RefreshAtmosphereMaterial(Material material, Vector3 planetPos, Vector3 sunDir, Vector4 planetRadius, Color sunAtmosColor, Color sunriseAtmosColor, Vector4 localPos, float scatterPower, float intensityControl, float distanceControl) { //IL_0010: 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_0021: 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_0032: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)material == (Object)null)) { SetVectorIfExists(material, "_PlanetPos", Vector4.op_Implicit(planetPos)); SetVectorIfExists(material, "_SunDir", Vector4.op_Implicit(sunDir)); SetVectorIfExists(material, "_PlanetRadius", planetRadius); SetColorIfExists(material, "_Color4", sunAtmosColor); SetColorIfExists(material, "_Sky4", sunriseAtmosColor); SetVectorIfExists(material, "_LocalPos", localPos); SetFloatIfExists(material, "_SunRiseScatterPower", scatterPower); SetFloatIfExists(material, "_IntensityControl", intensityControl); SetFloatIfExists(material, "_DistanceControl", distanceControl); } } private static void SetVectorIfExists(Material material, string property, Vector4 value) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (material.HasProperty(property)) { material.SetVector(property, value); } } private static void SetColorIfExists(Material material, string property, Color value) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (material.HasProperty(property)) { material.SetColor(property, value); } } private static void SetFloatIfExists(Material material, string property, float value) { if (material.HasProperty(property)) { material.SetFloat(property, value); } } private static void SetIntIfExists(Material material, string property, int value) { if ((Object)(object)material != (Object)null && material.HasProperty(property)) { material.SetInt(property, value); } } private static void SyncPlanetSimulatorMaterials(PlanetData planet) { //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) if (planet == null) { return; } PlanetSimulator val = null; try { UniverseSimulator universeSimulator = GameMain.universeSimulator; val = ((universeSimulator != null) ? universeSimulator.FindPlanetSimulator(planet) : null); } catch { val = null; } if ((Object)(object)val == (Object)null && (Object)(object)planet.gameObject != (Object)null) { val = planet.gameObject.GetComponent(); } if ((Object)(object)val == (Object)null) { return; } if (val.surfaceRenderer != null) { Renderer[] surfaceRenderer = val.surfaceRenderer; foreach (Renderer val2 in surfaceRenderer) { if ((Object)(object)val2 != (Object)null) { val2.sharedMaterial = planet.terrainMaterial; } } } if ((Object)(object)val.oceanCollider != (Object)null) { Renderer component = ((Component)val.oceanCollider).GetComponent(); if ((Object)(object)component != (Object)null) { component.enabled = (Object)(object)planet.oceanMaterial != (Object)null; component.sharedMaterial = planet.oceanMaterial; } } val.oceanMat = planet.oceanMaterial; if ((Object)(object)val.oceanMat != (Object)null) { val.oceanRenderQueue = val.oceanMat.renderQueue; } val.atmoMat = planet.atmosMaterial; val.atmoMatLate = planet.atmosMaterialLate; if ((Object)(object)val.atmoTrans1 != (Object)null) { Renderer component2 = ((Component)val.atmoTrans1).GetComponent(); if ((Object)(object)component2 != (Object)null && (Object)(object)val.atmoMat != (Object)null && (Object)(object)val.atmoMatLate != (Object)null) { component2.sharedMaterials = (Material[])(object)new Material[2] { val.atmoMat, val.atmoMatLate }; } } if ((Object)(object)val.atmoMat != (Object)null) { val.atmoMatRadiusParam = val.atmoMat.GetVector("_PlanetRadius"); } CopyTerrainLightingToReform(planet, val); } private static void CopyTerrainLightingToReform(PlanetData planet, PlanetSimulator simulator) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 if (planet != null && !((Object)(object)simulator == (Object)null) && (int)planet.type != 5 && !((Object)(object)planet.terrainMaterial == (Object)null)) { CopyMaterialColor(planet.terrainMaterial, simulator.reformMat0, "_AmbientColor0"); CopyMaterialColor(planet.terrainMaterial, simulator.reformMat0, "_AmbientColor1"); CopyMaterialColor(planet.terrainMaterial, simulator.reformMat0, "_AmbientColor2"); CopyMaterialColor(planet.terrainMaterial, simulator.reformMat0, "_LightColorScreen"); CopyMaterialFloat(planet.terrainMaterial, simulator.reformMat0, "_Multiplier"); CopyMaterialFloat(planet.terrainMaterial, simulator.reformMat0, "_AmbientInc"); CopyMaterialColor(planet.terrainMaterial, simulator.reformMat1, "_AmbientColor0"); CopyMaterialColor(planet.terrainMaterial, simulator.reformMat1, "_AmbientColor1"); CopyMaterialColor(planet.terrainMaterial, simulator.reformMat1, "_AmbientColor2"); CopyMaterialColor(planet.terrainMaterial, simulator.reformMat1, "_LightColorScreen"); CopyMaterialFloat(planet.terrainMaterial, simulator.reformMat1, "_Multiplier"); CopyMaterialFloat(planet.terrainMaterial, simulator.reformMat1, "_AmbientInc"); } } private static void CopyMaterialColor(Material source, Material target, string property) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)source != (Object)null && (Object)(object)target != (Object)null && source.HasProperty(property) && target.HasProperty(property)) { target.SetColor(property, source.GetColor(property)); } } private static void CopyMaterialFloat(Material source, Material target, string property) { if ((Object)(object)source != (Object)null && (Object)(object)target != (Object)null && source.HasProperty(property) && target.HasProperty(property)) { target.SetFloat(property, source.GetFloat(property)); } } private static ThemeProto RequireTheme(int id) { return ((ProtoSet)(object)LDB.themes).Select(id) ?? throw new Exception($"Theme #{id} is missing from game data"); } private static ThemeProto SelectThemeOrDefault(int? id, ThemeProto defaultTheme) { if (!id.HasValue) { return defaultTheme; } return RequireTheme(id.Value); } private static int FirstAlgo(ThemeProto theme) { if (theme.Algos == null || theme.Algos.Length == 0) { return 1; } return theme.Algos[0]; } private static void EnsureThemePreloaded(ThemeProto theme) { if (theme == null || (HasUsable(theme.terrainMat) && HasUsable(theme.nephogramMat) && HasUsable(theme.cloudMat) && HasUsable(theme.ambientDesc))) { return; } try { theme.Preload(); } catch (Exception ex) { Plugin.Instance.Logger.LogWarning((object)("Failed to preload theme " + ((Proto)theme).Name + ": " + ex.Message)); } } private static void EnsureUsableMaterials(ThemeProto proto, ThemeProto fallback) { proto.terrainMat = EnsureMaterials(proto.terrainMat, fallback.terrainMat); proto.oceanMat = EnsureMaterials(proto.oceanMat, fallback.oceanMat); proto.atmosMat = EnsureMaterials(proto.atmosMat, fallback.atmosMat); proto.nephogramMat = EnsureMaterials(proto.nephogramMat, fallback.nephogramMat); proto.cloudMat = EnsureMaterials(proto.cloudMat, fallback.cloudMat); proto.lowMat = EnsureMaterials(proto.lowMat, fallback.lowMat); proto.thumbMat = EnsureMaterials(proto.thumbMat, fallback.thumbMat); proto.minimapMat = EnsureMaterials(proto.minimapMat, fallback.minimapMat); proto.ambientDesc = EnsureObjects(proto.ambientDesc, fallback.ambientDesc, (Func)CreateDefaultAmbientDesc); proto.ambientSfx = EnsureObjects(proto.ambientSfx, fallback.ambientSfx, (Func)null); } private static Material[] EnsureMaterials(Material[] materials, Material[] fallback) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown if (HasUsable(materials)) { return FillMissingMaterials(CloneMaterials(materials), fallback); } Material[] array = CloneMaterials(fallback); if (HasUsable(array)) { return FillMissingMaterials(array, fallback); } Shader val = Shader.Find("Standard") ?? Shader.Find("Diffuse"); return (Material[])(object)new Material[1] { new Material(val) }; } private static Material[] FillMissingMaterials(Material[] materials, Material[] fallback) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown if (materials == null) { return null; } Material val = FirstUsable(fallback); for (int i = 0; i < materials.Length; i++) { if (!((Object)(object)materials[i] != (Object)null)) { if ((Object)(object)val != (Object)null) { materials[i] = Object.Instantiate(val); continue; } Shader val2 = Shader.Find("Standard") ?? Shader.Find("Diffuse"); materials[i] = new Material(val2); } } return materials; } private static T[] EnsureObjects(T[] objects, T[] fallback, Func createDefault) where T : Object { T[] objects2 = CloneUsableObjects(objects); if (HasUsable(objects2)) { return FillMissingObjects(objects2, fallback, createDefault); } objects2 = CloneUsableObjects(fallback); if (HasUsable(objects2)) { return FillMissingObjects(objects2, fallback, createDefault); } if (createDefault != null) { return new T[1] { createDefault() }; } return null; } private static T[] FillMissingObjects(T[] objects, T[] fallback, Func createDefault) where T : Object { if (objects == null) { return null; } T val = FirstUsable(fallback); for (int i = 0; i < objects.Length; i++) { if (!((Object)(object)objects[i] != (Object)null)) { if ((Object)(object)val != (Object)null) { objects[i] = Object.Instantiate(val); } else if (createDefault != null) { objects[i] = createDefault(); } } } return objects; } private static T[] CloneUsableObjects(T[] source) where T : Object { if (source == null) { return null; } T[] array = new T[source.Length]; for (int i = 0; i < source.Length; i++) { array[i] = (((Object)(object)source[i] == (Object)null) ? default(T) : Object.Instantiate(source[i])); } return array; } private static bool HasUsable(T[] objects) where T : Object { return objects?.Any((T item) => (Object)(object)item != (Object)null) ?? false; } private static T FirstUsable(T[] objects) where T : Object { if (objects != null) { return objects.FirstOrDefault((T item) => (Object)(object)item != (Object)null); } return default(T); } private static AmbientDesc CreateDefaultAmbientDesc() { //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_0053: Expected O, but got Unknown //IL_0053: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) ThemeProto obj = ((ProtoSet)(object)LDB.themes).Select(16) ?? ((ProtoSet)(object)LDB.themes).Select(1); EnsureThemePreloaded(obj); AmbientDesc val = FirstUsable(obj?.ambientDesc); if ((Object)(object)val != (Object)null) { return Object.Instantiate(val); } GameObject val2 = new GameObject("DSPAddPlanet Default AmbientDesc"); Object.DontDestroyOnLoad((Object)val2); ((Object)val2).hideFlags = (HideFlags)61; AmbientDesc obj2 = val2.AddComponent(); obj2.ambientColor0 = new Color(0.22f, 0.24f, 0.28f, 1f); obj2.ambientColor1 = new Color(0.12f, 0.14f, 0.18f, 1f); obj2.ambientColor2 = new Color(0.04f, 0.05f, 0.07f, 1f); obj2.waterAmbientColor0 = obj2.ambientColor0; obj2.waterAmbientColor1 = obj2.ambientColor1; obj2.waterAmbientColor2 = obj2.ambientColor2; return obj2; } private static void EnsureThemeText(ThemeProto proto, ThemeSpec spec) { if (string.IsNullOrWhiteSpace(proto.displayName)) { proto.displayName = spec.DisplayName; } if (string.IsNullOrWhiteSpace(proto.DisplayName)) { proto.DisplayName = spec.DisplayName; } FieldInfo field = typeof(ThemeProto).GetField("BriefIntroduction"); if (field != null && string.IsNullOrWhiteSpace(field.GetValue(proto) as string)) { field.SetValue(proto, spec.DisplayName + ";" + spec.DisplayName); } } private static void CopyOptionalField(ThemeProto source, ThemeProto target, string fieldName, object defaultValue) { FieldInfo field = typeof(ThemeProto).GetField(fieldName); if (!(field == null)) { object value = field.GetValue(source) ?? defaultValue; field.SetValue(target, value); } } private static void CloneOptionalObjectArrayField(ThemeProto source, ThemeProto target, string fieldName) { FieldInfo field = typeof(ThemeProto).GetField(fieldName); if (!(field == null) && field.GetValue(source) is Array array) { Array array2 = Array.CreateInstance(field.FieldType.GetElementType(), array.Length); for (int i = 0; i < array.Length; i++) { object? value = array.GetValue(i); Object val = (Object)((value is Object) ? value : null); array2.SetValue((val == (Object)null) ? null : Object.Instantiate(val), i); } field.SetValue(target, array2); } } private static Material[] CloneMaterials(Material[] source) { if (source == null) { return null; } Material[] array = (Material[])(object)new Material[source.Length]; for (int i = 0; i < source.Length; i++) { array[i] = (((Object)(object)source[i] == (Object)null) ? null : Object.Instantiate(source[i])); } return array; } private static Material[] CloneThemeMaterials(Material[] source, ThemeSpec spec) { if (!spec.UseSingleMaterial || source == null || source.Length <= 1) { return CloneMaterials(source); } Material val = FirstUsable(source); if (!((Object)(object)val == (Object)null)) { return (Material[])(object)new Material[1] { Object.Instantiate(val) }; } return null; } private static T[] CloneThemeObjects(T[] source, ThemeSpec spec) where T : Object { if (!spec.UseSingleMaterial || source == null || source.Length <= 1) { return CloneObjects(source); } T val = FirstUsable(source); if (!((Object)(object)val == (Object)null)) { return new T[1] { Object.Instantiate(val) }; } return null; } private static T[] CloneObjects(T[] source) where T : Object { if (source == null) { return null; } T[] array = new T[source.Length]; for (int i = 0; i < source.Length; i++) { array[i] = (((Object)(object)source[i] == (Object)null) ? default(T) : Object.Instantiate(source[i])); } return array; } private static int[] Clone(int[] source) { if (source != null) { return (int[])source.Clone(); } return null; } private static float[] Clone(float[] source) { if (source != null) { return (float[])source.Clone(); } return null; } private static Dictionary CloneColorDictionary(Dictionary source) { if (source != null) { return new Dictionary(source); } return new Dictionary(); } private static void ApplyGsTint(Dictionary colors, string property, Color tint) { //IL_001c: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0049: 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) if (colors != null && colors.TryGetValue(property, out var value)) { float grayscale = ((Color)(ref value)).grayscale; Color val = default(Color); ((Color)(ref val))..ctor(grayscale, grayscale, grayscale, value.a); Color val2 = default(Color); ((Color)(ref val2))..ctor(tint.r, tint.g, tint.b, value.a); colors[property] = Color.Lerp(val, val2, Mathf.Clamp01(tint.a)); } } private static void ApplyTint(Material[] materials, Color? tint, MaterialRole role) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0091: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: 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_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) if (!tint.HasValue || IsClear(tint.Value) || materials == null) { return; } foreach (Material val in materials) { if ((Object)(object)val == (Object)null) { continue; } switch (role) { case MaterialRole.Terrain: BlendColor(val, "_Color", tint.Value); BlendColor(val, "_AmbientColor0", tint.Value); BlendColor(val, "_AmbientColor1", tint.Value); BlendColor(val, "_AmbientColor2", tint.Value); BlendColor(val, "_LightColorScreen", tint.Value); BlendColor(val, "_HeightEmissionColor", tint.Value); BlendColor(val, "_SpeclColor", tint.Value); if (val.HasProperty("_EmissionStrength")) { val.SetFloat("_EmissionStrength", 0f); } break; case MaterialRole.Ocean: BlendColor(val, "_Color", tint.Value); BlendColor(val, "_Color0", tint.Value); BlendColor(val, "_Color1", tint.Value); BlendColor(val, "_Color2", tint.Value); BlendColor(val, "_Color3", tint.Value); BlendColor(val, "_FoamColor", tint.Value); BlendColor(val, "_FresnelColor", tint.Value); BlendColor(val, "_CausticsColor", tint.Value); BlendColor(val, "_SpeclColor", tint.Value); BlendColor(val, "_SpeclColor1", tint.Value); BlendColor(val, "_ReflectionColor", tint.Value); break; case MaterialRole.Atmosphere: BlendColor(val, "_CausticsColor", tint.Value); BlendColor(val, "_Color", tint.Value); BlendColor(val, "_Color0", tint.Value); BlendColor(val, "_Color1", tint.Value); BlendColor(val, "_Color2", tint.Value); BlendColor(val, "_Color3", tint.Value); BlendColor(val, "_Color4", tint.Value); BlendColor(val, "_Color5", tint.Value); BlendColor(val, "_Color6", tint.Value); BlendColor(val, "_Color7", tint.Value); BlendColor(val, "_Color8", tint.Value); BlendColor(val, "_ColorF", tint.Value); BlendColor(val, "_Sky0", tint.Value); BlendColor(val, "_Sky1", tint.Value); BlendColor(val, "_Sky2", tint.Value); BlendColor(val, "_Sky3", tint.Value); BlendColor(val, "_Sky4", tint.Value); BlendColor(val, "_EmissionColor", tint.Value); break; case MaterialRole.Thumb: case MaterialRole.Minimap: BlendColor(val, "_Color", tint.Value); val.color = Color.Lerp(val.color, tint.Value, Mathf.Clamp01(tint.Value.a)); break; } } } private static void BlendColor(Material material, string property, Color tint) { //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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0038: 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_004b: 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_0058: Unknown result type (might be due to invalid IL or missing references) if (material.HasProperty(property)) { Color color = material.GetColor(property); float grayscale = ((Color)(ref color)).grayscale; Color val = default(Color); ((Color)(ref val))..ctor(grayscale, grayscale, grayscale, color.a); Color val2 = default(Color); ((Color)(ref val2))..ctor(tint.r, tint.g, tint.b, color.a); material.SetColor(property, Color.Lerp(val, val2, Mathf.Clamp01(tint.a))); } } private static bool IsClear(Color color) { //IL_0000: 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_0024: 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) if (Mathf.Approximately(color.r, 0f) && Mathf.Approximately(color.g, 0f) && Mathf.Approximately(color.b, 0f)) { return Mathf.Approximately(color.a, 0f); } return false; } private static void ApplyParams(Material[] materials, Dictionary parameters) { if (materials == null || parameters == null) { return; } foreach (Material val in materials) { if ((Object)(object)val == (Object)null) { continue; } foreach (KeyValuePair parameter in parameters) { if (val.HasProperty(parameter.Key)) { val.SetFloat(parameter.Key, parameter.Value); } } } } private static void ApplyColors(Material[] materials, Dictionary colors) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (materials == null || colors == null) { return; } foreach (Material val in materials) { if ((Object)(object)val == (Object)null) { continue; } foreach (KeyValuePair color in colors) { if (val.HasProperty(color.Key)) { val.SetColor(color.Key, color.Value); } } } } private static void ApplyAmbientOverrides(AmbientDesc[] ambientDescs, ThemeSpec spec) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (ambientDescs == null) { return; } foreach (AmbientDesc val in ambientDescs) { if (!((Object)(object)val == (Object)null)) { if (spec.AmbientLutContribution.HasValue) { val.lutContribution = spec.AmbientLutContribution.Value; } if (spec.AmbientReflectionColor.HasValue && (Object)(object)val.reflectionMap != (Object)null) { val.customColor0 = spec.AmbientReflectionColor.Value; } spec.AmbientOverride?.Invoke(val); } } } private static void LogMaterialDiagnosticsOnce(PlanetData planet, ThemeSpec spec) { if (planet != null && spec != null && materialDiagnosticLogged.Add(planet.theme)) { Material terrainMaterial = planet.terrainMaterial; string text = (((Object)(object)terrainMaterial == (Object)null) ? "" : ((Object)terrainMaterial).name); string text2 = (((Object)(object)terrainMaterial == (Object)null || (Object)(object)terrainMaterial.shader == (Object)null) ? "" : ((Object)terrainMaterial.shader).name); Plugin.Instance.Logger.LogInfo((object)($"GalacticScale-style terrain material for theme {planet.theme} {spec.Name}: " + "material=" + text + ", shader=" + text2 + ", _Color=" + ReadColor(terrainMaterial, "_Color") + ", _AmbientColor0=" + ReadColor(terrainMaterial, "_AmbientColor0") + ", _LightColorScreen=" + ReadColor(terrainMaterial, "_LightColorScreen") + ", _HeightEmissionColor=" + ReadColor(terrainMaterial, "_HeightEmissionColor") + ", _Multiplier=" + ReadFloat(terrainMaterial, "_Multiplier") + ", _AmbientInc=" + ReadFloat(terrainMaterial, "_AmbientInc") + ", _HeightEmissionRadius=" + ReadFloat(terrainMaterial, "_HeightEmissionRadius"))); } } private static string ReadColor(Material material, string property) { //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_002d: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)material == (Object)null || !material.HasProperty(property)) { return "n/a"; } Color color = material.GetColor(property); return $"({color.r:F3},{color.g:F3},{color.b:F3},{color.a:F3})"; } private static string ReadFloat(Material material, string property) { if ((Object)(object)material == (Object)null || !material.HasProperty(property)) { return "n/a"; } return material.GetFloat(property).ToString("F3"); } private static string NormalizeName(string name) { if (string.IsNullOrWhiteSpace(name)) { return ""; } return new string(name.Where((char c) => !char.IsWhiteSpace(c) && c != '-' && c != '_' && c != '.').Select(char.ToLowerInvariant).ToArray()); } } internal static class Global { public static readonly int[] fixedPlatformSystemSegmentTable = new int[512] { 1, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16, 20, 20, 20, 20, 20, 20, 20, 20, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 248, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500 }; } internal static class ILUtility { public enum VariableType { Local, Argument } private static ManualLogSource logger; public static void Initialize(ManualLogSource logSource) { logger = logSource; } public static void ProcessObject(CodeMatcher matcher, VariableType variableType, int variableIndex, MethodInfo method) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown LoadVariable(matcher, variableType, variableIndex); matcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)method) }); } public static void PrintAllCodes(CodeMatcher matcher) { int pos = matcher.Pos; matcher.Start(); StringBuilder stringBuilder = new StringBuilder(); while (matcher.IsValid) { stringBuilder.Append(string.Format("\r\n{0,5}: {1,10} {2}", matcher.Pos, matcher.Opcode.Name, (matcher.Operand == null) ? "" : (matcher.Operand.ToString() + "(" + matcher.Operand.GetType()?.ToString() + ")"))); matcher.Advance(1); } matcher.Start(); matcher.Advance(pos); logger.LogInfo((object)stringBuilder); } public static void PrintCodes(CodeMatcher matcher, int offset, int length) { int pos = matcher.Pos; matcher.Advance(offset); int num = 0; StringBuilder stringBuilder = new StringBuilder(); while (matcher.IsValid && num < length) { stringBuilder.Append(string.Format("\r\n{0,5}: {1,10} {2}", matcher.Pos, matcher.Opcode.Name, (matcher.Operand == null) ? "" : (matcher.Operand.ToString() + "(" + matcher.Operand.GetType()?.ToString() + ")"))); matcher.Advance(1); num++; } matcher.Start(); matcher.Advance(pos); logger.LogInfo((object)stringBuilder); } public static void PrintInt(CodeMatcher matcher, VariableType variableType, int variableIndex, string variableName) { LoadString(matcher, variableName); LoadVariable(matcher, variableType, variableIndex); CallInternalMethod(matcher, "PrintIntInternal"); } public static void PrintInt(CodeMatcher matcher, VariableType variableType, int variableIndex, FieldInfo fieldInfo, string variableName) { LoadString(matcher, variableName); LoadVariable(matcher, variableType, variableIndex); LoadField(matcher, fieldInfo); CallInternalMethod(matcher, "PrintIntInternal"); } public static void PrintFloat(CodeMatcher matcher, VariableType variableType, int variableIndex, string variableName) { LoadString(matcher, variableName); LoadVariable(matcher, variableType, variableIndex); CallInternalMethod(matcher, "PrintFloatInternal"); } public static void PrintByteArrayLength(CodeMatcher matcher, VariableType variableType, int variableIndex, string variableName) { LoadString(matcher, variableName); LoadVariable(matcher, variableType, variableIndex); CallInternalMethod(matcher, "PrintByteArrayLengthInternal"); } public static void PrintByteArrayLength(CodeMatcher matcher, VariableType variableType, int variableIndex, FieldInfo fieldInfo, string variableName) { LoadString(matcher, variableName); LoadVariable(matcher, variableType, variableIndex); LoadField(matcher, fieldInfo); CallInternalMethod(matcher, "PrintByteArrayLengthInternal"); } public static void PrintIntArrayLength(CodeMatcher matcher, VariableType variableType, int variableIndex, string variableName) { LoadString(matcher, variableName); LoadVariable(matcher, variableType, variableIndex); CallInternalMethod(matcher, "PrintIntArrayLengthInternal"); } public static void PrintVector3ArrayLength(CodeMatcher matcher, VariableType variableType, int variableIndex, string variableName) { LoadString(matcher, variableName); LoadVariable(matcher, variableType, variableIndex); CallInternalMethod(matcher, "PrintVector3ArrayLengthInternal"); } public static void PrintVector3(CodeMatcher matcher, VariableType variableType, int variableIndex, string variableName) { LoadString(matcher, variableName); LoadVariable(matcher, variableType, variableIndex); CallInternalMethod(matcher, "PrintVector3Internal"); } public static void PrintByteArray(CodeMatcher matcher, VariableType variableType, int variableIndex, string variableName) { LoadString(matcher, variableName); LoadVariable(matcher, variableType, variableIndex); CallInternalMethod(matcher, "PrintByteArrayInternal"); } public static void PrintByteArray(CodeMatcher matcher, VariableType variableType, int variableIndex, FieldInfo field, string variableName) { LoadString(matcher, variableName); LoadVariable(matcher, variableType, variableIndex); LoadField(matcher, field); CallInternalMethod(matcher, "PrintByteArrayInternal"); } public static void PrintIntArray(CodeMatcher matcher, VariableType variableType, int variableIndex, string variableName) { LoadString(matcher, variableName); LoadVariable(matcher, variableType, variableIndex); CallInternalMethod(matcher, "PrintIntArrayInternal"); } public static void PrintIntArray(CodeMatcher matcher, VariableType variableType, int variableIndex, FieldInfo field, string variableName) { LoadString(matcher, variableName); LoadVariable(matcher, variableType, variableIndex); LoadField(matcher, field); CallInternalMethod(matcher, "PrintIntArrayInternal"); } private static void PrintIntInternal(string name, int value) { logger.LogInfo((object)$"PrintInt, name: {name}, value: {value}"); } private static void PrintFloatInternal(string name, float value) { logger.LogInfo((object)$"PrintFloat, name: {name}, value: {value}"); } private static void PrintByteArrayLengthInternal(string name, byte[] value) { logger.LogInfo((object)$"PrintByteArrayLength, name: {name}, value: {value.Length}"); } private static void PrintIntArrayLengthInternal(string name, int[] value) { logger.LogInfo((object)$"PrintIntArrayLength, name: {name}, value: {value.Length}"); } private static void PrintVector3ArrayLengthInternal(string name, Vector3[] value) { logger.LogInfo((object)$"PrintVector3ArrayLength, name: {name}, value: {value.Length}"); } private static void PrintVector3Internal(string name, Vector3 value) { //IL_0016: 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_0032: Unknown result type (might be due to invalid IL or missing references) logger.LogInfo((object)$"PrintVector3, name: {name}, value: ({value.x}, {value.y}, {value.z})"); } private static void PrintByteArrayInternal(string name, byte[] value) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append($"PrintByteArray, name: {name}, length: {value.Length}, value:"); for (int i = 0; i < value.Length; i++) { stringBuilder.Append($"\r\n {i,9}: {value[i]}"); } logger.LogInfo((object)stringBuilder); } private static void PrintIntArrayInternal(string name, int[] value) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append($"PrintIntArray, name: {name}, length: {value.Length}, value:"); for (int i = 0; i < value.Length; i++) { if (value[i] != 0) { stringBuilder.Append($"\r\n {i,9}: {value[i]}"); } } logger.LogInfo((object)stringBuilder); } private static void LoadString(CodeMatcher matcher, string str) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown matcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldstr, (object)str) }); } private static void LoadVariable(CodeMatcher matcher, VariableType variableType, int variableIndex) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown switch (variableType) { case VariableType.Local: matcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldloc_S, (object)variableIndex) }); break; case VariableType.Argument: matcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldarg_S, (object)variableIndex) }); break; default: throw new Exception("Unknown variableType: " + variableType); } } private static void LoadField(CodeMatcher matcher, FieldInfo fieldInfo) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown matcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo) }); } private static void CallInternalMethod(CodeMatcher matcher, string methodName) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown matcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)typeof(ILUtility).GetMethod(methodName, BindingFlags.Static | BindingFlags.NonPublic)) }); } } [BepInPlugin("Zincon.DSPAddPlanetMoon2Patch", "DSPAddPlanet-moon^2-patch", "3.0.15")] [BepInIncompatibility("dsp.galactic-scale.2")] [BepInIncompatibility("IndexOutOfRange.DSPAddPlanet")] public class Plugin : BaseUnityPlugin { private class Patch_GameData { [HarmonyPrefix] [HarmonyPatch(typeof(GameData), "Import")] private static void GameData_Import_Prefix() { ConfigUtility.ReadConfig(Instance.globalPlanetConfig, Instance.gameNameSpecificConfig); Instance.specialBirthStarId = (Instance.specialBirthPlanetId = 0); } } private class Patch_GameDesc { [HarmonyPostfix] [HarmonyPatch(typeof(GameDesc), "SetForNewGame")] private static void GameDesc_SetForNewGame_Postfix(GameDesc __instance) { GalacticScaleThemeRegistry.ApplyRandomGenerationToGameDesc(__instance, ConfigUtility.EnableGalacticScaleThemesInRandomGeneration); } } private class Patch_ThemeProto { [HarmonyPostfix] [HarmonyPatch(typeof(ThemeProto), "Preload")] private static void ThemeProto_Preload_Postfix(ThemeProto __instance) { GalacticScaleThemeRegistry.ReapplyRegisteredThemeMaterials(__instance); } } private class Patch_StarGen { [HarmonyPostfix] [HarmonyPatch(typeof(StarGen), "CreateStarPlanets")] private static void StarGen_CreateStarPlanets_Postfix(GalaxyData galaxy, StarData star, GameDesc gameDesc) { //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) //IL_0582: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_0670: Unknown result type (might be due to invalid IL or missing references) //IL_0675: Unknown result type (might be due to invalid IL or missing references) //IL_067c: Unknown result type (might be due to invalid IL or missing references) //IL_0684: Unknown result type (might be due to invalid IL or missing references) //IL_068c: Unknown result type (might be due to invalid IL or missing references) //IL_0765: Unknown result type (might be due to invalid IL or missing references) //IL_076a: Unknown result type (might be due to invalid IL or missing references) //IL_07c5: Unknown result type (might be due to invalid IL or missing references) //IL_07cb: Invalid comparison between Unknown and I4 //IL_05d9: Unknown result type (might be due to invalid IL or missing references) //IL_05de: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: Unknown result type (might be due to invalid IL or missing references) //IL_05ef: Unknown result type (might be due to invalid IL or missing references) //IL_05f4: Unknown result type (might be due to invalid IL or missing references) //IL_05f9: Unknown result type (might be due to invalid IL or missing references) //IL_062a: Unknown result type (might be due to invalid IL or missing references) //IL_0636: Unknown result type (might be due to invalid IL or missing references) //IL_063b: Unknown result type (might be due to invalid IL or missing references) //IL_0640: Unknown result type (might be due to invalid IL or missing references) //IL_0645: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_0617: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Unknown result type (might be due to invalid IL or missing references) //IL_0621: Unknown result type (might be due to invalid IL or missing references) //IL_082e: Unknown result type (might be due to invalid IL or missing references) //IL_0835: Expected O, but got Unknown GalacticScaleThemeRegistry.ApplyRandomGenerationToGameDesc(gameDesc, ConfigUtility.EnableGalacticScaleThemesInRandomGeneration); string uniqueStarId; List planetConfigList = Utility.GetPlanetConfigList(GameMain.gameName, gameDesc.clusterString, star.id, star.name, Instance.globalPlanetConfig, Instance.gameNameSpecificConfig, out uniqueStarId); if (planetConfigList == null) { return; } int num = 0; PlanetData[] planets; foreach (AdditionalPlanetConfig item in planetConfigList) { bool flag = false; planets = star.planets; for (int i = 0; i < planets.Length; i++) { if (planets[i].index == item.Index) { flag = true; break; } } if (!flag) { num++; } } Instance.Logger.LogInfo((object)$"{planetConfigList.Count} configurations, {num} new planets in {uniqueStarId} (current game name: {GameMain.gameName}"); int[] array = new int[star.planets.Length + num]; for (int j = 0; j < array.Length; j++) { array[j] = 2; } planets = star.planets; foreach (PlanetData val in planets) { array[val.index] = 0; } foreach (AdditionalPlanetConfig item2 in planetConfigList) { array[item2.Index] = 1; } for (int k = 0; k < array.Length; k++) { if (array[k] == 2) { throw new Exception($"Empty planet in {uniqueStarId}, planet index: {k} (current game name: {GameMain.gameName}). Please check the consistency of planets' indexes"); } } Instance.Logger.LogInfo((object)"Index consistency checked"); int num2 = star.planets.Length; PlanetData[] array2 = (PlanetData[])(object)new PlanetData[star.planets.Length + num]; Array.Copy(star.planets, array2, star.planets.Length); star.planets = array2; int planetCount = array2.Length; star.planetCount = num2; foreach (AdditionalPlanetConfig item3 in planetConfigList) { bool flag2 = false; int num3 = 0; for (int l = 0; l < num2; l++) { if (star.planets[l].index == item3.Index) { flag2 = true; num3 = item3.Index; break; } } PlanetData val2; if (!flag2) { int planetGenOrbitAround = GetPlanetGenOrbitAround(star, item3, uniqueStarId); val2 = PlanetGen.CreatePlanet(galaxy, star, gameDesc.savedThemeIds, item3.Index, planetGenOrbitAround, item3.OrbitIndex, item3.Number, item3.GasGiant, item3.InfoSeed, item3.GenSeed); star.planetCount = Math.Max(star.planetCount, val2.index + 1); Instance.Logger.LogInfo((object)$"Created new planet at {uniqueStarId}. Index: {item3.Index}, Number: {item3.Number}, Orbit index: {item3.OrbitIndex}, Gas giant: {item3.GasGiant}, Theme id: {item3.ThemeId}"); } else { val2 = star.planets[num3]; Instance.Logger.LogInfo((object)$"Replace existing planet at {uniqueStarId}. Index: {item3.Index}, Number: {item3.Number}, Orbit index: {item3.OrbitIndex}, Gas giant: {item3.GasGiant}, Theme id: {item3.ThemeId}"); } ConfigurePlanetOrbit(star, val2, item3, uniqueStarId); if (item3.IsBirthPoint) { if (Instance.specialBirthStarId != 0 || Instance.specialBirthPlanetId != 0) { Instance.Logger.LogWarning((object)$"Birth point overriding in {uniqueStarId}, from star id {Instance.specialBirthStarId}, planet id {Instance.specialBirthPlanetId}, to star id {val2.star.id}, planet id {val2.id}"); } Instance.specialBirthStarId = val2.star.id; Instance.specialBirthPlanetId = val2.id; } if (!item3.GasGiant) { val2.radius = item3.Radius; val2.scale = 1f; val2.precision = 200; val2.segment = 5; star.galaxy.astrosData[val2.id].uRadius = val2.realRadius; } val2.orbitalPeriod = item3.OrbitalPeriod; val2.rotationPeriod = item3.RotationPeriod; if (item3.IsTidalLocked) { PlanetData obj = val2; obj.singularity = (EPlanetSingularity)(obj.singularity | 1); } val2.orbitInclination = item3.OrbitInclination; val2.runtimeOrbitRotation = Quaternion.AngleAxis(val2.orbitLongitude, Vector3.up) * Quaternion.AngleAxis(val2.orbitInclination, Vector3.forward); if (val2.orbitAroundPlanet != null) { val2.runtimeOrbitRotation = val2.orbitAroundPlanet.runtimeOrbitRotation * val2.runtimeOrbitRotation; } val2.obliquity = item3.Obliquity; val2.runtimeSystemRotation = val2.runtimeOrbitRotation * Quaternion.AngleAxis(val2.obliquity, Vector3.forward); if (item3._HasOrbitLongitude) { if (val2.orbitInclination >= 0f) { val2.orbitLongitude = 180f - item3.OrbitLongitude; } else { val2.orbitLongitude = 0f - item3.OrbitLongitude; } val2.runtimeOrbitRotation = Quaternion.AngleAxis(val2.orbitLongitude, Vector3.up) * Quaternion.AngleAxis(val2.orbitInclination, Vector3.forward); if (val2.orbitAroundPlanet != null) { val2.runtimeOrbitRotation = val2.orbitAroundPlanet.runtimeOrbitRotation * val2.runtimeOrbitRotation; } val2.runtimeSystemRotation = val2.runtimeOrbitRotation * Quaternion.AngleAxis(val2.obliquity, Vector3.forward); } if (item3._HasThemeId) { ThemeProto val3 = ((ProtoSet)(object)LDB.themes).Select(item3.ThemeId); DotNet35Random val4 = new DotNet35Random(item3.InfoSeed); val4.NextDouble(); double num4 = val4.NextDouble(); double num5 = val4.NextDouble(); double num6 = val4.NextDouble(); int num7 = val4.Next(); val2.theme = item3.ThemeId; val2.algoId = 0; if (val3.Algos != null && val3.Algos.Length != 0) { val2.algoId = val3.Algos[(int)(num4 * (double)val3.Algos.Length) % val3.Algos.Length]; val2.mod_x = (double)val3.ModX.x + num5 * (double)(val3.ModX.y - val3.ModX.x); val2.mod_y = (double)val3.ModY.x + num6 * (double)(val3.ModY.y - val3.ModY.x); } val2.style = num7 % 60; val2.type = val3.PlanetType; val2.ionHeight = val3.IonHeight; val2.windStrength = val3.Wind; val2.waterHeight = val3.WaterHeight; val2.waterItemId = val3.WaterItemId; val2.levelized = val3.UseHeightForBuild; val2.iceFlag = val3.IceFlag; if ((int)val2.type == 5) { int num8 = val3.GasItems.Length; int num9 = val3.GasSpeeds.Length; int[] array3 = new int[num8]; float[] array4 = new float[num9]; float[] array5 = new float[num8]; for (int m = 0; m < num8; m++) { array3[m] = val3.GasItems[m]; } double num10 = 0.0; DotNet35Random val5 = new DotNet35Random(num7); for (int n = 0; n < num9; n++) { float num11 = val3.GasSpeeds[n]; num11 *= (float)val5.NextDouble() * 0.19090915f + 0.9090909f; array4[n] = num11 * Mathf.Pow(val2.star.resourceCoef, 0.3f); ItemProto val6 = ((ProtoSet)(object)LDB.items).Select(array3[n]); array5[n] = val6.HeatValue; num10 += (double)(array5[n] * array4[n]); } val2.gasItems = array3; val2.gasSpeeds = array4; val2.gasHeatValues = array5; val2.gasTotalHeat = num10; } } if (flag2) { star.planets[num3] = val2; } else { star.planets[val2.index] = val2; } } star.planetCount = planetCount; } private static int GetPlanetGenOrbitAround(StarData star, AdditionalPlanetConfig config, string uniqueStarId) { if (!config._HasOrbitAroundIndex && config.OrbitAround <= 0) { return 0; } return GetRootOrbitParent(ResolveOrbitParent(star, null, config, uniqueStarId)).number; } private static void ConfigurePlanetOrbit(StarData star, PlanetData planet, AdditionalPlanetConfig config, string uniqueStarId) { //IL_0082: 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_008a: Unknown result type (might be due to invalid IL or missing references) PlanetData val = ResolveOrbitParent(star, planet, config, uniqueStarId); if (val != null && IsOrbiting(val, planet)) { throw new Exception($"Invalid orbit parent in {uniqueStarId}, planet index: {config.Index}. This would create an orbit cycle."); } planet.orbitAroundPlanet = val; planet.orbitAround = val?.number ?? 0; planet.orbitIndex = config.OrbitIndex; planet.number = config.Number; if (val != null) { planet.orbitRadius = GetSatelliteOrbitRadius(star, val, config); planet.sunDistance = GetRootOrbitRadius(val); val.singularity = (EPlanetSingularity)(val.singularity | 0x20); Instance.needsOrderedPoseUpdate = true; } else { planet.sunDistance = planet.orbitRadius; } } private static PlanetData ResolveOrbitParent(StarData star, PlanetData planet, AdditionalPlanetConfig config, string uniqueStarId) { if (config._HasOrbitAroundIndex) { PlanetData obj = GetPlanetByIndex(star, config.OrbitAroundIndex) ?? throw new Exception($"Missing orbit parent in {uniqueStarId}, planet index: {config.Index}, OrbitAroundIndex: {config.OrbitAroundIndex}. Parent planets must exist or appear earlier in the config file."); if (obj == planet) { throw new Exception($"Planet cannot orbit itself in {uniqueStarId}, planet index: {config.Index}"); } return obj; } if (config.OrbitAround <= 0) { return null; } PlanetData val = null; PlanetData[] planets = star.planets; foreach (PlanetData val2 in planets) { if (val2 != null && val2 != planet && val2.number == config.OrbitAround && val2.orbitAround == 0) { if (val != null) { throw new Exception($"Ambiguous OrbitAround '{config.OrbitAround}' in {uniqueStarId}, planet index: {config.Index}. Add with the target parent planet's index."); } val = val2; } } if (val == null) { throw new Exception($"Missing orbit parent in {uniqueStarId}, planet index: {config.Index}, OrbitAround: {config.OrbitAround}. OrbitAround keeps the vanilla behavior and only targets planets that orbit the star; use to target a moon."); } return val; } private static bool IsOrbiting(PlanetData planet, PlanetData possibleParent) { for (PlanetData val = planet; val != null; val = val.orbitAroundPlanet) { if (val == possibleParent) { return true; } } return false; } private static PlanetData GetPlanetByIndex(StarData star, int index) { if (index < 0 || index >= star.planets.Length) { return null; } PlanetData val = star.planets[index]; if (val != null && val.index == index) { return val; } PlanetData[] planets = star.planets; foreach (PlanetData val2 in planets) { if (val2 != null && val2.index == index) { return val2; } } return null; } private static float GetSatelliteOrbitRadius(StarData star, PlanetData parent, AdditionalPlanetConfig config) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown DotNet35Random val = new DotNet35Random(config.InfoSeed); float num = Mathf.Pow(1.2f, (float)(val.NextDouble() * (val.NextDouble() - 0.5) * 0.5)); return (float)((double)((1600f * (float)config.OrbitIndex + 200f) * Mathf.Pow(star.orbitScaler, 0.3f) * Mathf.Lerp(num, 1f, 0.5f) + parent.realRadius) / 40000.0); } private static float GetRootOrbitRadius(PlanetData planet) { return GetRootOrbitParent(planet).orbitRadius; } private static PlanetData GetRootOrbitParent(PlanetData planet) { PlanetData val = planet; while (val.orbitAroundPlanet != null) { val = val.orbitAroundPlanet; } return val; } } private class Patch_UniverseGen { [HarmonyPrefix] [HarmonyPatch(typeof(UniverseGen), "CreateGalaxy")] private static void UniverseGen_CreateGalaxy_Prefix(GameDesc gameDesc) { ConfigUtility.ReadConfig(Instance.globalPlanetConfig, Instance.gameNameSpecificConfig); GalacticScaleThemeRegistry.ApplyRandomGenerationToGameDesc(gameDesc, ConfigUtility.EnableGalacticScaleThemesInRandomGeneration); } [HarmonyPostfix] [HarmonyPatch(typeof(UniverseGen), "CreateGalaxy")] private static void UniverseGen_CreateGalaxy_Postfix(GalaxyData __result) { if (Instance.specialBirthStarId != 0 && Instance.specialBirthPlanetId != 0) { __result.birthStarId = Instance.specialBirthStarId; __result.birthPlanetId = Instance.specialBirthPlanetId; } } } private class Patch_GalaxyData { [HarmonyPrefix] [HarmonyPatch(typeof(GalaxyData), "UpdatePoses")] private static bool GalaxyData_UpdatePoses_Prefix(GalaxyData __instance, double time) { if (!Instance.needsOrderedPoseUpdate) { return true; } for (int i = 0; i < __instance.starCount; i++) { StarData val = __instance.stars[i]; for (int j = 0; j < val.planetCount; j++) { PlanetData val2 = val.planets[j]; if (val2 != null && val2.orbitAroundPlanet == null) { UpdatePlanetAndSatellites(val, val2, time); } } } return false; } private static void UpdatePlanetAndSatellites(StarData star, PlanetData planet, double time) { planet.UpdateRuntimePose(time); for (int i = 0; i < star.planetCount; i++) { PlanetData val = star.planets[i]; if (val != null && val.orbitAroundPlanet == planet) { UpdatePlanetAndSatellites(star, val, time); } } } } private class Patch_StarData { [HarmonyPrefix] [HarmonyPatch(typeof(StarData), "get_systemRadius")] private static bool StarData_get_systemRadius_Prefix(StarData __instance, ref float __result) { if (!Instance.needsOrderedPoseUpdate) { return true; } float num = __instance.dysonRadius; if (__instance.planets != null) { for (int i = 0; i < __instance.planetCount; i++) { PlanetData val = __instance.planets[i]; if (val != null && val.sunDistance > num) { num = val.sunDistance; } } } __result = num; return false; } } private class Patch_GalacticScaleTerrain { private class GalacticScaleStylePlanetAlgorithm : PlanetAlgorithm { private PlanetAlgorithm baseAlgorithm; private PlanetAlgorithm BaseAlgorithm { get { if (baseAlgorithm == null) { baseAlgorithm = CreateBaseAlgorithm((base.planet != null) ? base.planet.algoId : 0); baseAlgorithm.Reset(base.seed, base.planet); } return baseAlgorithm; } } public override void GenerateTerrain(double modX, double modY) { if (base.planet == null || !GalacticScaleThemeRegistry.TryGenerateGalacticScaleTerrain(base.planet, modX, modY)) { BaseAlgorithm.GenerateTerrain(modX, modY); } } public override void GenerateVegetables() { BaseAlgorithm.GenerateVegetables(); } public override void GenerateVeins() { if (Patch_PlanetAlgorithms.ShouldGenerateVeinsForPlanet(base.planet)) { if (GalacticScaleThemeRegistry.TryGenerateGalacticScaleVeins(base.planet)) { Patch_PlanetAlgorithms.ApplyReplaceAllVeinsTo(base.planet); } else { BaseAlgorithm.GenerateVeins(); } } } public override void CalcWaterPercent() { BaseAlgorithm.CalcWaterPercent(); } private static PlanetAlgorithm CreateBaseAlgorithm(int algoId) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown return (PlanetAlgorithm)(algoId switch { 1 => (object)new PlanetAlgorithm1(), 2 => (object)new PlanetAlgorithm2(), 3 => (object)new PlanetAlgorithm3(), 4 => (object)new PlanetAlgorithm4(), 5 => (object)new PlanetAlgorithm5(), 6 => (object)new PlanetAlgorithm6(), 7 => (object)new PlanetAlgorithm7(), 8 => (object)new PlanetAlgorithm8(), 9 => (object)new PlanetAlgorithm9(), 10 => (object)new PlanetAlgorithm10(), 11 => (object)new PlanetAlgorithm11(), 12 => (object)new PlanetAlgorithm12(), 13 => (object)new PlanetAlgorithm13(), 14 => (object)new PlanetAlgorithm14(), _ => (object)new PlanetAlgorithm0(), }); } } private static readonly HashSet loggedCustomTerrainThemes = new HashSet(); [HarmonyPrefix] [HarmonyPatch(typeof(PlanetModelingManager), "Algorithm")] private static bool PlanetModelingManager_Algorithm_Prefix(PlanetData planet, ref PlanetAlgorithm __result) { if (planet == null || !GalacticScaleThemeRegistry.UsesGalacticScaleTerrain(planet.theme)) { return true; } PlanetAlgorithm val = (PlanetAlgorithm)(object)new GalacticScaleStylePlanetAlgorithm(); val.Reset(planet.seed, planet); __result = val; if (loggedCustomTerrainThemes.Add(planet.theme)) { ThemeProto val2 = ((ProtoSet)(object)LDB.themes).Select(planet.theme); string arg = ((val2 == null) ? planet.theme.ToString() : ((Proto)val2).Name); Instance.Logger.LogInfo((object)$"Using DSPAddPlanet GalacticScale-style terrain for theme {planet.theme}: {arg}"); } return false; } [HarmonyPrefix] [HarmonyPatch(typeof(PlanetAlgorithm1), "GenerateTerrain")] private static bool PlanetAlgorithm1_GenerateTerrain_Prefix(PlanetAlgorithm1 __instance, double modX, double modY) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown PlanetData val = (PlanetData)AccessTools.Field(typeof(PlanetAlgorithm), "planet").GetValue(__instance); if (val == null || val.data == null || !GalacticScaleThemeRegistry.UsesGalacticScaleTerrain(val.theme)) { return true; } return !GalacticScaleThemeRegistry.TryGenerateGalacticScaleTerrain(val, modX, modY); } } private class Patch_PlanetAlgorithms { private static DotNet35Random random = new DotNet35Random(); private static readonly HashSet loggedGalacticScaleVeinThemes = new HashSet(); [HarmonyPrefix] [HarmonyPatch(typeof(PlanetAlgorithm), "GenerateVeins")] private static bool PlanetAlgorithm_GenerateVeins_Prefix(PlanetAlgorithm __instance) { return PlanetAlgorithmX_GenerateVeins_Prefix(typeof(PlanetAlgorithm), __instance); } [HarmonyPrefix] [HarmonyPatch(typeof(PlanetAlgorithm0), "GenerateVeins")] private static bool PlanetAlgorithm0_GenerateVeins_Prefix(PlanetAlgorithm0 __instance) { return PlanetAlgorithmX_GenerateVeins_Prefix(typeof(PlanetAlgorithm0), __instance); } [HarmonyPrefix] [HarmonyPatch(typeof(PlanetAlgorithm7), "GenerateVeins")] private static bool PlanetAlgorithm7_GenerateVeins_Prefix(PlanetAlgorithm7 __instance) { return PlanetAlgorithmX_GenerateVeins_Prefix(typeof(PlanetAlgorithm7), __instance); } [HarmonyPrefix] [HarmonyPatch(typeof(PlanetAlgorithm11), "GenerateVeins")] private static bool PlanetAlgorithm11_GenerateVeins_Prefix(PlanetAlgorithm11 __instance) { return PlanetAlgorithmX_GenerateVeins_Prefix(typeof(PlanetAlgorithm11), __instance); } [HarmonyPrefix] [HarmonyPatch(typeof(PlanetAlgorithm12), "GenerateVeins")] private static bool PlanetAlgorithm12_GenerateVeins_Prefix(PlanetAlgorithm12 __instance) { return PlanetAlgorithmX_GenerateVeins_Prefix(typeof(PlanetAlgorithm12), __instance); } [HarmonyPrefix] [HarmonyPatch(typeof(PlanetAlgorithm13), "GenerateVeins")] private static bool PlanetAlgorithm13_GenerateVeins_Prefix(PlanetAlgorithm13 __instance) { return PlanetAlgorithmX_GenerateVeins_Prefix(typeof(PlanetAlgorithm13), __instance); } private static bool PlanetAlgorithmX_GenerateVeins_Prefix(Type type, object instance) { PlanetData planetFromAlgorithm = GetPlanetFromAlgorithm(type, instance); if (!ShouldGenerateVeinsForPlanet(planetFromAlgorithm)) { return false; } if (GalacticScaleThemeRegistry.TryGenerateGalacticScaleVeins(planetFromAlgorithm)) { ApplyReplaceAllVeinsTo(planetFromAlgorithm); if (planetFromAlgorithm != null && loggedGalacticScaleVeinThemes.Add(planetFromAlgorithm.theme)) { ThemeProto val = ((ProtoSet)(object)LDB.themes).Select(planetFromAlgorithm.theme); string arg = ((val == null) ? planetFromAlgorithm.theme.ToString() : ((Proto)val).Name); Instance.Logger.LogInfo((object)$"Using DSPAddPlanet GalacticScale-style veins for theme {planetFromAlgorithm.theme}: {arg}"); } return false; } return true; } public static bool ShouldGenerateVeinsForPlanet(PlanetData planet) { if (planet == null || planet.star == null || GameMain.data == null || GameMain.data.gameDesc == null) { return true; } string uniqueStarId; List planetConfigList = Utility.GetPlanetConfigList(GameMain.gameName, GameMain.data.gameDesc.clusterString, planet.star.id, planet.star.name, Instance.globalPlanetConfig, Instance.gameNameSpecificConfig, out uniqueStarId); if (planetConfigList == null) { return true; } foreach (AdditionalPlanetConfig item in planetConfigList) { if (item.Index == planet.index) { if (!item.DontGenerateVein) { return true; } return false; } } return true; } [HarmonyPostfix] [HarmonyPatch(typeof(PlanetAlgorithm), "GenerateVeins")] private static void PlanetAlgorithm_GenerateVeins_Postfix(PlanetAlgorithm __instance) { PlanetAlgorithmX_GenerateVeins_Postfix(typeof(PlanetAlgorithm), __instance); } [HarmonyPostfix] [HarmonyPatch(typeof(PlanetAlgorithm0), "GenerateVeins")] private static void PlanetAlgorithm0_GenerateVeins_Postfix(PlanetAlgorithm0 __instance) { PlanetAlgorithmX_GenerateVeins_Postfix(typeof(PlanetAlgorithm0), __instance); } [HarmonyPostfix] [HarmonyPatch(typeof(PlanetAlgorithm7), "GenerateVeins")] private static void PlanetAlgorithm7_GenerateVeins_Postfix(PlanetAlgorithm7 __instance) { PlanetAlgorithmX_GenerateVeins_Postfix(typeof(PlanetAlgorithm7), __instance); } [HarmonyPostfix] [HarmonyPatch(typeof(PlanetAlgorithm11), "GenerateVeins")] private static void PlanetAlgorithm11_GenerateVeins_Postfix(PlanetAlgorithm11 __instance) { PlanetAlgorithmX_GenerateVeins_Postfix(typeof(PlanetAlgorithm11), __instance); } [HarmonyPostfix] [HarmonyPatch(typeof(PlanetAlgorithm12), "GenerateVeins")] private static void PlanetAlgorithm12_GenerateVeins_Postfix(PlanetAlgorithm12 __instance) { PlanetAlgorithmX_GenerateVeins_Postfix(typeof(PlanetAlgorithm12), __instance); } [HarmonyPostfix] [HarmonyPatch(typeof(PlanetAlgorithm13), "GenerateVeins")] private static void PlanetAlgorithm13_GenerateVeins_Postfix(PlanetAlgorithm13 __instance) { PlanetAlgorithmX_GenerateVeins_Postfix(typeof(PlanetAlgorithm13), __instance); } private static void PlanetAlgorithmX_GenerateVeins_Postfix(Type type, object instance) { ApplyReplaceAllVeinsTo(GetPlanetFromAlgorithm(type, instance)); } private static PlanetData GetPlanetFromAlgorithm(Type type, object instance) { FieldInfo fieldInfo = AccessTools.Field(type, "planet") ?? AccessTools.Field(typeof(PlanetAlgorithm), "planet"); if (!(fieldInfo == null)) { object? value = fieldInfo.GetValue(instance); return (PlanetData)((value is PlanetData) ? value : null); } return null; } public static void ApplyReplaceAllVeinsTo(PlanetData planet) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected I4, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) if (planet == null || planet.star == null || planet.data == null || GameMain.data == null || GameMain.data.gameDesc == null) { return; } string uniqueStarId; List planetConfigList = Utility.GetPlanetConfigList(GameMain.gameName, GameMain.data.gameDesc.clusterString, planet.star.id, planet.star.name, Instance.globalPlanetConfig, Instance.gameNameSpecificConfig, out uniqueStarId); if (planetConfigList == null) { return; } foreach (AdditionalPlanetConfig item in planetConfigList) { if (item.Index != planet.index || !item._HasReplaceAllVeinsTo || planet.index != item.Index) { continue; } DotNet35Random val = new DotNet35Random(planet.seed); int[] veinModelIndexs = PlanetModelingManager.veinModelIndexs; int[] veinModelCounts = PlanetModelingManager.veinModelCounts; int[] veinProducts = PlanetModelingManager.veinProducts; int num = (int)item.ReplaceAllVeinsTo; VeinData[] veinPool = planet.data.veinPool; for (int i = 0; i < veinPool.Length; i++) { if (veinPool[i].id != 0) { veinPool[i].type = item.ReplaceAllVeinsTo; veinPool[i].modelIndex = (short)val.Next(veinModelIndexs[num], veinModelIndexs[num] + veinModelCounts[num]); veinPool[i].productId = veinProducts[num]; } } } } [HarmonyTranspiler] [HarmonyPatch(typeof(PlanetAlgorithm), "GenerateVeins")] private static IEnumerable PlanetAlgorithm_GenerateVeins_Transpiler(IEnumerable instructions, ILGenerator generator) { return PlanetAlgorithmX_GenerateVeins_Transpiler(typeof(PlanetAlgorithm), instructions, generator); } [HarmonyTranspiler] [HarmonyPatch(typeof(PlanetAlgorithm7), "GenerateVeins")] private static IEnumerable PlanetAlgorithm7_GenerateVeins_Transpiler(IEnumerable instructions, ILGenerator generator) { return PlanetAlgorithmX_GenerateVeins_Transpiler(typeof(PlanetAlgorithm7), instructions, generator); } [HarmonyTranspiler] [HarmonyPatch(typeof(PlanetAlgorithm11), "GenerateVeins")] private static IEnumerable PlanetAlgorithm11_GenerateVeins_Transpiler(IEnumerable instructions, ILGenerator generator) { return PlanetAlgorithmX_GenerateVeins_Transpiler(typeof(PlanetAlgorithm11), instructions, generator); } [HarmonyTranspiler] [HarmonyPatch(typeof(PlanetAlgorithm12), "GenerateVeins")] private static IEnumerable PlanetAlgorithm12_GenerateVeins_Transpiler(IEnumerable instructions, ILGenerator generator) { return PlanetAlgorithmX_GenerateVeins_Transpiler(typeof(PlanetAlgorithm12), instructions, generator); } [HarmonyTranspiler] [HarmonyPatch(typeof(PlanetAlgorithm13), "GenerateVeins")] private static IEnumerable PlanetAlgorithm13_GenerateVeins_Transpiler(IEnumerable instructions, ILGenerator generator) { return PlanetAlgorithmX_GenerateVeins_Transpiler(typeof(PlanetAlgorithm13), instructions, generator); } private static IEnumerable PlanetAlgorithmX_GenerateVeins_Transpiler(Type type, IEnumerable instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Expected O, but got Unknown //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Expected O, but got Unknown //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Expected O, but got Unknown //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Expected O, but got Unknown //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Expected O, but got Unknown //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Expected O, but got Unknown //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Expected O, but got Unknown //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Expected O, but got Unknown //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Expected O, but got Unknown //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Expected O, but got Unknown //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Expected O, but got Unknown //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Expected O, but got Unknown //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Expected O, but got Unknown //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Expected O, but got Unknown //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Expected O, but got Unknown //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Expected O, but got Unknown //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_042c: Expected O, but got Unknown //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_0440: Expected O, but got Unknown //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Expected O, but got Unknown //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Expected O, but got Unknown //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Expected O, but got Unknown //IL_04ad: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Expected O, but got Unknown //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Expected O, but got Unknown //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Expected O, but got Unknown //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Expected O, but got Unknown //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_050c: Expected O, but got Unknown //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Expected O, but got Unknown //IL_05c1: Unknown result type (might be due to invalid IL or missing references) //IL_05c7: Expected O, but got Unknown //IL_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Expected O, but got Unknown //IL_05dd: Unknown result type (might be due to invalid IL or missing references) //IL_05e3: Expected O, but got Unknown //IL_05fe: Unknown result type (might be due to invalid IL or missing references) //IL_0604: Expected O, but got Unknown //IL_0612: Unknown result type (might be due to invalid IL or missing references) //IL_0618: Expected O, but got Unknown //IL_0626: Unknown result type (might be due to invalid IL or missing references) //IL_062c: Expected O, but got Unknown //IL_0647: Unknown result type (might be due to invalid IL or missing references) //IL_064d: Expected O, but got Unknown //IL_066a: Unknown result type (might be due to invalid IL or missing references) //IL_0670: Expected O, but got Unknown //IL_068b: Unknown result type (might be due to invalid IL or missing references) //IL_0691: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.Start(); val.Insert((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(PlanetAlgorithm), "planet")), new CodeInstruction(OpCodes.Call, (object)typeof(Patch_PlanetAlgorithms).GetMethod("InitializeRandomGenerator", BindingFlags.Static | BindingFlags.NonPublic)) }); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Conv_U1, (object)null, (string)null) }); if (val.IsInvalid) { Instance.Logger.LogError((object)("PlanetAlgorithmX_GenerateVeins_Transpiler:无法在" + type.Name + "的GenerateVeins函数中找到指令conv.u1")); return instructions; } val.Advance(1); int localIndex = ((LocalBuilder)val.Operand).LocalIndex; val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ble, (object)null, (string)null) }); if (val.IsInvalid) { Instance.Logger.LogError((object)("PlanetAlgorithmX_GenerateVeins_Transpiler:无法在" + type.Name + "的GenerateVeins函数中找到形如 if (A > 1) 的代码")); return instructions; } int localIndex2 = ((LocalBuilder)val.Operand).LocalIndex; val.Advance(2); int pos = val.Pos; val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Br, (object)null, (string)null) }); if (val.IsInvalid) { Instance.Logger.LogError((object)("PlanetAlgorithmX_GenerateVeins_Transpiler:无法在" + type.Name + "的GenerateVeins函数中找到正确的for循环的头部代码")); return instructions; } val.Insert((CodeInstruction[])(object)new CodeInstruction[7] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(PlanetAlgorithm), "planet")), new CodeInstruction(OpCodes.Ldloc_S, (object)localIndex), new CodeInstruction(OpCodes.Ldloc_S, (object)localIndex2), new CodeInstruction(OpCodes.Call, (object)typeof(Patch_PlanetAlgorithms).GetMethod("GetVeinGroupCount", BindingFlags.Static | BindingFlags.NonPublic)), new CodeInstruction(OpCodes.Stloc_S, (object)localIndex2) }); Label label = generator.DefineLabel(); val.Instruction.labels.Add(label); val.Start(); val.Advance(pos); val.SetOperandAndAdvance((object)label); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[5] { new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_7, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Bne_Un, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null) }); if (val.IsInvalid) { Instance.Logger.LogError((object)("PlanetAlgorithmX_GenerateVeins_Transpiler:无法在" + type.Name + "的GenerateVeins函数中找到正确的给矿脉中矿点数量赋值的代码")); return instructions; } int localIndex3 = ((LocalBuilder)val.Operand).LocalIndex; val.Advance(4); int localIndex4 = ((LocalBuilder)val.Operand).LocalIndex; val.Advance(-4); val.Insert((CodeInstruction[])(object)new CodeInstruction[7] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(PlanetAlgorithm), "planet")), new CodeInstruction(OpCodes.Ldloc_S, (object)localIndex3), new CodeInstruction(OpCodes.Ldloc_S, (object)localIndex4), new CodeInstruction(OpCodes.Call, (object)typeof(Patch_PlanetAlgorithms).GetMethod("GetVeinCount", BindingFlags.Static | BindingFlags.NonPublic)), new CodeInstruction(OpCodes.Stloc_S, (object)localIndex4) }); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[9] { new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Brfalse, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldloc_S, (object)null, (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldfld && instruction.operand.ToString() == "EVeinType type"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_7, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Beq, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldloca_S, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4, (object)1000000000, (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Stfld && instruction.operand.ToString() == "System.Int32 amount"), (string)null) }); if (val.IsInvalid) { Instance.Logger.LogError((object)("PlanetAlgorithmX_GenerateVeins_Transpiler:无法在" + type.Name + "的GenerateVeins函数中找到最后一处给矿脉中矿点矿物数量赋值的代码")); return instructions; } val.Advance(1); int pos2 = val.Pos; val.Advance(4); int pos3 = val.Pos; val.Advance(1); int localIndex5 = ((LocalBuilder)val.Operand).LocalIndex; val.Advance(3); val.Insert((CodeInstruction[])(object)new CodeInstruction[9] { new CodeInstruction(OpCodes.Ldloca_S, (object)localIndex5), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(PlanetAlgorithm), "planet")), new CodeInstruction(OpCodes.Ldloc_S, (object)localIndex3), new CodeInstruction(OpCodes.Ldloc_S, (object)localIndex5), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(VeinData), "amount")), new CodeInstruction(OpCodes.Call, (object)typeof(Patch_PlanetAlgorithms).GetMethod("GetVeinAmount", BindingFlags.Static | BindingFlags.NonPublic)), new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(VeinData), "amount")) }); Label label2 = generator.DefineLabel(); val.Instruction.labels.Add(label2); val.Start(); val.Advance(pos2); val.SetOperandAndAdvance((object)label2); val.Start(); val.Advance(pos3); val.SetOperandAndAdvance((object)label2); return val.InstructionEnumeration(); } private static void InitializeRandomGenerator(PlanetData planet) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown random = new DotNet35Random(planet.seed); } private static int GetVeinGroupCount(PlanetAlgorithm _, PlanetData planet, EVeinType veinType, int originalValue) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) string uniqueStarId; List planetConfigList = Utility.GetPlanetConfigList(GameMain.gameName, GameMain.data.gameDesc.clusterString, planet.star.id, planet.star.name, Instance.globalPlanetConfig, Instance.gameNameSpecificConfig, out uniqueStarId); if (planetConfigList == null) { return originalValue; } foreach (AdditionalPlanetConfig item in planetConfigList) { if (item.Index == planet.index && item._HasVeinCustom && item.VeinCustom.ContainsKey(veinType)) { AdditionalPlanetConfig.VeinConfig.CustomValue veinGroupCount = item.VeinCustom[veinType].VeinGroupCount; if (veinGroupCount.Type == AdditionalPlanetConfig.VeinConfig.CustomValue.CustomType.Default) { return originalValue; } if (veinGroupCount.Type == AdditionalPlanetConfig.VeinConfig.CustomValue.CustomType.Accurate) { return veinGroupCount.AccurateValue; } if (veinGroupCount.Type == AdditionalPlanetConfig.VeinConfig.CustomValue.CustomType.Random) { return veinGroupCount.GetRandomResult(random); } } } return originalValue; } private static int GetVeinCount(PlanetAlgorithm _, PlanetData planet, EVeinType veinType, int originalValue) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) string uniqueStarId; List planetConfigList = Utility.GetPlanetConfigList(GameMain.gameName, GameMain.data.gameDesc.clusterString, planet.star.id, planet.star.name, Instance.globalPlanetConfig, Instance.gameNameSpecificConfig, out uniqueStarId); if (planetConfigList == null) { return originalValue; } foreach (AdditionalPlanetConfig item in planetConfigList) { if (item.Index == planet.index && item._HasVeinCustom && item.VeinCustom.ContainsKey(veinType)) { AdditionalPlanetConfig.VeinConfig.CustomValue veinSpotCount = item.VeinCustom[veinType].VeinSpotCount; if (veinSpotCount.Type == AdditionalPlanetConfig.VeinConfig.CustomValue.CustomType.Default) { return originalValue; } if (veinSpotCount.Type == AdditionalPlanetConfig.VeinConfig.CustomValue.CustomType.Accurate) { return veinSpotCount.AccurateValue; } if (veinSpotCount.Type == AdditionalPlanetConfig.VeinConfig.CustomValue.CustomType.Random) { return veinSpotCount.GetRandomResult(random); } } } return originalValue; } private static int GetVeinAmount(PlanetAlgorithm _, PlanetData planet, EVeinType veinType, int originalValue) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) string uniqueStarId; List planetConfigList = Utility.GetPlanetConfigList(GameMain.gameName, GameMain.data.gameDesc.clusterString, planet.star.id, planet.star.name, Instance.globalPlanetConfig, Instance.gameNameSpecificConfig, out uniqueStarId); if (planetConfigList == null) { return originalValue; } foreach (AdditionalPlanetConfig item in planetConfigList) { if (item.Index == planet.index && item._HasVeinCustom && item.VeinCustom.ContainsKey(veinType)) { AdditionalPlanetConfig.VeinConfig.CustomValue veinAmount = item.VeinCustom[veinType].VeinAmount; if (veinAmount.Type == AdditionalPlanetConfig.VeinConfig.CustomValue.CustomType.Default) { return originalValue; } if (veinAmount.Type == AdditionalPlanetConfig.VeinConfig.CustomValue.CustomType.Accurate) { return veinAmount.AccurateValue; } if (veinAmount.Type == AdditionalPlanetConfig.VeinConfig.CustomValue.CustomType.Random) { return veinAmount.GetRandomResult(random); } } } return originalValue; } } private class Patch_PlanetModeling { [HarmonyPrefix] [HarmonyPatch(typeof(PlanetModelingManager), "ModelingPlanetMain")] private static bool ModelingPlanetMain(PlanetData planet) { if (planet != null && (Object)(object)planet.terrainMaterial == (Object)null) { GalacticScaleThemeRegistry.PrepareRegisteredThemeForPlanet(planet); } planet.data.AddRadius(planet); return true; } [HarmonyPostfix] [HarmonyPatch(typeof(PlanetModelingManager), "ModelingPlanetMain")] private static void ModelingPlanetMain_Postfix(PlanetData planet) { GalacticScaleThemeRegistry.ApplyRegisteredThemeToLoadedPlanet(planet); } [HarmonyTranspiler] [HarmonyPatch(typeof(PlanetModelingManager), "ModelingPlanetMain")] private static IEnumerable ModelingPlanetMainTranspiler(IEnumerable instructions) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], typeof(PlanetRawData).GetMethod("GetModPlane"))) { list[i] = new CodeInstruction(OpCodes.Call, (object)typeof(PlanetRawDataExtension).GetMethod("GetModPlaneInt")); } } return list.AsEnumerable(); } [HarmonyTranspiler] [HarmonyPatch(typeof(PlanetData), "UpdateDirtyMesh")] private static IEnumerable UpdateDirtyMeshTranspiler(IEnumerable instructions) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], typeof(PlanetRawData).GetMethod("GetModPlane"))) { list[i] = new CodeInstruction(OpCodes.Call, (object)typeof(PlanetRawDataExtension).GetMethod("GetModPlaneInt")); } } return list.AsEnumerable(); } [HarmonyTranspiler] [HarmonyPatch(typeof(PlanetRawData), "QueryModifiedHeight")] private static IEnumerable QueryModifiedHeightTranspiler(IEnumerable instructions) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown List list = new List(instructions); for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i], typeof(PlanetRawData).GetMethod("GetModPlane"))) { list[i] = new CodeInstruction(OpCodes.Call, (object)typeof(PlanetRawDataExtension).GetMethod("GetModPlaneInt")); } } return list.AsEnumerable(); } } private class Patch_TrashSystem { [HarmonyTranspiler] [HarmonyPatch(typeof(TrashSystem), "Gravity")] private static IEnumerable TrashSystem_Gravity_Transpiler(IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_R8, (object)600.0, (string)null) }); if (val.IsInvalid) { Instance.Logger.LogError((object)"无法找到数字 600.0"); return instructions; } val.Set(OpCodes.Ldc_R8, (object)800.0); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[5] { new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloc_S && ((LocalBuilder)instruction.operand).LocalIndex == 6), (string)null), new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_8, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ble, (object)null, (string)null) }); if (val.IsInvalid) { Instance.Logger.LogError((object)"无法找到第形如 A <= B + 8 的代码"); return instructions; } val.Advance(2); val.Set(OpCodes.Ldc_I4_S, (object)99); return val.InstructionEnumeration(); } } private class Patch_PlayerController { [HarmonyPostfix] [HarmonyPatch(typeof(PlayerController), "OpenBlueprintCopyMode")] private static void PlayerController_OpenBlueprintCopyMode_Postfix() { if (GameMain.localPlanet != null) { GameCamera.instance.blueprintPoser.planetRadius = GameMain.localPlanet.realRadius; } } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerController), "OpenBlueprintPasteMode")] private static void PlayerController_OpenBlueprintPasteMode_Postfix() { if (GameMain.localPlanet != null) { GameCamera.instance.blueprintPoser.planetRadius = GameMain.localPlanet.realRadius; } } } private class Patch_PlanetRadiusCompatibility { private const float VANILLA_SOLID_RADIUS = 200f; private const float SMALL_PLANET_RADIUS = 100f; private static readonly HashSet atmosphereRadiusLogged = new HashSet(); private static readonly HashSet smallPlanetColliderLogged = new HashSet(); private static bool smallPlanetColliderErrorLogged; [HarmonyPrefix] [HarmonyPatch(typeof(CloudSimulator), "OnEnable")] private static void CloudSimulator_OnEnable_Prefix(CloudSimulator __instance) { ApplyAtmosphereRadius(__instance?.planet); } [HarmonyPostfix] [HarmonyPatch(typeof(PlanetAtmoBlur), "Update")] private static void PlanetAtmoBlur_Update_Postfix(PlanetAtmoBlur __instance) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0044: 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_007b: Unknown result type (might be due to invalid IL or missing references) PlanetData localPlanet = GameMain.localPlanet; if (localPlanet != null && (int)localPlanet.type != 5 && GameMain.mainPlayer != null && !((Object)(object)__instance?.blurMat == (Object)null)) { float num = Mathf.Max(localPlanet.realRadius, 1f); Vector3 position = GameMain.mainPlayer.position; float magnitude = ((Vector3)(ref position)).magnitude; float num2 = Mathf.Clamp01((GetAtmoBlurOuterRadius() - magnitude) / GetAtmoBlurFadeDistance()); __instance.blurMat.SetVector("_PlanetRadius", new Vector4(num, num, num * 1.2f, num2)); } } [HarmonyTranspiler] [HarmonyPatch(typeof(PlanetAtmoBlur), "Update")] private static IEnumerable PlanetAtmoBlur_Update_Transpiler(IEnumerable instructions) { MethodInfo getOuterRadius = AccessTools.Method(typeof(Patch_PlanetRadiusCompatibility), "GetAtmoBlurOuterRadius", (Type[])null, (Type[])null); MethodInfo getFadeDistance = AccessTools.Method(typeof(Patch_PlanetRadiusCompatibility), "GetAtmoBlurFadeDistance", (Type[])null, (Type[])null); int outerRadiusReplaced = 0; int fadeDistanceReplaced = 0; foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldc_R4 && instruction.operand is float num) { if (Mathf.Approximately(num, 800f)) { instruction.opcode = OpCodes.Call; instruction.operand = getOuterRadius; outerRadiusReplaced++; } else if (Mathf.Approximately(num, 300f)) { instruction.opcode = OpCodes.Call; instruction.operand = getFadeDistance; fadeDistanceReplaced++; } } yield return instruction; } if (outerRadiusReplaced != 1 || fadeDistanceReplaced != 1) { Instance.Logger.LogWarning((object)$"Atmosphere blur compatibility expected one 800 and one 300 constant, replaced {outerRadiusReplaced} and {fadeDistanceReplaced}"); } } [HarmonyTranspiler] [HarmonyPatch(typeof(MinerComponent), "IsTargetVeinInRange")] private static IEnumerable MinerComponent_IsTargetVeinInRange_Transpiler(IEnumerable instructions) { List list = new List(instructions); MethodInfo operand = AccessTools.Method(typeof(Patch_PlanetRadiusCompatibility), "GetLocalPlanetRadius", (Type[])null, (Type[])null); int num = 0; foreach (CodeInstruction item in list) { if (item.opcode == OpCodes.Ldc_R4 && item.operand is float num2 && Mathf.Approximately(num2, 200f)) { item.opcode = OpCodes.Call; item.operand = operand; num++; } } if (num != 2) { Instance.Logger.LogWarning((object)$"Miner radius compatibility expected 2 radius constants, replaced {num}"); } return list; } [HarmonyPrefix] [HarmonyPatch(typeof(BuildTool_Path), "GetGridWidth")] private static bool BuildTool_Path_GetGridWidth_Prefix(BuildTool_Path __instance, Vector3 _pos, Vector3 _forward, ref float __result) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) Vector3 normalized = ((Vector3)(ref _pos)).normalized; if (normalized.x * normalized.x + normalized.z * normalized.z <= 1E-06f) { __result = 1.254f; return false; } PlanetData planet = ((BuildTool)__instance).planet; float num = Mathf.Max((planet != null) ? planet.realRadius : 200f, 1f); int? obj; if (planet == null) { obj = null; } else { PlanetAuxData aux = planet.aux; obj = ((aux == null) ? ((int?)null) : aux.activeGrid?.segment); } int num2 = obj ?? Mathf.Max(4, (int)(num / 4f + 0.1f) * 4); Vector3 val = normalized * num; Vector3 val2 = ((normalized.y > 0f) ? new Vector3(0f, num, 0f) : new Vector3(0f, 0f - num, 0f)) - val; Vector3 normalized2 = ((Vector3)(ref val2)).normalized; float num3 = Mathf.Abs(Vector3.Dot(Vector3.Cross(normalized, normalized2), _forward)); int num4 = BlueprintUtils.GetLongitudeSegmentCount(normalized, num2) * 5; float num5 = Mathf.Sqrt(Mathf.Max(0f, 1f - normalized.y * normalized.y)) * num * (float)Math.PI * 2f / (float)Mathf.Max(num4, 1); __result = num3 * num5 + (1f - num3) * 1.254f; return false; } [HarmonyPrefix] [HarmonyPatch(typeof(NearColliderLogic), "GetVeinsInAreaNonAlloc")] private static bool NearColliderLogic_GetVeinsInAreaNonAlloc_Prefix(NearColliderLogic __instance, Vector3 center, float areaRadius, ref int[] veinIds, ref int __result, ColliderContainer[] ___colChunks, int[] ___activeColHashes, ref int ___activeColHashCount) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_004f: 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_0058: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Invalid comparison between Unknown and I4 //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) PlanetData val = ((__instance != null) ? __instance.planet : null); if (val == null || val.realRadius >= 100f || veinIds == null || ___colChunks == null || ___activeColHashes == null) { return true; } try { Array.Clear(veinIds, 0, veinIds.Length); ___activeColHashCount = 0; Vector3 normalized = ((Vector3)(ref center)).normalized; Vector3 val2 = Vector3.Cross(normalized, Vector3.up); Vector3 val3 = ((Vector3)(ref val2)).normalized; Vector3 val4; if (((Vector3)(ref val3)).sqrMagnitude < 0.25f) { val3 = Vector3.right; val4 = Vector3.forward; } else { val2 = Vector3.Cross(val3, normalized); val4 = ((Vector3)(ref val2)).normalized; } float num = 2f + (float)Mathf.RoundToInt(val.realRadius / 150f); int num2 = Mathf.CeilToInt(areaRadius / Mathf.Max(num, 1f)); float magnitude = ((Vector3)(ref center)).magnitude; for (int i = -num2; i <= num2; i++) { if (___activeColHashCount >= ___activeColHashes.Length) { break; } for (int j = -num2; j <= num2; j++) { if (___activeColHashCount >= ___activeColHashes.Length) { break; } Vector3 position = center + val3 * ((float)i * num) + val4 * ((float)j * num); position = ((Vector3)(ref position)).normalized * magnitude; AddActiveColliderHash(position, ___activeColHashes, ref ___activeColHashCount); } } int num3 = 0; for (int k = 0; k < ___activeColHashCount; k++) { int num4 = ___activeColHashes[k]; if (num4 < 0 || num4 >= ___colChunks.Length || ___colChunks[num4] == null) { continue; } ColliderData[] colliderPool = ___colChunks[num4].colliderPool; for (int l = 1; l < ___colChunks[num4].cursor; l++) { ColliderData val5 = colliderPool[l]; if (val5.idType == 0 || ((ColliderData)(ref val5)).isForBuild || (int)((ColliderData)(ref val5)).objType != 2) { continue; } val2 = val5.pos - center; if (((Vector3)(ref val2)).sqrMagnitude > areaRadius * areaRadius + ((Vector3)(ref val5.ext)).sqrMagnitude) { continue; } bool flag = false; for (int m = 0; m < num3; m++) { if (veinIds[m] == ((ColliderData)(ref val5)).objId) { flag = true; break; } } if (!flag) { if (num3 >= veinIds.Length) { Array.Resize(ref veinIds, Math.Max(4, veinIds.Length * 2)); } veinIds[num3++] = ((ColliderData)(ref val5)).objId; } } } __result = num3; if (smallPlanetColliderLogged.Add(val.id)) { Instance.Logger.LogInfo((object)$"Enabled small-planet vein collision sampling for {val.displayName}, radius {val.realRadius:F1}"); } return false; } catch (Exception ex) { if (!smallPlanetColliderErrorLogged) { smallPlanetColliderErrorLogged = true; Instance.Logger.LogWarning((object)("Small-planet vein collision sampling fell back to the game implementation: " + ex.Message)); } return true; } } public static void ApplyAtmosphereRadius(PlanetData planet) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 if (planet != null && (int)planet.type != 5 && !(planet.realRadius <= 0f) && (ScaleAtmosphereMaterial(planet.atmosMaterial, planet.realRadius) | ScaleAtmosphereMaterial(planet.atmosMaterialLate, planet.realRadius)) && atmosphereRadiusLogged.Add(planet.id)) { Instance.Logger.LogInfo((object)$"Scaled atmosphere and cloud shell for {planet.displayName}, radius {planet.realRadius:F1}"); } } private static bool ScaleAtmosphereMaterial(Material material, float targetRadius) { //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_0024: 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_0047: 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_0050: 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_005c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)material == (Object)null || !material.HasProperty("_PlanetRadius")) { return false; } Vector4 vector = material.GetVector("_PlanetRadius"); if (vector.x <= 0.01f || Mathf.Abs(vector.x - targetRadius) <= 0.01f) { return false; } vector *= targetRadius / vector.x; material.SetVector("_PlanetRadius", vector); return true; } private static float GetLocalPlanetRadius() { PlanetData localPlanet = GameMain.localPlanet; return Mathf.Max((localPlanet != null) ? localPlanet.realRadius : 200f, 1f); } private static float GetAtmoBlurOuterRadius() { return GetLocalPlanetRadius() * 4f; } private static float GetAtmoBlurFadeDistance() { return GetLocalPlanetRadius() * 1.5f; } private static void AddActiveColliderHash(Vector3 position, int[] activeHashes, ref int activeCount) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) int num = PlanetPhysics.HashPhysBlock(position); if (num < 0) { return; } for (int i = 0; i < activeCount; i++) { if (activeHashes[i] == num) { return; } } if (activeCount < activeHashes.Length) { activeHashes[activeCount++] = num; } } } private class Patch_StationComponent { [HarmonyTranspiler] [HarmonyPatch(typeof(StationComponent), "InternalTickRemote")] public static IEnumerable InternalTickRemoteTranspiler(IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Expected O, but got Unknown //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Expected O, but got Unknown //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Expected O, but got Unknown //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Expected O, but got Unknown //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Expected O, but got Unknown //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Expected O, but got Unknown //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Expected O, but got Unknown //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Expected O, but got Unknown //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Expected O, but got Unknown //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Expected O, but got Unknown //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Expected O, but got Unknown //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Expected O, but got Unknown //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Expected O, but got Unknown //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4] { new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Br), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloc_S && instruction.operand.ToString().StartsWith("ShipData")), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldfld && instruction.operand.ToString().Equals("System.Int32 stage")), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Brtrue), (string)null) }); if (val.IsInvalid) { Instance.Logger.LogError((object)"无法找到代码 if (shipData.stage == 0) 的位置"); return instructions; } val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[5] { new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloc_S && instruction.operand.ToString().StartsWith("System.Int32")), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloc_S && instruction.operand.ToString().StartsWith("System.Int32")), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => IsLdcI4(instruction, 10)), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Add), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Blt), (string)null) }); if (val.IsInvalid) { Instance.Logger.LogError((object)"无法找到第一处形如 A < B + 10 的代码"); return instructions; } val.Advance(2); val.SetAndAdvance(OpCodes.Ldc_I4, (object)100); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[5] { new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloc_S && instruction.operand.ToString().StartsWith("System.Int32")), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloc_S && instruction.operand.ToString().StartsWith("System.Int32")), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => IsLdcI4(instruction, 10)), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Add), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Blt), (string)null) }); if (val.IsInvalid) { Instance.Logger.LogError((object)"无法找到第二处形如 A < B + 10 的代码"); return instructions; } val.Advance(2); val.SetAndAdvance(OpCodes.Ldc_I4, (object)100); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[8] { new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloc_S && instruction.operand.ToString().StartsWith("System.Int32")), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => IsLdcI4(instruction, 100)), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Rem), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Brtrue), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloc_S && instruction.operand.ToString().StartsWith("System.Single")), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldc_R4 && (float)instruction.operand == 2.5f), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Mul), (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Stloc_S && instruction.operand.ToString().StartsWith("System.Single")), (string)null) }); if (val.IsInvalid) { Instance.Logger.LogError((object)"无法找到形如 if (A % 100 == 0) B *= 2.5f 的代码"); return instructions; } val.Advance(-2); val.SetOperandAndAdvance((object)1f); return val.InstructionEnumeration(); } private static bool IsLdcI4(CodeInstruction instruction, int value) { if (instruction == null) { return false; } if (TryReadLdcI4(instruction, out var value2)) { return value2 == value; } return false; } private static bool TryReadLdcI4(CodeInstruction instruction, out int value) { if (instruction.opcode == OpCodes.Ldc_I4_M1) { value = -1; return true; } if (instruction.opcode == OpCodes.Ldc_I4_0) { value = 0; return true; } if (instruction.opcode == OpCodes.Ldc_I4_1) { value = 1; return true; } if (instruction.opcode == OpCodes.Ldc_I4_2) { value = 2; return true; } if (instruction.opcode == OpCodes.Ldc_I4_3) { value = 3; return true; } if (instruction.opcode == OpCodes.Ldc_I4_4) { value = 4; return true; } if (instruction.opcode == OpCodes.Ldc_I4_5) { value = 5; return true; } if (instruction.opcode == OpCodes.Ldc_I4_6) { value = 6; return true; } if (instruction.opcode == OpCodes.Ldc_I4_7) { value = 7; return true; } if (instruction.opcode == OpCodes.Ldc_I4_8) { value = 8; return true; } if (instruction.opcode != OpCodes.Ldc_I4 && instruction.opcode != OpCodes.Ldc_I4_S) { value = 0; return false; } try { value = Convert.ToInt32(instruction.operand); return true; } catch { value = 0; return false; } } } private class Patch_PlanetSimulator { [HarmonyPrefix] [HarmonyPatch(typeof(PlanetSimulator), "SetPlanetData")] private static bool PlanetSimulator_SetPlanetData_Prefix(PlanetData planet, PlanetSimulator __instance, ref PlanetData ___planetData, ref Transform ___atmoTrans0, ref Transform ___atmoTrans1, ref Material ___atmoMat, ref Material ___atmoMatLate, ref Vector4 ___atmoMatRadiusParam, ref Material ___oceanMat, ref int ___oceanRenderQueue, ref Transform ___lookCamera, ref UniverseSimulator ___universe, ref StarSimulator ___star) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) ___planetData = planet; GalacticScaleThemeRegistry.ApplyRegisteredThemeToPlanet(___planetData); Patch_PlanetRadiusCompatibility.ApplyAtmosphereRadius(___planetData); if ((Object)(object)___planetData.atmosMaterial != (Object)null) { GameObject val = new GameObject("Atmosphere"); val.layer = 31; ___atmoTrans0 = val.transform; ___atmoTrans0.parent = ((Component)__instance).transform; ___atmoTrans0.localPosition = Vector3.zero; float planetScaleFactor = GetPlanetScaleFactor(planet); if (planetScaleFactor >= 1f) { Transform obj = ___atmoTrans0; obj.localScale *= planetScaleFactor; } else if (planetScaleFactor > 0f) { Transform obj2 = ___atmoTrans0; obj2.localScale /= planetScaleFactor; } GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)5); val2.layer = 31; ___atmoTrans1 = val2.transform; ___atmoTrans1.parent = ___atmoTrans0; ___atmoTrans1.localPosition = Vector3.zero; Object.Destroy((Object)(object)val2.GetComponent()); Renderer component = val2.GetComponent(); ___atmoMat = ___planetData.atmosMaterial; ___atmoMatLate = ___planetData.atmosMaterialLate; component.sharedMaterials = (Material[])(object)new Material[2] { ___atmoMat, ___atmoMatLate }; component.shadowCastingMode = (ShadowCastingMode)0; component.receiveShadows = false; component.lightProbeUsage = (LightProbeUsage)0; component.motionVectorGenerationMode = (MotionVectorGenerationMode)2; ___atmoTrans1.localScale = Vector3.one * (planet.realRadius * 5f * Mathf.Max(planetScaleFactor, 0.0001f)); ___atmoMatRadiusParam = ___atmoMat.GetVector("_PlanetRadius"); } ___oceanMat = ___planetData.oceanMaterial; if ((Object)(object)___oceanMat != (Object)null) { ___oceanRenderQueue = ___oceanMat.renderQueue; } ___lookCamera = ((Component)Camera.main).transform; ___universe = GameMain.universeSimulator; ___star = ___universe.FindStarSimulator(planet.star); return false; } [HarmonyPostfix] [HarmonyPatch(typeof(PlanetSimulator), "LateRefresh")] private static void PlanetSimulator_LateRefresh_Postfix(PlanetSimulator __instance, Transform ___lookCamera, StarSimulator ___star) { } private static float GetPlanetScaleFactor(PlanetData planet) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 if (planet == null) { return 1f; } if ((int)planet.type != 5) { return Mathf.Max(planet.radius / 200f, 0.0001f); } return Mathf.Max(planet.radius / 80f, 0.0001f); } } private class Patch_PlanetGrid { [HarmonyPrefix] [HarmonyPatch(typeof(PlanetGrid), "CalcSegmentsAcross")] private static bool PlanetGrid_CalcSegmentsAcross_Prefix(PlanetGrid __instance, Vector3 posR, Vector3 posA, Vector3 posB, ref float __result) { //IL_0015: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) ((Vector3)(ref posR)).Normalize(); ((Vector3)(ref posA)).Normalize(); ((Vector3)(ref posB)).Normalize(); float num = Mathf.Asin(posR.y); float num2 = num / ((float)Math.PI * 2f) * (float)__instance.segment; float num3 = PlanetGrid.DetermineLongitudeSegmentCount(Mathf.FloorToInt(Mathf.Max(0f, Mathf.Abs(num2) - 0.1f)), __instance.segment); float num4 = Mathf.Max(1f / (float)__instance.segment * 0.96f, Mathf.Cos(num) * (float)Math.PI * 2f / (num3 * 5f)); float num5 = (float)Math.PI * 2f / ((float)__instance.segment * 5f); float num6 = Mathf.Asin(posA.y); float num7 = Mathf.Atan2(posA.x, 0f - posA.z); float num8 = Mathf.Asin(posB.y); float num9 = Mathf.Atan2(posB.x, 0f - posB.z); float num10 = Mathf.Abs(Mathf.DeltaAngle(num7 * 57.29578f, num9 * 57.29578f) * ((float)Math.PI / 180f)); float num11 = Mathf.Abs(num6 - num8); float num12 = num11 + num10; float num13 = 0f; float num14 = 1f; if (num12 > 0f) { num13 = num10 / num12; num14 = num11 / num12; } float num15 = num4 * num13 + num5 * num14; Vector3 val = posA - posB; __result = ((Vector3)(ref val)).magnitude / num15; return false; } } private class Patch_UIGame { private static bool isCreated; [HarmonyPostfix] [HarmonyPatch(typeof(UIGame), "_OnCreate")] private static void UIGame__OnCreate_Postfix() { if (!isCreated) { isCreated = true; ResourceCache.InitializeResourceCache(); Instance.CreateUI(); } } [HarmonyPostfix] [HarmonyPatch(typeof(UIGame), "_OnFree")] private static void UIGame__OnFree_Postfix() { ((ManualBehaviour)Instance.uiAddPlanet)._Free(); } [HarmonyPostfix] [HarmonyPatch(typeof(UIGame), "_OnUpdate")] private static void UIGame__OnUpdate_Postfix() { if (!GameMain.isPaused && GameMain.isRunning) { ((ManualBehaviour)Instance.uiAddPlanet)._Update(); } } [HarmonyPostfix] [HarmonyPatch(typeof(UIGame), "_OnDestroy")] private static void UIGame__OnDestroy_Postfix() { ((ManualBehaviour)Instance.uiAddPlanet)._Destroy(); } [HarmonyPostfix] [HarmonyPatch(typeof(UIGame), "_OnInit")] private static void UIGame__OnInit_Postfix() { if (!((ManualBehaviour)Instance.uiAddPlanet).inited) { ((ManualBehaviour)Instance.uiAddPlanet)._Init(((ManualBehaviour)Instance.uiAddPlanet).data); } } [HarmonyPostfix] [HarmonyPatch(typeof(UIGame), "ShutAllFunctionWindow")] private static void UIGame_ShutAllFunctionWindow_Postfix() { ((ManualBehaviour)Instance.uiAddPlanet)._Close(); } } private class Patch_PlatformSystem { [HarmonyPostfix] [HarmonyPatch(typeof(PlatformSystem), "Import")] private static void PlatformSystem_Import_Postfix(PlatformSystem __instance) { if (__instance.reformData != null && __instance.maxReformCount > __instance.reformData.Length) { Array.Resize(ref __instance.reformData, __instance.maxReformCount); } } } private class Patch_BuildTool_BlueprintPaste { [HarmonyTranspiler] [HarmonyPatch(typeof(BuildTool_BlueprintPaste), "CheckBuildConditions")] private static IEnumerable BuildTool_BlueprintPaste_CheckBuildConditions_Transpiler(IEnumerable instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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 CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)200.2f, (string)null), new CodeMatch((OpCode?)OpCodes.Sub, (object)null, (string)null), new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Stloc_S), (string)null) }); if (val.IsInvalid) { Instance.Logger.LogError((object)"BuildTool_BlueprintPaste_CheckBuildConditions_Transpiler :无法找到形如 A = ? - 200.2f 的代码"); return instructions; } val.Set(OpCodes.Call, (object)typeof(Patch_BuildTool_BlueprintPaste).GetMethod("GetLocalPlanetRadius", BindingFlags.Static | BindingFlags.NonPublic)); return val.InstructionEnumeration(); } private static float GetLocalPlanetRadius() { PlanetData localPlanet = GameMain.localPlanet; return ((localPlanet != null) ? localPlanet.realRadius : 200f) + 0.2f; } } private class Patch_PlanetFactory { [HarmonyTranspiler] [HarmonyPatch(typeof(PlanetFactory), "FlattenTerrain")] private static IEnumerable PlanetFactory_FlattenTerrain_Transpiler(IEnumerable instructions, ILGenerator generator) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown LocalBuilder localBuilder = generator.DeclareLocal(typeof(int)); CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[6] { new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)100f, (string)null), new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)20f, (string)null), new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Conv_I2, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Stloc_S, (object)null, (string)null) }); if (val.IsInvalid) { Instance.Logger.LogError((object)"PlanetFactory_FlattenTerrain_Transpiler: matcher.IsInvalid"); return instructions; } int oldNum5Index = ((LocalBuilder)val.Operand).LocalIndex; val.Advance(-1); val.SetOpcodeAndAdvance(OpCodes.Conv_I4); val.SetAndAdvance(OpCodes.Stloc_S, (object)localBuilder.LocalIndex); while (val.IsValid) { val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((Func)((CodeInstruction instruction) => instruction.opcode == OpCodes.Ldloc_S && ((LocalBuilder)instruction.operand).LocalIndex == oldNum5Index), (string)null) }); if (val.IsValid) { val.SetAndAdvance(OpCodes.Ldloc_S, (object)localBuilder.LocalIndex); } } return val.InstructionEnumeration(); } } private class Patch_Debug { [HarmonyPrefix] [HarmonyPatch(typeof(PlanetGen), "SetPlanetTheme")] private static bool PlanetGen_SetPlanetTheme_Prefix(PlanetData planet, int[] themeIds) { Instance.Logger.LogInfo((object)$"planet.index: {planet.index}, planet.star.planets.Length: {planet.star.planets.Length}, themeIds.Length: {themeIds.Length}"); return true; } } public const string PLUGIN_GUID = "Zincon.DSPAddPlanetMoon2Patch"; public const string PLUGIN_NAME = "DSPAddPlanet-moon^2-patch"; public const string PLUGIN_VERSION = "3.0.15"; public const string BUILD_TAG = "dspaddplanet-3.0.15-package-name-fix-2026-07-23"; private static Plugin instance; private Dictionary> globalPlanetConfig = new Dictionary>(); private Dictionary> gameNameSpecificConfig = new Dictionary>(); private int specialBirthStarId; private int specialBirthPlanetId; private bool needsOrderedPoseUpdate; private UIAddPlanet uiAddPlanet; public static Plugin Instance => instance; public ManualLogSource Logger => ((BaseUnityPlugin)this).Logger; private void Awake() { //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_0045: 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_0065: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) instance = this; ILUtility.Initialize(Logger); Logger.LogInfo((object)"DSPAddPlanet-moon^2-patch 3.0.15 build: dspaddplanet-3.0.15-package-name-fix-2026-07-23"); PlatformSystem.segmentTable = Global.fixedPlatformSystemSegmentTable; Harmony val = new Harmony("Zincon.DSPAddPlanetMoon2Patch"); val.PatchAll(typeof(Patch_GameData)); val.PatchAll(typeof(Patch_GameDesc)); val.PatchAll(typeof(Patch_ThemeProto)); val.PatchAll(typeof(Patch_StarGen)); val.PatchAll(typeof(Patch_UniverseGen)); val.PatchAll(typeof(Patch_GalaxyData)); val.PatchAll(typeof(Patch_StarData)); val.PatchAll(typeof(Patch_GalacticScaleTerrain)); val.PatchAll(typeof(Patch_PlanetAlgorithms)); val.PatchAll(typeof(Patch_PlanetModeling)); val.PatchAll(typeof(Patch_TrashSystem)); val.PatchAll(typeof(Patch_PlayerController)); val.PatchAll(typeof(Patch_PlanetRadiusCompatibility)); val.PatchAll(typeof(Patch_StationComponent)); val.PatchAll(typeof(Patch_PlanetSimulator)); val.PatchAll(typeof(Patch_PlanetGrid)); val.PatchAll(typeof(Patch_PlatformSystem)); val.PatchAll(typeof(Patch_BuildTool_BlueprintPaste)); val.PatchAll(typeof(Patch_PlanetFactory)); val.PatchAll(typeof(Patch_UIGame)); } private void CreateUI() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_006c: Unknown result type (might be due to invalid IL or missing references) uiAddPlanet = UIAddPlanet.Create(); UIUtility.CreateTextButton("Add Planet", delegate { if (((ManualBehaviour)uiAddPlanet).active) { ((ManualBehaviour)uiAddPlanet)._Close(); } else { ((ManualBehaviour)uiAddPlanet)._Open(); ((Component)uiAddPlanet).transform.SetAsLastSibling(); } }, "add-planet-button", ((Component)UIRoot.instance).transform.Find("Overlay Canvas/In Game/Starmap UIs"), new Vector2(1f, 0f), new Vector2(1f, 0f), new Vector2(-190f, 10f), new Vector2(-100f, 40f)); } } internal static class ResourceCache { public static Font FontSAIRASB; public static void InitializeResourceCache() { Font[] array = Resources.FindObjectsOfTypeAll(); for (int i = 0; i < array.Length; i++) { if (((Object)array[i]).name == "SAIRASB") { FontSAIRASB = array[i]; } } } } internal class UIAddPlanet : ManualBehaviour { private GameObject goContentLeft; private GameObject goContentRight; private GameObject goStarPrefab; private UIStarmap uiStarmap; private ScrollRect rightScrollRect; private string uniqueStarIdXml = ""; public Text UniqueStarId { get; set; } public Text ExtraPlanetsInfo { get; set; } public Text PlanetIndexSummary { get; set; } public static UIAddPlanet Create() { //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Expected O, but got Unknown //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_0513: 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_05ca: Unknown result type (might be due to invalid IL or missing references) //IL_05d9: Unknown result type (might be due to invalid IL or missing references) //IL_05e8: Unknown result type (might be due to invalid IL or missing references) //IL_05f7: Unknown result type (might be due to invalid IL or missing references) GameObject gameObject = ((Component)((Component)UIRoot.instance).transform.Find("Overlay Canvas/In Game/Windows/Tutorial Window")).gameObject; GameObject val = Object.Instantiate(gameObject, gameObject.transform.parent); ((Object)val).name = "Add Planet"; UIAddPlanet uiAddPlanet = val.AddComponent(); ((ManualBehaviour)uiAddPlanet)._Create(); Object.Destroy((Object)(object)((Component)val.transform.Find("video-camera")).gameObject); Object.Destroy((Object)(object)((Component)val.transform.Find("video-player")).gameObject); uiAddPlanet.goContentLeft = ((Component)val.transform.Find("left-panel/ListView/Mask/Content Panel")).gameObject; for (int i = 0; i < uiAddPlanet.goContentLeft.transform.childCount; i++) { Object.Destroy((Object)(object)((Component)uiAddPlanet.goContentLeft.transform.GetChild(i)).gameObject); } GameObject gameObject2 = ((Component)val.transform.Find("left-panel/ListView")).gameObject; Object.Destroy((Object)(object)gameObject2.GetComponent()); gameObject2.GetComponent().vertical = true; uiAddPlanet.goContentRight = ((Component)val.transform.Find("right-panel/Scroll View/Viewport/Content")).gameObject; for (int j = 0; j < uiAddPlanet.goContentRight.transform.childCount; j++) { Object.Destroy((Object)(object)((Component)uiAddPlanet.goContentRight.transform.GetChild(j)).gameObject); } uiAddPlanet.rightScrollRect = ((Component)val.transform.Find("right-panel/Scroll View")).GetComponent(); if ((Object)(object)uiAddPlanet.rightScrollRect != (Object)null) { uiAddPlanet.rightScrollRect.horizontal = false; uiAddPlanet.rightScrollRect.vertical = true; } RectTransform component = uiAddPlanet.goContentRight.GetComponent(); component.Zeroize(); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(0.5f, 1f); component.offsetMin = new Vector2(0f, -400f); component.offsetMax = Vector2.zero; Object.Destroy((Object)(object)val.GetComponent()); GameObject gameObject3 = ((Component)val.transform.Find("panel-bg/title-text")).gameObject; Object.Destroy((Object)(object)gameObject3.GetComponent()); gameObject3.GetComponent().text = "Add Planet"; Button component2 = ((Component)val.transform.Find("panel-bg/close-btn")).GetComponent