Decompiled source of Rune Magic v1.2.0
RuneMagic.dll
Decompiled 6 months 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.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Net; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using HarmonyLib; using SoftReferenceableAssets; using Steamworks; using TMPro; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; using ValheimMod.External; using ValheimMod.External.MiniJSON; using ValheimMod.Monobehaviours; using ValheimMod.Monobehaviours.Runes; using ValheimMod.Patches; using ValheimMod.Profiling; using ValheimMod.ScriptableObjects; using ValheimMod.Setup; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ValheimMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ValheimMod")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("a1efb0fd-0465-47c9-8041-8ba880e78354")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] public class DeferredDecalSystem { private static DeferredDecalSystem m_Instance; internal HashSet<Decal> m_DecalsDiffuse = new HashSet<Decal>(); internal HashSet<Decal> m_DecalsNormals = new HashSet<Decal>(); internal HashSet<Decal> m_DecalsBoth = new HashSet<Decal>(); public static DeferredDecalSystem instance { get { if (m_Instance == null) { m_Instance = new DeferredDecalSystem(); } return m_Instance; } } public void AddDecal(Decal d) { RemoveDecal(d); } public void RemoveDecal(Decal d) { m_DecalsDiffuse.Remove(d); m_DecalsNormals.Remove(d); m_DecalsBoth.Remove(d); } } [ExecuteInEditMode] public class DeferredDecalRenderer : MonoBehaviour { public Mesh m_CubeMesh; private Dictionary<Camera, CommandBuffer> m_Cameras = new Dictionary<Camera, CommandBuffer>(); public void OnDisable() { foreach (KeyValuePair<Camera, CommandBuffer> camera in m_Cameras) { if (Object.op_Implicit((Object)(object)camera.Key)) { camera.Key.RemoveCommandBuffer((CameraEvent)6, camera.Value); } } } public void OnWillRenderObject() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) if (!((Component)this).gameObject.activeInHierarchy || !((Behaviour)this).enabled) { OnDisable(); return; } Camera current = Camera.current; if (!Object.op_Implicit((Object)(object)current)) { return; } CommandBuffer val = null; if (m_Cameras.ContainsKey(current)) { val = m_Cameras[current]; val.Clear(); } else { val = new CommandBuffer(); val.name = "Deferred decals"; m_Cameras[current] = val; current.AddCommandBuffer((CameraEvent)6, val); } DeferredDecalSystem instance = DeferredDecalSystem.instance; int num = Shader.PropertyToID("_NormalsCopy"); val.GetTemporaryRT(num, -1, -1); val.Blit(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)12), RenderTargetIdentifier.op_Implicit(num)); val.SetRenderTarget(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)10), RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2)); foreach (Decal item in instance.m_DecalsDiffuse) { val.DrawMesh(m_CubeMesh, ((Component)item).transform.localToWorldMatrix, item.m_Material); } val.SetRenderTarget(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)12), RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2)); foreach (Decal decalsNormal in instance.m_DecalsNormals) { val.DrawMesh(m_CubeMesh, ((Component)decalsNormal).transform.localToWorldMatrix, decalsNormal.m_Material); } RenderTargetIdentifier[] array = (RenderTargetIdentifier[])(object)new RenderTargetIdentifier[2] { RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)10), RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)12) }; val.SetRenderTarget(array, RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2)); foreach (Decal item2 in instance.m_DecalsBoth) { val.DrawMesh(m_CubeMesh, ((Component)item2).transform.localToWorldMatrix, item2.m_Material); } val.ReleaseTemporaryRT(num); } } namespace ValheimMod { public class Analytics { private class AnalyticsData { private Dictionary<string, string> data = new Dictionary<string, string>(); public string this[string key] { get { return data[key]; } set { data[key] = value; } } public void Add(string name, string value) { if (data.ContainsKey(name)) { throw new Exception("Attempting to send duplicate key: " + name); } if (name.Contains(",") || value.Contains(",")) { throw new Exception("Entry " + name + ":" + value + " contains commas"); } data.Add(name, value); } public bool ContainsKey(string name) { return data.ContainsKey(name); } public Dictionary<string, string> getDataForPost() { HashSet<string> hashSet = new HashSet<string>(); string text = ""; string text2 = ""; List<string> list = data.Keys.OrderBy((string k) => k).ToList(); foreach (string item in list) { text = text + item + ","; text2 = text2 + data[item] + ","; ValheimMod.DevModeLog(item + ":" + data[item]); } if (text.EndsWith(",")) { text = text.Substring(0, text.Length - 1); text2 = text2.Substring(0, text2.Length - 1); } ValheimMod.DevModeLog("Body size (bytes): " + Encoding.UTF8.GetByteCount(text2)); Dictionary<string, string> dictionary = new Dictionary<string, string>(); dictionary.Add("header", text); dictionary.Add("body", text2); return dictionary; } } private const string PLAYER_PREFS_UUID_KEY = "runemagic-uuid"; private readonly List<string> CONFIG_ENTRIES_TO_SEND = new List<string> { "RepairRune_HealRate", "RepairRune_EffectRadius", "runestoneMaxStoredEnergy", "runestoneSecondsToFullCharge", "runestoneUnlockNewRuneChance" }; private Dictionary<string, int> placedRunes = new Dictionary<string, int>(); private Dictionary<string, int> removedRunes = new Dictionary<string, int>(); private Dictionary<string, List<string>> terminalCommandsRun = new Dictionary<string, List<string>>(); private Dictionary<string, float> passiveRuneActiveTime = new Dictionary<string, float>(); public bool otherPlayersConnected; public bool wasPvpDamageTaken; public HashSet<string> exceptions = new HashSet<string>(); private Dictionary<string, string> uniqueEngravedRunesLoaded = new Dictionary<string, string>(); public Analytics() { foreach (string analyticsPieceName in ValheimMod.getAnalyticsPieceNames()) { if (!placedRunes.ContainsKey(analyticsPieceName)) { placedRunes.Add(analyticsPieceName, 0); } } foreach (string engravedRunePrefabName in ValheimMod.getEngravedRunePrefabNames()) { removedRunes.Add(engravedRunePrefabName, 0); } terminalCommandsRun.Add("discoverRune", new List<string>()); terminalCommandsRun.Add("forgetRune", new List<string>()); foreach (StatusEffect registeredStatusEffect in CustomContentSetupHandler.RegisteredStatusEffects) { passiveRuneActiveTime.Add(((Object)registeredStatusEffect).name, 0f); if (((object)registeredStatusEffect).GetType() == typeof(SE_WaterWalking)) { passiveRuneActiveTime.Add(((Object)registeredStatusEffect).name + "-hot", 0f); passiveRuneActiveTime.Add(((Object)registeredStatusEffect).name + "-cold", 0f); passiveRuneActiveTime.Add(((Object)registeredStatusEffect).name + "-lava", 0f); } } } public void piecePlaced(string name) { if (placedRunes.ContainsKey(name)) { placedRunes[name]++; } } public void engravedRuneRemoved(string name) { if (removedRunes.ContainsKey(name)) { removedRunes[name]++; } } public void registerUniqueRune(string name, ZDO zdo) { uniqueEngravedRunesLoaded[((object)(ZDOID)(ref zdo.m_uid)).ToString()] = name; } public void terminalCommandRun(string command, string args) { if (terminalCommandsRun.ContainsKey(command)) { terminalCommandsRun[command].Add(args); } } public void updatePassiveRuneTime(StatusEffect se, float dt) { if (passiveRuneActiveTime.ContainsKey(((Object)se).name)) { passiveRuneActiveTime[((Object)se).name] += dt; if (((object)se).GetType() == typeof(SE_WaterWalking)) { bool flag = IceTimedDestruction.anyInstancesActiveForPlayer(Player.m_localPlayer); bool flag2 = se.m_character.InLava(); bool flag3 = SE_WaterWalking.latestHotWaterFactor > 0f && flag; bool flag4 = SE_WaterWalking.latestColdWaterFactor > 0f && flag; passiveRuneActiveTime[((Object)se).name + "-hot"] += (flag3 ? dt : 0f); passiveRuneActiveTime[((Object)se).name + "-cold"] += (flag4 ? dt : 0f); passiveRuneActiveTime[((Object)se).name + "-lava"] += (flag2 ? dt : 0f); } } } public void sendAnalytics() { try { AnalyticsData analyticsData = getAnalyticsData(); postDataAsync(ConfigLoader.getString("analytics_address"), analyticsData.getDataForPost()); } catch (Exception ex) { sendErrorAnalytics(ex); } ValheimMod.analytics = new Analytics(); } private void sendErrorAnalytics(Exception ex) { try { Dictionary<string, string> dictionary = new Dictionary<string, string>(); dictionary.Add("analyticsFailure", getVersion() + " : " + getValheimVersion() + " : " + ex.ToString().Replace(',', '_')); postDataAsync(ConfigLoader.getString("analytics_error_address"), dictionary); } catch (Exception ex2) { ValheimMod.DevModeLog(ex2); } } private void postDataAsync(string address, Dictionary<string, string> data) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address); request.ContentType = "application/x-www-form-urlencoded"; request.Method = "POST"; byte[] bytes = FormUrlEncoder.GetContentByteArray(data); request.BeginGetRequestStream(delegate(IAsyncResult ar) { try { Stream stream = request.EndGetRequestStream(ar); stream.Write(bytes, 0, bytes.Length); stream.Close(); using ((HttpWebResponse)request.GetResponse()) { } } catch (Exception) { } }, null); } private AnalyticsData getAnalyticsData() { AnalyticsData analyticsData = new AnalyticsData(); appendPlacedAndRemovedRunes(analyticsData); appendUniqueEngravedRunes(analyticsData); appendConfigEntries(analyticsData); appendPassiveRuneTimes(analyticsData); analyticsData.Add("version", getVersion()); analyticsData.Add("isPTR", toString(isPTRBranch())); analyticsData.Add("valheimVersion", getValheimVersion()); analyticsData.Add("worldUid", getWorldUid()); bool flag = ZNet.instance.IsServer(); analyticsData.Add("isMultiplayerServer", toString(flag && otherPlayersConnected)); analyticsData.Add("isMultiplayerClient", toString(!flag)); string value = (((Object)(object)Player.m_localPlayer != (Object)null) ? toString(((Character)Player.m_localPlayer).IsPVPEnabled()) : "N/A"); analyticsData.Add("pvp", value); analyticsData.Add("numRuneFocus", getRuneFocusCount().ToString()); analyticsData.Add("uniqueId", getUniqueId()); analyticsData.Add("pvpDmg", toString(wasPvpDamageTaken)); analyticsData.Add("allUnlocked", toString(ConfigLoader.getBool("allRunesStartUnlocked"))); analyticsData.Add("canopyHidden", toString(ConfigLoader.getInt("canopyRune_visualQuality") == 0)); analyticsData.Add("canopyQuality", ConfigLoader.getInt("canopyRune_visualQuality").ToString()); analyticsData.Add("rangeExtensionOff", toString(ConfigLoader.getBool("disableRangeExtensionForLargePieces"))); appendEngravedRunes(analyticsData); analyticsData.Add("exceptions", string.Join(" +++ ", exceptions).Replace("\n", "\\n").Replace("\r", "\\r") .Replace(',', '_')); return analyticsData; } private void appendEngravedRunes(AnalyticsData holder) { foreach (string engravedRunePrefabName in ValheimMod.getEngravedRunePrefabNames()) { List<ZDO> list = new List<ZDO>(); int num = 0; while (!ZDOMan.instance.GetAllZDOsWithPrefabIterative(engravedRunePrefabName, list, ref num)) { } holder.Add("worldCount-" + engravedRunePrefabName, list.Count().ToString()); } } private void appendPlacedAndRemovedRunes(AnalyticsData holder) { foreach (string key in placedRunes.Keys) { holder.Add("placed-" + key, placedRunes[key].ToString()); } foreach (string key2 in removedRunes.Keys) { holder.Add("removed-" + key2, removedRunes[key2].ToString()); } } private void appendUniqueEngravedRunes(AnalyticsData holder) { foreach (string engravedRunePrefabName in ValheimMod.getEngravedRunePrefabNames()) { holder.Add("uniqueLoaded-" + engravedRunePrefabName, "0"); } foreach (string key in uniqueEngravedRunesLoaded.Keys) { string text = uniqueEngravedRunesLoaded[key]; string text2 = "uniqueLoaded-" + text; if (holder.ContainsKey(text2)) { holder[text2] = (int.Parse(holder[text2]) + 1).ToString(); } } } private void appendConfigEntries(AnalyticsData holder) { foreach (string key in terminalCommandsRun.Keys) { holder.Add("cmd-" + key, string.Join(":", terminalCommandsRun[key])); } foreach (RunemagicPieceConfig runemagicPieceConfig in ValheimMod.runemagicPieceConfigs) { bool value = runemagicPieceConfig.isEnabled(); holder.Add("enabled-" + runemagicPieceConfig.pieceName, toString(value)); if (ConfigLoader.containsKey("energyCost_" + runemagicPieceConfig.pieceName)) { holder.Add("energyCost-" + runemagicPieceConfig.pieceName, ConfigLoader.getString("energyCost_" + runemagicPieceConfig.pieceName)); } } foreach (string item in CONFIG_ENTRIES_TO_SEND) { holder.Add("cfg-" + item, ConfigLoader.getString(item)); } } private void appendPassiveRuneTimes(AnalyticsData holder) { foreach (string key in passiveRuneActiveTime.Keys) { holder.Add("passiveInUse-" + key, Mathf.RoundToInt(passiveRuneActiveTime[key]).ToString()); } } private static string getVersion() { string text = "1.2.0"; if (ValheimMod.PLATFORM == ValheimMod.Platform.NEXUS_MODS) { text += "-NM"; } else if (ValheimMod.PLATFORM == ValheimMod.Platform.THUNDERSTORE) { text += "-TS"; } if (ValheimMod.DEV_MODE) { text += "-devmode"; } return text; } private string getUniqueId() { if (!PlayerPrefs.HasKey("runemagic-uuid")) { PlayerPrefs.SetString("runemagic-uuid", Guid.NewGuid().ToString()); } return PlayerPrefs.GetString("runemagic-uuid"); } private string toString(bool value) { if (!value) { return "f"; } return "t"; } private int getRuneFocusCount() { if ((Object)(object)Player.m_localPlayer == (Object)null || ((Humanoid)Player.m_localPlayer).GetInventory() == null) { return 0; } Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); return inventory.CountItems("$item_runemagic_runefocus", -1, true); } private string getValheimVersion() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) try { GameVersion currentVersion = Version.CurrentVersion; string text = ((object)(GameVersion)(ref currentVersion)).ToString(); if (isPTRBranch()) { text += "-ptr"; } return text; } catch (Exception ex) { ValheimMod.DevModeLog(ex); } return "unknown"; } private bool isPTRBranch() { return getBranch().Equals("public-test"); } private string getBranch() { try { string result = default(string); if (SteamApps.GetCurrentBetaName(ref result, 512)) { return result; } return ""; } catch (Exception) { return "unknown"; } } private string getWorldUid() { if (ZNetPatch.CurrentWorldUID != 0L) { byte[] bytes = BitConverter.GetBytes(ZNetPatch.CurrentWorldUID); return Convert.ToBase64String(bytes); } return ""; } } internal class BoundingCircle { public Vector2 center; public float radius; public BoundingCircle(Vector2 center, float radius) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) this.center = center; this.radius = radius; } public BoundingCircle(float x, float y, float radius) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) center = new Vector2(x, y); this.radius = radius; } public static BoundingCircle minimumCircle(IEnumerable<Vector2> points) { HashSet<Vector2> points2 = new HashSet<Vector2>(points); return welzlInner(points2, new HashSet<Vector2>()); } private static BoundingCircle welzlInner(HashSet<Vector2> points, HashSet<Vector2> boundary) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (points.Count() == 0 || boundary.Count() == 3) { return trivial(boundary); } Vector2 val = points.First(); points.Remove(val); BoundingCircle boundingCircle = welzlInner(points, boundary); if (boundingCircle.contains(val)) { points.Add(val); return boundingCircle; } boundary.Add(val); BoundingCircle result = welzlInner(points, boundary); points.Add(val); boundary.Remove(val); return result; } public bool contains(Vector2 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) float num = p.x - center.x; float num2 = p.y - center.y; return num * num + num2 * num2 < radius * radius; } public static BoundingCircle trivial(IEnumerable<Vector2> points) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) List<Vector2> list = new List<Vector2>(points); if (points.Count() == 3) { return trivial3(list[0], list[1], list[2]); } if (points.Count() == 2) { return trivial2(list[0], list[1]); } if (points.Count() == 1) { return new BoundingCircle(list[0], 0f); } if (points.Count() == 0) { return new BoundingCircle(0f, 0f, 0f); } throw new Exception("Can't have a trivial circle with more than 3 points: " + points.Count()); } public static BoundingCircle trivial2(Vector2 a, Vector2 b) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0058: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor((a.x + b.x) / 2f, (a.y + b.y) / 2f); float num = a.x - val.x; float num2 = a.y - val.y; float num3 = (float)Math.Sqrt(num * num + num2 * num2); return new BoundingCircle(val, num3); } public static BoundingCircle trivial3(Vector2 a, Vector2 b, Vector2 c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0048: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_0120: 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) float num = b.x - a.x; float num2 = b.y - a.y; float num3 = c.x - a.x; float num4 = c.y - a.y; float num5 = num * (a.x + b.x) + num2 * (a.y + b.y); float num6 = num3 * (a.x + c.x) + num4 * (a.y + c.y); float num7 = 2f * (num * (c.y - b.y) - num2 * (c.x - b.x)); float num10; float num11; if ((double)Math.Abs(num7) < 1E-06) { float num8 = Math.Min(a.x, Math.Min(b.x, c.x)); float num9 = Math.Min(a.y, Math.Min(b.y, c.y)); num10 = (Math.Max(a.x, Math.Max(b.x, c.x)) - num8) * 0.5f; num11 = (Math.Max(a.y, Math.Max(b.y, c.y)) - num9) * 0.5f; return new BoundingCircle(num8 + num10, num9 + num11, (float)Math.Sqrt(num10 * num10 + num11 * num11)); } float num12 = (num4 * num5 - num2 * num6) / num7; float num13 = (num * num6 - num3 * num5) / num7; num10 = num12 - a.x; num11 = num13 - a.y; float num14 = (float)Math.Sqrt(num10 * num10 + num11 * num11); return new BoundingCircle(num12, num13, num14); } } public class BoundingSphere { public Vector3 center; public float radius; public BoundingSphere(Vector3 aCenter, float aRadius) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) center = aCenter; radius = aRadius; } public static BoundingSphere Calculate(Renderer rend) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = rend.bounds; Vector3 aCenter = ((Bounds)(ref bounds)).center; bounds = rend.bounds; Vector3 extents = ((Bounds)(ref bounds)).extents; float magnitude = ((Vector3)(ref extents)).magnitude; return new BoundingSphere(aCenter, magnitude); } public static BoundingSphere Calculate(GameObject obj) { Renderer[] componentsInChildren = obj.GetComponentsInChildren<Renderer>(true); BoundingSphere boundingSphere = null; Renderer[] array = componentsInChildren; foreach (Renderer rend in array) { if (boundingSphere == null) { boundingSphere = Calculate(rend); continue; } BoundingSphere boundingSphere2 = Calculate(rend); if (boundingSphere2.radius > boundingSphere.radius) { boundingSphere = boundingSphere2; } } return boundingSphere; } public static BoundingSphere Calculate(Transform xform, IEnumerable<Vector3> aPoints) { //IL_0000: 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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_006e: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_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) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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_0132: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) Vector3 val2; Vector3 val; Vector3 val3 = (val2 = (val = Vector3.one * float.PositiveInfinity)); Vector3 val5; Vector3 val4; Vector3 val6 = (val5 = (val4 = Vector3.one * float.NegativeInfinity)); foreach (Vector3 aPoint in aPoints) { Vector3 val7 = xform.TransformPoint(aPoint); if (val7.x < val3.x) { val3 = val7; } if (val7.x > val6.x) { val6 = val7; } if (val7.y < val2.y) { val2 = val7; } if (val7.y > val5.y) { val5 = val7; } if (val7.z < val.z) { val = val7; } if (val7.z > val4.z) { val4 = val7; } } Vector3 val8 = val6 - val3; float sqrMagnitude = ((Vector3)(ref val8)).sqrMagnitude; val8 = val5 - val2; float sqrMagnitude2 = ((Vector3)(ref val8)).sqrMagnitude; val8 = val4 - val; float sqrMagnitude3 = ((Vector3)(ref val8)).sqrMagnitude; Vector3 val9 = val3; Vector3 val10 = val6; float num = sqrMagnitude; if (sqrMagnitude2 > num) { num = sqrMagnitude2; val9 = val2; val10 = val5; } if (sqrMagnitude3 > num) { val9 = val; val10 = val4; } Vector3 val11 = (val9 + val10) * 0.5f; val8 = val10 - val11; float num2 = ((Vector3)(ref val8)).sqrMagnitude; float num3 = Mathf.Sqrt(num2); foreach (Vector3 aPoint2 in aPoints) { Vector3 val12 = xform.TransformPoint(aPoint2); val8 = val12 - val11; float sqrMagnitude4 = ((Vector3)(ref val8)).sqrMagnitude; if (sqrMagnitude4 > num2) { float num4 = Mathf.Sqrt(sqrMagnitude4); num3 = (num3 + num4) * 0.5f; num2 = num3 * num3; float num5 = num4 - num3; val11 = (num3 * val11 + num5 * val12) / num4; } } return new BoundingSphere(val11, num3); } } public static class ExtensionMethods { public static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> container, TKey key, TValue defaultValue) { if (!container.ContainsKey(key)) { return defaultValue; } return container[key]; } public static void AddToKey<TKey>(this IDictionary<TKey, int> container, TKey key, int toAdd) { container[key] = container.GetValueOrDefault(key, 0) + toAdd; } public static void AddToKey<TKey>(this IDictionary<TKey, float> container, TKey key, float toAdd) { container[key] = container.GetValueOrDefault(key, 0f) + toAdd; } public static void AddToKey<TKey>(this IDictionary<TKey, double> container, TKey key, double toAdd) { container[key] = container.GetValueOrDefault(key, 0.0) + toAdd; } public static bool ContainsRegex(this IList<string> container, string keyRegex) { Regex regex = new Regex(keyRegex); foreach (string item in container) { Match match = regex.Match(item); if (match.Success) { return true; } } return false; } public static void Merge(this IDictionary<string, Measurement> dict, IDictionary<string, Measurement> other) { foreach (string key in other.Keys) { if (!dict.ContainsKey(key)) { dict.Add(key, other[key]); } else { dict[key].Merge(other[key]); } } } public static string RemoveWhitespace(this string str) { return string.Join("", str.Split((string[]?)null, StringSplitOptions.RemoveEmptyEntries)); } public static Vector2 GetXZVector(this Vector3 vec) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return new Vector2(vec.x, vec.z); } } internal class ColorUtils { private const byte k_MaxByteForOverexposedColor = 191; public static void DecomposeHdrColor(Color linearColorHdr, out Color32 baseLinearColor, out float exposure) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) baseLinearColor = Color32.op_Implicit(linearColorHdr); float maxColorComponent = ((Color)(ref linearColorHdr)).maxColorComponent; if (maxColorComponent == 0f || (maxColorComponent <= 1f && maxColorComponent >= 0.003921569f)) { exposure = 0f; baseLinearColor.r = (byte)Mathf.RoundToInt(linearColorHdr.r * 255f); baseLinearColor.g = (byte)Mathf.RoundToInt(linearColorHdr.g * 255f); baseLinearColor.b = (byte)Mathf.RoundToInt(linearColorHdr.b * 255f); } else { float num = 191f / maxColorComponent; exposure = Mathf.Log(255f / num) / Mathf.Log(2f); baseLinearColor.r = Math.Min((byte)191, (byte)Mathf.CeilToInt(num * linearColorHdr.r)); baseLinearColor.g = Math.Min((byte)191, (byte)Mathf.CeilToInt(num * linearColorHdr.g)); baseLinearColor.b = Math.Min((byte)191, (byte)Mathf.CeilToInt(num * linearColorHdr.b)); } } public static Color fromHSVVector(Vector4 vec, bool zeroToOne) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (!zeroToOne) { vec.x /= 360f; vec.y /= 100f; vec.z /= 100f; vec.w /= 100f; } Color result = Color.HSVToRGB(vec.x, vec.y, vec.z); result.a = vec.w; return result; } public static Color applyIntensity(Color color, float intensity) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Pow(2f, intensity); return color * num; } public static Color fromVec(Vector4 vec) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new Color(vec.x, vec.y, vec.z, vec.w); } public static Texture2D duplicateTexture(Texture2D source) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) RenderTexture temporary = RenderTexture.GetTemporary(((Texture)source).width, ((Texture)source).height, 0, (RenderTextureFormat)7, (RenderTextureReadWrite)1); Graphics.Blit((Texture)(object)source, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val = new Texture2D(((Texture)source).width, ((Texture)source).height); val.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); return val; } } public class DebugUtils { public static void LogIfNearPlayer(string content, Vector3 pos, float distance = 10f) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Player.m_localPlayer == (Object)null) && Utils.DistanceSqr(((Component)Player.m_localPlayer).transform.position, pos) <= distance * distance) { Debug.Log((object)content); } } private static void getDebugObjectDetails() { PlayerRaycast playerRaycast = new PlayerRaycast(Player.m_localPlayer); if (playerRaycast.hit) { if ((Object)(object)((RaycastHit)(ref playerRaycast.hitInfo)).collider != (Object)null) { GameObject gameObject = ((Component)((RaycastHit)(ref playerRaycast.hitInfo)).collider).gameObject; printCompleteGameObject(gameObject); } else { Debug.Log((object)"Raycast returned true, but no hit"); } } else { Debug.Log((object)"Raycast returned false"); } } public static void printCompleteGameObject(GameObject obj) { while ((Object)(object)obj.transform.parent != (Object)null && !((Object)((Component)obj.transform.parent).gameObject).name.Equals("_NetSceneRoot")) { obj = ((Component)obj.transform.parent).gameObject; } printGameObjectDebugInfoHierarchy(obj, 0); } public static void printGameObjectDebugInfoHierarchy(GameObject obj, int level) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown string text = new string(' ', level * 6); if ((Object)(object)obj == (Object)null) { Debug.Log((object)(text + "Gameobject is null")); return; } printGameObjectDebugInfo(text, obj); if (obj.transform.childCount < 100) { foreach (Transform item in obj.transform) { Transform val = item; printGameObjectDebugInfoHierarchy(((Component)val).gameObject, level + 1); } return; } Debug.Log((object)$"Too many children: {obj.transform.childCount}"); } public static void printGameObjectDebugInfo(string prefix, GameObject obj) { //IL_002e: 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) Debug.Log((object)$"{prefix}Gameobject: {((Object)obj).name}, active {obj.activeInHierarchy}, localPos {obj.transform.localPosition}, worldPos {obj.transform.position}"); Debug.Log((object)$"{prefix}Layer: {obj.layer}, name: {LayerMask.LayerToName(obj.layer)}"); Component[] components = obj.GetComponents(typeof(Component)); Component[] array = components; foreach (Component val in array) { if (((object)val).ToString().Contains("(UnityEngine.Transform)")) { continue; } Debug.Log((object)(prefix + " Attached component: " + ((object)val).ToString())); Renderer val2 = (Renderer)(object)((val is Renderer) ? val : null); if (val2 != null) { Material[] materials = val2.materials; foreach (Material val3 in materials) { Debug.Log((object)(prefix + "Material " + ((Object)val3).name + " Shader: " + ((Object)val3.shader).name)); } } } } public static void printParticleSystemDebugInfoHierarchy(GameObject obj, int level = 0) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown string text = new string(' ', level * 6); if ((Object)(object)obj == (Object)null) { Debug.Log((object)(text + "Gameobject is null")); return; } printParticleSystemDebugInfo(text, obj); if (obj.transform.childCount < 100) { foreach (Transform item in obj.transform) { Transform val = item; printParticleSystemDebugInfoHierarchy(((Component)val).gameObject, level + 1); } return; } Debug.Log((object)$"Too many children: {obj.transform.childCount}"); } public static void printParticleSystemDebugInfo(string prefix, GameObject obj) { //IL_004a: 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_007a: 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_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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_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_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)$"{prefix}Gameobject: {((Object)obj).name}, active {obj.activeInHierarchy}, activeSelf {obj.activeSelf}"); Debug.Log((object)$"{prefix} localPos {obj.transform.localPosition}, worldPos {obj.transform.position}"); Debug.Log((object)$"{prefix} localRot {obj.transform.localEulerAngles}, worldRot {obj.transform.eulerAngles}"); ParticleSystem[] components = obj.GetComponents<ParticleSystem>(); ParticleSystem[] array = components; foreach (ParticleSystem val in array) { Debug.Log((object)$"{prefix} playing {val.isPlaying}, paused {val.isPaused}, stopped {val.isStopped}, emitting {val.isEmitting}, alive {val.IsAlive()}"); MainModule main = val.main; EmissionModule emission = val.emission; object[] obj2 = new object[4] { prefix, ((MainModule)(ref main)).maxParticles, val.particleCount, null }; MinMaxCurve rateOverTime = ((EmissionModule)(ref emission)).rateOverTime; obj2[3] = ((MinMaxCurve)(ref rateOverTime)).constant; Debug.Log((object)string.Format("{0} maxParticles {1}, current# {2}, emission {3}", obj2)); Debug.Log((object)$"{prefix} culling {((MainModule)(ref main)).cullingMode} emissionEnabled {((EmissionModule)(ref emission)).enabled}"); CustomDataModule customData = val.customData; if (((CustomDataModule)(ref customData)).enabled) { MinMaxGradient color = ((CustomDataModule)(ref customData)).GetColor((ParticleSystemCustomData)0); MinMaxGradient color2 = ((CustomDataModule)(ref customData)).GetColor((ParticleSystemCustomData)1); Debug.Log((object)(prefix + " CustomData: Grad1: " + minMaxGradientToString(color) + " Grad2: " + minMaxGradientToString(color2))); } else { Debug.Log((object)(prefix + " CustomData disabled")); } } ParticleSystemRenderer component = obj.GetComponent<ParticleSystemRenderer>(); if ((Object)(object)component == (Object)null) { Debug.Log((object)(prefix + " null ParticleSystemRenderer")); return; } List<ParticleSystemVertexStream> list = new List<ParticleSystemVertexStream>(); component.GetActiveVertexStreams(list); foreach (ParticleSystemVertexStream item in list) { ParticleSystemVertexStream current = item; Debug.Log((object)(prefix + " VertexData: " + ((object)(ParticleSystemVertexStream)(ref current)).ToString())); } } public static string minMaxGradientToString(MinMaxGradient mmg) { //IL_0002: 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_0028: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Invalid comparison between Unknown and I4 if ((int)((MinMaxGradient)(ref mmg)).mode == 0) { return $"MinMaxGradient({((MinMaxGradient)(ref mmg)).color})"; } if ((int)((MinMaxGradient)(ref mmg)).mode == 2) { return $"MinMaxGradient({((MinMaxGradient)(ref mmg)).colorMin}, {((MinMaxGradient)(ref mmg)).colorMax})"; } if ((int)((MinMaxGradient)(ref mmg)).mode == 1) { return "MinMaxGradient(alpha " + string.Join(",", ((MinMaxGradient)(ref mmg)).gradient.alphaKeys.Select((GradientAlphaKey x) => gradientKeyToString(x))) + " : color " + string.Join(",", ((MinMaxGradient)(ref mmg)).gradient.colorKeys.Select((GradientColorKey x) => gradientKeyToString(x))) + ")"; } if ((int)((MinMaxGradient)(ref mmg)).mode == 3) { return "MinMaxGradient(alpha1 " + string.Join(",", ((MinMaxGradient)(ref mmg)).gradientMin.alphaKeys.Select((GradientAlphaKey x) => gradientKeyToString(x))) + " : color1 " + string.Join(",", ((MinMaxGradient)(ref mmg)).gradientMin.colorKeys.Select((GradientColorKey x) => gradientKeyToString(x))) + " : alpha2 " + string.Join(",", ((MinMaxGradient)(ref mmg)).gradientMax.alphaKeys.Select((GradientAlphaKey x) => gradientKeyToString(x))) + " : color2 " + string.Join(",", ((MinMaxGradient)(ref mmg)).gradientMax.colorKeys.Select((GradientColorKey x) => gradientKeyToString(x))) + ")"; } return "MinMaxGradient(RandomColor)"; } public static string gradientKeyToString(GradientAlphaKey key) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) return "{" + $"{key.alpha}:{key.time:0.##}" + "}"; } public static string gradientKeyToString(GradientColorKey key) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) return "{" + $"{key.color}:{key.time:0.##}" + "}"; } public static void deepObjectComparison(object a, object b) { List<string> list = new List<string>(); foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(a)) { string name = property.Name; list.Add(name); object value = property.GetValue(a); object value2 = property.GetValue(b); Debug.Log((object)$"{name}: {value} | {value2}"); } foreach (PropertyDescriptor property2 in TypeDescriptor.GetProperties(b)) { string name2 = property2.Name; if (!list.Contains(name2)) { object value3 = property2.GetValue(a); object value4 = property2.GetValue(b); Debug.Log((object)$"{name2}: {value3} | {value4}"); } } } public static void DrawLine(Vector3 start, Vector3 end, Color color, float duration = 5f) { } public static void DrawRay(Vector3 start, Vector3 dir, Color color, float duration = 5f) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (ValheimMod.DEV_MODE) { DrawLine(start, start + dir, color, duration); } } public static void DrawBounds(Bounds bounds, Color color, float duration = 5f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) DrawBounds(bounds, color, color, color, duration); } public static void DrawBounds(Bounds bounds, Color top, Color bottom, Color sides, float duration = 5f) { } public static void DrawWireSphere(Vector3 center, float radius, Color color, float duration) { } public static void DrawWireDisc(Vector3 center, float radius, Color color, float duration) { } public static GameObject addDebugLocatorVFX(Vector3 position) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown if (!ValheimMod.DEV_MODE) { return new GameObject(); } GameObject prefabFromAssetBundle = AssetLoader.GetPrefabFromAssetBundle("vfx_DebugLocator"); return Object.Instantiate<GameObject>(prefabFromAssetBundle, position, Quaternion.identity); } public static RaycastHit debugRaycast(Player player, bool ignoreRigidbody, int layerMask = -1) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) if (layerMask == -1) { layerMask = (int)Traverse.Create((object)player).Field("m_placeRayMask").GetValue(); } Transform eye = ((Character)player).m_eye; float maxPlaceDistance = player.m_maxPlaceDistance; RaycastHit result = default(RaycastHit); if (Physics.Raycast(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, ref result, 50f, layerMask) && Object.op_Implicit((Object)(object)((RaycastHit)(ref result)).collider) && (ignoreRigidbody || !Object.op_Implicit((Object)(object)((RaycastHit)(ref result)).collider.attachedRigidbody)) && Vector3.Distance(eye.position, ((RaycastHit)(ref result)).point) < maxPlaceDistance) { return result; } return default(RaycastHit); } } internal class DecalManager { private static Dictionary<Camera, CommandBuffer> bufferMap = new Dictionary<Camera, CommandBuffer>(); public static void registerCamera(Camera cam) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown if (!bufferMap.ContainsKey(cam)) { CommandBuffer val = new CommandBuffer(); val.name = "Deferred decals"; bufferMap[cam] = val; cam.AddCommandBuffer((CameraEvent)20, val); } } public static CommandBuffer getBuffer(Camera cam) { return bufferMap[cam]; } } internal class GameObjectUtils { public static ParticleSystem CopyParticleSystem(ParticleSystem original, GameObject destination) { //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) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00c5: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_0109: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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_013c: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) ParticleSystem val = GameObjectUtils.CopyComponent<ParticleSystem>(original, destination); ParticleSystemRenderer val2 = GameObjectUtils.CopyComponent<ParticleSystemRenderer>(((Component)original).gameObject.GetComponent<ParticleSystemRenderer>(), destination); CopyFields<MainModule>(original.main, val.main); CopyFields<EmissionModule>(original.emission, val.emission); CopyFields<ShapeModule>(original.shape, val.shape); CopyFields<VelocityOverLifetimeModule>(original.velocityOverLifetime, val.velocityOverLifetime); CopyFields<LimitVelocityOverLifetimeModule>(original.limitVelocityOverLifetime, val.limitVelocityOverLifetime); CopyFields<InheritVelocityModule>(original.inheritVelocity, val.inheritVelocity); CopyFields<ForceOverLifetimeModule>(original.forceOverLifetime, val.forceOverLifetime); CopyFields<ColorOverLifetimeModule>(original.colorOverLifetime, val.colorOverLifetime); CopyFields<ColorBySpeedModule>(original.colorBySpeed, val.colorBySpeed); CopyFields<SizeOverLifetimeModule>(original.sizeOverLifetime, val.sizeOverLifetime); CopyFields<SizeBySpeedModule>(original.sizeBySpeed, val.sizeBySpeed); CopyFields<RotationOverLifetimeModule>(original.rotationOverLifetime, val.rotationOverLifetime); CopyFields<RotationBySpeedModule>(original.rotationBySpeed, val.rotationBySpeed); CopyFields<ExternalForcesModule>(original.externalForces, val.externalForces); CopyFields<NoiseModule>(original.noise, val.noise); CopyFields<CollisionModule>(original.collision, val.collision); CopyFields<TriggerModule>(original.trigger, val.trigger); CopyFields<TextureSheetAnimationModule>(original.textureSheetAnimation, val.textureSheetAnimation); CopyFields<LightsModule>(original.lights, val.lights); CopyFields<TrailModule>(original.trails, val.trails); CopyParticleCustomDataModule(original.customData, val.customData); return val; } public static T CopyComponent<T>(T original, GameObject destination) where T : Component { Type type = ((object)original).GetType(); Component component = destination.GetComponent(type); T val = (T)(object)((component is T) ? component : null); if (!Object.op_Implicit((Object)(object)val)) { Component obj = destination.AddComponent(type); val = (T)(object)((obj is T) ? obj : null); } CopyFields(original, val); if (original is ParticleSystemRenderer) { object obj2 = original; object original2 = ((obj2 is ParticleSystemRenderer) ? obj2 : null); object obj3 = val; CopyParticleSystemRendererSettings((ParticleSystemRenderer)original2, (ParticleSystemRenderer)((obj3 is ParticleSystemRenderer) ? obj3 : null)); } return val; } public static void CopyFields<T>(T original, T dst) { Type type = original.GetType(); FieldInfo[] fields = type.GetFields(); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { if (!fieldInfo.IsStatic) { fieldInfo.SetValue(dst, fieldInfo.GetValue(original)); } } PropertyInfo[] properties = type.GetProperties(); Dictionary<string, PropertyInfo> dictionary = new Dictionary<string, PropertyInfo>(); PropertyInfo[] array2 = properties; foreach (PropertyInfo propertyInfo in array2) { dictionary[propertyInfo.Name] = propertyInfo; if (propertyInfo.CanWrite && propertyInfo.CanWrite && !(propertyInfo.Name == "name") && !(propertyInfo.Name == "material") && !(propertyInfo.Name == "materials")) { propertyInfo.SetValue(dst, propertyInfo.GetValue(original, null), null); } } if (dictionary.ContainsKey("material") && dictionary.ContainsKey("sharedMaterial")) { Debug.Log((object)"Setting material property"); dictionary["material"].SetValue(dst, dictionary["sharedMaterial"].GetValue(original, null), null); } if (dictionary.ContainsKey("materials") && dictionary.ContainsKey("sharedMaterials")) { Debug.Log((object)"Setting materials property"); dictionary["materials"].SetValue(dst, dictionary["sharedMaterials"].GetValue(original, null), null); } } public static void CopyParticleCustomDataModule(CustomDataModule original, CustomDataModule dst) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Invalid comparison between Unknown and I4 //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) ((CustomDataModule)(ref dst)).enabled = ((CustomDataModule)(ref original)).enabled; ParticleSystemCustomData[] array = (ParticleSystemCustomData[])(object)new ParticleSystemCustomData[2] { default(ParticleSystemCustomData), (ParticleSystemCustomData)1 }; ParticleSystemCustomData[] array2 = array; foreach (ParticleSystemCustomData val in array2) { ((CustomDataModule)(ref dst)).SetMode(val, ((CustomDataModule)(ref original)).GetMode(val)); ParticleSystemCustomDataMode mode = ((CustomDataModule)(ref original)).GetMode(val); if ((int)mode == 2) { ((CustomDataModule)(ref dst)).SetColor(val, ((CustomDataModule)(ref original)).GetColor(val)); } else if ((int)mode == 1) { int vectorComponentCount = ((CustomDataModule)(ref original)).GetVectorComponentCount(val); ((CustomDataModule)(ref dst)).SetVectorComponentCount(val, vectorComponentCount); for (int j = 0; j < vectorComponentCount; j++) { ((CustomDataModule)(ref dst)).SetVector(val, j, ((CustomDataModule)(ref original)).GetVector(val, j)); } } } } public static void CopyParticleSystemRendererSettings(ParticleSystemRenderer original, ParticleSystemRenderer dst) { List<ParticleSystemVertexStream> list = new List<ParticleSystemVertexStream>(); original.GetActiveVertexStreams(list); dst.SetActiveVertexStreams(list); list.Clear(); original.GetActiveTrailVertexStreams(list); dst.SetActiveTrailVertexStreams(list); } public static GameObject copyGameObjectChain(GameObject root, GameObject leaf, GameObject attachTo = null) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown //IL_0147: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)(object)leaf) { GameObject val = new GameObject(); val.transform.parent = root.transform; val.transform.localPosition = default(Vector3); val.transform.localRotation = Quaternion.identity; val.transform.localScale = new Vector3(1f, 1f, 1f); val.layer = leaf.layer; return val; } string name = ((Object)leaf).name; GameObject val2 = new GameObject(((Object)leaf).name); GameObject val3 = val2; GameObject val4 = new GameObject(); val3.transform.parent = val4.transform; val3.layer = leaf.layer; val3.transform.localPosition = leaf.transform.localPosition; val3.transform.localRotation = leaf.transform.localRotation; val3.transform.localScale = leaf.transform.localScale; while ((Object)(object)leaf.transform.parent != (Object)null && (Object)(object)((Component)leaf.transform.parent).gameObject != (Object)(object)root) { leaf = ((Component)leaf.transform.parent).gameObject; val3 = val4; val4 = new GameObject(); ((Object)val3).name = ((Object)leaf).name; val3.layer = leaf.layer; val3.transform.parent = val4.transform; val3.transform.localPosition = leaf.transform.localPosition; val3.transform.localRotation = leaf.transform.localRotation; val3.transform.localScale = leaf.transform.localScale; } if ((Object)(object)leaf.transform.parent == (Object)null) { throw new Exception("Leaf " + name + " doesn't have " + ((Object)root).name + " in its hierarchy"); } val4.transform.parent = (attachTo ?? root).transform; val4.layer = (attachTo ?? root).layer; val4.transform.localPosition = default(Vector3); val4.transform.localRotation = Quaternion.identity; val4.transform.localScale = new Vector3(1f, 1f, 1f); return val2; } public static Transform getChildByPath(GameObject root, params string[] path) { if ((Object)(object)root == (Object)null) { return null; } if (path.Length == 0) { return null; } Transform val = root.transform; foreach (string text in path) { val = val.Find(text); if ((Object)(object)val == (Object)null) { return null; } } return val; } } public class GradientUtils { public static void rescaleAlphaTimes(Gradient grad, float minBound, float maxBound) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) GradientAlphaKey[] alphaKeys = grad.alphaKeys; GradientAlphaKey[] array = (GradientAlphaKey[])(object)new GradientAlphaKey[alphaKeys.Length]; for (int i = 0; i < alphaKeys.Length; i++) { array[i] = new GradientAlphaKey(alphaKeys[i].alpha, Mathf.Lerp(minBound, maxBound, alphaKeys[i].time)); } grad.SetKeys(grad.colorKeys, array); } public static Gradient getNormalizedGradient(Material mat, Gradient grad, Color baseColor) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_011c: 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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_010b: 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_03d8: Expected O, but got Unknown //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0284: 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_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: 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) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_0302: 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_0327: 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_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_04e9: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0508: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_05a6: Unknown result type (might be due to invalid IL or missing references) //IL_05b0: Unknown result type (might be due to invalid IL or missing references) //IL_05ba: Unknown result type (might be due to invalid IL or missing references) //IL_05d0: Unknown result type (might be due to invalid IL or missing references) //IL_05d4: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_0536: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_0585: 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) GradientColorKey[] colorKeys = grad.colorKeys; GradientAlphaKey[] alphaKeys = grad.alphaKeys; List<GradientColorKey> list = new List<GradientColorKey>(); List<GradientAlphaKey> list2 = new List<GradientAlphaKey>(); StandardShaderUtils.ParticleColorMode particleColorMode = (((Object)(object)mat != (Object)null) ? StandardShaderUtils.getColorMode(mat) : StandardShaderUtils.ParticleColorMode.Multiply); GradientColorKey[] array = colorKeys; foreach (GradientColorKey val in array) { Color color = val.color; switch (particleColorMode) { case StandardShaderUtils.ParticleColorMode.Multiply: color.r *= baseColor.r; color.g *= baseColor.g; color.b *= baseColor.b; break; case StandardShaderUtils.ParticleColorMode.Additive: color.r += baseColor.r; color.g += baseColor.g; color.b += baseColor.b; break; case StandardShaderUtils.ParticleColorMode.Subtractive: color.r = 1f - (baseColor.r - color.r); color.g = 1f - (baseColor.g - color.g); color.b = 1f - (baseColor.b - color.b); break; } list.Add(new GradientColorKey(color, val.time)); } GradientAlphaKey[] array2 = alphaKeys; foreach (GradientAlphaKey val2 in array2) { list2.Add(new GradientAlphaKey(val2.alpha * baseColor.a, val2.time)); } List<GradientAlphaKey> list3 = new List<GradientAlphaKey>(); float num = 0.0001f; if (list.Count > 1) { GradientColorKey item = default(GradientColorKey); GradientColorKey item2 = default(GradientColorKey); for (int k = 0; k < list.Count; k++) { GradientColorKey val3 = list[k]; if (val3.color != Color.black) { list3.Add(new GradientAlphaKey(1f, val3.time)); continue; } if (k == 0) { list.Remove(val3); list.Insert(0, new GradientColorKey(getNonblackAfter(list, val3.time).color, val3.time)); list3.Insert(0, new GradientAlphaKey(0f, val3.time)); continue; } if (k == list.Count - 1) { list.Remove(val3); list.Insert(k, new GradientColorKey(getNonblackBefore(list, val3.time).color, val3.time)); list3.Add(new GradientAlphaKey(0f, val3.time)); continue; } list.Remove(val3); ((GradientColorKey)(ref item))..ctor(getNonblackBefore(list, val3.time).color, Mathf.Max(0f, val3.time - num)); ((GradientColorKey)(ref item2))..ctor(getNonblackAfter(list, val3.time).color, Mathf.Min(1f, val3.time + num)); list.Add(item); list.Add(item2); list3.Add(new GradientAlphaKey(0f, Mathf.Max(0f, val3.time - num))); list3.Add(new GradientAlphaKey(0f, Mathf.Min(1f, val3.time + num))); list.Sort((GradientColorKey x, GradientColorKey y) => x.time.CompareTo(y.time)); k++; } } list2 = combineAlphas(list2, list3); list.Sort((GradientColorKey x, GradientColorKey y) => x.time.CompareTo(y.time)); list2.Sort((GradientAlphaKey x, GradientAlphaKey y) => x.time.CompareTo(y.time)); Gradient val4 = new Gradient(); val4.SetKeys(list.ToArray(), list2.ToArray()); HashSet<float> hashSet = new HashSet<float>(); hashSet.Add(0f); hashSet.Add(1f); foreach (GradientColorKey item3 in list) { hashSet.Add(item3.time); } foreach (GradientAlphaKey item4 in list2) { hashSet.Add(item4.time); } List<float> list4 = new List<float>(hashSet); list4.Sort(); List<GradientColorKey> list5 = new List<GradientColorKey>(); List<GradientAlphaKey> list6 = new List<GradientAlphaKey>(); Color val6 = default(Color); Color val7 = default(Color); foreach (float item5 in list4) { Color val5 = val4.Evaluate(item5); ((Color)(ref val6))..ctor(val5.r * val5.a, val5.g * val5.a, val5.b * val5.a); float num2 = Mathf.Max(new float[3] { val6.r, val6.g, val6.b }); float num3 = num2; if (num3 == 0f) { num2 = Mathf.Max(new float[3] { val5.r, val5.g, val5.b }); list5.Add(new GradientColorKey(new Color(val5.r / num2, val5.g / num2, val5.b / num2, 1f), item5)); list6.Add(new GradientAlphaKey(0f, item5)); } else { ((Color)(ref val7))..ctor(val6.r / num3, val6.g / num3, val6.b / num3, 1f); list5.Add(new GradientColorKey(val7, item5)); list6.Add(new GradientAlphaKey(num3, item5)); } } dedupeColorKeys(list5, num * 2f); dedupeAlphaKeys(list6, num * 2f); val4.SetKeys(list5.ToArray(), list6.ToArray()); return val4; } private static List<GradientAlphaKey> combineAlphas(List<GradientAlphaKey> a, List<GradientAlphaKey> b) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) a.Sort((GradientAlphaKey x, GradientAlphaKey y) => x.time.CompareTo(y.time)); b.Sort((GradientAlphaKey x, GradientAlphaKey y) => x.time.CompareTo(y.time)); Gradient val = new Gradient(); val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(Color.black, 0f), new GradientColorKey(Color.black, 1f) }, a.ToArray()); Gradient val2 = new Gradient(); val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(Color.black, 0f), new GradientColorKey(Color.black, 1f) }, b.ToArray()); List<GradientAlphaKey> list = new List<GradientAlphaKey>(); foreach (GradientAlphaKey item in a) { float num = item.alpha * val2.Evaluate(item.time).a; list.Add(new GradientAlphaKey(num, item.time)); } foreach (GradientAlphaKey item2 in b) { float num2 = item2.alpha * val.Evaluate(item2.time).a; list.Add(new GradientAlphaKey(num2, item2.time)); } list.Sort((GradientAlphaKey x, GradientAlphaKey y) => x.time.CompareTo(y.time)); for (int i = 0; i < list.Count - 1; i++) { if (list[i].time == list[i + 1].time) { list.RemoveAt(i); i--; } } return list; } private static void dedupeColorKeys(List<GradientColorKey> keys, float timeEpsilon) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_010c: Unknown result type (might be due to invalid IL or missing references) while (keys.Count > 1 && approxEqual(keys[0].color, keys[1].color)) { keys.RemoveAt(0); } while (keys.Count > 1 && approxEqual(keys[keys.Count - 1].color, keys[keys.Count - 2].color)) { keys.RemoveAt(keys.Count - 1); } for (int i = 1; i < keys.Count - 1; i++) { if (approxEqual(keys[i - 1].color, keys[i].color) && approxEqual(keys[i].color, keys[i + 1].color)) { keys.RemoveAt(i); i--; } } for (int j = 0; j < keys.Count - 1; j++) { if (approxEqual(keys[j].color, keys[j + 1].color) && Mathf.Abs(keys[j].time - keys[j + 1].time) < timeEpsilon) { keys.RemoveAt(j); j--; } } } private static bool approxEqual(Color a, Color b) { //IL_0006: 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_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) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) float num = 0.04f; if (Mathf.Abs(a.r - b.r) < num && Mathf.Abs(a.g - b.g) < num) { return Mathf.Abs(a.b - b.b) < num; } return false; } private static void dedupeAlphaKeys(List<GradientAlphaKey> keys, float timeEpsilon) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) while (keys.Count > 1 && keys[0].alpha == keys[1].alpha) { keys.RemoveAt(0); } while (keys.Count > 1 && keys[keys.Count - 1].alpha == keys[keys.Count - 2].alpha) { keys.RemoveAt(keys.Count - 1); } for (int i = 1; i < keys.Count - 1; i++) { float num = Mathf.Lerp(keys[i - 1].alpha, keys[i + 1].alpha, Mathf.InverseLerp(keys[i - 1].time, keys[i + 1].time, keys[i].time)); if (Mathf.Abs(num - keys[i].alpha) < 0.04f) { keys.RemoveAt(i); i--; } } for (int j = 0; j < keys.Count - 1; j++) { if (keys[j].alpha == keys[j + 1].alpha && Mathf.Abs(keys[j].time - keys[j + 1].time) < timeEpsilon) { keys.RemoveAt(j); j--; } } } private static GradientColorKey getNonblackBefore(List<GradientColorKey> colorKeys, float time) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) GradientColorKey val = colorKeys[0]; for (int i = 0; i < colorKeys.Count; i++) { if (val.color == Color.black) { val = colorKeys[i]; } else if (!(colorKeys[i].color == Color.black)) { if (colorKeys[i].time >= time) { return val; } val = colorKeys[i]; } } return val; } private static GradientColorKey getNonblackAfter(List<GradientColorKey> colorKeys, float time) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) GradientColorKey val = colorKeys.Last(); for (int num = colorKeys.Count - 1; num >= 0; num--) { if (val.color == Color.black) { val = colorKeys[num]; } else if (!(colorKeys[num].color == Color.black)) { if (colorKeys[num].time <= time) { return val; } val = colorKeys[num]; } } return val; } } internal class LayerMaskUtils { private static Dictionary<string, int> layerMap = new Dictionary<string, int>(); public static int NameToLayer(string name) { name = name.ToLower(); if (!layerMap.ContainsKey(name)) { for (int i = 0; i < 32; i++) {