Decompiled source of GalacticScale v2.15.4
GalacticScale.dll
Decompiled a month 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 System.Threading.Tasks; 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.15.4.0")] [assembly: AssemblyInformationalVersion("2.15.4+a03ddcf47781fc83ead5ce8dc75c379b44b9b2ba")] [assembly: AssemblyProduct("GalacticScale")] [assembly: AssemblyTitle("GalacticScale")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.15.4.0")] [module: UnverifiableCode] 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 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}", 59); 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}", 74); return maxExclusive - 1; } if (maxExclusive <= 0) { Error($"Max {maxExclusive} <= 0 {GetCaller()}", 80); 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}", 93); 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(), 124); } return items[Next(items.Count)]; } public (int, T) ItemWithIndex<T>(List<T> items) { if (items.Count == 0) { Error("Item Length 0 " + GetCaller(), 133); } 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(), 143); } 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(), 154); } return items[Next(items.Length)]; } public (int, T) ItemWithIndex<T>(T[] items) { if (items.Length == 0) { Error("Item Length 0 " + GetCaller(), 163); } 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(), 173); } 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__47_0; public static UnityAction <>9__47_1; public static Func<KeyValuePair<string, GSTheme>, GSTheme> <>9__48_0; public static Response <>9__115_0; internal void <UpdateNebulaSettings>b__47_0() { ShowMessage("Cannot Host a GS2 Game using Vanilla Generator", "Warning", Localization.Translate("OK")); } internal void <UpdateNebulaSettings>b__47_1() { ShowMessage("Cannot Host a GS2 Game using Vanilla Generator", "Warning", Localization.Translate("OK")); } internal GSTheme <Init>b__48_0(KeyValuePair<string, GSTheme> t) { return t.Value; } internal void <AbortGameStart>b__115_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 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__47_0; if (obj == null) { UnityAction val3 = delegate { ShowMessage("Cannot Host a GS2 Game using Vanilla Generator", "Warning", Localization.Translate("OK")); }; <>c.<>9__47_0 = val3; obj = (object)val3; } ((UnityEvent)onClick).AddListener((UnityAction)obj); ButtonClickedEvent onClick2 = component2.onClick; object obj2 = <>c.<>9__47_1; if (obj2 == null) { UnityAction val4 = delegate { ShowMessage("Cannot Host a GS2 Game using Vanilla Generator", "Warning", Localization.Translate("OK")); }; <>c.<>9__47_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) { if (GetGeneratorByID(generatorPreference.Key) is iConfigurableGenerator iConfigurableGenerator2) { 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_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) GlobalObject.LoadVersions(); 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); GlobalObject.LoadVersions(); 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__115_0; if (obj == null) { Response val = delegate { UIRoot.instance.OpenMainMenuUI(); UIRoot.ClearFatalError(); }; <>c.<>9__115_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.15.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Bootstrap : BaseUnityPlugin { public static Bootstrap instance; public static ManualLogSource Logger; public static Queue buffer = new Queue(); internal void Awake() { instance = this; InitializeLogger(); InitializeComponents(); ApplyHarmonyPatches(); } private void InitializeLogger() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown AppDomain.CurrentDomain.UnhandledException += delegate(object o, UnhandledExceptionEventArgs e) { GS2.LogError(o, e, 37); }; Version version = Assembly.GetExecutingAssembly().GetName().Version; Assembly assembly = Assembly.GetAssembly(typeof(GSStar)); GS2.Version = $"{version.Major}.{version.Minor}.{version.Build}"; BCE.Console.Init(); Logger = new ManualLogSource("GS2"); Logger.Sources.Add((ILogSource)(object)Logger); GS2.ConsoleSplash(); } private void InitializeComponents() { if ((Object)(object)GS2.TP == (Object)null) { GS2.TP = ((Component)this).gameObject.AddComponent<TeleportComponent>(); } if ((Object)(object)GS2.InputComponent == (Object)null) { GS2.InputComponent = ((Component)this).gameObject.AddComponent<InputComponent>(); } } private void ApplyHarmonyPatches() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown Directory.CreateDirectory("./mmdump"); FileInfo[] files = new DirectoryInfo("./mmdump").GetFiles(); foreach (FileInfo fileInfo in files) { fileInfo.Delete(); } try { Harmony val = new Har
GSUI.dll
Decompiled a month 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.Reflection; using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using UnityEditor; using UnityEditorInternal; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.Serialization; using UnityEngine.Sprites; using UnityEngine.UI.Extensions.EasingCore; using UnityEngine.UI.Extensions.Tweens; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyVersion("0.0.0.0")] [Serializable] public class ColorChangedEvent : UnityEvent<Color> { } public class HSVChangedEvent : UnityEvent<float, float, float> { } public class TestCompression : MonoBehaviour { private void Start() { } private void Update() { } } public class NewBehaviourScript : MonoBehaviour { private void Start() { } private void Update() { } } namespace UnityEngine.UI { [AddComponentMenu("UI/Extensions/Extensions Toggle", 31)] [RequireComponent(typeof(RectTransform))] public class ExtensionsToggle : Selectable, IPointerClickHandler, IEventSystemHandler, ISubmitHandler, ICanvasElement { public enum ToggleTransition { None, Fade } [Serializable] public class ToggleEvent : UnityEvent<bool> { } [Serializable] public class ToggleEventObject : UnityEvent<ExtensionsToggle> { } public string UniqueID; public ToggleTransition toggleTransition = ToggleTransition.Fade; public Graphic graphic; [SerializeField] private ExtensionsToggleGroup m_Group; [Tooltip("Use this event if you only need the bool state of the toggle that was changed")] public ToggleEvent onValueChanged = new ToggleEvent(); [Tooltip("Use this event if you need access to the toggle that was changed")] public ToggleEventObject onToggleChanged = new ToggleEventObject(); [FormerlySerializedAs("m_IsActive")] [Tooltip("Is the toggle currently on or off?")] [SerializeField] private bool m_IsOn; public ExtensionsToggleGroup Group { get { return m_Group; } set { m_Group = value; if (Application.isPlaying) { SetToggleGroup(m_Group, setMemberValue: true); PlayEffect(instant: true); } } } public bool IsOn { get { return m_IsOn; } set { Set(value); } } protected ExtensionsToggle() { } protected override void OnValidate() { ((Selectable)this).OnValidate(); Set(m_IsOn, sendCallback: false); PlayEffect(toggleTransition == ToggleTransition.None); if (!Application.isPlaying) { CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild((ICanvasElement)(object)this); } } public virtual void Rebuild(CanvasUpdate executing) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)executing == 0) { ((UnityEvent<bool>)onValueChanged).Invoke(m_IsOn); ((UnityEvent<ExtensionsToggle>)onToggleChanged).Invoke(this); } } public virtual void LayoutComplete() { } public virtual void GraphicUpdateComplete() { } protected override void OnEnable() { ((Selectable)this).OnEnable(); SetToggleGroup(m_Group, setMemberValue: false); PlayEffect(instant: true); } protected override void OnDisable() { SetToggleGroup(null, setMemberValue: false); ((Selectable)this).OnDisable(); } protected override void OnDidApplyAnimationProperties() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)graphic != (Object)null) { bool flag = !Mathf.Approximately(graphic.canvasRenderer.GetColor().a, 0f); if (m_IsOn != flag) { m_IsOn = flag; Set(!flag); } } ((Selectable)this).OnDidApplyAnimationProperties(); } private void SetToggleGroup(ExtensionsToggleGroup newGroup, bool setMemberValue) { ExtensionsToggleGroup group = m_Group; if ((Object)(object)m_Group != (Object)null) { m_Group.UnregisterToggle(this); } if (setMemberValue) { m_Group = newGroup; } if ((Object)(object)m_Group != (Object)null && ((UIBehaviour)this).IsActive()) { m_Group.RegisterToggle(this); } if ((Object)(object)newGroup != (Object)null && (Object)(object)newGroup != (Object)(object)group && IsOn && ((UIBehaviour)this).IsActive()) { m_Group.NotifyToggleOn(this); } } private void Set(bool value) { Set(value, sendCallback: true); } private void Set(bool value, bool sendCallback) { if (m_IsOn != value) { m_IsOn = value; if ((Object)(object)m_Group != (Object)null && ((UIBehaviour)this).IsActive() && (m_IsOn || (!m_Group.AnyTogglesOn() && !m_Group.AllowSwitchOff))) { m_IsOn = true; m_Group.NotifyToggleOn(this); } PlayEffect(toggleTransition == ToggleTransition.None); if (sendCallback) { ((UnityEvent<bool>)onValueChanged).Invoke(m_IsOn); ((UnityEvent<ExtensionsToggle>)onToggleChanged).Invoke(this); } } } private void PlayEffect(bool instant) { if (!((Object)(object)graphic == (Object)null)) { if (!Application.isPlaying) { graphic.canvasRenderer.SetAlpha(m_IsOn ? 1f : 0f); } else { graphic.CrossFadeAlpha(m_IsOn ? 1f : 0f, instant ? 0f : 0.1f, true); } } } protected override void Start() { PlayEffect(instant: true); } private void InternalToggle() { if (((UIBehaviour)this).IsActive() && ((Selectable)this).IsInteractable()) { IsOn = !IsOn; } } public virtual void OnPointerClick(PointerEventData eventData) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)eventData.button <= 0) { InternalToggle(); } } public virtual void OnSubmit(BaseEventData eventData) { InternalToggle(); } [SpecialName] Transform ICanvasElement.get_transform() { return ((Component)this).transform; } } [AddComponentMenu("UI/Extensions/Extensions Toggle Group")] [DisallowMultipleComponent] public class ExtensionsToggleGroup : UIBehaviour { [Serializable] public class ToggleGroupEvent : UnityEvent<bool> { } [SerializeField] private bool m_AllowSwitchOff = false; private List<ExtensionsToggle> m_Toggles = new List<ExtensionsToggle>(); public ToggleGroupEvent onToggleGroupChanged = new ToggleGroupEvent(); public ToggleGroupEvent onToggleGroupToggleChanged = new ToggleGroupEvent(); public bool AllowSwitchOff { get { return m_AllowSwitchOff; } set { m_AllowSwitchOff = value; } } public ExtensionsToggle SelectedToggle { get; private set; } protected ExtensionsToggleGroup() { } private void ValidateToggleIsInGroup(ExtensionsToggle toggle) { if ((Object)(object)toggle == (Object)null || !m_Toggles.Contains(toggle)) { throw new ArgumentException(string.Format("Toggle {0} is not part of ToggleGroup {1}", new object[2] { toggle, this })); } } public void NotifyToggleOn(ExtensionsToggle toggle) { ValidateToggleIsInGroup(toggle); for (int i = 0; i < m_Toggles.Count; i++) { if ((Object)(object)m_Toggles[i] == (Object)(object)toggle) { SelectedToggle = toggle; } else { m_Toggles[i].IsOn = false; } } ((UnityEvent<bool>)onToggleGroupChanged).Invoke(AnyTogglesOn()); } public void UnregisterToggle(ExtensionsToggle toggle) { if (m_Toggles.Contains(toggle)) { m_Toggles.Remove(toggle); ((UnityEvent<bool>)toggle.onValueChanged).RemoveListener((UnityAction<bool>)NotifyToggleChanged); } } private void NotifyToggleChanged(bool isOn) { ((UnityEvent<bool>)onToggleGroupToggleChanged).Invoke(isOn); } public void RegisterToggle(ExtensionsToggle toggle) { if (!m_Toggles.Contains(toggle)) { m_Toggles.Add(toggle); ((UnityEvent<bool>)toggle.onValueChanged).AddListener((UnityAction<bool>)NotifyToggleChanged); } } public bool AnyTogglesOn() { return (Object)(object)m_Toggles.Find((ExtensionsToggle x) => x.IsOn) != (Object)null; } public IEnumerable<ExtensionsToggle> ActiveToggles() { return m_Toggles.Where((ExtensionsToggle x) => x.IsOn); } public void SetAllTogglesOff() { bool allowSwitchOff = m_AllowSwitchOff; m_AllowSwitchOff = true; for (int i = 0; i < m_Toggles.Count; i++) { m_Toggles[i].IsOn = false; } m_AllowSwitchOff = allowSwitchOff; } public void HasTheGroupToggle(bool value) { Debug.Log((object)("Testing, the group has toggled [" + value + "]")); } public void HasAToggleFlipped(bool value) { Debug.Log((object)("Testing, a toggle has toggled [" + value + "]")); } } [RequireComponent(typeof(InputField))] [AddComponentMenu("UI/Extensions/Return Key Trigger")] public class ReturnKeyTriggersButton : MonoBehaviour, ISubmitHandler, IEventSystemHandler { private EventSystem _system; public Button button; private bool highlight = true; public float highlightDuration = 0.2f; private void Start() { _system = EventSystem.current; } private void RemoveHighlight() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown ((Selectable)button).OnPointerExit(new PointerEventData(_system)); } public void OnSubmit(BaseEventData eventData) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if (highlight) { ((Selectable)button).OnPointerEnter(new PointerEventData(_system)); } button.OnPointerClick(new PointerEventData(_system)); if (highlight) { ((MonoBehaviour)this).Invoke("RemoveHighlight", highlightDuration); } } } } namespace UnityEngine.UI.Extensions { [RequireComponent(typeof(HorizontalOrVerticalLayoutGroup), typeof(ContentSizeFitter), typeof(ToggleGroup))] [AddComponentMenu("UI/Extensions/Accordion/Accordion Group")] public class Accordion : MonoBehaviour { public enum Transition { Instant, Tween } private bool m_expandVertical = true; [SerializeField] private Transition m_Transition = Transition.Instant; [SerializeField] private float m_TransitionDuration = 0.3f; [HideInInspector] public bool ExpandVerticval => m_expandVertical; public Transition transition { get { return m_Transition; } set { m_Transition = value; } } public float transitionDuration { get { return m_TransitionDuration; } set { m_TransitionDuration = value; } } private void Awake() { m_expandVertical = ((!Object.op_Implicit((Object)(object)((Component)this).GetComponent<HorizontalLayoutGroup>())) ? true : false); ToggleGroup component = ((Component)this).GetComponent<ToggleGroup>(); } private void OnValidate() { if (!Object.op_Implicit((Object)(object)((Component)this).GetComponent<HorizontalLayoutGroup>()) && !Object.op_Implicit((Object)(object)((Component)this).GetComponent<VerticalLayoutGroup>())) { Debug.LogError((object)"Accordion requires either a Horizontal or Vertical Layout group to place children"); } } } [RequireComponent(typeof(RectTransform), typeof(LayoutElement))] [AddComponentMenu("UI/Extensions/Accordion/Accordion Element")] public class AccordionElement : Toggle { [SerializeField] private float m_MinHeight = 18f; [SerializeField] private float m_MinWidth = 40f; private Accordion m_Accordion; private RectTransform m_RectTransform; private LayoutElement m_LayoutElement; [NonSerialized] private readonly TweenRunner<FloatTween> m_FloatTweenRunner; public float MinHeight => m_MinHeight; public float MinWidth => m_MinWidth; protected AccordionElement() { if (m_FloatTweenRunner == null) { m_FloatTweenRunner = new TweenRunner<FloatTween>(); } m_FloatTweenRunner.Init((MonoBehaviour)(object)this); } protected override void Awake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) ((Selectable)this).Awake(); ((Selectable)this).transition = (Transition)0; base.toggleTransition = (ToggleTransition)0; m_Accordion = ((Component)this).gameObject.GetComponentInParent<Accordion>(); ref RectTransform rectTransform = ref m_RectTransform; Transform transform = ((Component)this).transform; rectTransform = (RectTransform)(object)((transform is RectTransform) ? transform : null); m_LayoutElement = ((Component)this).gameObject.GetComponent<LayoutElement>(); ((UnityEvent<bool>)(object)base.onValueChanged).AddListener((UnityAction<bool>)OnValueChanged); } protected override void OnValidate() { ((Toggle)this).OnValidate(); m_Accordion = ((Component)this).gameObject.GetComponentInParent<Accordion>(); if ((Object)(object)((Toggle)this).group == (Object)null) { ToggleGroup componentInParent = ((Component)this).GetComponentInParent<ToggleGroup>(); if ((Object)(object)componentInParent != (Object)null) { ((Toggle)this).group = componentInParent; } } LayoutElement component = ((Component)this).gameObject.GetComponent<LayoutElement>(); if (!((Object)(object)component != (Object)null) || !((Object)(object)m_Accordion != (Object)null)) { return; } if (((Toggle)this).isOn) { if (m_Accordion.ExpandVerticval) { component.preferredHeight = -1f; } else { component.preferredWidth = -1f; } } else if (m_Accordion.ExpandVerticval) { component.preferredHeight = m_MinHeight; } else { component.preferredWidth = m_MinWidth; } } public void OnValueChanged(bool state) { //IL_0167: 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_0142: 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) if ((Object)(object)m_LayoutElement == (Object)null) { return; } Accordion.Transition transition = (((Object)(object)m_Accordion != (Object)null) ? m_Accordion.transition : Accordion.Transition.Instant); if (transition == Accordion.Transition.Instant && (Object)(object)m_Accordion != (Object)null) { if (state) { if (m_Accordion.ExpandVerticval) { m_LayoutElement.preferredHeight = -1f; } else { m_LayoutElement.preferredWidth = -1f; } } else if (m_Accordion.ExpandVerticval) { m_LayoutElement.preferredHeight = m_MinHeight; } else { m_LayoutElement.preferredWidth = m_MinWidth; } } else { if (transition != Accordion.Transition.Tween) { return; } Rect rect; if (state) { if (m_Accordion.ExpandVerticval) { StartTween(m_MinHeight, GetExpandedHeight()); } else { StartTween(m_MinWidth, GetExpandedWidth()); } } else if (m_Accordion.ExpandVerticval) { rect = m_RectTransform.rect; StartTween(((Rect)(ref rect)).height, m_MinHeight); } else { rect = m_RectTransform.rect; StartTween(((Rect)(ref rect)).width, m_MinWidth); } } } protected float GetExpandedHeight() { if ((Object)(object)m_LayoutElement == (Object)null) { return m_MinHeight; } float preferredHeight = m_LayoutElement.preferredHeight; m_LayoutElement.preferredHeight = -1f; float preferredHeight2 = LayoutUtility.GetPreferredHeight(m_RectTransform); m_LayoutElement.preferredHeight = preferredHeight; return preferredHeight2; } protected float GetExpandedWidth() { if ((Object)(object)m_LayoutElement == (Object)null) { return m_MinWidth; } float preferredWidth = m_LayoutElement.preferredWidth; m_LayoutElement.preferredWidth = -1f; float preferredWidth2 = LayoutUtility.GetPreferredWidth(m_RectTransform); m_LayoutElement.preferredWidth = preferredWidth; return preferredWidth2; } protected void StartTween(float startFloat, float targetFloat) { float duration = (((Object)(object)m_Accordion != (Object)null) ? m_Accordion.transitionDuration : 0.3f); FloatTween floatTween = default(FloatTween); floatTween.duration = duration; floatTween.startFloat = startFloat; floatTween.targetFloat = targetFloat; FloatTween info = floatTween; if (m_Accordion.ExpandVerticval) { info.AddOnChangedCallback(SetHeight); } else { info.AddOnChangedCallback(SetWidth); } info.ignoreTimeScale = true; m_FloatTweenRunner.StartTween(info); } protected void SetHeight(float height) { if (!((Object)(object)m_LayoutElement == (Object)null)) { m_LayoutElement.preferredHeight = height; } } protected void SetWidth(float width) { if (!((Object)(object)m_LayoutElement == (Object)null)) { m_LayoutElement.preferredWidth = width; } } } [RequireComponent(typeof(RectTransform))] [AddComponentMenu("UI/Extensions/BoxSlider")] public class BoxSlider : Selectable, IDragHandler, IEventSystemHandler, IInitializePotentialDragHandler, ICanvasElement { public enum Direction { LeftToRight, RightToLeft, BottomToTop, TopToBottom } [Serializable] public class BoxSliderEvent : UnityEvent<float, float> { } private enum Axis { Horizontal, Vertical } [SerializeField] private RectTransform m_HandleRect; [Space(6f)] [SerializeField] private float m_MinValue = 0f; [SerializeField] private float m_MaxValue = 1f; [SerializeField] private bool m_WholeNumbers = false; [SerializeField] private float m_ValueX = 1f; [SerializeField] private float m_ValueY = 1f; [Space(6f)] [SerializeField] private BoxSliderEvent m_OnValueChanged = new BoxSliderEvent(); private Transform m_HandleTransform; private RectTransform m_HandleContainerRect; private Vector2 m_Offset = Vector2.zero; private DrivenRectTransformTracker m_Tracker; public RectTransform HandleRect { get { return m_HandleRect; } set { if (SetClass(ref m_HandleRect, value)) { UpdateCachedReferences(); UpdateVisuals(); } } } public float MinValue { get { return m_MinValue; } set { if (SetStruct(ref m_MinValue, value)) { SetX(m_ValueX); SetY(m_ValueY); UpdateVisuals(); } } } public float MaxValue { get { return m_MaxValue; } set { if (SetStruct(ref m_MaxValue, value)) { SetX(m_ValueX); SetY(m_ValueY); UpdateVisuals(); } } } public bool WholeNumbers { get { return m_WholeNumbers; } set { if (SetStruct(ref m_WholeNumbers, value)) { SetX(m_ValueX); SetY(m_ValueY); UpdateVisuals(); } } } public float ValueX { get { if (WholeNumbers) { return Mathf.Round(m_ValueX); } return m_ValueX; } set { SetX(value); } } public float NormalizedValueX { get { if (Mathf.Approximately(MinValue, MaxValue)) { return 0f; } return Mathf.InverseLerp(MinValue, MaxValue, ValueX); } set { ValueX = Mathf.Lerp(MinValue, MaxValue, value); } } public float ValueY { get { if (WholeNumbers) { return Mathf.Round(m_ValueY); } return m_ValueY; } set { SetY(value); } } public float NormalizedValueY { get { if (Mathf.Approximately(MinValue, MaxValue)) { return 0f; } return Mathf.InverseLerp(MinValue, MaxValue, ValueY); } set { ValueY = Mathf.Lerp(MinValue, MaxValue, value); } } public BoxSliderEvent OnValueChanged { get { return m_OnValueChanged; } set { m_OnValueChanged = value; } } private float StepSize => WholeNumbers ? 1f : ((MaxValue - MinValue) * 0.1f); protected BoxSlider() { }//IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) protected override void OnValidate() { ((Selectable)this).OnValidate(); if (WholeNumbers) { m_MinValue = Mathf.Round(m_MinValue); m_MaxValue = Mathf.Round(m_MaxValue); } UpdateCachedReferences(); SetX(m_ValueX, sendCallback: false); SetY(m_ValueY, sendCallback: false); if (!Application.isPlaying) { UpdateVisuals(); } if (!Application.isPlaying) { CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild((ICanvasElement)(object)this); } } public virtual void Rebuild(CanvasUpdate executing) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)executing == 0) { ((UnityEvent<float, float>)OnValueChanged).Invoke(ValueX, ValueY); } } public void LayoutComplete() { } public 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(); SetX(m_ValueX, sendCallback: false); SetY(m_ValueY, sendCallback: false); UpdateVisuals(); } protected override void OnDisable() { ((DrivenRectTransformTracker)(ref m_Tracker)).Clear(); ((Selectable)this).OnDisable(); } private void UpdateCachedReferences() { if (Object.op_Implicit((Object)(object)m_HandleRect)) { m_HandleTransform = ((Component)m_HandleRect).transform; if ((Object)(object)m_HandleTransform.parent != (Object)null) { m_HandleContainerRect = ((Component)m_HandleTransform.parent).GetComponent<RectTransform>(); } } else { m_HandleContainerRect = null; } } private void SetX(float input) { SetX(input, sendCallback: true); } private void SetX(float input, bool sendCallback) { float num = Mathf.Clamp(input, MinValue, MaxValue); if (WholeNumbers) { num = Mathf.Round(num); } if (m_ValueX != num) { m_ValueX = num; UpdateVisuals(); if (sendCallback) { ((UnityEvent<float, float>)m_OnValueChanged).Invoke(num, ValueY); } } } private void SetY(float input) { SetY(input, sendCallback: true); } private void SetY(float input, bool sendCallback) { float num = Mathf.Clamp(input, MinValue, MaxValue); if (WholeNumbers) { num = Mathf.Round(num); } if (m_ValueY != num) { m_ValueY = num; UpdateVisuals(); if (sendCallback) { ((UnityEvent<float, float>)m_OnValueChanged).Invoke(ValueX, num); } } } protected override void OnRectTransformDimensionsChange() { ((UIBehaviour)this).OnRectTransformDimensionsChange(); UpdateVisuals(); } private void UpdateVisuals() { //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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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) if (!Application.isPlaying) { UpdateCachedReferences(); } ((DrivenRectTransformTracker)(ref m_Tracker)).Clear(); if ((Object)(object)m_HandleContainerRect != (Object)null) { ((DrivenRectTransformTracker)(ref m_Tracker)).Add((Object)(object)this, m_HandleRect, (DrivenTransformProperties)3840); Vector2 zero = Vector2.zero; Vector2 one = Vector2.one; float num = (((Vector2)(ref one))[0] = NormalizedValueX); ((Vector2)(ref zero))[0] = num; num = (((Vector2)(ref one))[1] = NormalizedValueY); ((Vector2)(ref zero))[1] = num; if (Application.isPlaying) { m_HandleRect.anchorMin = zero; m_HandleRect.anchorMax = one; } } } private void UpdateDrag(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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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_008a: 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_00ac: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_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) RectTransform handleContainerRect = m_HandleContainerRect; if ((Object)(object)handleContainerRect != (Object)null) { Rect rect = handleContainerRect.rect; Vector2 val = ((Rect)(ref rect)).size; Vector2 val2 = default(Vector2); if (((Vector2)(ref val))[0] > 0f && RectTransformUtility.ScreenPointToLocalPointInRectangle(handleContainerRect, eventData.position, cam, ref val2)) { Vector2 val3 = val2; rect = handleContainerRect.rect; val2 = val3 - ((Rect)(ref rect)).position; val = val2 - m_Offset; float num = ((Vector2)(ref val))[0]; rect = handleContainerRect.rect; val = ((Rect)(ref rect)).size; float normalizedValueX = Mathf.Clamp01(num / ((Vector2)(ref val))[0]); NormalizedValueX = normalizedValueX; val = val2 - m_Offset; float num2 = ((Vector2)(ref val))[1]; rect = handleContainerRect.rect; val = ((Rect)(ref rect)).size; float normalizedValueY = Mathf.Clamp01(num2 / ((Vector2)(ref val))[1]); NormalizedValueY = normalizedValueY; } } } private bool CanDrag(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_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_003c: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!CanDrag(eventData)) { return; } ((Selectable)this).OnPointerDown(eventData); m_Offset = Vector2.zero; if ((Object)(object)m_HandleContainerRect != (Object)null && RectTransformUtility.RectangleContainsScreenPoint(m_HandleRect, eventData.position, eventData.enterEventCamera)) { Vector2 offset = default(Vector2); if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_HandleRect, eventData.position, eventData.pressEventCamera, ref offset)) { m_Offset = offset; } m_Offset.y = 0f - m_Offset.y; } else { UpdateDrag(eventData, eventData.pressEventCamera); } } public virtual void OnDrag(PointerEventData eventData) { if (CanDrag(eventData)) { UpdateDrag(eventData, eventData.pressEventCamera); } } public virtual void OnInitializePotentialDrag(PointerEventData eventData) { eventData.useDragThreshold = false; } [SpecialName] Transform ICanvasElement.get_transform() { return ((Component)this).transform; } } public class TiltWindow : MonoBehaviour, IDragHandler, IEventSystemHandler { public Vector2 range = new Vector2(5f, 3f); private Transform mTrans; private Quaternion mStart; private Vector2 mRot = Vector2.zero; private Vector2 m_screenPos; private void Start() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) mTrans = ((Component)this).transform; mStart = mTrans.localRotation; } private void Update() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_005e: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector2.op_Implicit(m_screenPos); float num = (float)Screen.width * 0.5f; float num2 = (float)Screen.height * 0.5f; float num3 = Mathf.Clamp((val.x - num) / num, -1f, 1f); float num4 = Mathf.Clamp((val.y - num2) / num2, -1f, 1f); mRot = Vector2.Lerp(mRot, new Vector2(num3, num4), Time.deltaTime * 5f); mTrans.localRotation = mStart * Quaternion.Euler((0f - mRot.y) * range.y, mRot.x * range.x, 0f); } public void OnDrag(PointerEventData eventData) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) m_screenPos = eventData.position; } } public enum AutoCompleteSearchType { ArraySort, Linq } [RequireComponent(typeof(RectTransform))] [AddComponentMenu("UI/Extensions/AutoComplete ComboBox")] public class AutoCompleteComboBox : MonoBehaviour { [Serializable] public class SelectionChangedEvent : UnityEvent<string, bool> { } [Serializable] public class SelectionTextChangedEvent : UnityEvent<string> { } [Serializable] public class SelectionValidityChangedEvent : UnityEvent<bool> { } public Color disabledTextColor; public List<string> AvailableOptions; private bool _isPanelActive = false; private bool _hasDrawnOnce = false; private InputField _mainInput; private RectTransform _inputRT; private RectTransform _rectTransform; private RectTransform _overlayRT; private RectTransform _scrollPanelRT; private RectTransform _scrollBarRT; private RectTransform _slidingAreaRT; private RectTransform _scrollHandleRT; private RectTransform _itemsPanelRT; private Canvas _canvas; private RectTransform _canvasRT; private ScrollRect _scrollRect; private List<string> _panelItems; private List<string> _prunedPanelItems; private Dictionary<string, GameObject> panelObjects; private GameObject itemTemplate; [SerializeField] private float _scrollBarWidth = 20f; [SerializeField] private int _itemsToDisplay; public bool SelectFirstItemOnStart = false; [SerializeField] [Tooltip("Change input text color based on matching items")] private bool _ChangeInputTextColorBasedOnMatchingItems = false; public float DropdownOffset = 10f; public Color ValidSelectionTextColor = Color.green; public Color MatchingItemsRemainingTextColor = Color.black; public Color NoItemsRemainingTextColor = Color.red; public AutoCompleteSearchType autocompleteSearchType = AutoCompleteSearchType.Linq; [SerializeField] private bool _displayPanelAbove = false; private bool _selectionIsValid = false; public SelectionTextChangedEvent OnSelectionTextChanged; public SelectionValidityChangedEvent OnSelectionValidityChanged; public SelectionChangedEvent OnSelectionChanged; public DropDownListItem SelectedItem { get; private set; } public string Text { get; private set; } public float ScrollBarWidth { get { return _scrollBarWidth; } set { _scrollBarWidth = value; RedrawPanel(); } } public int ItemsToDisplay { get { return _itemsToDisplay; } set { _itemsToDisplay = value; RedrawPanel(); } } public bool InputColorMatching { get { return _ChangeInputTextColorBasedOnMatchingItems; } set { _ChangeInputTextColorBasedOnMatchingItems = value; if (_ChangeInputTextColorBasedOnMatchingItems) { SetInputTextColor(); } } } public void Awake() { Initialize(); } public void Start() { if (SelectFirstItemOnStart && AvailableOptions.Count > 0) { ToggleDropdownPanel(); OnItemClicked(AvailableOptions[0]); } RedrawPanel(); } private bool Initialize() { //IL_012a: Unknown result type (might be due to invalid IL or missing references) bool result = true; try { _rectTransform = ((Component)this).GetComponent<RectTransform>(); _inputRT = ((Component)((Transform)_rectTransform).Find("InputField")).GetComponent<RectTransform>(); _mainInput = ((Component)_inputRT).GetComponent<InputField>(); _overlayRT = ((Component)((Transform)_rectTransform).Find("Overlay")).GetComponent<RectTransform>(); ((Component)_overlayRT).gameObject.SetActive(false); _scrollPanelRT = ((Component)((Transform)_overlayRT).Find("ScrollPanel")).GetComponent<RectTransform>(); _scrollBarRT = ((Component)((Transform)_scrollPanelRT).Find("Scrollbar")).GetComponent<RectTransform>(); _slidingAreaRT = ((Component)((Transform)_scrollBarRT).Find("SlidingArea")).GetComponent<RectTransform>(); _scrollHandleRT = ((Component)((Transform)_slidingAreaRT).Find("Handle")).GetComponent<RectTransform>(); _itemsPanelRT = ((Component)((Transform)_scrollPanelRT).Find("Items")).GetComponent<RectTransform>(); _canvas = ((Component)this).GetComponentInParent<Canvas>(); _canvasRT = ((Component)_canvas).GetComponent<RectTransform>(); _scrollRect = ((Component)_scrollPanelRT).GetComponent<ScrollRect>(); _scrollRect.scrollSensitivity = _rectTransform.sizeDelta.y / 2f; _scrollRect.movementType = (MovementType)2; _scrollRect.content = _itemsPanelRT; itemTemplate = ((Component)((Transform)_rectTransform).Find("ItemTemplate")).gameObject; itemTemplate.SetActive(false); } catch (NullReferenceException ex) { Debug.LogException((Exception)ex); Debug.LogError((object)"Something is setup incorrectly with the dropdownlist component causing a Null Reference Exception"); result = false; } panelObjects = new Dictionary<string, GameObject>(); _prunedPanelItems = new List<string>(); _panelItems = new List<string>(); RebuildPanel(); return result; } public void AddItem(string item) { if (!AvailableOptions.Contains(item)) { AvailableOptions.Add(item); RebuildPanel(); } else { Debug.LogWarning((object)("AutoCompleteComboBox.AddItem: items may only exists once. '" + item + "' can not be added.")); } } public void RemoveItem(string item) { if (AvailableOptions.Contains(item)) { AvailableOptions.Remove(item); RebuildPanel(); } } public void SetAvailableOptions(List<string> newOptions) { List<string> list = newOptions.Distinct().ToList(); if (newOptions.Count != list.Count) { Debug.LogWarning((object)string.Format("{0}.{1}: items may only exists once. {2} duplicates.", "AutoCompleteComboBox", "SetAvailableOptions", newOptions.Count - list.Count)); } AvailableOptions.Clear(); AvailableOptions = list; RebuildPanel(); } public void SetAvailableOptions(string[] newOptions) { List<string> list = newOptions.Distinct().ToList(); if (newOptions.Length != list.Count) { Debug.LogWarning((object)string.Format("{0}.{1}: items may only exists once. {2} duplicates.", "AutoCompleteComboBox", "SetAvailableOptions", newOptions.Length - list.Count)); } AvailableOptions.Clear(); for (int i = 0; i < newOptions.Length; i++) { AvailableOptions.Add(newOptions[i]); } RebuildPanel(); } public void ResetItems() { AvailableOptions.Clear(); RebuildPanel(); } private void RebuildPanel() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Expected O, but got Unknown if (_isPanelActive) { ToggleDropdownPanel(); } _panelItems.Clear(); _prunedPanelItems.Clear(); panelObjects.Clear(); foreach (Transform item in ((Component)_itemsPanelRT).transform) { Transform val = item; Object.Destroy((Object)(object)((Component)val).gameObject); } foreach (string availableOption in AvailableOptions) { _panelItems.Add(availableOption.ToLower()); } List<GameObject> list = new List<GameObject>(panelObjects.Values); int num = 0; while (list.Count < AvailableOptions.Count) { GameObject val2 = Object.Instantiate<GameObject>(itemTemplate); ((Object)val2).name = "Item " + num; val2.transform.SetParent((Transform)(object)_itemsPanelRT, false); list.Add(val2); num++; } for (int i = 0; i < list.Count; i++) { list[i].SetActive(i <= AvailableOptions.Count); if (i < AvailableOptions.Count) { ((Object)list[i]).name = "Item " + i + " " + _panelItems[i]; ((Component)list[i].transform.Find("Text")).GetComponent<Text>().text = AvailableOptions[i]; Button component = list[i].GetComponent<Button>(); ((UnityEventBase)component.onClick).RemoveAllListeners(); string textOfItem = _panelItems[i]; ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { OnItemClicked(textOfItem); }); panelObjects[_panelItems[i]] = list[i]; } } SetInputTextColor(); } private void OnItemClicked(string item) { Text = item; _mainInput.text = Text; ToggleDropdownPanel(directClick: true); } private void RedrawPanel() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: 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_0225: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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_02c8: Unknown result type (might be due to invalid IL or missing references) float num = ((_panelItems.Count > ItemsToDisplay) ? _scrollBarWidth : 0f); ((Component)_scrollBarRT).gameObject.SetActive(_panelItems.Count > ItemsToDisplay); if (!_hasDrawnOnce || _rectTransform.sizeDelta != _inputRT.sizeDelta) { _hasDrawnOnce = true; _inputRT.SetSizeWithCurrentAnchors((Axis)0, _rectTransform.sizeDelta.x); _inputRT.SetSizeWithCurrentAnchors((Axis)1, _rectTransform.sizeDelta.y); ((Transform)_scrollPanelRT).SetParent(((Component)this).transform, true); _scrollPanelRT.anchoredPosition = (_displayPanelAbove ? new Vector2(0f, DropdownOffset + _rectTransform.sizeDelta.y * (float)_panelItems.Count - 1f) : new Vector2(0f, 0f - _rectTransform.sizeDelta.y)); ((Transform)_overlayRT).SetParent(((Component)_canvas).transform, false); _overlayRT.SetSizeWithCurrentAnchors((Axis)0, _canvasRT.sizeDelta.x); _overlayRT.SetSizeWithCurrentAnchors((Axis)1, _canvasRT.sizeDelta.y); ((Transform)_overlayRT).SetParent(((Component)this).transform, true); ((Transform)_scrollPanelRT).SetParent((Transform)(object)_overlayRT, true); } if (_panelItems.Count >= 1) { float num2 = _rectTransform.sizeDelta.y * (float)Mathf.Min(_itemsToDisplay, _panelItems.Count) + DropdownOffset; _scrollPanelRT.SetSizeWithCurrentAnchors((Axis)1, num2); _scrollPanelRT.SetSizeWithCurrentAnchors((Axis)0, _rectTransform.sizeDelta.x); _itemsPanelRT.SetSizeWithCurrentAnchors((Axis)0, _scrollPanelRT.sizeDelta.x - num - 5f); _itemsPanelRT.anchoredPosition = new Vector2(5f, 0f); _scrollBarRT.SetSizeWithCurrentAnchors((Axis)0, num); _scrollBarRT.SetSizeWithCurrentAnchors((Axis)1, num2); if (num == 0f) { ((Component)_scrollHandleRT).gameObject.SetActive(false); } else { ((Component)_scrollHandleRT).gameObject.SetActive(true); } _slidingAreaRT.SetSizeWithCurrentAnchors((Axis)0, 0f); _slidingAreaRT.SetSizeWithCurrentAnchors((Axis)1, num2 - _scrollBarRT.sizeDelta.x); } } public void OnValueChanged(string currText) { Text = currText; PruneItems(currText); RedrawPanel(); if (_panelItems.Count == 0) { _isPanelActive = true; ToggleDropdownPanel(); } else if (!_isPanelActive) { ToggleDropdownPanel(); } bool flag = _panelItems.Contains(Text) != _selectionIsValid; _selectionIsValid = _panelItems.Contains(Text); ((UnityEvent<string, bool>)OnSelectionChanged).Invoke(Text, _selectionIsValid); ((UnityEvent<string>)OnSelectionTextChanged).Invoke(Text); if (flag) { ((UnityEvent<bool>)OnSelectionValidityChanged).Invoke(_selectionIsValid); } SetInputTextColor(); } private void SetInputTextColor() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (InputColorMatching) { if (_selectionIsValid) { ((Graphic)_mainInput.textComponent).color = ValidSelectionTextColor; } else if (_panelItems.Count > 0) { ((Graphic)_mainInput.textComponent).color = MatchingItemsRemainingTextColor; } else { ((Graphic)_mainInput.textComponent).color = NoItemsRemainingTextColor; } } } public void ToggleDropdownPanel(bool directClick = false) { _isPanelActive = !_isPanelActive; ((Component)_overlayRT).gameObject.SetActive(_isPanelActive); if (_isPanelActive) { ((Component)this).transform.SetAsLastSibling(); } else if (!directClick) { } } private void PruneItems(string currText) { if (autocompleteSearchType == AutoCompleteSearchType.Linq) { PruneItemsLinq(currText); } else { PruneItemsArray(currText); } } private void PruneItemsLinq(string currText) { currText = currText.ToLower(); string[] array = _panelItems.Where((string x) => !x.Contains(currText)).ToArray(); string[] array2 = array; foreach (string text in array2) { panelObjects[text].SetActive(false); _panelItems.Remove(text); _prunedPanelItems.Add(text); } string[] array3 = _prunedPanelItems.Where((string x) => x.Contains(currText)).ToArray(); string[] array4 = array3; foreach (string text2 in array4) { panelObjects[text2].SetActive(true); _panelItems.Add(text2); _prunedPanelItems.Remove(text2); } } private void PruneItemsArray(string currText) { string value = currText.ToLower(); for (int num = _panelItems.Count - 1; num >= 0; num--) { string text = _panelItems[num]; if (!text.Contains(value)) { panelObjects[_panelItems[num]].SetActive(false); _panelItems.RemoveAt(num); _prunedPanelItems.Add(text); } } for (int num2 = _prunedPanelItems.Count - 1; num2 >= 0; num2--) { string text2 = _prunedPanelItems[num2]; if (text2.Contains(value)) { panelObjects[_prunedPanelItems[num2]].SetActive(true); _prunedPanelItems.RemoveAt(num2); _panelItems.Add(text2); } } } } [RequireComponent(typeof(RectTransform))] [AddComponentMenu("UI/Extensions/ComboBox")] public class ComboBox : MonoBehaviour { [Serializable] public class SelectionChangedEvent : UnityEvent<string> { } public Color disabledTextColor; public List<string> AvailableOptions; [SerializeField] private float _scrollBarWidth = 20f; [SerializeField] private int _itemsToDisplay; [SerializeField] private bool _displayPanelAbove = false; public SelectionChangedEvent OnSelectionChanged; private bool _isPanelActive = false; private bool _hasDrawnOnce = false; private InputField _mainInput; private RectTransform _inputRT; private RectTransform _rectTransform; private RectTransform _overlayRT; private RectTransform _scrollPanelRT; private RectTransform _scrollBarRT; private RectTransform _slidingAreaRT; private RectTransform _scrollHandleRT; private RectTransform _itemsPanelRT; private Canvas _canvas; private RectTransform _canvasRT; private ScrollRect _scrollRect; private List<string> _panelItems; private Dictionary<string, GameObject> panelObjects; private GameObject itemTemplate; public DropDownListItem SelectedItem { get; private set; } public string Text { get; private set; } public float ScrollBarWidth { get { return _scrollBarWidth; } set { _scrollBarWidth = value; RedrawPanel(); } } public int ItemsToDisplay { get { return _itemsToDisplay; } set { _itemsToDisplay = value; RedrawPanel(); } } public void Awake() { Initialize(); } public void Start() { RedrawPanel(); } private bool Initialize() { //IL_012a: Unknown result type (might be due to invalid IL or missing references) bool result = true; try { _rectTransform = ((Component)this).GetComponent<RectTransform>(); _inputRT = ((Component)((Transform)_rectTransform).Find("InputField")).GetComponent<RectTransform>(); _mainInput = ((Component)_inputRT).GetComponent<InputField>(); _overlayRT = ((Component)((Transform)_rectTransform).Find("Overlay")).GetComponent<RectTransform>(); ((Component)_overlayRT).gameObject.SetActive(false); _scrollPanelRT = ((Component)((Transform)_overlayRT).Find("ScrollPanel")).GetComponent<RectTransform>(); _scrollBarRT = ((Component)((Transform)_scrollPanelRT).Find("Scrollbar")).GetComponent<RectTransform>(); _slidingAreaRT = ((Component)((Transform)_scrollBarRT).Find("SlidingArea")).GetComponent<RectTransform>(); _scrollHandleRT = ((Component)((Transform)_slidingAreaRT).Find("Handle")).GetComponent<RectTransform>(); _itemsPanelRT = ((Component)((Transform)_scrollPanelRT).Find("Items")).GetComponent<RectTransform>(); _canvas = ((Component)this).GetComponentInParent<Canvas>(); _canvasRT = ((Component)_canvas).GetComponent<RectTransform>(); _scrollRect = ((Component)_scrollPanelRT).GetComponent<ScrollRect>(); _scrollRect.scrollSensitivity = _rectTransform.sizeDelta.y / 2f; _scrollRect.movementType = (MovementType)2; _scrollRect.content = _itemsPanelRT; itemTemplate = ((Component)((Transform)_rectTransform).Find("ItemTemplate")).gameObject; itemTemplate.SetActive(false); } catch (NullReferenceException ex) { Debug.LogException((Exception)ex); Debug.LogError((object)"Something is setup incorrectly with the dropdownlist component causing a Null Reference Exception"); result = false; } panelObjects = new Dictionary<string, GameObject>(); _panelItems = AvailableOptions.ToList(); RebuildPanel(); return result; } public void AddItem(string item) { AvailableOptions.Add(item); RebuildPanel(); } public void RemoveItem(string item) { AvailableOptions.Remove(item); RebuildPanel(); } public void SetAvailableOptions(List<string> newOptions) { AvailableOptions.Clear(); AvailableOptions = newOptions; RebuildPanel(); } public void SetAvailableOptions(string[] newOptions) { AvailableOptions.Clear(); for (int i = 0; i < newOptions.Length; i++) { AvailableOptions.Add(newOptions[i]); } RebuildPanel(); } public void ResetItems() { AvailableOptions.Clear(); RebuildPanel(); } private void RebuildPanel() { //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Expected O, but got Unknown _panelItems.Clear(); foreach (string availableOption in AvailableOptions) { _panelItems.Add(availableOption.ToLower()); } List<GameObject> list = new List<GameObject>(panelObjects.Values); panelObjects.Clear(); int num = 0; while (list.Count < AvailableOptions.Count) { GameObject val = Object.Instantiate<GameObject>(itemTemplate); ((Object)val).name = "Item " + num; val.transform.SetParent((Transform)(object)_itemsPanelRT, false); list.Add(val); num++; } for (int i = 0; i < list.Count; i++) { list[i].SetActive(i <= AvailableOptions.Count); if (i < AvailableOptions.Count) { ((Object)list[i]).name = "Item " + i + " " + _panelItems[i]; ((Component)list[i].transform.Find("Text")).GetComponent<Text>().text = AvailableOptions[i]; Button component = list[i].GetComponent<Button>(); ((UnityEventBase)component.onClick).RemoveAllListeners(); string textOfItem = _panelItems[i]; ((UnityEvent)component.onClick).AddListener((UnityAction)delegate { OnItemClicked(textOfItem); }); panelObjects[_panelItems[i]] = list[i]; } } } private void OnItemClicked(string item) { Text = item; _mainInput.text = Text; ToggleDropdownPanel(directClick: true); } private void RedrawPanel() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) float num = ((_panelItems.Count > ItemsToDisplay) ? _scrollBarWidth : 0f); ((Component)_scrollBarRT).gameObject.SetActive(_panelItems.Count > ItemsToDisplay); if (!_hasDrawnOnce || _rectTransform.sizeDelta != _inputRT.sizeDelta) { _hasDrawnOnce = true; _inputRT.SetSizeWithCurrentAnchors((Axis)0, _rectTransform.sizeDelta.x); _inputRT.SetSizeWithCurrentAnchors((Axis)1, _rectTransform.sizeDelta.y); ((Transform)_scrollPanelRT).SetParent(((Component)this).transform, true); _scrollPanelRT.anchoredPosition = (_displayPanelAbove ? new Vector2(0f, _rectTransform.sizeDelta.y * (float)ItemsToDisplay - 1f) : new Vector2(0f, 0f - _rectTransform.sizeDelta.y)); ((Transform)_overlayRT).SetParent(((Component)_canvas).transform, false); _overlayRT.SetSizeWithCurrentAnchors((Axis)0, _canvasRT.sizeDelta.x); _overlayRT.SetSizeWithCurrentAnchors((Axis)1, _canvasRT.sizeDelta.y); ((Transform)_overlayRT).SetParent(((Component)this).transform, true); ((Transform)_scrollPanelRT).SetParent((Transform)(object)_overlayRT, true); } if (_panelItems.Count >= 1) { float num2 = _rectTransform.sizeDelta.y * (float)Mathf.Min(_itemsToDisplay, _panelItems.Count); _scrollPanelRT.SetSizeWithCurrentAnchors((Axis)1, num2); _scrollPanelRT.SetSizeWithCurrentAnchors((Axis)0, _rectTransform.sizeDelta.x); _itemsPanelRT.SetSizeWithCurrentAnchors((Axis)0, _scrollPanelRT.sizeDelta.x - num - 5f); _itemsPanelRT.anchoredPosition = new Vector2(5f, 0f); _scrollBarRT.SetSizeWithCurrentAnchors((Axis)0, num); _scrollBarRT.SetSizeWithCurrentAnchors((Axis)1, num2); if (num == 0f) { ((Component)_scrollHandleRT).gameObject.SetActive(false); } else { ((Component)_scrollHandleRT).gameObject.SetActive(true); } _slidingAreaRT.SetSizeWithCurrentAnchors((Axis)0, 0f); _slidingAreaRT.SetSizeWithCurrentAnchors((Axis)1, num2 - _scrollBarRT.sizeDelta.x); } } public void OnValueChanged(string currText) { Text = currText; RedrawPanel(); if (_panelItems.Count == 0) { _isPanelActive = true; ToggleDropdownPanel(directClick: false); } else if (!_isPanelActive) { ToggleDropdownPanel(directClick: false); } ((UnityEvent<string>)OnSelectionChanged).Invoke(Text); } public void ToggleDropdownPanel(bool directClick) { _isPanelActive = !_isPanelActive; ((Component)_overlayRT).gameObject.SetActive(_isPanelActive); if (_isPanelActive) { ((Component)this).transform.SetAsLastSibling(); } else if (!directClick) { } } } [RequireComponent(typeof(RectTransform))] [AddComponentMenu("UI/Extensions/Dropdown List")] public class DropDownList : MonoBehaviour { [Serializable] public class SelectionChangedEvent : UnityEvent<int> { } public Color disabledTextColor; public List<DropDownListItem> Items; public bool OverrideHighlighted = true; private bool _isPanelActive = false; private bool _hasDrawnOnce = false; private DropDownListButton _mainButton; private RectTransform _rectTransform; private RectTransform _overlayRT; private RectTransform _scrollPanelRT; private RectTransform _scrollBarRT; private RectTransform _slidingAreaRT; private RectTransform _scrollHandleRT; private RectTransform _itemsPanelRT; private Canvas _canvas; private RectTransform _canvasRT; private ScrollRect _scrollRect; private List<DropDownListButton> _panelItems; private GameObject _itemTemplate; [SerializeField] private float _scrollBarWidth = 20f; private int _selectedIndex = -1; [SerializeField] private int _itemsToDisplay; public bool SelectFirstItemOnStart = false; [SerializeField] private bool _displayPanelAbove = false; public SelectionChangedEvent OnSelectionChanged; public DropDownListItem SelectedItem { get; private set; } public float ScrollBarWidth { get { return _scrollBarWidth; } set { _scrollBarWidth = value; RedrawPanel(); } } public int ItemsToDisplay { get { return _itemsToDisplay; } set { _itemsToDisplay = value; RedrawPanel(); } } public void Start() { Initialize(); if (SelectFirstItemOnStart && Items.Count > 0) { ToggleDropdownPanel(directClick: false); OnItemClicked(0); } RedrawPanel(); } private bool Initialize() { //IL_011e: Unknown result type (might be due to invalid IL or missing references) bool result = true; try { _rectTransform = ((Component)this).GetComponent<RectTransform>(); _mainButton = new DropDownListButton(((Component)((Transform)_rectTransform).Find("MainButton")).gameObject); _overlayRT = ((Component)((Transform)_rectTransform).Find("Overlay")).GetComponent<RectTransform>(); ((Component)_overlayRT).gameObject.SetActive(false); _scrollPanelRT = ((Component)((Transform)_overlayRT).Find("ScrollPanel")).GetComponent<RectTransform>(); _scrollBarRT = ((Component)((Transform)_scrollPanelRT).Find("Scrollbar")).GetComponent<RectTransform>(); _slidingAreaRT = ((Component)((Transform)_scrollBarRT).Find("SlidingArea")).GetComponent<RectTransform>(); _scrollHandleRT = ((Component)((Transform)_slidingAreaRT).Find("Handle")).GetComponent<RectTransform>(); _itemsPanelRT = ((Component)((Transform)_scrollPanelRT).Find("Items")).GetComponent<RectTransform>(); _canvas = ((Component)this).GetComponentInParent<Canvas>(); _canvasRT = ((Component)_canvas).GetComponent<RectTransform>(); _scrollRect = ((Component)_scrollPanelRT).GetComponent<ScrollRect>(); _scrollRect.scrollSensitivity = _rectTransform.sizeDelta.y / 2f; _scrollRect.movementType = (MovementType)2; _scrollRect.content = _itemsPanelRT; _itemTemplate = ((Component)((Transform)_rectTransform).Find("ItemTemplate")).gameObject; _itemTemplate.SetActive(false); } catch (NullReferenceException ex) { Debug.LogException((Exception)ex); Debug.LogError((object)"Something is setup incorrectly with the dropdownlist component causing a Null Reference Exception"); result = false; } _panelItems = new List<DropDownListButton>(); RebuildPanel(); RedrawPanel(); return result; } public void RefreshItems(params object[] list) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown Items.Clear(); List<DropDownListItem> list2 = new List<DropDownListItem>(); foreach (object obj in list) { if (obj is DropDownListItem) { list2.Add((DropDownListItem)obj); continue; } if (obj is string) { list2.Add(new DropDownListItem((string)obj)); continue; } if (obj is Sprite) { list2.Add(new DropDownListItem("", "", (Sprite)obj)); continue; } throw new Exception("Only ComboBoxItems, Strings, and Sprite types are allowed"); } Items.AddRange(list2); RebuildPanel(); } public void AddItem(DropDownListItem item) { Items.Add(item); RebuildPanel(); } public void AddItem(string item) { Items.Add(new DropDownListItem(item)); RebuildPanel(); } public void AddItem(Sprite item) { Items.Add(new DropDownListItem("", "", item)); RebuildPanel(); } public void RemoveItem(DropDownListItem item) { Items.Remove(item); RebuildPanel(); } public void RemoveItem(string item) { Items.Remove(new DropDownListItem(item)); RebuildPanel(); } public void RemoveItem(Sprite item) { Items.Remove(new DropDownListItem("", "", item)); RebuildPanel(); } public void ResetItems() { Items.Clear(); RebuildPanel(); } private void RebuildPanel() { //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Expected O, but got Unknown //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) if (Items.Count == 0) { return; } int num = _panelItems.Count; while (_panelItems.Count < Items.Count) { GameObject val = Object.Instantiate<GameObject>(_itemTemplate); ((Object)val).name = "Item " + num; val.transform.SetParent((Transform)(object)_itemsPanelRT, false); _panelItems.Add(new DropDownListButton(val)); num++; } for (int i = 0; i < _panelItems.Count; i++) { if (i < Items.Count) { DropDownListItem item = Items[i]; _panelItems[i].txt.text = item.Caption; if (item.IsDisabled) { ((Graphic)_panelItems[i].txt).color = disabledTextColor; } if ((Object)(object)_panelItems[i].btnImg != (Object)null) { _panelItems[i].btnImg.sprite = null; } _panelItems[i].img.sprite = item.Image; ((Graphic)_panelItems[i].img).color = (Color)(((Object)(object)item.Image == (Object)null) ? new Color(1f, 1f, 1f, 0f) : (item.IsDisabled ? new Color(1f, 1f, 1f, 0.5f) : Color.white)); int ii = i; ((UnityEventBase)_panelItems[i].btn.onClick).RemoveAllListeners(); ((UnityEvent)_panelItems[i].btn.onClick).AddListener((UnityAction)delegate { OnItemClicked(ii); if (item.OnSelect != null) { item.OnSelect(); } }); } _panelItems[i].gameobject.SetActive(i < Items.Count); } } private void OnItemClicked(int indx) { if (indx != _selectedIndex && OnSelectionChanged != null) { ((UnityEvent<int>)OnSelectionChanged).Invoke(indx); } _selectedIndex = indx; ToggleDropdownPanel(directClick: true); UpdateSelected(); } private void UpdateSelected() { //IL_0089: 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_011f: 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_0108: Unknown result type (might be due to invalid IL or missing references) SelectedItem = ((_selectedIndex > -1 && _selectedIndex < Items.Count) ? Items[_selectedIndex] : null); if (SelectedItem == null) { return; } if ((Object)(object)SelectedItem.Image != (Object)null) { _mainButton.img.sprite = SelectedItem.Image; ((Graphic)_mainButton.img).color = Color.white; } else { _mainButton.img.sprite = null; } _mainButton.txt.text = SelectedItem.Caption; if (!OverrideHighlighted) { return; } for (int i = 0; i < ((Transform)_itemsPanelRT).childCount; i++) { Image btnImg = _panelItems[i].btnImg; ? color; if (_selectedIndex != i) { color = new Color(0f, 0f, 0f, 0f); } else { ColorBlock colors = ((Selectable)_mainButton.btn).colors; color = ((ColorBlock)(ref colors)).highlightedColor; } ((Graphic)btnImg).color = (Color)color; } } private void RedrawPanel() { //IL_0030: 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_006e: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) float num = ((Items.Count > ItemsToDisplay) ? _scrollBarWidth : 0f); if (!_hasDrawnOnce || _rectTransform.sizeDelta != _mainButton.rectTransform.sizeDelta) { _hasDrawnOnce = true; _mainButton.rectTransform.SetSizeWithCurrentAnchors((Axis)0, _rectTransform.sizeDelta.x); _mainButton.rectTransform.SetSizeWithCurrentAnchors((Axis)1, _rectTransform.sizeDelta.y); ((Graphic)_mainButton.txt).rectTransform.offsetMax = new Vector2(4f, 0f); ((Transform)_scrollPanelRT).SetParent(((Component)this).transform, true); _scrollPanelRT.anchoredPosition = (_displayPanelAbove ? new Vector2(0f, _rectTransform.sizeDelta.y * (float)ItemsToDisplay - 1f) : new Vector2(0f, 0f - _rectTransform.sizeDelta.y)); ((Transform)_overlayRT).SetParent(((Component)_canvas).transform, false); _overlayRT.SetSizeWithCurrentAnchors((Axis)0, _canvasRT.sizeDelta.x); _overlayRT.SetSizeWithCurrentAnchors((Axis)1, _canvasRT.sizeDelta.y); ((Transform)_overlayRT).SetParent(((Component)this).transform, true); ((Transform)_scrollPanelRT).SetParent((Transform)(object)_overlayRT, true); } if (Items.Count >= 1) { float num2 = _rectTransform.sizeDelta.y * (float)Mathf.Min(_itemsToDisplay, Items.Count); _scrollPanelRT.SetSizeWithCurrentAnchors((Axis)1, num2); _scrollPanelRT.SetSizeWithCurrentAnchors((Axis)0, _rectTransform.sizeDelta.x); _itemsPanelRT.SetSizeWithCurrentAnchors((Axis)0, _scrollPanelRT.sizeDelta.x - num - 5f); _itemsPanelRT.anchoredPosition = new Vector2(5f, 0f); _scrollBarRT.SetSizeWithCurrentAnchors((Axis)0, num); _scrollBarRT.SetSizeWithCurrentAnchors((Axis)1, num2); if (num == 0f) { ((Component)_scrollHandleRT).gameObject.SetActive(false); } else { ((Component)_scrollHandleRT).gameObject.SetActive(true); } _slidingAreaRT.SetSizeWithCurrentAnchors((Axis)0, 0f); _slidingAreaRT.SetSizeWithCurrentAnchors((Axis)1, num2 - _scrollBarRT.sizeDelta.x); } } public void ToggleDropdownPanel(bool directClick) { //IL_001b: 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) ((Component)_overlayRT).transform.localScale = new Vector3(1f, 1f, 1f); ((Component)_scrollBarRT).transform.localScale = new Vector3(1f, 1f, 1f); _isPanelActive = !_isPanelActive; ((Component)_overlayRT).gameObject.SetActive(_isPanelActive); if (_isPanelActive) { ((Component)this).transform.SetAsLastSibling(); } else if (!directClick) { } } } [RequireComponent(typeof(RectTransform), typeof(Button))] public class DropDownListButton { public RectTransform rectTransform; public Button btn; public Text txt; public Image btnImg; public Image img; public GameObject gameobject; public DropDownListButton(GameObject btnObj) { gameobject = btnObj; rectTransform = btnObj.GetComponent<RectTransform>(); btnImg = btnObj.GetComponent<Image>(); btn = btnObj.GetComponent<Button>(); txt = ((Component)((Transform)rectTransform).Find("Text")).GetComponent<Text>(); img = ((Component)((Transform)rectTransform).Find("Image")).GetComponent<Image>(); } } [Serializable] public class DropDownListItem { [SerializeField] private string _caption; [SerializeField] private Sprite _image; [SerializeField] private bool _isDisabled; [SerializeField] private string _id; public Action OnSelect = null; internal Action OnUpdate = null; public string Caption { get { return _caption; } set { _caption = value; if (OnUpdate != null) { OnUpdate(); } } } public Sprite Image { get { return _image; } set { _image = value; if (OnUpdate != null) { OnUpdate(); } } } public bool IsDisabled { get { return _isDisabled; } set { _isDisabled = value; if (OnUpdate != null) { OnUpdate(); } } } public string ID { get { return _id; } set { _id = value; } } public DropDownListItem(string caption = "", string inId = "", Sprite image = null, bool disabled = false, Action onSelect = null) { _caption = caption; _image = image; _id = inId; _isDisabled = disabled; OnSelect = onSelect; } } [AddComponentMenu("UI/Extensions/Cooldown Button")] public class CooldownButton : MonoBehaviour, IPointerDownHandler, IEventSystemHandler { [Serializable] public class CooldownButtonEvent : UnityEvent<InputButton> { } [SerializeField] private float cooldownTimeout; [SerializeField] private float cooldownSpeed = 1f; [SerializeField] [ReadOnly] private bool cooldownActive; [SerializeField] [ReadOnly] private bool cooldownInEffect; [SerializeField] [ReadOnly] private float cooldownTimeElapsed; [SerializeField] [ReadOnly] private float cooldownTimeRemaining; [SerializeField] [ReadOnly] private int cooldownPercentRemaining; [SerializeField] [ReadOnly] private int cooldownPercentComplete; private PointerEventData buttonSource; [Tooltip("Event that fires when a button is initially pressed down")] public CooldownButtonEvent OnCooldownStart; [Tooltip("Event that fires when a button is released")] public CooldownButtonEvent OnButtonClickDuringCooldown; [Tooltip("Event that continually fires while a button is held down")] public CooldownButtonEvent OnCoolDownFinish; public float CooldownTimeout { get { return cooldownTimeout; } set { cooldownTimeout = value; } } public float CooldownSpeed { get { return cooldownSpeed; } set { cooldownSpeed = value; } } public bool CooldownInEffect => cooldownInEffect; public bool CooldownActive { get { return cooldownActive; } set { cooldownActive = value; } } public float CooldownTimeElapsed { get { return cooldownTimeElapsed; } set { cooldownTimeElapsed = value; } } public float CooldownTimeRemaining => cooldownTimeRemaining; public int CooldownPercentRemaining => cooldownPercentRemaining; public int CooldownPercentComplete => cooldownPercentComplete; private void Update() { if (CooldownActive) { cooldownTimeRemaining -= Time.deltaTime * cooldownSpeed; cooldownTimeElapsed = CooldownTimeout - CooldownTimeRemaining; if (cooldownTimeRemaining < 0f) { StopCooldown(); return; } cooldownPercentRemaining = (int)(100f * cooldownTimeRemaining * CooldownTimeout / 100f); cooldownPercentComplete = (int)((CooldownTimeout - cooldownTimeRemaining) / CooldownTimeout * 100f); } } public void PauseCooldown() { if (CooldownInEffect) { CooldownActive = false; } } public void RestartCooldown() { if (CooldownInEffect) { CooldownActive = true; } } public void StartCooldown() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) PointerEventData val = (buttonSource = new PointerEventData(EventSystem.current)); ((UnityEvent<InputButton>)OnCooldownStart).Invoke(val.button); cooldownTimeRemaining = cooldownTimeout; CooldownActive = (cooldownInEffect = true); } public void StopCooldown() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) cooldownTimeElapsed = CooldownTimeout; cooldownTimeRemaining = 0f; cooldownPercentRemaining = 0; cooldownPercentComplete = 100; cooldownActive = (cooldownInEffect = false); if (OnCoolDownFinish != null) { ((UnityEvent<InputButton>)OnCoolDownFinish).Invoke(buttonSource.button); } } public void CancelCooldown() { cooldownActive = (cooldownInEffect = false); } void IPointerDownHandler.OnPointerDown(PointerEventData eventData) { //IL_0027: 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) buttonSource = eventData; if (CooldownInEffect && OnButtonClickDuringCooldown != null) { ((UnityEvent<InputButton>)OnButtonClickDuringCooldown).Invoke(eventData.button); } if (!CooldownInEffect) { if (OnCooldownStart != null) { ((UnityEvent<InputButton>)OnCooldownStart).Invoke(eventData.button); } cooldownTimeRemaining = cooldownTimeout; cooldownActive = (cooldownInEffect = true); } } } [RequireComponent(typeof(InputField))] [AddComponentMenu("UI/Extensions/InputFocus")] public class InputFocus : MonoBehaviour { protected InputField _inputField; public bool _ignoreNextActivation = false; private void Start() { _inputField = ((Component)this).GetComponent<InputField>(); } private void Update() { if (UIExtensionsInputManager.GetKeyUp((KeyCode)13) && !_inputField.isFocused) { if (_ignoreNextActivation) { _ignoreNextActivation = false; return; } ((Selectable)_inputField).Select(); _inputField.ActivateInputField(); } } public void buttonPressed() { bool flag = _inputField.text == ""; _inputField.text = ""; if (!flag) { ((Selectable)_inputField).Select(); _inputField.ActivateInputField(); } } public void OnEndEdit(string textString) { if (UIExtensionsInputManager.GetKeyDown((KeyCode)13)) { bool flag = _inputField.text == ""; _inputField.text = ""; if (flag) { _ignoreNextActivation = true; } } } } [AddComponentMenu("UI/Extensions/MultiTouchScrollRect")] public class MultiTouchScrollRect : ScrollRect { private int pid = -100; public override void OnBeginDrag(PointerEventData eventData) { pid = eventData.pointerId; ((ScrollRect)this).OnBeginDrag(eventData); } public override void OnDrag(PointerEventData eventData) { if (pid == eventData.pointerId) { ((ScrollRect)this).OnDrag(eventData); } } public override void OnEndDrag(PointerEventData eventData) { pid = -100; ((ScrollRect)this).OnEndDrag(eventData); } } [AddComponentMenu("UI/Extensions/Radial Slider")] [RequireComponent(typeof(Image))] public class RadialSlider : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerDownHandler, IPointerUpHandler, IDragHandler { [Serializable] public class RadialSliderValueChangedEvent : UnityEvent<int> { } [Serializable] public class RadialSliderTextValueChangedEvent : UnityEvent<string> { } private bool isPointerDown; private bool isPointerReleased; private bool lerpInProgress; private Vector2 m_localPos; private Vector2 m_screenPos; private float m_targetAngle; private float m_lerpTargetAngle; private float m_startAngle; private float m_currentLerpTime; private float m_lerpTime; private Camera m_eventCamera; private Image m_image; [SerializeField] [Tooltip("Radial Gradient Start Color")] private Color m_startColor = Color.green; [SerializeField] [Tooltip("Radial Gradient End Color")] private Color m_endColor = Color.red; [Tooltip("Move slider absolute or use Lerping?\nDragging only supported with absolute")] [SerializeField] private bool m_lerpToTarget; [Tooltip("Curve to apply to the Lerp\nMust be set to enable Lerp")] [SerializeField] private AnimationCurve m_lerpCurve; [Tooltip("Event fired when value of control changes, outputs an INT angle value")] [SerializeField] private RadialSliderValueChangedEvent _onValueChanged = new RadialSliderValueChangedEvent(); [Tooltip("Event fired when value of control changes, outputs a TEXT angle value")] [SerializeField] private RadialSliderTextValueChangedEvent _onTextValueChanged = new RadialSliderTextValueChangedEvent(); public float Angle { get { return RadialImage.fillAmount * 360f; } set { if (LerpToTarget) { StartLerp(value / 360f); } else { UpdateRadialImage(value / 360f); } } } public float Value { get { return RadialImage.fillAmount; } set { if (LerpToTarget) { StartLerp(value); } else { UpdateRadialImage(value); } } } public Color EndColor { 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_endColor; } 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_endColor = value; } } public Color StartColor { 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_startColor; } 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_startColor = value; } } public bool LerpToTarget { get { return m_lerpToTarget; } set { m_lerpToTarget = value; } } public AnimationCurve LerpCurve { get { return m_lerpCurve; } set { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) m_lerpCurve = value; Keyframe val = LerpCurve[LerpCurve.length - 1]; m_lerpTime = ((Keyframe)(ref val)).time; } } public bool LerpInProgress => lerpInProgress; public Image RadialImage { get { if ((Object)(object)m_image == (Object)null) { m_image = ((Component)this).GetComponent<Image>(); m_image.type = (Type)3; m_image.fillMethod = (FillMethod)4; m_image.fillAmount = 0f; } return m_image; } } public RadialSliderValueChangedEvent onValueChanged { get { return _onValueChanged; } set { _onValueChanged = value; } } public RadialSliderTextValueChangedEvent onTextValueChanged { get { return _onTextValueChanged; } set { _onTextValueChanged = value; } } private void Awake() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (LerpCurve != null && LerpCurve.length > 0) { Keyframe val = LerpCurve[LerpCurve.length - 1]; m_lerpTime = ((Keyframe)(ref val)).time; } else { m_lerpTime = 1f; } } private void Update() { if (isPointerDown) { m_targetAngle = GetAngleFromMousePoint(); if (!lerpInProgress) { if (!LerpToTarget) { UpdateRadialImage(m_targetAngle); NotifyValueChanged(); } else { if (isPointerReleased) { StartLerp(m_targetAngle); } isPointerReleased = false; } } } if (lerpInProgress && Value != m_lerpTargetAngle) { m_currentLerpTime += Time.deltaTime; float num = m_currentLerpTime / m_lerpTime; if (LerpCurve != null && LerpCurve.length > 0) { UpdateRadialImage(Mathf.Lerp(m_startAngle, m_lerpTargetAngle, LerpCurve.Evaluate(num))); } else { UpdateRadialImage(Mathf.Lerp(m_startAngle, m_lerpTargetAngle, num)); } } if (m_currentLerpTime >= m_lerpTime || Value == m_lerpTargetAngle) { lerpInProgress = false; UpdateRadialImage(m_lerpTargetAngle); NotifyValueChanged(); } } private void StartLerp(float targetAngle) { if (!lerpInProgress) { m_startAngle = Value; m_lerpTargetAngle = targetAngle; m_currentLerpTime = 0f; lerpInProgress = true; } } private float GetAngleFromMousePoint() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)this).transform; RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)(object)((transform is RectTransform) ? transform : null), m_screenPos, m_eventCamera, ref m_localPos); return (Mathf.Atan2(0f - m_localPos.y, m_localPos.x) * 180f / MathF.PI + 180f) / 360f; } private void UpdateRadialImage(float targetAngle) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) RadialImage.fillAmount = targetAngle; ((Graphic)RadialImage).color = Color.Lerp(m_startColor, m_endColor, targetAngle); } private void NotifyValueChanged() { ((UnityEvent<int>)_onValueChanged).Invoke((int)(m_targetAngle * 360f)); ((UnityEvent<string>)_onTextValueChanged).Invoke(((int)(m_targetAngle * 360f)).ToString()); } public void OnPointerEnter(PointerEventData eventData) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) m_screenPos = eventData.position; m_eventCamera = eventData.enterEventCamera; } public void OnPointerDown(PointerEventData eventData) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) m_screenPos = eventData.position; m_eventCamera = eventData.enterEventCamera; isPointerDown = true; } public void OnPointerUp(PointerEventData eventData) { //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) m_screenPos = Vector2.zero; isPointerDown = false; isPointerReleased = true; } public void OnDrag(PointerEventData eventData) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) m_screenPos = eventData.position; } } [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) protected override void OnValidate() { ((Selectable)this).OnValidate(); if (WholeNumbers) { m_MinValue = Mathf.Round(m_MinValue); m_MaxValue = Mathf.Round(m_MaxValue); } if (((UIBehaviour)this).IsActive()) { UpdateCachedReferences(); SetLow(m_LowValue, sendCallback: false); SetHigh(m_HighValue, sendCallback: false); m_DelayedUpdateVisuals = true; } if (!PrefabUtility.IsPartOfPrefabAsset((Object)(object)this) && !Application.isPlaying) { CanvasUpdateRegistry.RegisterCanvasElementForLayoutRebuild((ICanvasElement)(object)this); } } public virtual void Rebuild(CanvasUpdate executing) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)executing == 0) { ((UnityEvent<float, float>)OnValueChanged).Invoke(LowValue, HighValue); } } 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) if (!Application.isPlaying) { UpdateCachedReferences(); } ((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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) 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