Decompiled source of GalacticScale v2.76.2
GalacticScale.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using ABN; using BepInEx; using BepInEx.Logging; using GSSerializer; using GSSerializer.Internal; using GSSerializer.Internal.DirectConverters; using GalacticScale; using GalacticScale.Generators; using HarmonyLib; using NGPT; using NebulaAPI; using NebulaAPI.Interfaces; using NebulaAPI.Networking; using NebulaAPI.Packets; using NebulaCompatibility; using PCGSharp; using PowerNetworkStructures; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.UI; using UnityEngine.UI.Extensions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("GalacticScale")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Galaxy Customization for Dyson Sphere Program")] [assembly: AssemblyFileVersion("2.76.1.0")] [assembly: AssemblyInformationalVersion("2.76.1+f0511294639c38d2a23556da7231405e4ecc4a12")] [assembly: AssemblyProduct("GalacticScale")] [assembly: AssemblyTitle("GalacticScale")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.76.1.0")] [module: UnverifiableCode] internal class Program { private static void Main() { double num = 80.0; double num2 = 510.0; int num3 = 1; int num4 = (int)Math.Ceiling(Math.PI * num2 / (2.0 * num)); Console.WriteLine($"Latitude rings (rCount): {num4}"); num3 += num4; for (int i = 1; i <= num4; i++) { double a = (double)i * Math.PI / (double)num4; double num5 = num2 * Math.Sin(a); int num6 = (int)Math.Ceiling(Math.PI * num5 * 2.0 / (2.0 * num)); num3 += num6 - 1; Console.WriteLine($"Ring {i}: Adding {num6 - 1} generators (radius={num5:F2})"); } Console.WriteLine($"Total generators needed: {num3}"); } } namespace NebulaCompatibility { [BepInPlugin("dsp.galactic-scale.2.nebula", "Galactic Scale 2 Nebula Compatibility Plug-In", "1.0.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Ignore_This_Warning_If_Not_Using_Nebula_Multiplayer_Mod : BaseUnityPlugin, IMultiplayerModWithSettings, IMultiplayerMod { public static ManualLogSource Logger; public string Version => GS2.Version; public void Awake() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown NebulaModAPI.RegisterPackets(Assembly.GetExecutingAssembly()); BCE.Console.Init(); if (NebulaModAPI.NebulaIsInstalled) { NebulaModAPI.OnMultiplayerGameStarted = (Action)Delegate.Combine(NebulaModAPI.OnMultiplayerGameStarted, new Action(NebulaCompat.NebulaStart)); NebulaModAPI.OnMultiplayerGameEnded = (Action)Delegate.Combine(NebulaModAPI.OnMultiplayerGameEnded, new Action(NebulaCompat.NebulaEnd)); } Logger = new ManualLogSource("GS2DepCheck"); Logger.Sources.Add((ILogSource)(object)Logger); Logger.Log((LogLevel)8, (object)"Loaded"); } bool IMultiplayerMod.CheckVersion(string hostVersion, string clientVersion) { if (GS2.ActiveGenerator.GUID == "space.customizing.generators.vanilla") { GS2.ShowMessage("Cannot Play Multiplayer using the Vanilla Generator", "Warning", Localization.Translate("OK")); GS2.ShowMessage(GS2.ActiveGenerator.GUID, "Warning", Localization.Translate("OK")); return false; } return hostVersion.Equals(clientVersion); } public void Export(BinaryWriter w) { string value = GSSettings.Serialize(); w.Write(value); } public void Import(BinaryReader r) { string json = r.ReadString(); GSSettings.DeSerialize(json); GS2.ActiveGenerator = GS2.GetGeneratorByID(GSSettings.Instance.generatorGUID); } } public static class NebulaCompat { public static bool IsMultiplayerActive; public static bool IsClient; public static bool IsMPGameLoaded() { return IsMultiplayerActive && NebulaModAPI.MultiplayerSession.IsGameLoaded; } public static void NebulaStart() { IsMultiplayerActive = NebulaModAPI.IsMultiplayerActive; IsClient = NebulaModAPI.IsMultiplayerActive && NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient; GS2.Log($"IsMultiplayerActive:{IsMultiplayerActive} IsClient:{IsClient}", 74); } public static void NebulaEnd() { IsMultiplayerActive = false; IsClient = false; } public static void SendPacket(LobbyRequestUpdateSolarSystems packet) { NebulaModAPI.MultiplayerSession.Network.SendPacket<LobbyRequestUpdateSolarSystems>(packet); } } [RegisterPacketProcessor] public class LobbyRequestUpdateSolarSystemsProcessor : BasePacketProcessor<LobbyRequestUpdateSolarSystems> { public override void ProcessPacket(LobbyRequestUpdateSolarSystems packet, INebulaConnection conn) { if (base.IsClient) { return; } List<string> list = new List<string>(); List<int> list2 = new List<int>(); List<int> list3 = new List<int>(); if (GameMain.galaxy != null) { StarData[] stars = GameMain.galaxy.stars; foreach (StarData val in stars) { if (!string.IsNullOrEmpty(val.overrideName)) { list.Add(val.overrideName); list2.Add(val.id); list3.Add(-2); } PlanetData[] planets = val.planets; foreach (PlanetData val2 in planets) { if (!string.IsNullOrEmpty(val2.overrideName)) { list.Add(val2.overrideName); list2.Add(-1); list3.Add(val2.id); } } } } using MemoryStream memoryStream = new MemoryStream(); using BinaryWriter binaryWriter = new BinaryWriter(memoryStream); string value = GSSettings.Serialize(); binaryWriter.Write(value); binaryWriter.Close(); byte[] gssettings = memoryStream.ToArray(); conn.SendPacket<LobbyResponseUpdateSolarSystems>(new LobbyResponseUpdateSolarSystems(gssettings, list.ToArray(), list2.ToArray(), list3.ToArray())); } } [RegisterPacketProcessor] public class LobbyResponseUpdateSolarSystemsProcessor : BasePacketProcessor<LobbyResponseUpdateSolarSystems> { public override void ProcessPacket(LobbyResponseUpdateSolarSystems packet, INebulaConnection conn) { if (base.IsHost) { return; } GameDesc gameDesc = UIRoot.instance.galaxySelect.gameDesc; GalaxyData galaxyData = UIRoot.instance.galaxySelect.starmap.galaxyData; if (galaxyData == null) { galaxyData = (GS2.Vanilla ? UniverseGen.CreateGalaxy(gameDesc) : GS2.ProcessGalaxy(gameDesc, sketchOnly: true)); UIRoot.instance.galaxySelect.starmap.galaxyData = galaxyData; } using (MemoryStream input = new MemoryStream(packet.GSSettings)) { using BinaryReader binaryReader = new BinaryReader(input); GSSettings.FromString(binaryReader.ReadString()); } GSSettings.lobbyReceivedUpdateValues = true; UIRoot.instance.galaxySelect.SetStarmapGalaxy(); galaxyData = UIRoot.instance.galaxySelect.starmap.galaxyData; for (int i = 0; i < packet.Names.Length; i++) { GS2.Warn($"{packet.Names[i]} {packet.StarIds[i]} {packet.PlanetIds[i]}", 40); if (packet.StarIds[i] != -1) { StarData val = galaxyData.StarById(packet.StarIds[i]); val.overrideName = packet.Names[i]; val.NotifyOnDisplayNameChange(); } else { PlanetData val2 = galaxyData.PlanetById(packet.PlanetIds[i]); val2.overrideName = packet.Names[i]; val2.NotifyOnDisplayNameChange(); } } UIRoot.instance.galaxySelect.starmap.OnGalaxyDataReset(); } } } namespace GalacticScale { public static class GS2 { private class exceptionOutput { public string exception; public string generator; public string version; public exceptionOutput(string e) { version = Version; exception = e; generator = ActiveGenerator?.Name; } } private class ErrorObject { public readonly List<string> stack = new List<string>(); public string message; public string version = Version; } public class GSPreferences { public readonly Dictionary<string, GSGenPreferences> GeneratorPreferences = new Dictionary<string, GSGenPreferences>(); public readonly Dictionary<string, GSGenPreferences> PluginPreferences = new Dictionary<string, GSGenPreferences>(); public GSGenPreferences MainSettings = new GSGenPreferences(); public int version; public static bool WriteToDisk(GSPreferences preferences) { fsSerializer fsSerializer = new fsSerializer(); fsData data; fsResult fsResult = fsSerializer.TrySerialize(Preferences, out data); if (fsResult.Failed) { Error(fsResult.FormattedMessages, 113); return false; } string contents = fsJsonPrinter.PrettyJson(data); if (!Directory.Exists(DataDir)) { Directory.CreateDirectory(DataDir); } if (!Directory.Exists(DataDir)) { return false; } try { File.WriteAllText(Path.Combine(DataDir, "Preferences.json"), contents); } catch (Exception ex) { Error(ex.Message, 126); return false; } return true; } public static GSPreferences ReadFromDisk() { string text = Path.Combine(DataDir, "Preferences.json"); if (!CheckJsonFileExists(text)) { Warn("Cannot find Preferences.json. Creating", 139); GSPreferences gSPreferences = new GSPreferences(); WriteToDisk(gSPreferences); return gSPreferences; } Log("Loading Preferences from " + text, 146); fsSerializer fsSerializer = new fsSerializer(); string input = File.ReadAllText(text); GSPreferences instance = new GSPreferences(); fsData data = fsJsonParser.Parse(input); fsResult fsResult = fsSerializer.TryDeserialize(data, ref instance); if (fsResult.Failed) { Error("Failed to Deserialize Preferences.json", 154); Warn(fsResult.FormattedMessages, 155); return new GSPreferences(); } return instance; } public void Save(iConfigurableGenerator generator) { GSGenPreferences value = generator.Export(); GeneratorPreferences[generator.GUID] = value; } public GSGenPreferences Load(iConfigurableGenerator generator, bool fromFile = false) { if (!fromFile) { if (GeneratorPreferences.ContainsKey(generator.GUID)) { return GeneratorPreferences[generator.GUID]; } Warn("Generator Preferences do not exist, creating new", 185); return new GSGenPreferences(); } GSPreferences gSPreferences = ReadFromDisk(); if (gSPreferences.GeneratorPreferences.ContainsKey(generator.GUID)) { return gSPreferences.GeneratorPreferences[generator.GUID]; } Warn("Generator Preferences do not exist, creating new", 191); return new GSGenPreferences(); } } public enum Alignment { Left, Right, Center } public static class ExternalThemeProcessor { public static void LoadEnabledThemes() { externalThemes = new ThemeLibrary(); foreach (string externalThemeName in Config.ExternalThemeNames) { string[] array = externalThemeName.Split(new char[1] { '|' }); string text = array[0]; string text2 = array[1]; if (availableExternalThemes.ContainsKey(text) && availableExternalThemes[text].ContainsKey(text2)) { externalThemes.Add(text2, availableExternalThemes[text][text2]); Log("Added " + externalThemeName, 23); } else { Warn("Missing Theme " + text + " - " + text2, 28); } } } } public class Random : Pcg { private int count; private int seed = 1; public int Seed { get { return seed; } set { seed = value; reseed(value); } } public string Id => $"[{seed}=>{count}]"; public Random(int seed) : base(seed) { Seed = seed; } public static Random getNewInstance() { return new Random(increment++); } public bool NextPick(double chance) { return NextDouble() < chance; } public override uint NextUInt() { count++; return base.NextUInt(); } public float Normal(float averageValue, float standardDeviation) { return averageValue + standardDeviation * (float)(Math.Sqrt(-2.0 * Math.Log(1.0 - NextDouble())) * Math.Sin(Math.PI * 2.0 * NextDouble())); } public new float NextFloat(float min, float max) { if (Math.Abs(min - max) < float.MinValue) { return min; } if (min > max) { Warn($"{GetCaller()}-NextFloat: Min > Max. {min} {max}", 63); return max; } return base.NextFloat(min, max); } public new int Next(int minInclusive, int maxExclusive) { if (minInclusive == maxExclusive) { return minInclusive; } if (minInclusive > maxExclusive) { Error($"Next: Min > Max. {minInclusive} {maxExclusive}", 78); return maxExclusive - 1; } if (maxExclusive <= 0) { Error($"Max {maxExclusive} <= 0 {GetCaller()}", 84); return maxExclusive; } return base.Next(minInclusive, maxExclusive); } public int NextInclusive(int minInclusive, int maxInclusive) { if (minInclusive == maxInclusive) { return minInclusive; } if (minInclusive > maxInclusive) { Error($"Next: Min > Max. {minInclusive} {maxInclusive}", 97); return maxInclusive; } return base.Next(minInclusive, maxInclusive + 1); } public float ClampedNormal(float min, float max, int bias) { float num = max - min; float num2 = (float)bias / 100f * num + min; float val = (max - num2) / 3f; float val2 = (num2 - min) / 3f; float standardDeviation = Math.Max(val2, val); float num3 = Normal(num2, standardDeviation); return Mathf.Clamp(num3, min, max); } public VectorLF3 PointOnSphere(double radius) { //IL_008c: 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_0095: Unknown result type (might be due to invalid IL or missing references) double num = NextDouble() * 2.0 * radius - radius; double num2 = NextDouble() * Math.PI * 2.0; double num3 = Math.Sqrt(Math.Pow(radius, 2.0) - Math.Pow(num, 2.0)) * Math.Cos(num2); double num4 = Math.Sqrt(Math.Pow(radius, 2.0) - Math.Pow(num, 2.0)) * Math.Sin(num2); return new VectorLF3(num3, num4, num); } public T Item<T>(List<T> items) { if (items.Count == 0) { Error("Item Length 0 " + GetCaller(), 128); } return items[Next(items.Count)]; } public (int, T) ItemWithIndex<T>(List<T> items) { if (items.Count == 0) { Error("Item Length 0 " + GetCaller(), 137); } int num = Next(items.Count); return (num, items[num]); } public T ItemAndRemove<T>(List<T> items) { if (items.Count == 0) { Error("Item Length 0 " + GetCaller(), 147); } int index = Next(items.Count); T result = items[index]; items.RemoveAt(index); return result; } public T Item<T>(T[] items) { if (items.Length == 0) { Error("Item Length 0 " + GetCaller(), 158); } return items[Next(items.Length)]; } public (int, T) ItemWithIndex<T>(T[] items) { if (items.Length == 0) { Error("Item Length 0 " + GetCaller(), 167); } int num = Next(items.Length); return (num, items[num]); } public KeyValuePair<W, X> Item<W, X>(Dictionary<W, X> items) { if (items.Count == 0) { Error("Item Length 0 " + GetCaller(), 177); } W[] array = new W[0]; items.Keys.CopyTo(array, 0); W key = array[Next(array.Length)]; return new KeyValuePair<W, X>(key, items[key]); } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__48_0; public static UnityAction <>9__48_1; public static Func<KeyValuePair<string, GSTheme>, GSTheme> <>9__49_0; public static Response <>9__116_0; internal void <UpdateNebulaSettings>b__48_0() { ShowMessage("Cannot Host a GS2 Game using Vanilla Generator", "Warning", Localization.Translate("OK")); } internal void <UpdateNebulaSettings>b__48_1() { ShowMessage("Cannot Host a GS2 Game using Vanilla Generator", "Warning", Localization.Translate("OK")); } internal GSTheme <Init>b__49_0(KeyValuePair<string, GSTheme> t) { return t.Value; } internal void <AbortGameStart>b__116_0() { UIRoot.instance.OpenMainMenuUI(); UIRoot.ClearFatalError(); } } public static int PreferencesVersion = 2104; private static iGenerator _activeGenerator = new Vanilla(); public static List<iGenerator> Generators = new List<iGenerator> { new GS2Generator3(), new GS2Generator2(), new Sol() }; public static string Version; private static readonly string AssemblyPath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(GS2)).Location); private static readonly string OldDataDir = Path.Combine(AssemblyPath, "config"); public static readonly string DataDir = Path.Combine(Paths.ConfigPath, "GalacticScale2"); public static bool Failed = false; public static string updateMessage = ""; public static bool ModellingDone = true; public static Dictionary<string, ThemeLibrary> availableExternalThemes = new Dictionary<string, ThemeLibrary>(); public static bool canvasOverlay = false; public static Image splashImage; public static bool SaveOrLoadWindowOpen = false; public static bool Initialized = false; public static bool MenuHasLoaded; public static int increment = 0; public static DebugTool debugtool; public static bool ResearchUnlocked = false; public static List<Sprite> SplashSprites = new List<Sprite>(); public static TeleportComponent TP; public static InputComponent InputComponent; public static TerrainAlgorithmLibrary TerrainAlgorithmLibrary = TerrainAlgorithmLibrary.Init(); public static VeinAlgorithmLibrary VeinAlgorithmLibrary = VeinAlgorithmLibrary.Init(); public static VegeAlgorithmLibrary VegeAlgorithmLibrary = VegeAlgorithmLibrary.Init(); public static GS2MainSettings Config = new GS2MainSettings(); public static GalaxyData galaxy; public static GameDesc gameDesc; public static Dictionary<int, GSPlanet> gsPlanets = new Dictionary<int, GSPlanet>(); public static Dictionary<int, GSStar> gsStars = new Dictionary<int, GSStar>(); private static AssetBundle bundle; private static ButtonClickedEvent origHost; private static ButtonClickedEvent origLoad; public static List<iConfigurablePlugin> Plugins = new List<iConfigurablePlugin>(); public static GSPreferences Preferences = new GSPreferences(); public static ThemeLibrary externalThemes = new ThemeLibrary(); public static Dictionary<int, int[]> keyedLUTs = new Dictionary<int, int[]>(); public static iGenerator ActiveGenerator { get { return _activeGenerator; } set { _activeGenerator = value; } } public static bool IsMenuDemo => DSPGame.IsMenuDemo || !Initialized; public static bool Vanilla => ActiveGenerator.GUID == "space.customizing.generators.vanilla"; public static AssetBundle Bundle { get { if ((Object)(object)bundle == (Object)null) { string text = Path.Combine(AssemblyPath, "galacticbundle"); string text2 = Path.Combine(AssemblyPath, "galactic.bundle"); if (File.Exists(text)) { bundle = AssetBundle.LoadFromFile(text); } else { bundle = AssetBundle.LoadFromFile(text2); } } if ((Object)(object)bundle == (Object)null) { Error(Localization.Translate("Failed to load AssetBundle!"), 69); UIMessageBox.Show("Error", Localization.Translate("Asset Bundle not found. \r\nPlease ensure your directory structure is correct.\r\n Installation instructions can be found at https://centrebra.in/release. \r\nAn error log has been generated in the plugin/ErrorLog Directory"), Localization.Translate("Return"), 0); return null; } return bundle; } } private static bool DebugOn => Config?.DebugMode ?? true; public static void CreateStarPlanetsAstroPoses(Random random) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0109: 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_011a: 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_0123: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0319: 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_0330: 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_0336: 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) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) HighStopwatch val = new HighStopwatch(); val.Begin(); int num = galaxy.starCount * 1000; galaxy.astrosData = (AstroData[])(object)new AstroData[num]; galaxy.astrosFactory = (PlanetFactory[])(object)new PlanetFactory[num]; Log("Creating Stars", 14); for (int i = 0; i < GSSettings.StarCount; i++) { galaxy.stars[i] = CreateStar(i, random); } if (!GSSettings.Instance.imported) { foreach (GSStar star in GSSettings.Stars) { if (star.BinaryCompanion != null) { GSStar gSStar = GetGSStar(star.BinaryCompanion); if (gSStar == null) { Error("Could not find Binary Companion:" + star.BinaryCompanion, 30); continue; } StarData obj = galaxy.stars[gSStar.assignedIndex]; VectorLF3 position = (gSStar.position = star.position + gSStar.position); obj.position = position; galaxy.stars[gSStar.assignedIndex].uPosition = galaxy.stars[gSStar.assignedIndex].position * 2400000.0; } } } Log($"Stars Created in {val.duration:F5}s", 46); val.Begin(); Log("Creating Planets", 48); for (int j = 0; j < GSSettings.StarCount; j++) { CreateStarPlanets(ref galaxy.stars[j], gameDesc, random); } Log($"Planets Created in {val.duration:F5}s", 52); val.Begin(); Log("Planets have been created", 54); galaxy.starCount = galaxy.stars.Length; AstroData[] astrosData = galaxy.astrosData; for (int k = 0; k < galaxy.astrosData.Length; k++) { astrosData[k].uRot.w = 1f; astrosData[k].uRotNext.w = 1f; } Log($"Astroposes Reset in {val.duration:F5}s", 63); val.Begin(); for (int l = 0; l < GSSettings.StarCount; l++) { int astroId = galaxy.stars[l].astroId; astrosData[astroId].id = astroId; astrosData[astroId].type = (EAstroType)1; astrosData[astroId].uPos = (astrosData[astroId].uPosNext = galaxy.stars[l].uPosition); astrosData[astroId].uRot = (astrosData[astroId].uRotNext = Quaternion.identity); astrosData[astroId].uRadius = galaxy.stars[l].physicsRadius; } Log($"Astroposes filled in {val.duration:F5}s", 83); val.Begin(); for (int m = 0; m < galaxy.stars.Length; m++) { if (galaxy.stars[m] == null) { Error($"GalaxyStars[{m}] null", 92); } galaxy.stars[m].planetCount = galaxy.stars[m].planets.Length; for (int n = 0; n < galaxy.stars[m].planets.Length; n++) { if (galaxy.stars[m].planets[n] == null) { Error($"GalaxyStars[{m}].planets[{n}] null", 95); } else { galaxy.stars[m].planets[n].UpdateRuntimePose(0.0); } } } Log($"Astroposes Initialized in {val.duration:F5}s", 100); val.Begin(); Log("End", 102); } public static GalaxyData ProcessGalaxy(GameDesc desc, bool sketchOnly = false) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_025b: 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_02f3: Expected O, but got Unknown //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) Log($"Start ProcessGalaxy:{sketchOnly} StarCount:{gameDesc.starCount} Seed:{gameDesc.galaxySeed} Called By{GetCaller()}. Galaxy StarCount : {galaxy?.stars?.Length}", 11); Random random = new Random(GSSettings.Seed); try { if (Config.ForceRare) { GSSettings.GalaxyParams.forceSpecials = true; } HighStopwatch val = new HighStopwatch(); val.Begin(); gameDesc = desc; Log($"Generating Galaxy of {GSSettings.StarCount}|{gameDesc.starCount} stars", 19); Failed = false; GameObject startButton = PatchOnUIGalaxySelect.StartButton; if (startButton != null) { startButton.SetActive(true); } if (!GSSettings.Instance.imported && sketchOnly) { GSSettings.Reset(gameDesc.galaxySeed); if (((ProtoSet<ThemeProto>)(object)LDB._themes).dataArray != null && ((ProtoSet<ThemeProto>)(object)LDB._themes).dataArray.Length > 128) { Array.Resize(ref ((ProtoSet<ThemeProto>)(object)LDB._themes).dataArray, 128); } Log("Seed From gameDesc = " + GSSettings.Seed, 33); gsPlanets.Clear(); gsStars.Clear(); Warn("Loading Data from Generator : " + ActiveGenerator.Name, 38); ActiveGenerator.Generate(gameDesc.starCount); GSSettings.Instance.galaxyParams.resourceMulti = gameDesc.resourceMultiplier; GSSettings.Instance.generatorGUID = ActiveGenerator.GUID; } else { Log($"Settings Loaded From Save File {GSSettings.BirthPlanet.Name} {GSSettings.Instance.stars.Count} {GSSettings.StarCount}", 49); gameDesc.resourceMultiplier = GSSettings.Instance.galaxyParams.resourceMulti; } LogJson(gameDesc.combatSettings); Log($"Galaxy Loaded: {val.duration:F5}", 55); val.Begin(); gameDesc.starCount = GSSettings.StarCount; int num = StarPositions.GenerateTempPoses(random.Next(), GSSettings.StarCount, GSSettings.GalaxyParams.iterations, GSSettings.GalaxyParams.minDistance, GSSettings.GalaxyParams.minStepLength, GSSettings.GalaxyParams.maxStepLength, GSSettings.GalaxyParams.flatten); val.Begin(); galaxy = new GalaxyData(); galaxy.seed = GSSettings.Seed; galaxy.starCount = GSSettings.StarCount; galaxy.stars = (StarData[])(object)new StarData[GSSettings.StarCount]; if (GSSettings.StarCount <= 0) { Log("StarCount <= 0, returning galaxy", 70); return galaxy; } CreateStarPlanetsAstroPoses(random); StarData val2 = galaxy.stars[galaxy.birthStarId - 1]; Log($"Astroposes Initialized: {val.duration:F5}", 78); val.Begin(); Warn($"Setting up birthPlanet {GSSettings.BirthPlanetId}", 83); galaxy.birthPlanetId = GSSettings.BirthPlanetId; galaxy.birthStarId = GSSettings.BirthStarId; StarData val3 = galaxy.StarById(galaxy.birthStarId); AssignStarLevels(GSSettings.BirthStar); for (int i = 0; i < galaxy.starCount; i++) { if (galaxy.starCount <= 1) { break; } StarData val4 = galaxy.stars[i]; VectorLF3 val5 = val4.position - val3.position; float num2 = (float)((VectorLF3)(ref val5)).magnitude / 32f; if ((double)num2 > 1.0) { num2 = Mathf.Log(Mathf.Log(Mathf.Log(Mathf.Log(Mathf.Log(num2) + 1f) + 1f) + 1f) + 1f) + 1f; } float resourceCoef = Mathf.Pow(7f, num2) * 0.6f; val4.resourceCoef = resourceCoef; } Log($"Resource Coefficients Set: {val.duration:F5}", 102); val.Begin(); UniverseGen.CreateGalaxyStarGraph(galaxy); Log($"Stargraph Generated: {val.duration:F5}", 106); val.Begin(); Log($"Galaxy Created. birthStarid:{galaxy.birthStarId}", 110); Log($"birthPlanetId:{galaxy.birthPlanetId}", 111); Log("birthPlanet:" + galaxy.PlanetById(galaxy.birthPlanetId).name, 112); Log($"birthStarName: {galaxy.stars[galaxy.birthStarId - 1].name} Radius:{galaxy.PlanetById(galaxy.birthPlanetId).radius} Scale:{galaxy.PlanetById(galaxy.birthPlanetId).scale}", 113); if (Config.Dev) { DumpObjectToJson(Path.Combine(DataDir, "ldbthemesPost.json"), ((ProtoSet<ThemeProto>)(object)LDB._themes).dataArray); } Log("Galaxy Generated", 115); Log($"{val2.name} - {val2.initialHiveCount}/{val2.maxHiveCount}", 116); if (GSSettings.Instance.Preferences == null) { GSSettings.Instance.Preferences = Preferences; } return galaxy; } catch (Exception ex) { GameObject.Find("UI Root/Overlay Canvas/Galaxy Select/start-button").gameObject.SetActive(false); Log(ex.ToString(), 123); Log(GetCaller(), 124); Log(GetCaller(1), 125); UIMessageBox.Show("Error", "There has been a problem creating the galaxy. \nPlease let the Galactic Scale team know in our discord server. An error log has been generated in the plugin/ErrorLog Directory", "Return", 0); UIRoot.instance.OnGameLoadFailed(); return null; } } public static void AssignStarLevels(GSStar birthStar) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_00a2: Unknown result type (might be due to invalid IL or missing references) birthStar.level = 0f; float num = 0f; VectorLF3 position; foreach (GSStar star in GSSettings.Stars) { position = star.position; float num2 = (float)((VectorLF3)(ref position)).magnitude; position = birthStar.position; float num3 = num2 - (float)((VectorLF3)(ref position)).magnitude; if (num3 > num) { num = num3; } } foreach (GSStar star2 in GSSettings.Stars) { position = star2.position; float num4 = (float)((VectorLF3)(ref position)).magnitude; position = birthStar.position; float num5 = num4 - (float)((VectorLF3)(ref position)).magnitude; star2.level = num5 / num; } } public static void GenerateVeins(bool SketchOnly) { for (int i = 1; i < galaxy.starCount; i++) { StarData val = galaxy.stars[i]; for (int j = 0; j < val.planetCount; j++) { PlanetModelingManager.Algorithm(val.planets[j]).GenerateVeins(); } } } public static iGenerator GetGeneratorByID(string guid) { foreach (iGenerator generator in Generators) { if (generator.GUID == guid) { return generator; } } return GetGeneratorByID("space.customizing.generators.gs2dev"); } public static int GetCurrentGeneratorIndex() { for (int i = 0; i < Generators.Count; i++) { if (Generators[i] == ActiveGenerator) { return i; } } return -1; } public static void UpdateNebulaSettings() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //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_00aa: Expected O, but got Unknown //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_00d6: Expected O, but got Unknown GameObject val = GameObject.Find("UI Root/Overlay Canvas/Main Menu/multiplayer-menu/button-multiplayer/"); GameObject val2 = GameObject.Find("UI Root/Overlay Canvas/Main Menu/multiplayer-menu/button-new/"); if (!((Object)(object)val != (Object)null)) { return; } if (ActiveGenerator.GUID == "space.customizing.generators.vanilla") { Button component = val.GetComponent<Button>(); Button component2 = val2.GetComponent<Button>(); origHost = component.onClick; origLoad = component2.onClick; component.onClick = new ButtonClickedEvent(); component2.onClick = new ButtonClickedEvent(); ButtonClickedEvent onClick = component.onClick; object obj = <>c.<>9__48_0; if (obj == null) { UnityAction val3 = delegate { ShowMessage("Cannot Host a GS2 Game using Vanilla Generator", "Warning", Localization.Translate("OK")); }; <>c.<>9__48_0 = val3; obj = (object)val3; } ((UnityEvent)onClick).AddListener((UnityAction)obj); ButtonClickedEvent onClick2 = component2.onClick; object obj2 = <>c.<>9__48_1; if (obj2 == null) { UnityAction val4 = delegate { ShowMessage("Cannot Host a GS2 Game using Vanilla Generator", "Warning", Localization.Translate("OK")); }; <>c.<>9__48_1 = val4; obj2 = (object)val4; } ((UnityEvent)onClick2).AddListener((UnityAction)obj2); } else { Button component3 = val.GetComponent<Button>(); Button component4 = val2.GetComponent<Button>(); if (origHost != null) { component3.onClick = origHost; } if (origLoad != null) { component4.onClick = origLoad; } } } public static void Init() { Config.Preferences.Set("Debug Log", true); if (File.Exists(Path.Combine(AssemblyPath, "icon.png"))) { if (ActiveGenerator != null && ActiveGenerator.GUID == "space.customizing.generators.vanilla") { updateMessage += Localization.Translate("BACKUP YOUR SAVES. This version has potentially BREAKING CHANGES.\r\nNote: Settings for this mod are in the settings menu. Make sure to change the Generator to get the full Galactic Scale experience.\r\n"); } updateMessage += Localization.Translate("Update Detected. Please do not save over existing saves \r\nuntil you are sure you can load saves saved with this version!\r\nPlease Click GS2 Help and click the link to join our community on discord for preview builds and to help shape the mod going forward"); File.Delete(Path.Combine(AssemblyPath, "icon.png")); updateMessage += Localization.Translate("The latest DSP update has added additional planet themes which are yet to be included in GS2. \r\nI'm working on getting them added to the GS2 themeset, as well as implementing their new subtheme system"); } if (Directory.Exists(OldDataDir) && !Directory.Exists(DataDir)) { Warn("Moving Configs from " + OldDataDir + " to " + DataDir, 126); Directory.Move(OldDataDir, DataDir); updateMessage += Localization.Translate("Galactic Scale config Directory has changed to \r\n ...\\BepInEx\\config\\GalacticScale \r\nThis is to prevent data being lost when updating using the mod manager.\r\n"); } if (!Directory.Exists(DataDir)) { Directory.CreateDirectory(DataDir); } if (Directory.Exists(Path.Combine(DataDir, "Splash"))) { Utils.LoadSplashImagesFromDirectory(); } CleanErrorLogs(); LoadShaders(); Config.Init(); LoadPreferences(debug: true); ActiveGenerator = GetGeneratorByID(Config.GeneratorID); List<GSTheme> list = GSSettings.ThemeLibrary.Select((KeyValuePair<string, GSTheme> t) => t.Value).ToList(); foreach (GSTheme item in list) { item.Process(); } LoadGenerators(); LoadPreferences(); } public static void ShowMessage(string message, string title = "Galactic Scale", string button = "OK") { UIMessageBox.Show(Localization.Translate(title), Localization.Translate(message), Localization.Translate(button), 0); } public static void OnMenuLoaded() { if (MenuHasLoaded) { return; } MenuHasLoaded = true; LoadExternalThemes(Path.Combine(DataDir, "CustomThemes")); ExternalThemeProcessor.LoadEnabledThemes(); Config.InitThemePanel(); if (Config.Dev) { DumpObjectToJson(Path.Combine(DataDir, "ldbthemes.json"), ((ProtoSet<ThemeProto>)(object)LDB._themes).dataArray); } ((ProtoSet<ThemeProto>)(object)LDB._themes).Select(1); if (Config.Dev) { Utils.DumpProtosToCSharp(); } if (Config.Dev) { VegeProto[] dataArray = ((ProtoSet<VegeProto>)(object)LDB._veges).dataArray; Dictionary<int, string> dictionary = new Dictionary<int, string>(); VegeProto[] array = dataArray; foreach (VegeProto val in array) { string name = ((Proto)val).Name; string name2 = ((Proto)val).name; int iD = ((Proto)val).ID; dictionary.Add(iD, Localization.Translate(name) + " " + Localization.Translate(name2)); } DumpObjectToJson(Path.Combine(DataDir, "ldbvege.json"), dictionary); } if (updateMessage != "") { UIMessageBox.Show("Update Information", updateMessage, "Noted!", 0); updateMessage = ""; } UpdateNebulaSettings(); Utils.InitMk2MinerEffectVertices(); } public static void LoadShaders() { string text = "assets/planet_atfield_shape.shader"; Shader val = Bundle.LoadAsset<Shader>(text); if ((Object)(object)val == (Object)null) { Error(text + " not found", 218); } else { Utils.AddSwapShaderMapping("Unlit/Planet ATField Shape", val); } } public static void LoadExternalThemes(string path) { ThemeLibrary themeLibrary = new ThemeLibrary(); availableExternalThemes.Clear(); if (!Directory.Exists(path)) { Warn("External Theme Directory Not Found. Creating", 17); Directory.CreateDirectory(path); return; } string[] files = Directory.GetFiles(path); string[] directories = Directory.GetDirectories(path); if (files.Length == 0 && directories.Length == 0) { return; } string[] array = directories; foreach (string path2 in array) { string name = new DirectoryInfo(path2).Name; if (availableExternalThemes.ContainsKey(name)) { availableExternalThemes[name] = LoadDirectoryJsonThemes(path2); } else { availableExternalThemes.Add(name, LoadDirectoryJsonThemes(path2)); } } string[] array2 = files; foreach (string text in array2) { if (new FileInfo(text).Extension != ".json") { continue; } GSTheme gSTheme = LoadJsonTheme(text); if (gSTheme != null) { if (themeLibrary.ContainsKey(gSTheme.Name)) { themeLibrary[gSTheme.Name] = gSTheme; } else { themeLibrary.Add(gSTheme.Name, gSTheme); } } } if (availableExternalThemes.ContainsKey("Root")) { availableExternalThemes["Root"] = themeLibrary; } else { availableExternalThemes.Add("Root", themeLibrary); } } public static ThemeLibrary LoadDirectoryJsonThemes(string path) { ThemeLibrary themeLibrary = new ThemeLibrary(); string[] directories = Directory.GetDirectories(path); string[] files = Directory.GetFiles(path); string[] array = directories; foreach (string path2 in array) { ThemeLibrary values = LoadDirectoryJsonThemes(path2); themeLibrary.AddRange(values); } string[] array2 = files; foreach (string filename in array2) { GSTheme gSTheme = LoadJsonTheme(filename); if (gSTheme != null) { themeLibrary.Add(gSTheme.Name, gSTheme); } } return themeLibrary; } public static GSTheme LoadJsonTheme(string filename) { if (new FileInfo(filename).Extension != ".json") { return null; } string input = File.ReadAllText(filename); GSTheme instance = new GSTheme(); fsData data; fsResult fsResult = fsJsonParser.Parse(input, out data); if (fsResult.Failed) { Error("Loading of Json Theme " + filename + " failed. " + fsResult.FormattedMessages, 85); return null; } fsSerializer fsSerializer = new fsSerializer(); fsResult fsResult2 = fsSerializer.TryDeserialize(data, ref instance); if (fsResult2.Failed) { Error("Failed to deserialize " + filename + ": " + fsResult2.FormattedMessages, 94); return null; } return instance; } public static bool LoadSettingsFromJson(string path) { Log("Start", 103); if (!CheckJsonFileExists(path)) { return false; } Log("Path = " + path, 106); fsSerializer fsSerializer = new fsSerializer(); GSSettings.Stars.Clear(); Log("Initializing ThemeLibrary", 109); GSSettings.ThemeLibrary = ThemeLibrary.Vanilla(); GSSettings.GalaxyParams = new GSGalaxyParams(); Log("Reading JSON", 112); string input = File.ReadAllText(path); GSSettings instance = GSSettings.Instance; Log("Parsing JSON", 115); fsData data = fsJsonParser.Parse(input); Log("Trying To Deserialize JSON", 117); fsSerializer.TryDeserialize(data, ref instance); LogJson(instance.galaxyParams); Log("End", 120); return true; } public static void SaveSettingsToJson(string path) { fsSerializer fsSerializer = new fsSerializer(); fsSerializer.TrySerialize(GSSettings.Instance, out var data).AssertSuccessWithoutWarnings(); string contents = fsJsonPrinter.PrettyJson(data); File.WriteAllText(path, contents); } public static void DumpObjectToJson(string path, object obj) { fsSerializer fsSerializer = new fsSerializer(); fsSerializer.TrySerialize(obj, out var data).AssertSuccessWithoutWarnings(); string contents = fsJsonPrinter.PrettyJson(data); File.WriteAllText(path, contents); } public static void DumpException(Exception e) { Error(e.Message + " " + GetCaller(1) + " " + GetCaller(2) + " " + GetCaller(3) + " " + GetCaller(4) + " " + GetCaller(5), 146); string text = Path.Combine(AssemblyPath, "ErrorLog"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } text = Path.Combine(text, DateTime.Now.ToString("yyMMddHHmmss")); text += ".exceptionlog.json"; if (!File.Exists(text)) { Log(text, 154); Log("Logging Error to " + text, 155); exceptionOutput instance = new exceptionOutput(e.ToString()); fsSerializer fsSerializer = new fsSerializer(); fsSerializer.TrySerialize(instance, out var data).AssertSuccessWithoutWarnings(); string contents = fsJsonPrinter.PrettyJson(data); File.WriteAllText(text, contents); Log("End", 161); } } public static void DumpError(string message) { string text = Path.Combine(AssemblyPath, "ErrorLog"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } text = Path.Combine(text, DateTime.Now.ToString("yyMMddHHmmss")); text += ".errorlog.json"; Log(text, 170); Log("Logging Error to " + text, 171); ErrorObject errorObject = new ErrorObject(); errorObject.message = message; for (int i = 0; i < 100; i++) { string caller = GetCaller(i); if (caller != "") { errorObject.stack.Add(caller); } } fsSerializer fsSerializer = new fsSerializer(); fsSerializer.TrySerialize(errorObject, out var data).AssertSuccessWithoutWarnings(); string contents = fsJsonPrinter.PrettyJson(data); File.AppendAllText(text, contents); Log("End", 184); } private static void CleanErrorLogs() { string path = Path.Combine(AssemblyPath, "ErrorLog"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string[] files = Directory.GetFiles(path, "*.json"); string[] array = files; foreach (string fileName in array) { FileInfo fileInfo = new FileInfo(fileName); if (fileInfo.LastAccessTime < DateTime.Now.AddDays(-7.0)) { fileInfo.Delete(); } } } private static bool CheckJsonFileExists(string path) { if (File.Exists(path)) { return true; } Log("Json file does not exist at " + path, 206); return false; } public static void LoadPlugins() { Log("Start", 14); if (!Directory.Exists(Path.Combine(DataDir, "Plugins"))) { Directory.CreateDirectory(Path.Combine(DataDir, "Plugins")); } string[] files = Directory.GetFiles(Path.Combine(DataDir, "Plugins")); foreach (string text in files) { Log(text, 20); try { Assembly assembly = Assembly.LoadFrom(text); Type[] types = assembly.GetTypes(); foreach (Type type in types) { Type[] interfaces = type.GetInterfaces(); foreach (Type type2 in interfaces) { if (type2.Name == "iConfigurablePlugin" && !type.IsAbstract && !type.IsInterface) { Warn("Loading Plugin: " + assembly.GetName().Name, 29); iConfigurablePlugin iConfigurablePlugin2 = (iConfigurablePlugin)Activator.CreateInstance(type); Plugins.Add(iConfigurablePlugin2); iConfigurablePlugin2.Init(); } } } } catch (Exception ex) { Warn("Failed to load plugin:" + ex.Message, 37); updateMessage = updateMessage + "Failed to load plugin:" + text + "\r\nIf you have recently upgraded GS2, Please check to see if an updated build of the plugin is available, or downgrade GS2 to continue using it\r\n"; } } foreach (iGenerator generator in Generators) { Log("GalacticScale2|LoadPlugins|Loading Generator:" + generator.Name, 44); generator.Init(); } Log("End", 48); } public static void LoadGenerators() { Log("Start", 54); if (!Directory.Exists(Path.Combine(DataDir, "Generators"))) { Directory.CreateDirectory(Path.Combine(DataDir, "Generators")); } string[] files = Directory.GetFiles(Path.Combine(DataDir, "Generators")); foreach (string text in files) { Log(text, 60); try { Assembly assembly = Assembly.LoadFrom(text); Type[] types = assembly.GetTypes(); foreach (Type type in types) { Type[] interfaces = type.GetInterfaces(); foreach (Type type2 in interfaces) { if (type2.Name == "iGenerator" && !type.IsAbstract && !type.IsInterface) { Generators.Add((iGenerator)Activator.CreateInstance(type)); } } } } catch (Exception ex) { Warn("Failed to load generator:" + ex.Message, 72); updateMessage = updateMessage + "Failed to load external generator:" + text + "\r\nIf you have recently upgraded GS2, Please check to see if an updated build of the generator is available, or downgrade GS2 to continue using it\r\n"; } } foreach (iGenerator generator in Generators) { Log("GalacticScale2|LoadPlugins|Loading Generator:" + generator.Name, 79); generator.Init(); } Log("End", 83); } public static void SavePreferences() { Preferences.version = PreferencesVersion; Preferences.MainSettings = Config.Export(); foreach (iConfigurablePlugin plugin in Plugins) { if (plugin != null) { iConfigurablePlugin iConfigurablePlugin2 = plugin; GSGenPreferences value = iConfigurablePlugin2.Export(); Preferences.PluginPreferences[iConfigurablePlugin2.GUID] = value; } } foreach (iGenerator generator in Generators) { Preferences.Save(generator as iConfigurableGenerator); } GSPreferences.WriteToDisk(Preferences); Log("Preferences Saved", 31); } public static void LoadPreferences(bool debug = false) { Preferences = GSPreferences.ReadFromDisk(); if (!debug) { ParsePreferences(Preferences); } else { Config.Import(Preferences.MainSettings); } Log("Preferences loaded", 61); } private static void ParsePreferences(GSPreferences p) { Config.Import(p.MainSettings); if (p.GeneratorPreferences != null) { foreach (KeyValuePair<string, GSGenPreferences> generatorPreference in p.GeneratorPreferences) { Log("Generator Preferences for " + generatorPreference.Key + "found", 72); if (GetGeneratorByID(generatorPreference.Key) is iConfigurableGenerator iConfigurableGenerator2) { Log(iConfigurableGenerator2.Name + "'s preferences exported to generator", 76); iConfigurableGenerator2.Import(generatorPreference.Value); } } } if (p.PluginPreferences == null) { return; } foreach (KeyValuePair<string, GSGenPreferences> pluginPreference in p.PluginPreferences) { GetPluginByID(pluginPreference.Key)?.Import(pluginPreference.Value); } } public static void Export(BinaryWriter w) { } public static bool Import(BinaryReader r, string LoadPath = "") { Warn("Import", 22); Log("Importing from Save.", 24); if (!SaveOrLoadWindowOpen) { GSSettings.Reset(0); } fsSerializer fsSerializer = new fsSerializer(); long position = r.BaseStream.Position; Warn($"Initial Stream Position:{position}", 28); string text = "2"; string text2 = ""; text = r.ReadString(); text2 = r.ReadString(); fsData data; fsResult fsResult = fsJsonParser.Parse(text2, out data); if (fsResult.Failed) { Warn("DSV Contained No GS2 Data.", 38); Warn(fsResult.FormattedMessages, 39); r.BaseStream.Position = position; if (SaveOrLoadWindowOpen) { return true; } if (LoadPath == "" || !File.Exists(LoadPath)) { ActiveGenerator = GetGeneratorByID("space.customizing.generators.vanilla"); return false; } } Warn($"parseResult:{fsResult.Succeeded}", 49); Warn("Input file : " + LoadPath, 50); Warn($"After Parse, Stream Position:{r.BaseStream.Position}", 51); if (SaveOrLoadWindowOpen) { return true; } GSSettings instance = new GSSettings(0); if (LoadPath != "") { Warn("*** Loading Settings From " + LoadPath, 56); LoadSettingsFromJson(LoadPath); Warn($"StarCount : {GSSettings.StarCount}", 58); } else { try { if (fsSerializer.TryDeserialize(data, ref instance).Failed) { Warn("Deserialize Failed", 67); if (LoadPath == "") { r.BaseStream.Position = position; } if (LoadPath == "") { ActiveGenerator = GetGeneratorByID("space.customizing.generators.vanilla"); } Warn($"After Deserialize Stream Position:{r.BaseStream.Position}", 70); if (LoadPath == "") { return false; } } else { GSSettings.Instance = instance; } } catch (Exception ex) { Warn(ex.Message ?? "", 80); } } Warn($"StarCount2 : {GSSettings.StarCount}", 84); if (Vanilla) { ActiveGenerator = GetGeneratorByID("space.customizing.generators.gs2dev"); } Warn($"StarCount3 : {GSSettings.StarCount}", 97); GSSettings.Instance.imported = true; Warn($"Final Stream Position:{r.BaseStream.Position}", 99); return true; } public static void ConsoleSplash() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) Version gameVersion = GameConfig.gameVersion; string arg = ((object)(Version)(ref gameVersion)).ToString(); if (!BCE.disabled) { BCE.Console.WriteLine("┌─────────────────────────────────────────────────────────────────────────┐", ConsoleColor.Red); BCE.Console.Write("│", ConsoleColor.Red); BCE.Console.Write(" ╔═╗┌─┐┬ ┌─┐┌─┐┌┬┐┬┌─┐ ╔═╗┌─┐┌─┐┬ ┌─┐ ", ConsoleColor.White); BCE.Console.Write("│\n", ConsoleColor.Red); BCE.Console.Write("│", ConsoleColor.Red); BCE.Console.Write($" ║ ╦├─┤│ ├─┤│ │ ││ ╚═╗│ ├─┤│ ├┤ DSP Version {arg,17} ", ConsoleColor.Gray); BCE.Console.Write("│\n", ConsoleColor.Red); BCE.Console.Write("│", ConsoleColor.Red); BCE.Console.Write(" ╚═╝┴ ┴┴─┘┴ ┴└─┘ ┴ ┴└─┘ ╚═╝└─┘┴ ┴┴─┘└─┘ ", ConsoleColor.DarkGray); BCE.Console.Write($"Version {Version,9} Initializing ", ConsoleColor.White); BCE.Console.Write("│\n", ConsoleColor.Red); BCE.Console.WriteLine("└─────────────────────────────────────────────────────────────────────────┘", ConsoleColor.Red); } else { Bootstrap.Debug(" "); Bootstrap.Debug(".─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─."); Bootstrap.Debug("│ ╔═╗┌─┐┬ ┌─┐┌─┐┌┬┐┬┌─┐ ╔═╗┌─┐┌─┐┬ ┌─┐ │"); Bootstrap.Debug($"│ ║ ╦├─┤│ ├─┤│ │ ││ ╚═╗│ ├─┤│ ├┤ DSP Version {arg,17} │"); Bootstrap.Debug($"│ ╚═╝┴ ┴┴─┘┴ ┴└─┘ ┴ ┴└─┘ ╚═╝└─┘┴ ┴┴─┘└─┘ Version {Version,8} Initializing │"); Bootstrap.Debug("└──────https://discord.gg/NbpBn6gM6d──────────────────────────────────────┘"); } Bootstrap.Debug(""); } public static void Log(string s, [CallerLineNumber] int lineNumber = 0) { if (DebugOn) { Bootstrap.Debug(lineNumber.ToString().PadLeft(4) + ":" + GetCaller() + s); } } public static void LogTop(int width = 80) { if (BCE.disabled) { Log("-----", 26); return; } int num = width - 21; int num2 = Mathf.FloorToInt((float)(num / 2)) - 2; int spaces = num - num2 - 4; BCE.Console.Write("\r\n╔═", ConsoleColor.White); BCE.Console.Write("═", ConsoleColor.Gray); BCE.Console.Write("═", ConsoleColor.DarkGray); BCE.Console.Write(SpaceString(num2), ConsoleColor.Green); BCE.Console.Write("*", ConsoleColor.Yellow); BCE.Console.Write(".·", ConsoleColor.Gray); BCE.Console.Write(":", ConsoleColor.DarkGray); BCE.Console.Write("·.", ConsoleColor.Gray); BCE.Console.Write("✧", ConsoleColor.DarkCyan); BCE.Console.Write(" ✦ ", ConsoleColor.Cyan); BCE.Console.Write("✧", ConsoleColor.DarkCyan); BCE.Console.Write(".·", ConsoleColor.Gray); BCE.Console.Write(":", ConsoleColor.DarkGray); BCE.Console.Write("·.", ConsoleColor.Gray); BCE.Console.Write("*", ConsoleColor.Yellow); BCE.Console.Write(SpaceString(spaces), ConsoleColor.Green); BCE.Console.Write("═", ConsoleColor.DarkGray); BCE.Console.Write("═", ConsoleColor.Gray); BCE.Console.Write("═╗\r\n", ConsoleColor.White); } public static void LogBot(int width = 80) { if (BCE.disabled) { Log("-----", 58); return; } int num = width - 21; int num2 = Mathf.FloorToInt((float)(num / 2)) - 2; int spaces = num - num2 - 4; BCE.Console.Write("╚═", ConsoleColor.White); BCE.Console.Write("═", ConsoleColor.Gray); BCE.Console.Write("═", ConsoleColor.DarkGray); BCE.Console.Write(SpaceString(num2), ConsoleColor.Green); BCE.Console.Write("*", ConsoleColor.Yellow); BCE.Console.Write(".·", ConsoleColor.Gray); BCE.Console.Write(":", ConsoleColor.DarkGray); BCE.Console.Write("·.", ConsoleColor.Gray); BCE.Console.Write("✧", ConsoleColor.DarkCyan); BCE.Console.Write(" ✦ ", ConsoleColor.Cyan); BCE.Console.Write("✧", ConsoleColor.DarkCyan); BCE.Console.Write(".·", ConsoleColor.Gray); BCE.Console.Write(":", ConsoleColor.DarkGray); BCE.Console.Write("·.", ConsoleColor.Gray); BCE.Console.Write("*", ConsoleColor.Yellow); BCE.Console.Write(SpaceString(spaces), ConsoleColor.Green); BCE.Console.Write("═", ConsoleColor.DarkGray); BCE.Console.Write("═", ConsoleColor.Gray); BCE.Console.WriteLine("═╝", ConsoleColor.White); } public static string SpaceString(int spaces) { return new string(' ', spaces); } public static void LogMid(string text, int width = 80) { string[] array = text.Split(new char[1] { '\n' }); if (array.Length > 1) { string[] array2 = array; foreach (string text2 in array2) { LogMid(text2, width); } } if (BCE.disabled) { Log(text, 107); return; } if (text.Length < width - 4) { LogMidLine(text, width); return; } List<string> list = new List<string>(); int startIndex = 0; while (text.Length > width - 4) { LogMidLine(text.Substring(startIndex, width - 4), width); text = text.Remove(startIndex, width - 4); } } public static void LogMidLine(string text, int width = 80) { BCE.Console.Write("║ ", ConsoleColor.White); BCE.Console.Write(string.Format("{0," + (width - 4) + "}", text), ConsoleColor.Green); BCE.Console.Write(" ║\r\n", ConsoleColor.White); } public static void LogSpace(int lineCount = 1) { if (DebugOn) { for (int i = 0; i < lineCount; i++) { Bootstrap.Debug(" ", (LogLevel)8, isActive: true); } } } public static void Error(string message, [CallerLineNumber] int lineNumber = 0) { Bootstrap.Debug($"{lineNumber,4}:{GetCaller()}{message}", (LogLevel)2, isActive: true); DumpError(lineNumber + "|" + message); } public static void Warn(string message, [CallerLineNumber] int lineNumber = 0) { Bootstrap.Debug(lineNumber.ToString().PadLeft(4) + ":" + GetCaller() + message, (LogLevel)4, isActive: true); } public static void LogGen(string message, [CallerLineNumber] int lineNumber = 0) { if (Config.GenLog) { Bootstrap.Debug(lineNumber.ToString().PadLeft(4) + ":" + GetCaller() + message, (LogLevel)4, isActive: true); } } public static void DevLog(string message, [CallerLineNumber] int lineNumber = 0) { if (Config.Dev) { Bootstrap.Debug(lineNumber.ToString().PadLeft(4) + ":" + GetCaller() + message, (LogLevel)4, isActive: true); } } public static void LogJson(object o, bool force = false) { if (DebugOn || force) { fsSerializer fsSerializer = new fsSerializer(); fsSerializer.TrySerialize(o, out var data).AssertSuccessWithoutWarnings(); string text = fsJsonPrinter.PrettyJson(data); Bootstrap.Debug(GetCaller() + text); } } public static void WarnJson(object o) { fsSerializer fsSerializer = new fsSerializer(); fsSerializer.TrySerialize(o, out var data).AssertSuccessWithoutWarnings(); string text = fsJsonPrinter.PrettyJson(data); Bootstrap.Debug(GetCaller() + text, (LogLevel)4, isActive: true); } public static string GetCaller(int depth = 0) { depth += 2; StackTrace stackTrace = new StackTrace(); if (stackTrace.FrameCount <= depth) { return ""; } string text = stackTrace.GetFrame(depth).GetMethod().Name; Type reflectedType = stackTrace.GetFrame(depth).GetMethod().ReflectedType; if (reflectedType != null) { string text2 = reflectedType.ToString().Split(new char[1] { '.' })[^1]; if (text == ".ctor") { text = "<Constructor>"; } return text2 + "|" + text + "|"; } return "ERROR GETTING CALLER"; } public static void LogError(object sender, UnhandledExceptionEventArgs e, [CallerLineNumber] int lineNumber = 0) { Error($"{lineNumber} {GetCaller()}", 195); LogException(e.ExceptionObject as Exception); } private static void LogException(Exception ex) { Error(ex.StackTrace, 201); } public static string FormatTableHeader(string[] headers, int[] columnWidths, params Alignment[] alignments) { if (headers.Length != columnWidths.Length || headers.Length != alignments.Length) { throw new ArgumentException("Input arrays must have the same length."); } string format = GenerateFormatString(columnWidths, alignments); string text = string.Format(format, headers); return text ?? ""; } public static string FormatTable(string[] values, int[] columnWidths, params Alignment[] alignments) { if (values.Length != columnWidths.Length || values.Length != alignments.Length) { throw new ArgumentException("Input arrays must have the same length."); } string format = GenerateFormatString(columnWidths, alignments); string text = string.Format(format, values); return text ?? ""; } private static string GenerateFormatString(int[] columnWidths, Alignment[] alignments) { if (columnWidths.Length != alignments.Length) { throw new ArgumentException("Column widths and alignments must have the same length."); } string text = ""; for (int i = 0; i < columnWidths.Length; i++) { text += $"{{{i},-{columnWidths[i]}}}"; if (i < columnWidths.Length - 1) { text += " "; } } return text; } public static IEnumerable<CodeInstruction> LogTranspilerError(IEnumerable<CodeInstruction> instructions, string text) { Error(text, 261); Log(GetCaller(), 262); LogTop(); foreach (CodeInstruction instruction in instructions) { LogMid(((object)instruction).ToString()); } LogBot(); return instructions; } public static iConfigurablePlugin GetPluginByID(string guid) { foreach (iConfigurablePlugin plugin in Plugins) { if (plugin.GUID == guid) { return plugin; } } return null; } public static PlanetData CreatePlanet(ref StarData star, GSPlanet gsPlanet, Random random, PlanetData host = null) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_0283: 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_0396: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: 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_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: 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_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Invalid comparison between Unknown and I4 //IL_05d0: Unknown result type (might be due to invalid IL or missing references) //IL_05d6: Unknown result type (might be due to invalid IL or missing references) //IL_05d7: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_0612: Unknown result type (might be due to invalid IL or missing references) //IL_0646: Unknown result type (might be due to invalid IL or missing references) //IL_064c: Unknown result type (might be due to invalid IL or missing references) //IL_064d: Unknown result type (might be due to invalid IL or missing references) //IL_0668: Unknown result type (might be due to invalid IL or missing references) //IL_066f: 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_069a: Unknown result type (might be due to invalid IL or missing references) //IL_06a0: Unknown result type (might be due to invalid IL or missing references) //IL_06a1: Unknown result type (might be due to invalid IL or missing references) //IL_06bf: Unknown result type (might be due to invalid IL or missing references) //IL_06c6: Unknown result type (might be due to invalid IL or missing references) //IL_06c7: Unknown result type (might be due to invalid IL or missing references) if (GSSettings.Stars[star.index].counter > 99) { Error("Create Planet failed: Star '" + star.name + "' already has 99 bodies", 12); return null; } bool flag = host != null; if (GSSettings.Stars[star.index] == null) { Error($"Star Index {star.index} does not exist in GSSettings.Stars", 22); } int counter = GSSettings.Stars[star.index].counter; PlanetData planetData = new PlanetData(); int counter2 = GSSettings.Stars[star.index].counter; planetData.index = counter; planetData.galaxy = galaxy; planetData.star = star; PlanetData obj = planetData; int seed = (gsPlanet.Seed = ((gsPlanet.Seed < 0) ? random.Next() : gsPlanet.Seed)); obj.seed = seed; if (flag) { planetData.orbitAround = host.number; planetData.orbitAroundPlanet = host; } else { planetData.orbitAround = 0; } planetData.number = counter + 1; planetData.id = star.id * 100 + counter + 1; if (!gsPlanets.ContainsKey(planetData.id)) { gsPlanets.Add(planetData.id, gsPlanet); } else { gsPlanets[planetData.id] = gsPlanet; } string text = ""; if (flag) { if (RomanNumbers.roman.Length <= host.number + 1) { Error($"Roman Number Conversion Error for {host.number + 1}", 53); } text = RomanNumbers.roman[host.number + 1] + " - "; } if (RomanNumbers.roman.Length <= counter + 1) { Error($"Roman Number Conversion Error for {counter + 1}", 60); } text += RomanNumbers.roman[counter + 1]; planetData.name = ((gsPlanet.Name != "") ? gsPlanet.Name : (star.name + " " + text)); planetData.orbitRadius = gsPlanet.OrbitRadius; if (planetData.orbitRadius < 0f) { Warn($"Planet {planetData.name} orbit broken. {star.type} {star.spectr}", 68); planetData.orbitRadius = random.NextFloat(1f, 50f); } planetData.orbitInclination = gsPlanet.OrbitInclination; planetData.orbitLongitude = gsPlanet.OrbitLongitude; planetData.orbitalPeriod = gsPlanet.OrbitalPeriod; planetData.orbitPhase = gsPlanet.OrbitPhase; planetData.obliquity = gsPlanet.Obliquity; planetData.rotationPeriod = gsPlanet.RotationPeriod; planetData.rotationPhase = gsPlanet.RotationPhase; planetData.sunDistance = GetSunDistance(GSSettings.Stars[star.index], gsPlanet, host); planetData.radius = gsPlanet.Radius; planetData.segment = 5; int num2 = (int)(planetData.radius / 4f + 0.1f) * 4; if (!PatchOnUIBuildingGrid.LUT512.ContainsKey(num2)) { SetLuts(num2, planetData.radius); } PatchOnUIBuildingGrid.refreshGridRadius = Mathf.RoundToInt(planetData.radius); planetData.runtimeOrbitRotation = Quaternion.AngleAxis(planetData.orbitLongitude, Vector3.up) * Quaternion.AngleAxis(planetData.orbitInclination, Vector3.forward); planetData.runtimeSystemRotation = planetData.runtimeOrbitRotation * Quaternion.AngleAxis(planetData.obliquity, Vector3.forward); planetData.type = GSSettings.ThemeLibrary.Find(gsPlanet.Theme).PlanetType; planetData.scale = 1f; if ((int)planetData.type == 5) { planetData.scale = 10f; } if (gsPlanet.Scale > 0f) { planetData.scale = gsPlanet.Scale; } planetData.precision = gsPlanet.Radius; gsPlanet.planetData = planetData; planetData.luminosity = gsPlanet.Luminosity; SetPlanetTheme(planetData, gsPlanet); planetData.temperatureBias = gsPlanet.GsTheme.AtmoHeight; if (star.galaxy.astrosData == null) { Error("Astroposes array does not exist", 119); } if (star.galaxy.astrosData.Length <= planetData.id) { Error($"Astroposes does not contain index {planetData.id} when trying to set planet uRadius", 122); } star.galaxy.astrosData[planetData.id].uRadius = planetData.realRadius; if (star.planets.Length <= counter2) { Error($"star.planets length of {star.planets.Length} <= counter {counter2}", 126); } star.planets[counter2] = planetData; if (GSSettings.Stars.Count <= star.index) { Error($"GSSettings.Stars[{star.index}] does not exist", 130); } GSSettings.Stars[star.index].counter++; if (gsPlanet.MoonsCount > 0) { CreateMoons(ref planetData, gsPlanet, random); } if (Math.Abs(planetData.orbitalPeriod - planetData.rotationPeriod) < 1.0) { PlanetData obj2 = planetData; obj2.singularity = (EPlanetSingularity)(obj2.singularity | 1); } if (Math.Abs(planetData.orbitalPeriod - planetData.rotationPeriod * 2.0) < 1.0) { PlanetData obj3 = planetData; obj3.singularity = (EPlanetSingularity)(obj3.singularity | 2); } if (Math.Abs(planetData.orbitalPeriod - planetData.rotationPeriod * 4.0) < 1.0) { PlanetData obj4 = planetData; obj4.singularity = (EPlanetSingularity)(obj4.singularity | 4); } if (gsPlanet.Bodies.Count > 2) { PlanetData obj5 = planetData; obj5.singularity = (EPlanetSingularity)(obj5.singularity | 0x20); } if (planetData.obliquity > 75f || planetData.obliquity < -75f) { PlanetData obj6 = planetData; obj6.singularity = (EPlanetSingularity)(obj6.singularity | 8); } if (planetData.rotationPeriod < 0.0) { PlanetData obj7 = planetData; obj7.singularity = (EPlanetSingularity)(obj7.singularity | 0x10); } return planetData; } public static float GetSunDistance(GSStar star, GSPlanet planet, PlanetData host) { if (host == null) { return planet.OrbitRadius; } if (IsPlanetOfStar(star, GetGSPlanet(host))) { return host.orbitRadius; } foreach (GSPlanet planet2 in star.Planets) { foreach (GSPlanet body in planet2.Bodies) { if (planet == body) { return planet2.OrbitRadius; } } } Error("Cannot Get Sun Distance for planet " + planet.Name, 168); return 100f; } public static void CreateMoons(ref PlanetData planetData, GSPlanet planet, Random random) { for (int i = 0; i < planet.Moons.Count; i++) { if (GSSettings.Stars[planetData.star.index].counter > 99) { Error("Create Planet failed: Star '" + planetData.star.name + "' already has 99 bodies", 178); break; } PlanetData val = CreatePlanet(ref planetData.star, planet.Moons[i], random, planetData); if (val == null) { Error("Creating moons for planet '" + planet.Name + "' failed. No moon returned", 185); break; } val.orbitAroundPlanet = planetData; } } public static void DebugPlanet(PlanetData planet) { //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: 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) //IL_0206: 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_022c: 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_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0278: 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_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_0572: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_05b9: Unknown result type (might be due to invalid IL or missing references) //IL_05be: Unknown result type (might be due to invalid IL or missing references) BCE.Console.WriteLine("Creating Planet " + planet.id, ConsoleColor.Red); BCE.Console.WriteLine("Index " + planet.index, ConsoleColor.Green); BCE.Console.WriteLine("OrbitAround " + planet.orbitAround, ConsoleColor.Green); BCE.Console.WriteLine("Seed " + planet.seed, ConsoleColor.Green); BCE.Console.WriteLine("Period " + planet.orbitalPeriod, ConsoleColor.Green); BCE.Console.WriteLine("Inclination " + planet.orbitInclination, ConsoleColor.Green); BCE.Console.WriteLine("Orbit Index " + planet.orbitIndex, ConsoleColor.Green); BCE.Console.WriteLine("Orbit Longitude " + planet.orbitLongitude, ConsoleColor.Green); BCE.Console.WriteLine("Orbit Phase " + planet.orbitPhase, ConsoleColor.Green); BCE.Console.WriteLine("Orbit Radius " + planet.orbitRadius, ConsoleColor.Green); BCE.Console.WriteLine("Precision " + planet.precision, ConsoleColor.Green); BCE.Console.WriteLine("Radius " + planet.radius, ConsoleColor.Green); BCE.Console.WriteLine("Rotation Period " + planet.rotationPeriod, ConsoleColor.Green); BCE.Console.WriteLine("Rotation Phase " + planet.rotationPhase, ConsoleColor.Green); Vector3 val = planet.runtimeLocalSunDirection; BCE.Console.WriteLine("RuntimeLocalSunDirection " + ((object)(Vector3)(ref val)).ToString(), ConsoleColor.Green); BCE.Console.WriteLine("RuntimeOrbitPhase " + planet.runtimeOrbitPhase, ConsoleColor.Green); Quaternion val2 = planet.runtimeOrbitRotation; BCE.Console.WriteLine("RuntimeOrbitRotation " + ((object)(Quaternion)(ref val2)).ToString(), ConsoleColor.Green); VectorLF3 val3 = planet.runtimePosition; BCE.Console.WriteLine("RuntimePosition " + ((object)(VectorLF3)(ref val3)).ToString(), ConsoleColor.Green); val3 = planet.runtimePositionNext; BCE.Console.WriteLine("RuntimePositionNext " + ((object)(VectorLF3)(ref val3)).ToString(), ConsoleColor.Green); val2 = planet.runtimeRotation; BCE.Console.WriteLine("RuntimeRotation " + ((object)(Quaternion)(ref val2)).ToString(), ConsoleColor.Green); val2 = planet.runtimeRotationNext; BCE.Console.WriteLine("RuntimeRotationNext " + ((object)(Quaternion)(ref val2)).ToString(), ConsoleColor.Green); BCE.Console.WriteLine("RuntimeRotationPhase " + planet.runtimeRotationPhase, ConsoleColor.Green); val2 = planet.runtimeSystemRotation; BCE.Console.WriteLine("RuntimeSystemRotation " + ((object)(Quaternion)(ref val2)).ToString(), ConsoleColor.Green); BCE.Console.WriteLine("SingularityString " + planet.singularityString, ConsoleColor.Green); BCE.Console.WriteLine("Sundistance " + planet.sunDistance, ConsoleColor.Green); BCE.Console.WriteLine("TemperatureBias " + planet.temperatureBias, ConsoleColor.Green); BCE.Console.WriteLine("Theme " + planet.theme, ConsoleColor.Green); BCE.Console.WriteLine("Type " + ((object)(EPlanetType)(ref planet.type)).ToString(), ConsoleColor.Green); val3 = planet.uPosition; BCE.Console.WriteLine("uPosition " + ((object)(VectorLF3)(ref val3)).ToString(), ConsoleColor.Green); val3 = planet.uPositionNext; BCE.Console.WriteLine("uPositionNext " + ((object)(VectorLF3)(ref val3)).ToString(), ConsoleColor.Green); BCE.Console.WriteLine("Wanted " + planet.wanted, ConsoleColor.Green); BCE.Console.WriteLine("WaterHeight " + planet.waterHeight, ConsoleColor.Green); BCE.Console.WriteLine("WaterItemID " + planet.waterItemId, ConsoleColor.Green); BCE.Console.WriteLine("WindStrength " + planet.windStrength, ConsoleColor.Green); BCE.Console.WriteLine("Number " + planet.number, ConsoleColor.Green); BCE.Console.WriteLine("Obliquity " + planet.obliquity, ConsoleColor.Green); BCE.Console.WriteLine("Name " + planet.name, ConsoleColor.Green); BCE.Console.WriteLine("mod_y " + planet.mod_y, ConsoleColor.Green); BCE.Console.WriteLine("mod_x " + planet.mod_x, ConsoleColor.Green); BCE.Console.WriteLine("Luminosity " + planet.luminosity, ConsoleColor.Green); BCE.Console.WriteLine("Levelized " + planet.levelized, ConsoleColor.Green); BCE.Console.WriteLine("Land% " + planet.landPercent, ConsoleColor.Green); BCE.Console.WriteLine("Ion Height " + planet.ionHeight, ConsoleColor.Green); BCE.Console.WriteLine("HabitableBias " + planet.habitableBias, ConsoleColor.Green); BCE.Console.WriteLine("GasTotalHeat " + planet.gasTotalHeat, ConsoleColor.Green); val = planet.birthResourcePoint1; BCE.Console.WriteLine("BirthResourcePoint1 " + ((object)(Vector3)(ref val)).ToString(), ConsoleColor.Green); val = planet.birthResourcePoint0; BCE.Console.WriteLine("BirthResourcePoint0 " + ((object)(Vector3)(ref val)).ToString(), ConsoleColor.Green); val = planet.birthPoint; BCE.Console.WriteLine("BirthPoint " + ((object)(Vector3)(ref val)).ToString(), ConsoleColor.Green); BCE.Console.WriteLine("Algo ID " + planet.algoId, ConsoleColor.Green); BCE.Console.WriteLine("---------------------", ConsoleColor.Red); } public static void SetLuts(int segments, float planetRadius) { if (DSPGame.IsMenuDemo || Vanilla || (keyedLUTs.ContainsKey(segments) && PatchOnUIBuildingGrid.LUT512.ContainsKey(segments))) { return; } if (segments < 4 || planetRadius < 5f) { planetRadius = GameMain.data.localPlanet.realRadius; segments = Mathf.CeilToInt(GameMain.data.localPlanet.radius / 4f + 0.1f) * 4; } int num = segments / 4; int[] array = new int[num]; float num2 = (float)Math.PI / 2f / (float)num; float num3 = planetRadius; int num4 = num * 4; int[] array2 = new int[512]; array2[0] = 1; for (int i = 0; i < num; i++) { float num5 = Mathf.Cos((float)i * num2) * planetRadius; int num6 = Mathf.CeilToInt(Mathf.Abs(Mathf.Cos((float)((double)((float)(i + 1) / ((float)segments / 4f)) * Math.PI * 0.5))) * (float)segments); if ((double)num5 < 0.9 * (double)num3) { num3 = num5; num4 = (int)((double)num5 / 4.0) * 4; } array[i] = num4; if (num6 >= array2.Length) { num6 = array2.Length - 1; } array2[num6] = num4; } int num7 = 1; for (int j = 1; j < 512; j++) { if (array2[j] > num7) { int num8 = array2[j]; array2[j] = num7; num7 = num8; } else { array2[j] = num7; } } if (segments == 200) { array = new int[50] { 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 120, 120, 120, 120, 120, 100, 100, 100, 100, 100, 80, 80, 80, 60, 60, 60, 40, 40, 32, 32, 20, 16, 8, 4 }; array2 = 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, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 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, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 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 }; } if (!keyedLUTs.ContainsKey(segments)) { keyedLUTs.Add(segments, array); } if (!PatchOnUIBuildingGrid.LUT512.ContainsKey(segments)) { PatchOnUIBuildingGrid.LUT512.Add(segments, array2); } } public static void SetPlanetTheme(PlanetData planet, GSPlanet gsPlanet) { //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Invalid comparison between Unknown and I4 int seed = 0; GSTheme gSTheme = GSSettings.ThemeLibrary.Find(gsPlanet.Theme); int num = gSTheme.AddToThemeProtoSet(); if (gsPlanet.Seed > -1) { seed = gsPlanet.Seed; } Random random = new Random(seed); double num2 = random.NextDouble(); double num3 = random.NextDouble(); double num4 = random.NextDouble(); planet.theme = num; ThemeProto val = ((ProtoSet<ThemeProto>)(object)LDB.themes).Select(num); Log(gsPlanet.GsTheme.DisplayName + " " + val.EigenBit + " " + planet.briefString, 29); planet.algoId = gSTheme.Algo; planet.mod_x = (double)gSTheme.ModX.x + num3 * ((double)gSTheme.ModX.y - (double)gSTheme.ModX.x); planet.mod_y = (double)gSTheme.ModY.x + num4 * ((double)gSTheme.ModY.y - (double)gSTheme.ModY.x); planet.type = gSTheme.PlanetType; planet.ionHeight = gSTheme.IonHeight; planet.windStrength = gSTheme.Wind; planet.iceFlag = gSTheme.IceFlag; planet.waterHeight = gSTheme.WaterHeight; planet.waterItemId = gSTheme.WaterItemId; planet.levelized = gSTheme.UseHeightForBuild; if ((int)planet.type == 5) { int num5 = gSTheme.GasItems.Length; int num6 = gSTheme.GasSpeeds.Length; int[] array = new int[num5]; float[] array2 = new float[num6]; float[] array3 = new float[num5]; for (int i = 0; i < num5; i++) { array[i] = gSTheme.GasItems[i]; } double num7 = 0.0; for (int j = 0; j < num6; j++) { float num8 = gSTheme.GasSpeeds[j] * (float)(num2 * 0.190909147262573 + 0.909090876579285); array2[j] = num8 * Mathf.Pow(planet.star.resourceCoef, 0.3f); ItemProto val2 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(array[j]); array3[j] = val2.HeatValue; num7 += (double)array3[j] * (double)array2[j]; } planet.gasItems = array; planet.gasSpeeds = array2; planet.gasHeatValues = array3; planet.gasTotalHeat = num7; } } public static void ConfigureBirthStarHiveSettings(Random random, StarData starData) { starData.hivePatternLevel = 0; starData.safetyFactor = 0.847f + (float)random.NextDouble() * 0.026f; float maxDensity = gameDesc.combatSettings.maxDensity; float initialColonize = gameDesc.combatSettings.initialColonize; Log($"Setting up Birth Star Hive System for {starData.name} Initial Colonize: {initialColonize} MaxDensity: {gameDesc.combatSettings.maxDensity}", 15); starData.maxHiveCount = Mathf.RoundToInt(maxDensity * 4f / 3f); starData.maxHiveCount = Mathf.Clamp(starData.maxHiveCount, 1, 8); starData.initialHiveCount = Mathf.RoundToInt(initialColonize / 2f * ((float)starData.maxHiveCount - 0.2f)); starData.initialHiveCount = Mathf.Clamp(starData.initialHiveCount, 1, starData.maxHiveCount); if (initialColonize < 0.015f) { Log("Preventing Birth System from having a Hive", 24); starData.initialHiveCount = 0; } Log("Birth System (" + starData.name + ") Hive Settings Applied : " + starData.initialHiveCount + " / " + starData.maxHiveCount, 27); } public static void ConfigureStarHiveSettings(Random random, StarData star) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Invalid comparison between Unknown and I4 //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 float initialColonize = gameDesc.combatSettings.initialColonize; float maxDensity = gameDesc.combatSettings.maxDensity; Log("Generating Hive Settings to " + star.name, 34); float level = star.level; bool flag = (int)star.type == 4 || (int)star.type == 3; star.hivePatternLevel = 0; star.safetyFactor = 0.847f + (float)random.NextDouble() * 0.026f; if (flag) { star.safetyFactor = 1f; } star.safetyFactor *= maxDensity / 3f; star.safetyFactor = Mathf.Clamp01(star.safetyFactor); star.maxHiveCount = Mathf.RoundToInt(maxDensity * 4f / 3f); star.maxHiveCount += Mathf.RoundToInt(4f * level); if (flag) { star.maxHiveCount += 2; } if (initialColonize < 0.015f) { star.initialHiveCount = 0; } else { star.initialHiveCount = Mathf.RoundToInt(initialColonize / 2f * ((float)star.maxHiveCount - 0.2f)); star.initialHiveCount += Mathf.RoundToInt(level * 2f); } star.maxHiveCount = Mathf.Clamp(star.maxHiveCount, 0, 8); star.initialHiveCount = Mathf.Clamp(star.initialHiveCount, 0, star.maxHiveCount); } public static void CreateDarkFogHive(StarData star, Random random) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_00ed: 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_0100: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) Log("Generating Hive Orbits For " + star.name, 72); GSStar gSStar = GetGSStar(star); List<float> items = GeneratePossibleHiveOrbits(gSStar); int num = 8; if (gSStar.Decorative || gSStar.PlanetCount == 0) { star.initialHiveCount = 0; star.maxHiveCount = 0; star.hivePatternLevel = 0; } star.hiveAstroOrbits = (AstroOrbitData[])(object)new AstroOrbitData[num]; AstroOrbitData[] hiveAstroOrbits = star.hiveAstroOrbits; for (int i = 0; i < num; i++) { hiveAstroOrbits[i] = new AstroOrbitData(); float orbitRadius = random.ItemAndRemove(items); hiveAstroOrbits[i].orbitRadius = orbitRadius; hiveAstroOrbits[i].orbitInclination = random.NextFloat(); hiveAstroOrbits[i].orbitLongitude = random.NextFloat(); hiveAstroOrbits[i].orbitPhase = random.NextFloat(); hiveAstroOrbits[i].orbitalPeriod = Utils.CalculateOrbitPeriod(hiveAstroOrbits[i].orbitRadius); hiveAstroOrbits[i].orbitRotation = Quaternion.AngleAxis(hiveAstroOrbits[i].orbitLongitude, Vector3.up) * Quaternion.AngleAxis(hiveAstroOrbits[i].orbitInclination, Vector3.forward); AstroOrbitData obj = hiveAstroOrbits[i]; VectorLF3 val = Maths.QRotateLF(hiveAstroOrbits[i].orbitRotation, new VectorLF3(0f, 1f, 0f)); obj.orbitNormal = ((VectorLF3)(ref val)).normalized; } } public static List<float> GeneratePossibleHiveOrbits(GSStar gsStar, int count = 10, Random random = null) { if (gsStar.PlanetCount == 0 || gsStar.Decorative) { return new List<float> { 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f }; } List<(float, float)> list = new List<(float, float)>(); List<(float, float)> list2 = new List<(float, float)>(); List<float> list3 = new List<float>(); float num = gsStar.SystemRadius; if (random == null) { random = new Random(Mathf.CeilToInt(gsStar.luminosity * gsStar.age * gsStar.SystemRadius)); } foreach (GSPlanet planet in gsStar.Planets) { list.Add((planet.OrbitRadius - planet.SystemRadius, planet.OrbitRadius + planet.SystemRadius)); } if (list[0].Item1 > gsStar.RadiusAU + 0.1f) { list2.Add((gsStar.RadiusAU + 0.1f, list[0].Item1)); } for (int i = 0; i < list.Count - 1; i++) { list2.Add((list[i].Item2, list[i + 1].Item1)); } if (list[list.Count - 1].Item2 < num) { list2.Add((list[list.Count - 1].Item2, num)); } for (int j = 0; j < count - 1; j++) { if (list2.Count == 0) { float item = num; num += 5f; list2.Add((item, num)); } (float, float) item2 = random.Item(list2); float num2 = random.ClampedNormal(item2.Item1, item2.Item2, 50); list3.Add(num2); list2.Remove(item2); (float, float) item3 = (item2.Item1, num2 - 0.05f); (float, float) item4 = (num2 + 0.05f, item2.Item2); if (item3.Item2 - item3.Item1 > 0.1f) { list2.Add(item3); } if (item4.Item2 - item4.Item1 > 0.1f) { list2.Add(item4); } } return list3; } public static StarData CreateStar(int index, Random random) { return CreateStar(galaxy, index + 1, random); } public static StarData CreateStar(GalaxyData galaxy, int id, Random random) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_00b1: 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_00bd: 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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_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) StarData val = new StarData(); int num = id - 1; GSStar gSStar = GSSettings.Stars[num]; gSStar.assignedIndex = num; if (gSStar.Seed < 0) { gSStar.Seed = random.Next(); } if (!gsStars.ContainsKey(id)) { gsStars.Add(id, gSStar); } else { gsStars[id] = gSStar; } val.galaxy = galaxy; val.index = num; val.level = ((galaxy.starCount > 1) ? ((float)val.index / (float)(galaxy.starCount - 1)) : 0f); val.id = id; val.seed = gSStar.Seed; val.position = gSStar.position; val.uPosition = val.position * 2400000.0; val.planetCount = gSStar.bodyCount; val.resourceCoef = gSStar.resourceCoef; val.name = gSStar.Name; val.overrideName = string.Empty; val.mass = gSStar.mass; val.age = gSStar.age; val.lifetime = gSStar.lifetime; val.temperature = gSStar.temperature; val.luminosity = gSStar.luminosity; val.color = gSStar.color; val.classFactor = gSStar.classFactor; val.radius = gSStar.radius; val.acdiskRadius = gSStar.acDiscRadius; val.habitableRadius = gSStar.habitableRadius; val.lightBalanceRadius = gSStar.lightBalanceRadius; val.orbitScaler = gSStar.orbitScaler; val.dysonRadius = gSStar.dysonRadius; val.type = gSStar.Type; val.spectr = gSStar.Spectr; if (gSStar == GSSettings.BirthStar) { galaxy.birthStarId = val.id; ConfigureBirthStarHiveSettings(random, val); } else { ConfigureStarHiveSettings(random, val); } return val; } public static void CreateStarPlanets(ref StarData star, GameDesc gameDesc, Random random) { GSStar gSStar = GSSettings.Stars[star.index]; gSStar.counter = 0; while (gSStar.bodyCount > 99) { Log($"Truncating planets for star {star.name} as it has {gSStar.bodyCount}", 15); gSStar.Planets.RemoveAt(gSStar.Planets.Count - 1); Warn($"New BodyCount = {gSStar.bodyCount}, existing planetCount was {star.planetCount}", 17); star.planetCount = gSStar.bodyCount; } star.planets = (PlanetData[])(object)new PlanetData[Math.Min(100, gSStar.bodyCount)]; for (int i = 0; i < gSStar.PlanetCount; i++) { CreatePlanet(ref star, gSStar.Planets[i], random); } star.planetCount = star.planets.Length; CreateDarkFogHive(star, random); } public static bool AbortGameStart(string message) { //IL_0070: 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_007b: Expected O, but got Unknown Error("Aborting Game Start|" + message, 7); Failed = true; UIRoot.instance.CloseLoadingUI(); UIRoot.instance.CloseGameUI(); UIRoot.instance.launchSplash.Restart(); DSPGame.StartDemoGame(0); string text = "Cannot Start Game. Possibly reason: " + message; object obj = <>c.<>9__116_0; if (obj == null) { Response val = delegate { UIRoot.instance.OpenMainMenuUI(); UIRoot.ClearFatalError(); }; <>c.<>9__116_0 = val; obj = (object)val; } UIMessageBox.Show("Somewhat Fatal Error", text, "Rats!", 3, (Response)obj); UIRoot.ClearFatalError(); return false; } public static void EndGame() { GameMain.End(); } public static bool IsPlanetOfStar(GSStar star, GSPlanet planet) { foreach (GSPlanet planet2 in star.Planets) { if (planet == planet2) { return true; } } return false; } public static bool IsMoonOfPlanet(GSPlanet planet, GSPlanet moon) { foreach (GSPlanet moon2 in planet.Moons) { if (moon == moon2) { return true; } } return false; } public static bool IsMoonOfPlanet(GSPlanet planet, GSPlanet moon, bool deep) { if (!deep) { return IsMoonOfPlanet(planet, moon); } foreach (GSPlanet moon2 in planet.Moons) { if (moon == moon2) { return true; } if (IsMoonOfPlanet(moon2, moon, deep: true)) { return true; } } return false; } public static GSStar GetBinaryStarHost(GSStar star) { if (star.Decorative) { foreach (GSStar star2 in GSSettings.Stars) { if (star2.BinaryCompanion == star.Name) { return star2; } } } return null; } public static GSStar GetGSStar(StarData star) { return GetGSStar(star.id); } public static GSStar GetGSStar(int id) { GSStar result = null; if (gsStars.ContainsKey(id)) { result = gsStars[id]; } return result; } public static GSStar GetGSStar(string name) { foreach (KeyValuePair<int, GSStar> gsStar in gsStars) { GSStar value = gsStar.Value; if (value.Name == name) { return value; } } Error("Star not found", 68); return null; } public static GSPlanet GetGSPlanet(PlanetData planet) { return GetGSPlanet(planet.id); } public static GSPlanet GetGSPlanet(string name) { foreach (KeyValuePair<int, GSPlanet> gsPlanet in gsPlanets) { GSPlanet value = gsPlanet.Value; if (value.Name == name) { return value; } } Error("Planet not found", 87); return null; } public static GSPlanet GetGSPlanet(int vanillaID) { if (vanillaID < 0) { Warn("Failed to get GSPlanet. ID less than 0. ID:" + vanillaID, 96); return null; } if (!gsPlanets.ContainsKey(vanillaID)) { Warn("Failed to get GSPlanet. ID does not exist. ID:" + vanillaID + GetCaller(), 103); return null; } if (gsPlanets[vanillaID] == null) { Warn("Failed to get GSPlanet. ID exists, but GSPlanet is null. ID:" + vanillaID, 110); return null; } return gsPlanets[vanillaID]; } public static GSStar GetGSStar(GSPlanet planet) { if (planet.planetData != null) { return GetGSStar(planet.planetData.star); } for (int i = 0; i < GSSettings.StarCount; i++) { for (int j = 0; j < GSSettings.Stars[i].Bodies.Count; j++) { if (GSSettings.Stars[i].Bodies[j] == planet) { return GSSettings.Stars[i]; } } } Error("Failed to get GSStar. Could not find planet in GSSettings.Stars", 124); return null; } } [BepInPlugin("dsp.galactic-scale.2", "Galactic Scale 2 Plug-In", "2.76.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Bootstrap : BaseUnityPlugin { [CompilerGenerated] private sealed class <>c__DisplayClass10_0 { public TestFunction t; internal bool <WaitUntilRoutine>b__0() { return t(); } } [CompilerGenerated] private sealed class <WaitUntilRoutine>d__10 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public TestFunction t; public TestThen u; private <>c__DisplayClass10_0 <>8__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitUntilRoutine>d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] vo
GSUI.dll
Decompiled 3 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using UnityEngine.EventSystems; using UnityEngine.Events; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.0")] namespace UnityEngine.UI.Extensions; [AddComponentMenu("UI/Extensions/Range Slider", 34)] [ExecuteInEditMode] [RequireComponent(typeof(RectTransform))] public class RangeSlider : Selectable, IDragHandler, IEventSystemHandler, IInitializePotentialDragHandler, ICanvasElement { [Serializable] public class RangeSliderEvent : UnityEvent<float, float> { } private enum InteractionState { Low, High, Bar, None } [SerializeField] private RectTransform m_FillRect; [SerializeField] private RectTransform m_LowHandleRect; [SerializeField] private RectTransform m_HighHandleRect; [Space] [SerializeField] private float m_MinValue = 0f; [SerializeField] private float m_MaxValue = 1f; [SerializeField] private bool m_WholeNumbers = false; [SerializeField] private float m_LowValue; [SerializeField] private float m_HighValue; [Space] [SerializeField] private RangeSliderEvent m_OnValueChanged = new RangeSliderEvent(); private InteractionState interactionState = InteractionState.None; private Image m_FillImage; private Transform m_FillTransform; private RectTransform m_FillContainerRect; private Transform m_HighHandleTransform; private RectTransform m_HighHandleContainerRect; private Transform m_LowHandleTransform; private RectTransform m_LowHandleContainerRect; private Vector2 m_LowOffset = Vector2.zero; private Vector2 m_HighOffset = Vector2.zero; private DrivenRectTransformTracker m_Tracker; private bool m_DelayedUpdateVisuals = false; public RectTransform FillRect { get { return m_FillRect; } set { if (SetClass(ref m_FillRect, value)) { UpdateCachedReferences(); UpdateVisuals(); } } } public RectTransform LowHandleRect { get { return m_LowHandleRect; } set { if (SetClass(ref m_LowHandleRect, value)) { UpdateCachedReferences(); UpdateVisuals(); } } } public RectTransform HighHandleRect { get { return m_HighHandleRect; } set { if (SetClass(ref m_HighHandleRect, value)) { UpdateCachedReferences(); UpdateVisuals(); } } } public float MinValue { get { return m_MinValue; } set { if (SetStruct(ref m_MinValue, value)) { SetLow(m_LowValue); SetHigh(m_HighValue); UpdateVisuals(); } } } public float MaxValue { get { return m_MaxValue; } set { if (SetStruct(ref m_MaxValue, value)) { SetLow(m_LowValue); SetHigh(m_HighValue); UpdateVisuals(); } } } public bool WholeNumbers { get { return m_WholeNumbers; } set { if (SetStruct(ref m_WholeNumbers, value)) { SetLow(m_LowValue); SetHigh(m_HighValue); UpdateVisuals(); } } } public virtual float LowValue { get { if (WholeNumbers) { return Mathf.Round(m_LowValue); } return m_LowValue; } set { SetLow(value); } } public float NormalizedLowValue { get { if (Mathf.Approximately(MinValue, MaxValue)) { return 0f; } return Mathf.InverseLerp(MinValue, MaxValue, LowValue); } set { LowValue = Mathf.Lerp(MinValue, MaxValue, value); } } public virtual float HighValue { get { if (WholeNumbers) { return Mathf.Round(m_HighValue); } return m_HighValue; } set { SetHigh(value); } } public float NormalizedHighValue { get { if (Mathf.Approximately(MinValue, MaxValue)) { return 0f; } return Mathf.InverseLerp(MinValue, MaxValue, HighValue); } set { HighValue = Mathf.Lerp(MinValue, MaxValue, value); } } public RangeSliderEvent OnValueChanged { get { return m_OnValueChanged; } set { m_OnValueChanged = value; } } private float StepSize => WholeNumbers ? 1f : ((MaxValue - MinValue) * 0.1f); public virtual void SetValueWithoutNotify(float low, float high) { SetLow(low, sendCallback: false); SetHigh(high, sendCallback: false); } protected RangeSlider() { }//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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) public virtual void Rebuild(CanvasUpdate executing) { } public virtual void LayoutComplete() { } public virtual void GraphicUpdateComplete() { } public static bool SetClass<T>(ref T currentValue, T newValue) where T : class { if ((currentValue == null && newValue == null) || (currentValue != null && currentValue.Equals(newValue))) { return false; } currentValue = newValue; return true; } public static bool SetStruct<T>(ref T currentValue, T newValue) where T : struct { if (currentValue.Equals(newValue)) { return false; } currentValue = newValue; return true; } protected override void OnEnable() { ((Selectable)this).OnEnable(); UpdateCachedReferences(); SetLow(LowValue, sendCallback: false); SetHigh(HighValue, sendCallback: false); UpdateVisuals(); } protected override void OnDisable() { ((DrivenRectTransformTracker)(ref m_Tracker)).Clear(); ((Selectable)this).OnDisable(); } protected virtual void Update() { if (m_DelayedUpdateVisuals) { m_DelayedUpdateVisuals = false; UpdateVisuals(); } } protected override void OnDidApplyAnimationProperties() { ((Selectable)this).OnDidApplyAnimationProperties(); } private void UpdateCachedReferences() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)m_FillRect) && (Object)(object)m_FillRect != (Object)(RectTransform)((Component)this).transform) { m_FillTransform = ((Component)m_FillRect).transform; m_FillImage = ((Component)m_FillRect).GetComponent<Image>(); if ((Object)(object)m_FillTransform.parent != (Object)null) { m_FillContainerRect = ((Component)m_FillTransform.parent).GetComponent<RectTransform>(); } } else { m_FillRect = null; m_FillContainerRect = null; m_FillImage = null; } if (Object.op_Implicit((Object)(object)m_HighHandleRect) && (Object)(object)m_HighHandleRect != (Object)(RectTransform)((Component)this).transform) { m_HighHandleTransform = ((Component)m_HighHandleRect).transform; if ((Object)(object)m_HighHandleTransform.parent != (Object)null) { m_HighHandleContainerRect = ((Component)m_HighHandleTransform.parent).GetComponent<RectTransform>(); } } else { m_HighHandleRect = null; m_HighHandleContainerRect = null; } if (Object.op_Implicit((Object)(object)m_LowHandleRect) && (Object)(object)m_LowHandleRect != (Object)(RectTransform)((Component)this).transform) { m_LowHandleTransform = ((Component)m_LowHandleRect).transform; if ((Object)(object)m_LowHandleTransform.parent != (Object)null) { m_LowHandleContainerRect = ((Component)m_LowHandleTransform.parent).GetComponent<RectTransform>(); } } else { m_LowHandleRect = null; m_LowHandleContainerRect = null; } } private void SetLow(float input) { SetLow(input, sendCallback: true); } protected virtual void SetLow(float input, bool sendCallback) { float num = Mathf.Clamp(input, MinValue, HighValue); if (WholeNumbers) { num = Mathf.Round(num); } if (m_LowValue != num) { m_LowValue = num; UpdateVisuals(); if (sendCallback) { UISystemProfilerApi.AddMarker("RangeSlider.lowValue", (Object)(object)this); ((UnityEvent<float, float>)m_OnValueChanged).Invoke(num, HighValue); } } } private void SetHigh(float input) { SetHigh(input, sendCallback: true); } protected virtual void SetHigh(float input, bool sendCallback) { float num = Mathf.Clamp(input, LowValue, MaxValue); if (WholeNumbers) { num = Mathf.Round(num); } if (m_HighValue != num) { m_HighValue = num; UpdateVisuals(); if (sendCallback) { UISystemProfilerApi.AddMarker("RangeSlider.highValue", (Object)(object)this); ((UnityEvent<float, float>)m_OnValueChanged).Invoke(LowValue, num); } } } protected override void OnRectTransformDimensionsChange() { ((UIBehaviour)this).OnRectTransformDimensionsChange(); if (((UIBehaviour)this).IsActive()) { UpdateVisuals(); } } private void UpdateVisuals() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) ((DrivenRectTransformTracker)(ref m_Tracker)).Clear(); if ((Object)(object)m_FillContainerRect != (Object)null) { ((DrivenRectTransformTracker)(ref m_Tracker)).Add((Object)(object)this, m_FillRect, (DrivenTransformProperties)3840); Vector2 zero = Vector2.zero; Vector2 one = Vector2.one; ((Vector2)(ref zero))[0] = NormalizedLowValue; ((Vector2)(ref one))[0] = NormalizedHighValue; m_FillRect.anchorMin = zero; m_FillRect.anchorMax = one; } if ((Object)(object)m_LowHandleContainerRect != (Object)null) { ((DrivenRectTransformTracker)(ref m_Tracker)).Add((Object)(object)this, m_LowHandleRect, (DrivenTransformProperties)3840); Vector2 zero2 = Vector2.zero; Vector2 one2 = Vector2.one; float num = (((Vector2)(ref one2))[0] = NormalizedLowValue); ((Vector2)(ref zero2))[0] = num; m_LowHandleRect.anchorMin = zero2; m_LowHandleRect.anchorMax = one2; } if ((Object)(object)m_HighHandleContainerRect != (Object)null) { ((DrivenRectTransformTracker)(ref m_Tracker)).Add((Object)(object)this, m_HighHandleRect, (DrivenTransformProperties)3840); Vector2 zero3 = Vector2.zero; Vector2 one3 = Vector2.one; float num = (((Vector2)(ref one3))[0] = NormalizedHighValue); ((Vector2)(ref zero3))[0] = num; m_HighHandleRect.anchorMin = zero3; m_HighHandleRect.anchorMax = one3; } } private void UpdateDrag(PointerEventData eventData, Camera cam) { //IL_002d: 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) switch (interactionState) { case InteractionState.Low: NormalizedLowValue = CalculateDrag(eventData, cam, m_LowHandleContainerRect, m_LowOffset); break; case InteractionState.High: NormalizedHighValue = CalculateDrag(eventData, cam, m_HighHandleContainerRect, m_HighOffset); break; case InteractionState.Bar: CalculateBarDrag(eventData, cam); break; case InteractionState.None: break; } } private float CalculateDrag(PointerEventData eventData, Camera cam, RectTransform containerRect, Vector2 offset) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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) //IL_0090: 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) RectTransform val = containerRect ?? m_FillContainerRect; if ((Object)(object)val != (Object)null) { Rect rect = val.rect; Vector2 val2 = ((Rect)(ref rect)).size; if (((Vector2)(ref val2))[0] > 0f) { Vector2 val3 = default(Vector2); if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(val, eventData.position, cam, ref val3)) { return 0f; } Vector2 val4 = val3; rect = val.rect; val3 = val4 - ((Rect)(ref rect)).position; val2 = val3 - offset; float num = ((Vector2)(ref val2))[0]; rect = val.rect; val2 = ((Rect)(ref rect)).size; return Mathf.Clamp01(num / ((Vector2)(ref val2))[0]); } } return 0f; } private void CalculateBarDrag(PointerEventData eventData, Camera cam) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_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_003c: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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) RectTransform fillContainerRect = m_FillContainerRect; if (!((Object)(object)fillContainerRect != (Object)null)) { return; } Rect rect = fillContainerRect.rect; Vector2 size = ((Rect)(ref rect)).size; Vector2 val = default(Vector2); if (!(((Vector2)(ref size))[0] > 0f) || !RectTransformUtility.ScreenPointToLocalPointInRectangle(fillContainerRect, eventData.position, cam, ref val)) { return; } Vector2 val2 = val; rect = fillContainerRect.rect; val = val2 - ((Rect)(ref rect)).position; if (NormalizedLowValue >= 0f && NormalizedHighValue <= 1f) { float num = (NormalizedHighValue + NormalizedLowValue) / 2f; float num2 = ((Vector2)(ref val))[0]; rect = fillContainerRect.rect; size = ((Rect)(ref rect)).size; float num3 = Mathf.Clamp01(num2 / ((Vector2)(ref size))[0]); float num4 = num3 - num; if (NormalizedLowValue + num4 < 0f) { num4 = 0f - NormalizedLowValue; } else if (NormalizedHighValue + num4 > 1f) { num4 = 1f - NormalizedHighValue; } NormalizedLowValue += num4; NormalizedHighValue += num4; } } private bool MayDrag(PointerEventData eventData) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 return ((UIBehaviour)this).IsActive() && ((Selectable)this).IsInteractable() && (int)eventData.button == 0; } public override void OnPointerDown(PointerEventData eventData) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_008b: Invalid comparison between Unknown and I4 //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_0141: 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_00e3: 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) //IL_0175: Invalid comparison between Unknown and I4 //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Invalid comparison between Unknown and I4 //IL_00fd: 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) if (!MayDrag(eventData)) { return; } m_LowOffset = (m_HighOffset = Vector2.zero); Vector2 val = default(Vector2); if ((Object)(object)m_HighHandleRect != (Object)null && RectTransformUtility.RectangleContainsScreenPoint(m_HighHandleRect, eventData.position, eventData.enterEventCamera)) { if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_HighHandleRect, eventData.position, eventData.pressEventCamera, ref val)) { m_HighOffset = val; } interactionState = InteractionState.High; if ((int)((Selectable)this).transition == 1) { ((Selectable)this).targetGraphic = ((Component)m_HighHandleRect).GetComponent<Graphic>(); } } else if ((Object)(object)m_LowHandleRect != (Object)null && RectTransformUtility.RectangleContainsScreenPoint(m_LowHandleRect, eventData.position, eventData.enterEventCamera)) { if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_LowHandleRect, eventData.position, eventData.pressEventCamera, ref val)) { m_LowOffset = val; } interactionState = InteractionState.Low; if ((int)((Selectable)this).transition == 1) { ((Selectable)this).targetGraphic = ((Component)m_LowHandleRect).GetComponent<Graphic>(); } } else { UpdateDrag(eventData, eventData.pressEventCamera); RaycastResult pointerCurrentRaycast = eventData.pointerCurrentRaycast; if ((Object)(object)((RaycastResult)(ref pointerCurrentRaycast)).gameObject == (Object)(object)((Component)m_FillRect).gameObject) { interactionState = InteractionState.Bar; } if ((int)((Selectable)this).transition == 1) { ((Selectable)this).targetGraphic = (Graphic)(object)m_FillImage; } } ((Selectable)this).OnPointerDown(eventData); } public virtual void OnDrag(PointerEventData eventData) { if (MayDrag(eventData)) { UpdateDrag(eventData, eventData.pressEventCamera); } } public override void OnPointerUp(PointerEventData eventData) { ((Selectable)this).OnPointerUp(eventData); interactionState = InteractionState.None; } public override void OnMove(AxisEventData eventData) { } public virtual void OnInitializePotentialDrag(PointerEventData eventData) { eventData.useDragThreshold = false; } Transform ICanvasElement.get_transform() { return ((Component)this).transform; } } internal static class SetPropertyUtility { public static bool SetColor(ref Color currentValue, Color newValue) { //IL_0007: 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_0023: 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_0046: 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) if (currentValue.r == newValue.r && currentValue.g == newValue.g && currentValue.b == newValue.b && currentValue.a == newValue.a) { return false; } currentValue = newValue; return true; } public static bool SetStruct<T>(ref T currentValue, T newValue) where T : struct { if (currentValue.Equals(newValue)) { return false; } currentValue = newValue; return true; } public static bool SetClass<T>(ref T currentValue, T newValue) where T : class { if ((currentValue == null && newValue == null) || (currentValue != null && currentValue.Equals(newValue))) { return false; } currentValue = newValue; return true; } } [AddComponentMenu("UI/Extensions/Primitives/Cut Corners")] public class UICornerCut : UIPrimitiveBase { public Vector2 cornerSize = new Vector2(16f, 16f); [Header("Corners to cut")] [SerializeField] private bool m_cutUL = true; [SerializeField] private bool m_cutUR; [SerializeField] private bool m_cutLL; [SerializeField] private bool m_cutLR; [Tooltip("Up-Down colors become Left-Right colors")] [SerializeField] private bool m_makeColumns; [Header("Color the cut bars differently")] [SerializeField] private bool m_useColorUp; [SerializeField] private Color32 m_colorUp; [SerializeField] private bool m_useColorDown; [SerializeField] private Color32 m_colorDown; public bool CutUL { get { return m_cutUL; } set { m_cutUL = value; ((Graphic)this).SetAllDirty(); } } public bool CutUR { get { return m_cutUR; } set { m_cutUR = value; ((Graphic)this).SetAllDirty(); } } public bool CutLL { get { return m_cutLL; } set { m_cutLL = value; ((Graphic)this).SetAllDirty(); } } public bool CutLR { get { return m_cutLR; } set { m_cutLR = value; ((Graphic)this).SetAllDirty(); } } public bool MakeColumns { get { return m_makeColumns; } set { m_makeColumns = value; ((Graphic)this).SetAllDirty(); } } public bool UseColorUp { get { return m_useColorUp; } set { m_useColorUp = value; } } public Color32 ColorUp { get { //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_000a: Unknown result type (might be due to invalid IL or missing references) return m_colorUp; } set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) m_colorUp = value; } } public bool UseColorDown { get { return m_useColorDown; } set { m_useColorDown = value; } } public Color32 ColorDown { get { //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_000a: Unknown result type (might be due to invalid IL or missing references) return m_colorDown; } set { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) m_colorDown = value; } } protected override void OnPopulateMesh(VertexHelper vh) { //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_000e: 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_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_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: 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_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0366: 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_0325: 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_020a: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: 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_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_023f: 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_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) Rect rect = ((Graphic)this).rectTransform.rect; Rect val = rect; Color32 val2 = Color32.op_Implicit(((Graphic)this).color); bool flag = m_cutUL | m_cutUR; bool flag2 = m_cutLL | m_cutLR; bool flag3 = m_cutLL | m_cutUL; bool flag4 = m_cutLR | m_cutUR; if (!(flag || flag2) || !(((Vector2)(ref cornerSize)).sqrMagnitude > 0f)) { return; } vh.Clear(); if (flag3) { ((Rect)(ref val)).xMin = ((Rect)(ref val)).xMin + cornerSize.x; } if (flag2) { ((Rect)(ref val)).yMin = ((Rect)(ref val)).yMin + cornerSize.y; } if (flag) { ((Rect)(ref val)).yMax = ((Rect)(ref val)).yMax - cornerSize.y; } if (flag4) { ((Rect)(ref val)).xMax = ((Rect)(ref val)).xMax - cornerSize.x; } Vector2 val3 = default(Vector2); Vector2 val4 = default(Vector2); Vector2 val5 = default(Vector2); Vector2 val6 = default(Vector2); if (m_makeColumns) { ((Vector2)(ref val3))..ctor(((Rect)(ref rect)).xMin, m_cutUL ? ((Rect)(ref val)).yMax : ((Rect)(ref rect)).yMax); ((Vector2)(ref val4))..ctor(((Rect)(ref rect)).xMax, m_cutUR ? ((Rect)(ref val)).yMax : ((Rect)(ref rect)).yMax); ((Vector2)(ref val5))..ctor(((Rect)(ref rect)).xMin, m_cutLL ? ((Rect)(ref val)).yMin : ((Rect)(ref rect)).yMin); ((Vector2)(ref val6))..ctor(((Rect)(ref rect)).xMax, m_cutLR ? ((Rect)(ref val)).yMin : ((Rect)(ref rect)).yMin); if (flag3) { AddSquare(val5, val3, new Vector2(((Rect)(ref val)).xMin, ((Rect)(ref rect)).yMax), new Vector2(((Rect)(ref val)).xMin, ((Rect)(ref rect)).yMin), rect, m_useColorUp ? m_colorUp : val2, vh); } if (flag4) { AddSquare(val4, val6, new Vector2(((Rect)(ref val)).xMax, ((Rect)(ref rect)).yMin), new Vector2(((Rect)(ref val)).xMax, ((Rect)(ref rect)).yMax), rect, m_useColorDown ? m_colorDown : val2, vh); } } else { ((Vector2)(ref val3))..ctor(m_cutUL ? ((Rect)(ref val)).xMin : ((Rect)(ref rect)).xMin, ((Rect)(ref rect)).yMax); ((Vector2)(ref val4))..ctor(m_cutUR ? ((Rect)(ref val)).xMax : ((Rect)(ref rect)).xMax, ((Rect)(ref rect)).yMax); ((Vector2)(ref val5))..ctor(m_cutLL ? ((Rect)(ref val)).xMin : ((Rect)(ref rect)).xMin, ((Rect)(ref rect)).yMin); ((Vector2)(ref val6))..ctor(m_cutLR ? ((Rect)(ref val)).xMax : ((Rect)(ref rect)).xMax, ((Rect)(ref rect)).yMin); if (flag2) { AddSquare(val6, val5, new Vector2(((Rect)(ref rect)).xMin, ((Rect)(ref val)).yMin), new Vector2(((Rect)(ref rect)).xMax, ((Rect)(ref val)).yMin), rect, m_useColorDown ? m_colorDown : val2, vh); } if (flag) { AddSquare(val3, val4, new Vector2(((Rect)(ref rect)).xMax, ((Rect)(ref val)).yMax), new Vector2(((Rect)(ref rect)).xMin, ((Rect)(ref val)).yMax), rect, m_useColorUp ? m_colorUp : val2, vh); } } if (m_makeColumns) { AddSquare(new Rect(((Rect)(ref val)).xMin, ((Rect)(ref rect)).yMin, ((Rect)(ref val)).width, ((Rect)(ref rect)).height), rect, val2, vh); } else { AddSquare(new Rect(((Rect)(ref rect)).xMin, ((Rect)(ref val)).yMin, ((Rect)(ref rect)).width, ((Rect)(ref val)).height), rect, val2, vh); } } private static void AddSquare(Rect rect, Rect rectUV, Color32 color32, VertexHelper vh) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0054: 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) int num = AddVert(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).yMin, rectUV, color32, vh); int num2 = AddVert(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).yMax, rectUV, color32, vh); int num3 = AddVert(((Rect)(ref rect)).xMax, ((Rect)(ref rect)).yMax, rectUV, color32, vh); int num4 = AddVert(((Rect)(ref rect)).xMax, ((Rect)(ref rect)).yMin, rectUV, color32, vh); vh.AddTriangle(num, num2, num3); vh.AddTriangle(num3, num4, num); } private static void AddSquare(Vector2 a, Vector2 b, Vector2 c, Vector2 d, Rect rectUV, Color32 color32, VertexHelper vh) { //IL_0001: 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_000d: 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) //IL_0019: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0055: 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) int num = AddVert(a.x, a.y, rectUV, color32, vh); int num2 = AddVert(b.x, b.y, rectUV, color32, vh); int num3 = AddVert(c.x, c.y, rectUV, color32, vh); int num4 = AddVert(d.x, d.y, rectUV, color32, vh); vh.AddTriangle(num, num2, num3); vh.AddTriangle(num3, num4, num); } private static int AddVert(float x, float y, Rect area, Color32 color32, VertexHelper vh) { //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_003a: 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) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(Mathf.InverseLerp(((Rect)(ref area)).xMin, ((Rect)(ref area)).xMax, x), Mathf.InverseLerp(((Rect)(ref area)).yMin, ((Rect)(ref area)).yMax, y)); vh.AddVert(new Vector3(x, y), color32, Vector4.op_Implicit(val)); return vh.currentVertCount - 1; } } public enum ResolutionMode { None, PerSegment, PerLine } [RequireComponent(typeof(CanvasRenderer))] public class UIPrimitiveBase : MaskableGraphic, ILayoutElement, ICanvasRaycastFilter { protected static Material s_ETC1DefaultUI; private List<Vector2> outputList = new List<Vector2>(); [SerializeField] private Sprite m_Sprite; [NonSerialized] private Sprite m_OverrideSprite; internal float m_EventAlphaThreshold = 1f; [SerializeField] private ResolutionMode m_improveResolution; [SerializeField] protected float m_Resolution; [SerializeField] private bool m_useNativeSize; public Sprite sprite { get { return m_Sprite; } set { if (SetPropertyUtility.SetClass(ref m_Sprite, value)) { GeneratedUVs(); } ((Graphic)this).SetAllDirty(); } } public Sprite overrideSprite { get { return activeSprite; } set { if (SetPropertyUtility.SetClass(ref m_OverrideSprite, value)) { GeneratedUVs(); } ((Graphic)this).SetAllDirty(); } } protected Sprite activeSprite => ((Object)(object)m_OverrideSprite != (Object)null) ? m_OverrideSprite : sprite; public float eventAlphaThreshold { get { return m_EventAlphaThreshold; } set { m_EventAlphaThreshold = value; } } public ResolutionMode ImproveResolution { get { return m_improveResolution; } set { m_improveResolution = value; ((Graphic)this).SetAllDirty(); } } public float Resolution { get { return m_Resolution; } set { m_Resolution = value; ((Graphic)this).SetAllDirty(); } } public bool UseNativeSize { get { return m_useNativeSize; } set { m_useNativeSize = value; ((Graphic)this).SetAllDirty(); } } public static Material defaultETC1GraphicMaterial { get { if ((Object)(object)s_ETC1DefaultUI == (Object)null) { s_ETC1DefaultUI = Canvas.GetETC1SupportedCanvasMaterial(); } return s_ETC1DefaultUI; } } public override Texture mainTexture { get { if ((Object)(object)activeSprite == (Object)null) { if ((Object)(object)((Graphic)this).material != (Object)null && (Object)(object)((Graphic)this).material.mainTexture != (Object)null) { return ((Graphic)this).material.mainTexture; } return (Texture)(object)Graphic.s_WhiteTexture; } return (Texture)(object)activeSprite.texture; } } public bool hasBorder { get { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)activeSprite != (Object)null) { Vector4 border = activeSprite.border; return ((Vector4)(ref border)).sqrMagnitude > 0f; } return false; } } public float pixelsPerUnit { get { float num = 100f; if (Object.op_Implicit((Object)(object)activeSprite)) { num = activeSprite.pixelsPerUnit; } float num2 = 100f; if (Object.op_Implicit((Object)(object)((Graphic)this).canvas)) { num2 = ((Graphic)this).canvas.referencePixelsPerUnit; } return num / num2; } } public override Material material { get { if ((Object)(object)((Graphic)this).m_Material != (Object)null) { return ((Graphic)this).m_Material; } if (Object.op_Implicit((Object)(object)activeSprite) && (Object)(object)activeSprite.associatedAlphaSplitTexture != (Object)null) { return defaultETC1GraphicMaterial; } return ((Graphic)this).defaultMaterial; } set { ((Graphic)this).material = value; } } public virtual float minWidth => 0f; public virtual float preferredWidth { get { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)overrideSprite == (Object)null) { return 0f; } Rect rect = overrideSprite.rect; return ((Rect)(ref rect)).size.x / pixelsPerUnit; } } public virtual float flexibleWidth => -1f; public virtual float minHeight => 0f; public virtual float preferredHeight { get { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)overrideSprite == (Object)null) { return 0f; } Rect rect = overrideSprite.rect; return ((Rect)(ref rect)).size.y / pixelsPerUnit; } } public virtual float flexibleHeight => -1f; public virtual int layoutPriority => 0; protected UIPrimitiveBase() { ((Graphic)this).useLegacyMeshGeneration = false; } protected UIVertex[] SetVbo(Vector2[] vertices, Vector2[] uvs) { //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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_004e: Unknown result type (might be due to invalid IL or missing references) UIVertex[] array = (UIVertex[])(object)new UIVertex[4]; for (int i = 0; i < vertices.Length; i++) { UIVertex simpleVert = UIVertex.simpleVert; simpleVert.color = Color32.op_Implicit(((Graphic)this).color); simpleVert.position = Vector2.op_Implicit(vertices[i]); simpleVert.uv0 = Vector4.op_Implicit(uvs[i]); array[i] = simpleVert; } return array; } protected Vector2[] IncreaseResolution(Vector2[] input) { return IncreaseResolution(new List<Vector2>(input)).ToArray(); } protected List<Vector2> IncreaseResolution(List<Vector2> input) { //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_0147: 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_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0188: 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) //IL_0190: 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_0040: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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) //IL_0105: Unknown result type (might be due to invalid IL or missing references) outputList.Clear(); switch (ImproveResolution) { case ResolutionMode.PerLine: { float num3 = 0f; float num = 0f; for (int j = 0; j < input.Count - 1; j++) { num3 += Vector2.Distance(input[j], input[j + 1]); } ResolutionToNativeSize(num3); num = num3 / m_Resolution; int num4 = 0; for (int k = 0; k < input.Count - 1; k++) { Vector2 val3 = input[k]; outputList.Add(val3); Vector2 val4 = input[k + 1]; float num5 = Vector2.Distance(val3, val4) / num; float num6 = 1f / num5; for (int l = 0; (float)l < num5; l++) { outputList.Add(Vector2.Lerp(val3, val4, (float)l * num6)); num4++; } outputList.Add(val4); } break; } case ResolutionMode.PerSegment: { for (int i = 0; i < input.Count - 1; i++) { Vector2 val = input[i]; outputList.Add(val); Vector2 val2 = input[i + 1]; ResolutionToNativeSize(Vector2.Distance(val, val2)); float num = 1f / m_Resolution; for (float num2 = 1f; num2 < m_Resolution; num2 += 1f) { outputList.Add(Vector2.Lerp(val, val2, num * num2)); } outputList.Add(val2); } break; } } return outputList; } protected virtual void GeneratedUVs() { } protected virtual void ResolutionToNativeSize(float distance) { } public virtual void CalculateLayoutInputHorizontal() { } public virtual void CalculateLayoutInputVertical() { } public virtual bool IsRaycastLocationValid(Vector2 screenPoint, Camera eventCamera) { //IL_0143: Expected O, but got Unknown //IL_0041: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_009a: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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) //IL_00aa: 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_00d9: 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_0128: Unknown result type (might be due to invalid IL or missing references) if (m_EventAlphaThreshold >= 1f) { return true; } Sprite val = overrideSprite; if ((Object)(object)val == (Object)null) { return true; } Vector2 local = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle(((Graphic)this).rectTransform, screenPoint, eventCamera, ref local); Rect pixelAdjustedRect = ((Graphic)this).GetPixelAdjustedRect(); local.x += ((Graphic)this).rectTransform.pivot.x * ((Rect)(ref pixelAdjustedRect)).width; local.y += ((Graphic)this).rectTransform.pivot.y * ((Rect)(ref pixelAdjustedRect)).height; local = MapCoordinate(local, pixelAdjustedRect); Rect textureRect = val.textureRect; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(local.x / ((Rect)(ref textureRect)).width, local.y / ((Rect)(ref textureRect)).height); float num = Mathf.Lerp(((Rect)(ref textureRect)).x, ((Rect)(ref textureRect)).xMax, val2.x) / (float)((Texture)val.texture).width; float num2 = Mathf.Lerp(((Rect)(ref textureRect)).y, ((Rect)(ref textureRect)).yMax, val2.y) / (float)((Texture)val.texture).height; try { return val.texture.GetPixelBilinear(num, num2).a >= m_EventAlphaThreshold; } catch (UnityException val3) { UnityException val4 = val3; Debug.LogError((object)("Using clickAlphaThreshold lower than 1 on Image whose sprite texture cannot be read. " + ((Exception)(object)val4).Message + " Also make sure to disable sprite packing for this sprite."), (Object)(object)this); return true; } } private Vector2 MapCoordinate(Vector2 local, Rect rect) { //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_001b: 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_0031: Unknown result type (might be due to invalid IL or missing references) Rect rect2 = sprite.rect; return new Vector2(local.x * ((Rect)(ref rect)).width, local.y * ((Rect)(ref rect)).height); } private Vector4 GetAdjustedBorders(Vector4 border, Rect rect) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00ae: 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) for (int i = 0; i <= 1; i++) { float num = ((Vector4)(ref border))[i] + ((Vector4)(ref border))[i + 2]; Vector2 size = ((Rect)(ref rect)).size; if (((Vector2)(ref size))[i] < num && num != 0f) { size = ((Rect)(ref rect)).size; float num2 = ((Vector2)(ref size))[i] / num; ref Vector4 reference = ref border; int num3 = i; ((Vector4)(ref reference))[num3] = ((Vector4)(ref reference))[num3] * num2; reference = ref border; num3 = i + 2; ((Vector4)(ref reference))[num3] = ((Vector4)(ref reference))[num3] * num2; } } return border; } protected override void OnEnable() { ((MaskableGraphic)this).OnEnable(); ((Graphic)this).SetAllDirty(); } }