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.Reflection.Emit; 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 System.Threading; using BepInEx; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using SoftReferenceableAssets; using Steamworks; using TMPro; using Unity.Collections; using Unity.Collections.LowLevel.Unsafe; using Unity.Jobs; using UnityEngine; using UnityEngine.Experimental.Rendering; using UnityEngine.Rendering; using UnityEngine.UI; using ValheimMod.External; using ValheimMod.External.MiniJSON; using ValheimMod.Monobehaviours; using ValheimMod.Monobehaviours.FireBehaviors; using ValheimMod.Monobehaviours.Lava; using ValheimMod.Monobehaviours.Runes; using ValheimMod.Patches; using ValheimMod.Profiling; using ValheimMod.ScriptableObjects; using ValheimMod.Setup; using ValheimMod.Utilities; [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.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] public class DeferredDecalSystem { private static DeferredDecalSystem m_Instance; internal HashSet m_DecalsDiffuse = new HashSet(); internal HashSet m_DecalsNormals = new HashSet(); internal HashSet m_DecalsBoth = new HashSet(); 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 m_Cameras = new Dictionary(); public void OnDisable() { foreach (KeyValuePair 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 { public class AnalyticsData { private Dictionary data = new Dictionary(); 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 getDataForPost() { HashSet hashSet = new HashSet(); string text = ""; string text2 = ""; List 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 dictionary = new Dictionary(); dictionary.Add("header", text); dictionary.Add("body", text2); return dictionary; } } private const string PLAYER_PREFS_UUID_KEY = "runemagic-uuid"; private readonly List CONFIG_ENTRIES_TO_SEND = new List { "RepairRune_HealRate", "RepairRune_EffectRadius", "ExtinguishingRune_EffectRadius", "runestoneMaxStoredEnergy", "runestoneSecondsToFullCharge", "runestoneUnlockNewRuneChance", "energyCost_runemagic_passive_WaterWalking-hotWaterCostMultiplier", "energyCost_runemagic_passive_WaterWalking-lavaCostMultiplier" }; private Dictionary placedRunes = new Dictionary(); private Dictionary removedRunes = new Dictionary(); private Dictionary> terminalCommandsRun = new Dictionary>(); private Dictionary passiveRuneActiveTime = new Dictionary(); public bool otherPlayersConnected; public bool wasPvpDamageTaken; public HashSet exceptions = new HashSet(); private Dictionary uniqueEngravedRunesLoaded = new Dictionary(); 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()); terminalCommandsRun.Add("forgetRune", new List()); 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.Replace(",", "..")); } } 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 dictionary = new Dictionary(); 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 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)); analyticsData.Add("pvp", getPVPStatus(Player.m_localPlayer)); analyticsData.Add("numRuneFocus", getRuneFocusCount().ToString()); analyticsData.Add("compShadSupport", toString(SystemInfo.supportsComputeShaders && SystemInfo.supportsAsyncGPUReadback)); 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("repairVisQuality", ConfigLoader.getInt("repairRune_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 list = new List(); int num = 0; int num2 = -1; try { if (ZDOMan.instance != null) { while (!ZDOMan.instance.GetAllZDOsWithPrefabIterative(engravedRunePrefabName, list, ref num)) { } num2 = list.Count(); } } catch (IndexOutOfRangeException) { } catch (NullReferenceException) { } holder.Add("worldCount-" + engravedRunePrefabName, num2.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.configName)) { string @string = ConfigLoader.getString("energyCost_" + runemagicPieceConfig.configName); @string = parseNumericConfigValue(@string); holder.Add("energyCost-" + runemagicPieceConfig.pieceName, @string); } } foreach (string item in CONFIG_ENTRIES_TO_SEND) { string value2 = parseNumericConfigValue(ConfigLoader.getString(item)); holder.Add("cfg-" + item, value2); } } private void appendPassiveRuneTimes(AnalyticsData holder) { foreach (string key in passiveRuneActiveTime.Keys) { holder.Add("passiveInUse-" + key, Mathf.RoundToInt(passiveRuneActiveTime[key]).ToString()); } } private string parseNumericConfigValue(string val) { int num = val.LastIndexOf(','); if (num != -1) { val = val.Substring(0, num) + "." + val.Substring(num + 1); val = val.Replace(",", ""); int num2 = val.LastIndexOf("."); val = val.Substring(0, num2).Replace(".", "") + "." + val.Substring(num2 + 1); } return val; } private string getPVPStatus(Player p) { if ((Object)(object)p == (Object)null) { return "N/A"; } try { return toString(((Character)p).IsPVPEnabled()); } catch (NullReferenceException) { return "N/A"; } } private static string getVersion() { string text = "1.4.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() { try { if ((Object)(object)Player.m_localPlayer == (Object)null || ((Humanoid)Player.m_localPlayer).GetInventory() == null) { return -1; } Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); return inventory.CountItems("$item_runemagic_runefocus", -1, true); } catch (NullReferenceException) { return -1; } } 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() { try { return getBranch().Equals("public-test"); } catch (Exception) { return false; } } 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 points) { HashSet points2 = new HashSet(points); return welzlInner(points2, new HashSet()); } private static BoundingCircle welzlInner(HashSet points, HashSet 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 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 list = new List(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(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 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(this IDictionary container, TKey key, TValue defaultValue) { if (!container.ContainsKey(key)) { return defaultValue; } return container[key]; } public static void AddToKey(this IDictionary container, TKey key, int toAdd) { container[key] = container.GetValueOrDefault(key, 0) + toAdd; } public static void AddToKey(this IDictionary container, TKey key, float toAdd) { container[key] = container.GetValueOrDefault(key, 0f) + toAdd; } public static void AddToKey(this IDictionary container, TKey key, double toAdd) { container[key] = container.GetValueOrDefault(key, 0.0) + toAdd; } public static bool ContainsRegex(this IList 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 dict, IDictionary 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); } public static Vector3 GetXYZVector(this 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) return new Vector3(vec.x, vec.y, vec.z); } public static float GetAvgEmission(this MinMaxCurve curve) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Invalid comparison between Unknown and I4 if ((int)((MinMaxCurve)(ref curve)).mode == 3) { return (((MinMaxCurve)(ref curve)).constantMax + ((MinMaxCurve)(ref curve)).constantMin) / 2f; } if ((int)((MinMaxCurve)(ref curve)).mode == 1) { return ((MinMaxCurve)(ref curve)).curve.GetAverageValueFromKeyframes() * ((MinMaxCurve)(ref curve)).curveMultiplier; } if ((int)((MinMaxCurve)(ref curve)).mode == 2) { float num = (((MinMaxCurve)(ref curve)).curveMin.GetAverageValueFromKeyframes() + ((MinMaxCurve)(ref curve)).curveMax.GetAverageValueFromKeyframes()) / 2f; return num * ((MinMaxCurve)(ref curve)).curveMultiplier; } return ((MinMaxCurve)(ref curve)).constant; } public static float GetAverageValueFromKeyframes(this AnimationCurve curve) { if (curve == null || curve.length == 0) { return 0f; } if (curve.length == 1) { return ((Keyframe)(ref curve.keys[0])).value; } Keyframe[] keys = curve.keys; float num = 0f; float num2 = 0f; for (int i = 0; i < keys.Length - 1; i++) { float time = ((Keyframe)(ref keys[i])).time; float time2 = ((Keyframe)(ref keys[i + 1])).time; float value = ((Keyframe)(ref keys[i])).value; float value2 = ((Keyframe)(ref keys[i + 1])).value; float num3 = time2 - time; if (!(num3 <= 0f)) { float num4 = (value + value2) * 0.5f; num += num4 * num3; num2 += num3; } } if (!(num2 > 0f)) { return 0f; } return num / num2; } public static bool IsInView(this Camera cam, Vector3 worldPoint) { //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_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_0022: 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_003c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = cam.WorldToViewportPoint(worldPoint); if (val.z > 0f && val.x > 0f && val.x < 1f && val.y > 0f) { return val.y < 1f; } return false; } } public 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 static Texture2D GetRenderTexturePixels(RenderTexture rt) { //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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) RenderTexture active = RenderTexture.active; RenderTexture.active = rt; Texture2D val = new Texture2D(((Texture)rt).width, ((Texture)rt).height, GraphicsFormatUtility.GetTextureFormat(rt.graphicsFormat), false); val.ReadPixels(new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), 0, 0); RenderTexture.active = active; 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) { ValheimMod.DevModeLog(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 { ValheimMod.DevModeLog("Raycast returned true, but no hit"); } } else { ValheimMod.DevModeLog("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) { ValheimMod.DevModeLog(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; } ValheimMod.DevModeLog($"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) ValheimMod.DevModeLog($"{prefix}Gameobject: {((Object)obj).name}, active {obj.activeInHierarchy}, localPos {obj.transform.localPosition}, worldPos {obj.transform.position}"); ValheimMod.DevModeLog($"{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; } ValheimMod.DevModeLog(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) { ValheimMod.DevModeLog(prefix + $"Material {((Object)val3).name} Shader: {((Object)val3.shader).name} ShaderInstId: {((Object)val3.shader).GetInstanceID()}"); } } } } 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) { ValheimMod.DevModeLog(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; } ValheimMod.DevModeLog($"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) ValheimMod.DevModeLog($"{prefix}Gameobject: {((Object)obj).name}, active {obj.activeInHierarchy}, activeSelf {obj.activeSelf}"); ValheimMod.DevModeLog($"{prefix} localPos {obj.transform.localPosition}, worldPos {obj.transform.position}"); ValheimMod.DevModeLog($"{prefix} localRot {obj.transform.localEulerAngles}, worldRot {obj.transform.eulerAngles}"); ParticleSystem[] components = obj.GetComponents(); ParticleSystem[] array = components; foreach (ParticleSystem val in array) { ValheimMod.DevModeLog($"{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; ValheimMod.DevModeLog(string.Format("{0} maxParticles {1}, current# {2}, emission {3}", obj2)); ValheimMod.DevModeLog($"{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); ValheimMod.DevModeLog(prefix + " CustomData: Grad1: " + minMaxGradientToString(color) + " Grad2: " + minMaxGradientToString(color2)); } else { ValheimMod.DevModeLog(prefix + " CustomData disabled"); } } ParticleSystemRenderer component = obj.GetComponent(); if ((Object)(object)component == (Object)null) { ValheimMod.DevModeLog(prefix + " null ParticleSystemRenderer"); return; } List list = new List(); component.GetActiveVertexStreams(list); foreach (ParticleSystemVertexStream item in list) { ParticleSystemVertexStream current = item; ValheimMod.DevModeLog(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 list = new List(); foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(a)) { string name = property.Name; list.Add(name); object value = property.GetValue(a); object value2 = property.GetValue(b); ValheimMod.DevModeLog($"{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); ValheimMod.DevModeLog($"{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(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); } public static Transform findInHierarchy(Transform t, string regex) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown Match match = Regex.Match(((Object)t).name, regex, RegexOptions.IgnoreCase); if (match.Success) { return t; } foreach (Transform item in t) { Transform t2 = item; Transform val = findInHierarchy(t2, regex); if ((Object)(object)val != (Object)null) { return val; } } return null; } } internal class DecalManager { private static Dictionary bufferMap = new Dictionary(); 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(original, destination); ParticleSystemRenderer val2 = GameObjectUtils.CopyComponent(((Component)original).gameObject.GetComponent(), destination); CopyFields(original.main, val.main); CopyFields(original.emission, val.emission); CopyFields(original.shape, val.shape); CopyFields(original.velocityOverLifetime, val.velocityOverLifetime); CopyFields(original.limitVelocityOverLifetime, val.limitVelocityOverLifetime); CopyFields(original.inheritVelocity, val.inheritVelocity); CopyFields(original.forceOverLifetime, val.forceOverLifetime); CopyFields(original.colorOverLifetime, val.colorOverLifetime); CopyFields(original.colorBySpeed, val.colorBySpeed); CopyFields(original.sizeOverLifetime, val.sizeOverLifetime); CopyFields(original.sizeBySpeed, val.sizeBySpeed); CopyFields(original.rotationOverLifetime, val.rotationOverLifetime); CopyFields(original.rotationBySpeed, val.rotationBySpeed); CopyFields(original.externalForces, val.externalForces); CopyFields(original.noise, val.noise); CopyFields(original.collision, val.collision); CopyFields(original.trigger, val.trigger); CopyFields(original.textureSheetAnimation, val.textureSheetAnimation); CopyFields(original.lights, val.lights); CopyFields(original.trails, val.trails); CopyParticleCustomDataModule(original.customData, val.customData); return val; } public static T CopyComponent(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 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 dictionary = new Dictionary(); 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")) { dictionary["material"].SetValue(dst, dictionary["sharedMaterial"].GetValue(original, null), null); } if (dictionary.ContainsKey("materials") && dictionary.ContainsKey("sharedMaterials")) { 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 list = new List(); 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 static bool isTrueNull(Component c) { return c == null; } } 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 list = new List(); List list2 = new List(); 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 list3 = new List(); 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 hashSet = new HashSet(); 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 list4 = new List(hashSet); list4.Sort(); List list5 = new List(); List list6 = new List(); 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 combineAlphas(List a, List 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 list = new List(); 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 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 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 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 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; } } public class GridMap where T : Component { private Dictionary grid = new Dictionary(); private float edgeLength; private bool zeroCentered; private float inclusiveCellBoundingCircleRadius; private float exclusiveCellBoundingCircleRadius; public GridMap(float edgeLength, bool zeroCentered) { this.edgeLength = edgeLength; this.zeroCentered = zeroCentered; float num = edgeLength / 2f; exclusiveCellBoundingCircleRadius = (num + (inclusiveCellBoundingCircleRadius = Mathf.Sqrt(2f * num * num))) / 2f; } public float getCellBoundingCircleRadius(bool inclusive) { if (!inclusive) { return exclusiveCellBoundingCircleRadius; } return inclusiveCellBoundingCircleRadius; } public void Add(T t) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) Vector2i coord = GetCoord(((Component)t).transform.position); grid[coord] = t; } public void Add(Vector2i coord, T t) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) grid[coord] = t; } public void Remove(T t) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) Vector2i coord = GetCoord(((Component)t).transform.position); Remove(coord); } public void Remove(Vector2i coord) { //IL_0006: 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) if (grid.ContainsKey(coord)) { grid.Remove(coord); } } public void Clear() { grid.Clear(); } public int Count() { return grid.Count; } public T GetAdjacent(T t, int dx, int dz) { //IL_002c: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)t == (Object)null) { return default(T); } if (dx == 0 && dz == 0) { return t; } Vector2i coord = GetCoord(((Component)t).transform.position); coord += new Vector2i(dx, dz); if (grid.ContainsKey(coord)) { return grid[coord]; } return default(T); } public T Get(Vector3 worldPos) { //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_0009: Unknown result type (might be due to invalid IL or missing references) Vector2i coord = GetCoord(worldPos); return Get(coord); } public T Get(Vector2i coord) { //IL_0006: 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) if (grid.ContainsKey(coord)) { return grid[coord]; } return default(T); } public Vector2i GetCoord(Vector3 pos) { //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) return GetCoord(pos.GetXZVector()); } public Vector2i GetCoord(Vector2 xzPos) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0051: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (zeroCentered) { xzPos += new Vector2(edgeLength / 2f, edgeLength / 2f); } xzPos /= edgeLength; return new Vector2i(Mathf.FloorToInt(xzPos.x), Mathf.FloorToInt(xzPos.y)); } public HashSet GetGridCellsOverlappingArea(Vector2 center, float radius, bool inclusive) { //IL_0019: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_016b: 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_00fe: 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_015b: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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) if (!inclusive && radius < edgeLength / 2f) { return new HashSet(); } Vector2i coord = GetCoord(center - new Vector2(radius, radius)); Vector2i coord2 = GetCoord(center + new Vector2(radius, radius)); if (!inclusive) { if ((center.x - radius) % edgeLength != 0f) { coord.x++; } if ((center.x + radius) % edgeLength != 0f) { coord2.x--; } if ((center.y - radius) % edgeLength != 0f) { coord.y++; } if ((center.y + radius) % edgeLength != 0f) { coord2.y--; } } HashSet hashSet = new HashSet(); float cellBoundingCircleRadius = getCellBoundingCircleRadius(inclusive); float num = radius - cellBoundingCircleRadius; num *= num; float num2 = radius + cellBoundingCircleRadius; num2 *= num2; Vector2i val = default(Vector2i); for (int i = coord.y; i <= coord2.y; i++) { for (int j = coord.x; j <= coord2.x; j++) { ((Vector2i)(ref val))..ctor(j, i); Vector2 centerXZ = GetCenterXZ(val); Vector2 val2 = center - centerXZ; float sqrMagnitude = ((Vector2)(ref val2)).sqrMagnitude; if (sqrMagnitude <= num) { hashSet.Add(val); } else if (inclusive && sqrMagnitude < num2) { hashSet.Add(val); } } } return hashSet; } public HashSet GetGridCentersInArea(Vector2 centerPt, float radius) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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_0013: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_005e: 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_0074: Unknown result type (might be due to invalid IL or missing references) Vector2i coord = GetCoord(centerPt - new Vector2(radius, radius)); Vector2i coord2 = GetCoord(centerPt + new Vector2(radius, radius)); HashSet hashSet = new HashSet(); float num = radius * radius; Vector2i val = default(Vector2i); for (int i = coord.y; i <= coord2.y; i++) { for (int j = coord.x; j <= coord2.x; j++) { ((Vector2i)(ref val))..ctor(j, i); Vector2 centerXZ = GetCenterXZ(val); Vector2 val2 = centerPt - centerXZ; float sqrMagnitude = ((Vector2)(ref val2)).sqrMagnitude; if (sqrMagnitude <= num) { hashSet.Add(val); } } } return hashSet; } public Vector3 GetCenter(Vector2i coord) { //IL_0002: 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_0015: 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_0021: 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_0059: 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_002a: 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_004d: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor((float)coord.x, (float)coord.y); val *= edgeLength; if (!zeroCentered) { val += new Vector2(edgeLength / 2f, edgeLength / 2f); } return new Vector3(val.x, 0f, val.y); } public Vector2 GetCenterXZ(Vector2i coord) { //IL_0002: 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_0015: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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_004d: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor((float)coord.x, (float)coord.y); val *= edgeLength; if (!zeroCentered) { val += new Vector2(edgeLength / 2f, edgeLength / 2f); } return val; } public Rect GetBoundingRect(Vector2i coord) { //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_0008: 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_003a: Unknown result type (might be due to invalid IL or missing references) Vector2 centerXZ = GetCenterXZ(coord); return new Rect(centerXZ.x - edgeLength / 2f, centerXZ.y - edgeLength / 2f, edgeLength, edgeLength); } public float GetScale() { return edgeLength; } public bool ContainsKey(Vector2i key) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return grid.ContainsKey(key); } public ICollection GetKeys() { return grid.Keys; } } internal class LayerMaskUtils { private static Dictionary layerMap = new Dictionary(); public static int NameToLayer(string name) { name = name.ToLower(); if (!layerMap.ContainsKey(name)) { for (int i = 0; i < 32; i++) { layerMap[LayerMask.LayerToName(i).ToLower()] = i; } } return layerMap[name]; } public static string LayerToName(int layerNum) { return LayerMask.LayerToName(layerNum); } public static int GetMask(params string[] layerNames) { int num = 0; foreach (string name in layerNames) { int num2 = NameToLayer(name); num += 1 << num2; } return num; } } internal class LocalizationManager { public static readonly string InternalTranslationFilename = "runemagic_english_translations.json"; public static readonly string ExternalTranslationsFilename = "runemagic.json"; private const string DEFAULT_LANGUAGE = "English"; public static void LoadTranslations() { Dictionary dictionary = parseJSON(AssetLoader.ReadEmbeddedResource(InternalTranslationFilename)); addTranslationsToGame(dictionary); if (ValheimMod.DEV_MODE) { validateNoDuplicateTranslations(dictionary); } if (Directory.Exists(getTranslationsFolder())) { Directory.CreateDirectory(getFolderForLanguage("English")); File.WriteAllText(getFileForLanguage("English"), AssetLoader.ReadEmbeddedResource(InternalTranslationFilename)); if (Localization.instance.GetSelectedLanguage() != "English" && File.Exists(getFileForLanguage(Localization.instance.GetSelectedLanguage()))) { Dictionary translations = parseJSON(File.ReadAllText(getFileForLanguage(Localization.instance.GetSelectedLanguage()))); addTranslationsToGame(translations); } } } public static void FixPlayerKnowledge(Player player) { List> list = new List>(); list.Add(Traverse.Create((object)player).Field("m_knownMaterial").GetValue() as HashSet); list.Add(Traverse.Create((object)player).Field("m_knownRecipes").GetValue() as HashSet); Dictionary dictionary = parseJSON(AssetLoader.ReadEmbeddedResource(InternalTranslationFilename)); foreach (HashSet item in list) { foreach (KeyValuePair item2 in dictionary) { if (item.Contains(item2.Key) || item.Contains(item2.Value)) { item.Add(item2.Key); item.Add(item2.Value); } } } player.UpdateAvailablePiecesList(); } private static void validateNoDuplicateTranslations(Dictionary englishTranslations) { HashSet hashSet = new HashSet(); foreach (KeyValuePair englishTranslation in englishTranslations) { if (hashSet.Contains(englishTranslation.Value)) { throw new Exception("Found duplicate translation: " + englishTranslation.Key + ":" + englishTranslation.Value); } hashSet.Add(englishTranslation.Value); } } private static string getTranslationsFolder() { string pluginPath = Paths.PluginPath; char directorySeparatorChar = Path.DirectorySeparatorChar; return pluginPath + directorySeparatorChar + "Translations"; } private static string getFolderForLanguage(string language) { string translationsFolder = getTranslationsFolder(); char directorySeparatorChar = Path.DirectorySeparatorChar; return translationsFolder + directorySeparatorChar + language; } private static string getFileForLanguage(string language) { string folderForLanguage = getFolderForLanguage(language); char directorySeparatorChar = Path.DirectorySeparatorChar; return folderForLanguage + directorySeparatorChar + ExternalTranslationsFilename; } private static void addTranslationsToGame(Dictionary translations) { Localization instance = Localization.instance; MethodInfo method = ((object)Localization.instance).GetType().GetMethod("AddWord", BindingFlags.Instance | BindingFlags.NonPublic); foreach (KeyValuePair translation in translations) { string text = translation.Key; if (text.StartsWith("$")) { text = text.Substring(1); } method.Invoke(instance, new object[2] { text, translation.Value }); } } private static Dictionary parseCSV(string[] lines) { Dictionary dictionary = new Dictionary(); foreach (string text in lines) { string[] array = Regex.Split(text, ", *"); if (array.Length != 2) { LogUtils.LogWarning("Unparsable translation entry: " + text); } else { dictionary[array[0]] = array[1]; } } return dictionary; } private static Dictionary parseJSON(string json) { Dictionary dictionary = new Dictionary(); foreach (KeyValuePair item in Json.Deserialize(json) as Dictionary) { dictionary.Add(item.Key, (string)item.Value); } return dictionary; } } public class MathUtils { public class MeshRaycastHit { public bool hit; public RaycastHit closest; public RaycastHit farthest; } public static MeshRaycastHit findRayMeshIntersection(Ray raycast, MeshFilter[] filters) { //IL_0071: 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_0084: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d4: 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_00eb: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) MeshRaycastHit meshRaycastHit = new MeshRaycastHit(); ((RaycastHit)(ref meshRaycastHit.farthest)).distance = 0f; ((RaycastHit)(ref meshRaycastHit.closest)).distance = float.MaxValue; Ray ray = default(Ray); foreach (MeshFilter val in filters) { Mesh sharedMesh = val.sharedMesh; if (!sharedMesh.isReadable) { continue; } Vector3[] vertices = sharedMesh.vertices; Vector3[] normals = sharedMesh.normals; int[] triangles = sharedMesh.triangles; for (int j = 0; j < vertices.Length; j++) { ref Vector3 reference = ref vertices[j]; reference += normals[j] * 0.1f; } ((Ray)(ref ray))..ctor(((Component)val).transform.InverseTransformPoint(((Ray)(ref raycast)).origin), ((Component)val).transform.InverseTransformDirection(((Ray)(ref raycast)).direction)); for (int k = 0; k < triangles.Length; k += 3) { if (IntersectRayTriangle(ray, vertices[triangles[k]], vertices[triangles[k + 1]], vertices[triangles[k + 2]], bidirectional: true, out var hit)) { Vector3 val2 = ((Component)val).transform.TransformDirection(((RaycastHit)(ref hit)).normal); float num = ((Vector3)(ref val2)).magnitude * ((RaycastHit)(ref hit)).distance; if (num < ((RaycastHit)(ref meshRaycastHit.closest)).distance) { meshRaycastHit.closest = hit; ((RaycastHit)(ref meshRaycastHit.closest)).point = ((Component)val).transform.TransformPoint(((RaycastHit)(ref hit)).point); ((RaycastHit)(ref meshRaycastHit.closest)).distance = num; meshRaycastHit.hit = true; } if (num > ((RaycastHit)(ref meshRaycastHit.farthest)).distance) { meshRaycastHit.farthest = hit; ((RaycastHit)(ref meshRaycastHit.farthest)).point = ((Component)val).transform.TransformPoint(((RaycastHit)(ref hit)).point); ((RaycastHit)(ref meshRaycastHit.farthest)).distance = num; meshRaycastHit.hit = true; } } } } return meshRaycastHit; } public static bool IntersectRayTriangle(Ray ray, Vector3 v0, Vector3 v1, Vector3 v2, bool bidirectional, out RaycastHit hit) { //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_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_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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_011b: 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) hit = default(RaycastHit); Vector3 val = v1 - v0; Vector3 val2 = v2 - v0; Vector3 val3 = Vector3.Cross(val, val2); float num = Vector3.Dot(-((Ray)(ref ray)).direction, val3); if (num <= 0f) { return false; } Vector3 val4 = ((Ray)(ref ray)).origin - v0; float num2 = Vector3.Dot(val4, val3); if (num2 < 0f && !bidirectional) { return false; } Vector3 val5 = Vector3.Cross(-((Ray)(ref ray)).direction, val4); float num3 = Vector3.Dot(val2, val5); if (num3 < 0f || num3 > num) { return false; } float num4 = 0f - Vector3.Dot(val, val5); if (num4 < 0f || num3 + num4 > num) { return false; } float num5 = 1f / num; num2 *= num5; num3 *= num5; num4 *= num5; float num6 = 1f - num3 - num4; ((RaycastHit)(ref hit)).point = ((Ray)(ref ray)).origin + num2 * ((Ray)(ref ray)).direction; ((RaycastHit)(ref hit)).distance = num2; ((RaycastHit)(ref hit)).barycentricCoordinate = new Vector3(num6, num3, num4); ((RaycastHit)(ref hit)).normal = Vector3.Normalize(val3); return true; } public static float InverseLerpUnclamped(float a, float b, float value) { if (a != b) { return (value - a) / (b - a); } return 0f; } public static float LerpUnclamped(float a, float b, float t) { return a * t + b * (1f - t); } public static float quadLerp(float minXminY, float maxXminY, float minXmaxY, float maxXmaxY, float tX, float tY) { float num = Mathf.Lerp(minXminY, maxXminY, tX); float num2 = Mathf.Lerp(minXmaxY, maxXmaxY, tX); return Mathf.Lerp(num, num2, tY); } public static float hemisphereVolume(float radius) { return sphereVolume(radius) / 2f; } public static float sphereVolume(float radius) { return 4.1887903f * Mathf.Pow(radius, 3f); } public static Color lerp(Color c1, Color c2, float t) { //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_0013: 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_0026: 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_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_0050: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Lerp(c1.r, c2.r, t); float num2 = Mathf.Lerp(c1.g, c2.g, t); float num3 = Mathf.Lerp(c1.b, c2.b, t); float num4 = Mathf.Lerp(c1.a, c2.a, t); return new Color(num, num2, num3, num4); } public static float distanceXZSqr(Vector3 a, Vector3 b) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = a - b; return val.x * val.x + val.z * val.z; } } internal class PlayerVFXQueue { public enum VFXType { Eyes } private class VFXEntry { public PlayerVFX vfx; public int priority; public VFXEntry(PlayerVFX vfx, int priority) { this.vfx = vfx; this.priority = priority; } } public interface PlayerVFX { VFXType getType(); } public class PlayerEyeVFX : PlayerVFX { public Vector3 color; public PlayerEyeVFX(Vector3 color) { //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.color = color; } public VFXType getType() { return VFXType.Eyes; } } private static readonly string PLAYER_EYE_GLOW_ENABLED_KEY = "eyeGlow-enabled"; private static readonly string PLAYER_EYE_GLOW_COLOR_KEY = "eyeGlow-color"; private static Dictionary localVFX = new Dictionary(); public static void enableLocalPlayerVFX(PlayerVFX vfx, string source, int priority) { if (!localVFX.ContainsKey(source)) { localVFX[source] = new VFXEntry(vfx, priority); updateLocalPlayerVFX(vfx.getType()); } } public static void disableLocalPlayerVFX(string source) { if (localVFX.ContainsKey(source)) { VFXEntry vFXEntry = localVFX[source]; localVFX.Remove(source); updateLocalPlayerVFX(vFXEntry.vfx.getType()); } } private static void updateLocalPlayerVFX(VFXType type) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) ZNetView component = ((Component)Player.m_localPlayer).gameObject.GetComponent(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return; } VFXEntry vFXEntry = null; foreach (VFXEntry value in localVFX.Values) { if (value != null && value.vfx.getType() == type && (vFXEntry == null || value.priority > vFXEntry.priority)) { vFXEntry = value; } } if (vFXEntry != null) { if (vFXEntry.vfx is PlayerEyeVFX playerEyeVFX) { component.GetZDO().Set(PLAYER_EYE_GLOW_ENABLED_KEY, true); component.GetZDO().Set(PLAYER_EYE_GLOW_COLOR_KEY, playerEyeVFX.color); } } else if (type == VFXType.Eyes) { component.GetZDO().Set(PLAYER_EYE_GLOW_ENABLED_KEY, false); } } public static void handlePlayerVFX(Player player) { ZNetView component = ((Component)player).gameObject.GetComponent(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { handleEyeVFX(player, component); } } private static void handleEyeVFX(Player player, ZNetView nview) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0074: 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_007c: 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_008a: 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_0098: 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) bool @bool = nview.GetZDO().GetBool(PLAYER_EYE_GLOW_ENABLED_KEY, false); Transform val = ((Component)player).transform.Find("Visual/Armature/Hips/Spine/Spine1/Spine2/Neck/Head"); Transform val2 = val.Find("PlayerEyes(Clone)"); if ((Object)(object)val2 == (Object)null) { GameObject val3 = Object.Instantiate(AssetLoader.GetPrefabFromAssetBundle("PlayerEyes"), val); val2 = val3.transform; } if (@bool) { MeshRenderer[] componentsInChildren = ((Component)val2).gameObject.GetComponentsInChildren(); MaterialPropertyBlock val4 = new MaterialPropertyBlock(); Vector3 vec = nview.GetZDO().GetVec3(PLAYER_EYE_GLOW_COLOR_KEY, default(Vector3)); val4.SetColor("_EmissionColor", new Color(vec.x, vec.y, vec.z)); MeshRenderer[] array = componentsInChildren; foreach (MeshRenderer val5 in array) { ((Renderer)val5).SetPropertyBlock(val4); } } ((Component)val2).gameObject.SetActive(@bool); } } public class Profiler : IDisposable { private static Dictionary activeStopwatches = new Dictionary(); private static Dictionary measurements = new Dictionary(); private string instanceKey; public Profiler(string instanceKey) { this.instanceKey = instanceKey; start(instanceKey); } public void Dispose() { stop(instanceKey); } public static void start(string key) { } public static void stop(string key) { } public static void addMeasurement(string key, float value) { } public static void print() { } public static Dictionary getMeasurements() { return measurements.ToDictionary((KeyValuePair entry) => entry.Key, (KeyValuePair entry) => new Measurement(entry.Value)); } public static void reset() { } } internal interface ResizableRune { void setSize(float size); float getSize(); } public interface PlacementGhostBehavior { bool AdjustPlacementGhost(Player player, GameObject ghost, PlayerRaycast ray); } public class PlayerRaycast { public RaycastHit hitInfo; public bool hit; public PlayerRaycast(Player player, int layerMask = -1, bool allowRigidbody = false) { //IL_002a: 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_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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) if (layerMask == -1) { layerMask = player.m_placeRayMask; } Transform eye = ((Character)player).m_eye; float num = player.m_maxPlaceDistance; RaycastHit val = default(RaycastHit); if (Physics.Raycast(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, ref val, 50f, layerMask)) { if (Object.op_Implicit((Object)(object)player.m_placementGhost)) { Piece component = player.m_placementGhost.GetComponent(); if (component != null) { num += (float)component.m_extraPlacementDistance; } } if (Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider) && (!Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider.attachedRigidbody) || allowRigidbody) && Vector3.Distance(eye.position, ((RaycastHit)(ref val)).point) < num) { hitInfo = val; hit = true; return; } } hit = false; } } internal class PoissonDiscSampler { private float width; private float height; private float radius; private List samples = new List(); private int k = 4; private float radiusSq; private float cellSize; private int gridWidth; private int gridHeight; private Vector2[] grid; private List queue; private int limit; public PoissonDiscSampler(float width, float height, float radius, int limit = int.MaxValue) { this.width = width; this.height = height; this.radius = radius; this.limit = limit; radiusSq = radius * radius; cellSize = radius * (float)Math.Sqrt(0.5); gridWidth = (int)Math.Ceiling(width / cellSize); gridHeight = (int)Math.Ceiling(height / cellSize); grid = (Vector2[])(object)new Vector2[gridWidth * gridHeight]; queue = new List(); generateSamples(); } private void generateSamples() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_0137: Unknown result type (might be due to invalid IL or missing references) sample(width / 2f, height / 2f); while (queue.Count > 0 && samples.Count < limit) { int num = Random.Range(0, queue.Count); Vector2 val = queue[num]; float num2 = Random.Range(0f, 1f); float num3 = 0.0001f; bool flag = false; for (int i = 0; i < k; i++) { float num4 = (float)Math.PI * 2f * (num2 + 1f * (float)i / (float)k); float num5 = radius + num3; float num6 = val.x + num5 * (float)Math.Cos(num4); float num7 = val.y + num5 * (float)Math.Sin(num4); if (0f <= num6 && num6 < width && 0f <= num7 && num7 < height && isFar(num6, num7)) { sample(num6, num7); flag = true; } } if (!flag) { Vector2 value = queue[queue.Count - 1]; if (num < queue.Count) { queue[num] = value; queue.RemoveAt(queue.Count - 1); } } } } private bool isFar(float x, float y) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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) int num = (int)(x / cellSize); int num2 = (int)(y / cellSize); int num3 = Math.Max(num - 2, 0); int num4 = Math.Max(num2 - 2, 0); int num5 = Math.Min(num + 3, gridWidth); int num6 = Math.Min(num2 + 3, gridHeight); for (int i = num4; i < num6; i++) { int num7 = i * gridWidth; for (int j = num3; j < num5; j++) { Vector2 val = grid[num7 + j]; float num8 = val.x - x; float num9 = val.y - y; if (num8 * num8 + num9 * num9 < radiusSq) { return false; } } } return true; } private void sample(float x, float y) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(x, y); grid[gridWidth * (int)(y / cellSize) + (int)(x / cellSize)] = val; queue.Add(val); samples.Add(val - new Vector2(width / 2f, height / 2f)); } public List getSamples() { return samples; } } internal class RockAnimator : MonoBehaviour, ZNetViewHook { private const float Speed = 1f; private const string ShouldAnimateKey = "shouldAnimate"; private const string PlayerPlacedKey = "placedByPlayer"; private ZNetView netView; private Vector3 targetPosition; private Vector3 initialPosition; private float distance; private float initialTime; private float timeToHitTarget; private GameObject runeBlocker; private GameObject vfxPrefab; private int solidLayerMask; private int terrainLayerMask; private List vfxPoints; private List constructedVFX = new List(); private void Awake() { if (ZoneSystemPatch.ZoneSpawning || ZNetScenePatch.ChangingLoadedObjects) { Object.Destroy((Object)(object)((Component)this).GetComponent()); } } private void Start() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_0086: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) if (!shouldAnimate()) { Object.Destroy((Object)(object)this); return; } vfxPrefab = AssetLoader.GetPrefabFromAssetBundle("vfx_DustCloud"); vfxPrefab.GetComponent().m_triggerOnAwake = false; solidLayerMask = LayerMask.GetMask(new string[1] { "static_solid" }); terrainLayerMask = LayerMask.GetMask(new string[1] { "terrain" }); targetPosition = ((Component)this).transform.position; Bounds bounds = ValheimMod.getComponentInChildrenAll(((Component)this).gameObject).bounds; initialPosition = targetPosition - Vector3.up * ((Bounds)(ref bounds)).extents.y * 2f; runeBlocker = new GameObject(); runeBlocker.transform.position = targetPosition; RuneProjectorBlocker runeProjectorBlocker = runeBlocker.AddComponent(); runeProjectorBlocker.radius = 3f; Vector3 val = targetPosition - initialPosition; distance = ((Vector3)(ref val)).magnitude; timeToHitTarget = distance / 1f; initialTime = Time.time; Object.Destroy((Object)(object)((Component)this).GetComponent()); calculateVFXPositions(); ((Component)this).transform.position = initialPosition; if ((Object)(object)((Component)this).GetComponent() == (Object)null) { ((Component)this).gameObject.AddComponent(); Rigidbody component = ((Component)this).GetComponent(); component.mass = 1f; component.useGravity = false; component.linearDamping = 0f; component.angularDamping = 0f; component.isKinematic = true; component.collisionDetectionMode = (CollisionDetectionMode)0; component.constraints = (RigidbodyConstraints)126; } } private bool shouldAnimate() { return netView.GetZDO().GetBool("shouldAnimate", false); } public void PostZNetViewAwake(ZNetView view) { netView = ((Component)this).GetComponent(); if (PlayerPatch.PlayerPlacing) { netView.GetZDO().Set("shouldAnimate", true); netView.GetZDO().Set("placedByPlayer", true); } } private void calculateVFXPositions() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_004f: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = ValheimMod.getComponentInChildrenAll(((Component)this).gameObject).bounds; Vector3 extents = ((Bounds)(ref bounds)).extents; float val = Math.Min(extents.x / 2f, extents.z / 2f); val = Math.Min(val, 3f); PoissonDiscSampler poissonDiscSampler = new PoissonDiscSampler(extents.x * 2f, extents.z * 2f, val); vfxPoints = poissonDiscSampler.getSamples(); vfxPoints.Reverse(); } private void setupVFXPartial() { //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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) int num = Math.Min(vfxPoints.Count, 5); List range = vfxPoints.GetRange(vfxPoints.Count - num, num); vfxPoints.RemoveRange(vfxPoints.Count - num, num); RaycastHit val2 = default(RaycastHit); RaycastHit val3 = default(RaycastHit); foreach (Vector2 item in range) { Vector3 val = targetPosition + new Vector3(item.x, 1000f, item.y); if (Physics.Raycast(val, Vector3.down, ref val2, 2000f, solidLayerMask) && Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).collider) && ValheimMod.isChild(((Component)this).gameObject.transform, ((Component)((RaycastHit)(ref val2)).collider).gameObject.transform) && Physics.Raycast(val, Vector3.down, ref val3, 2000f, terrainLayerMask) && Object.op_Implicit((Object)(object)((RaycastHit)(ref val3)).collider)) { Quaternion rotation = Random.rotation; GameObject val4 = Object.Instantiate(vfxPrefab, ((RaycastHit)(ref val3)).point, rotation); val4.GetComponent().Trigger(timeToHitTarget + 10f); constructedVFX.Add(val4); } } } private void Update() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) setupVFXPartial(); float num = Time.time - initialTime; float num2 = Mathf.Clamp(num / timeToHitTarget, 0f, 1f); ((Component)this).transform.position = Vector3.Lerp(initialPosition, targetPosition, num2); if ((double)(timeToHitTarget - num) < 2.5) { foreach (GameObject item in constructedVFX) { if ((Object)(object)item == (Object)null) { continue; } ParticleSystem[] componentsInChildren = item.GetComponentsInChildren(); ParticleSystem[] array = componentsInChildren; foreach (ParticleSystem val in array) { if (!((Object)(object)val == (Object)null)) { val.Stop(); } } } constructedVFX.Clear(); } if (num2 >= 1f) { if ((Object)(object)netView != (Object)null) { netView.GetZDO().Set("shouldAnimate", false); } LogUtils.LogDebug("Destroying rockAnimator"); Object.Destroy((Object)(object)((Component)this).gameObject.GetComponent()); Object.Destroy((Object)(object)runeBlocker); Object.Destroy((Object)(object)this); } } } internal abstract class ProgressiveAlteration { protected Vector2 start; public float speed; public float effectWidth; public float currentDistance { get; set; } public ProgressiveAlteration(Vector3 start, float speed, float effectWidth) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_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) this.start = new Vector2(start.x, start.z); this.speed = speed; this.effectWidth = effectWidth; currentDistance = (0f - effectWidth) / 2f; } public void update(float deltaTime) { currentDistance += speed * deltaTime; } public abstract bool isPointInsideOuterEdge(Vector3 pos); public abstract bool isPointInsideCenterEdge(Vector3 pos); public abstract bool isPointInsideInnerEdge(Vector3 pos); public abstract float getDistanceToCenterEdge(Vector3 pos); public abstract float getFractionOfWaveCrossed(Vector3 pos); } internal class LinearProgressiveAlteration : ProgressiveAlteration { private Vector2 direction; public LinearProgressiveAlteration(Vector3 start, float speed, float effectWidth, Vector2 direction) : base(start, speed, effectWidth) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) this.direction = ((Vector2)(ref direction)).normalized; } public override bool isPointInsideOuterEdge(Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return insideRange(pos, base.currentDistance + effectWidth / 2f); } public override bool isPointInsideCenterEdge(Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return insideRange(pos, base.currentDistance); } public override bool isPointInsideInnerEdge(Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return insideRange(pos, base.currentDistance - effectWidth / 2f); } public override float getDistanceToCenterEdge(Vector3 pos) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(pos.x, pos.z); Vector2 val2 = val - start; float num = Vector2.Dot(val2, direction); return num - base.currentDistance; } public override float getFractionOfWaveCrossed(Vector3 pos) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(pos.x, pos.z); Vector2 val2 = val - start; float value = Vector2.Dot(val2, direction); return MathUtils.InverseLerpUnclamped(base.currentDistance + effectWidth / 2f, base.currentDistance - effectWidth / 2f, value); } private bool insideRange(Vector3 pos, float distance) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(pos.x, pos.z); Vector2 val2 = val - start; float num = Vector2.Dot(val2, direction); return num < distance; } } internal class RadialProgressiveAlteration : ProgressiveAlteration { public RadialProgressiveAlteration(Vector3 start, float speed, float effectWidth) : base(start, speed, effectWidth) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) public override bool isPointInsideOuterEdge(Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return insideRange(pos, base.currentDistance + effectWidth / 2f); } public override bool isPointInsideCenterEdge(Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return insideRange(pos, base.currentDistance); } public override bool isPointInsideInnerEdge(Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return insideRange(pos, base.currentDistance - effectWidth / 2f); } public override float getDistanceToCenterEdge(Vector3 pos) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(pos.x, pos.z); Vector2 val2 = val - start; return ((Vector2)(ref val2)).magnitude - base.currentDistance; } public override float getFractionOfWaveCrossed(Vector3 pos) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(pos.x, pos.z); Vector2 val2 = val - start; float magnitude = ((Vector2)(ref val2)).magnitude; return MathUtils.InverseLerpUnclamped(base.currentDistance + effectWidth / 2f, base.currentDistance - effectWidth / 2f, magnitude); } private bool insideRange(Vector3 pos, float distance) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(pos.x, pos.z); Vector2 val2 = val - start; return ((Vector2)(ref val2)).magnitude <= distance; } } public static class AssetLoader { private static Dictionary loadedBundles = new Dictionary(); private static Dictionary cachedPrefabs = new Dictionary(); private static Dictionary cachedSprites = new Dictionary(); private const string DefaultConfigPath = "ValheimMod.Resources."; private const string AssetBundleName = "testitem"; private const string PrefabPathPrefix = "Assets/CustomPrefabs/"; private const string SpritePathPrefix = "Assets/CustomSprites/"; private const string ScriptableObjectPathPrefix = "Assets/CustomScriptableObjects/"; private const string MeshPathPrefix = "Assets/CustomModels/"; private const string MaterialPathPrefix = "Assets/CustomMaterials/"; private const string TexturePathPrefix = "Assets/CustomTextures/"; public static GameObject GetPrefabFromAssetBundle(string prefabName) { if (!cachedPrefabs.ContainsKey(prefabName)) { string text = "Assets/CustomPrefabs/" + prefabName + ".prefab"; AssetBundle assetBundleFromResources = GetAssetBundleFromResources("testitem"); cachedPrefabs[prefabName] = assetBundleFromResources.LoadAsset(text); } return cachedPrefabs[prefabName]; } public static Sprite GetSpriteFromAssetBundle(string spriteName) { if (!cachedSprites.ContainsKey(spriteName)) { string text = "Assets/CustomSprites/" + spriteName; AssetBundle assetBundleFromResources = GetAssetBundleFromResources("testitem"); cachedSprites[spriteName] = assetBundleFromResources.LoadAsset(text); } return cachedSprites[spriteName]; } public static Sprite GetSpriteFromAssetBundle(string resourceName, string spriteName) { AssetBundle assetBundleFromResources = GetAssetBundleFromResources("testitem"); Sprite[] array = assetBundleFromResources.LoadAssetWithSubAssets("Assets/CustomSprites/" + resourceName); Sprite[] array2 = array; foreach (Sprite val in array2) { if (((Object)val).name.Equals(spriteName)) { return val; } } return null; } public static ScriptableObject GetScriptableObject(string name) { string text = "Assets/CustomScriptableObjects/" + name + ".asset"; AssetBundle assetBundleFromResources = GetAssetBundleFromResources("testitem"); return assetBundleFromResources.LoadAsset(text); } public static Mesh GetMesh(string containerName, string meshName) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown string text = "Assets/CustomModels/" + containerName; AssetBundle assetBundleFromResources = GetAssetBundleFromResources("testitem"); GameObject val = assetBundleFromResources.LoadAsset(text); foreach (Transform item in val.transform) { Transform val2 = item; if (((Object)((Component)val2).gameObject).name.Equals(meshName)) { return ((Component)val2).gameObject.GetComponent().mesh; } } return null; } public static Material GetMaterial(string materialName) { string text = "Assets/CustomMaterials/" + materialName + ".mat"; AssetBundle assetBundleFromResources = GetAssetBundleFromResources("testitem"); return assetBundleFromResources.LoadAsset(text); } public static Texture GetTexture(string textureName) { string text = "Assets/CustomTextures/" + textureName; AssetBundle assetBundleFromResources = GetAssetBundleFromResources("testitem"); return assetBundleFromResources.LoadAsset(text); } public static string ReadEmbeddedResource(string name) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name2 = "ValheimMod.Resources." + name; using Stream stream = executingAssembly.GetManifestResourceStream(name2); using StreamReader streamReader = new StreamReader(stream); return streamReader.ReadToEnd(); } private static AssetBundle GetAssetBundleFromResources(string fileName) { if (!loadedBundles.ContainsKey(fileName)) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(fileName)); using Stream stream = executingAssembly.GetManifestResourceStream(name); loadedBundles.Add(fileName, AssetBundle.LoadFromStream(stream)); } return loadedBundles[fileName]; } public static Sprite LoadSprite(string path, Rect size, Vector2 pivot, int units = 100) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //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) Assembly executingAssembly = Assembly.GetExecutingAssembly(); Stream manifestResourceStream = executingAssembly.GetManifestResourceStream(path); Texture2D val = new Texture2D((int)((Rect)(ref size)).width, (int)((Rect)(ref size)).height, (TextureFormat)4, false, true); using MemoryStream memoryStream = new MemoryStream(); manifestResourceStream.CopyTo(memoryStream); val.LoadRawTextureData(memoryStream.ToArray()); val.Apply(); return Sprite.Create(val, size, pivot, (float)units); } } internal class DelayedExecutor { [CompilerGenerated] private sealed class d__10 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Func condition; public Action lambda; public object[] parameters; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitUntil(condition); <>1__state = 1; return true; case 1: <>1__state = -1; lambda(parameters); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__11 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Func condition; public MethodInfo method; public DelayedExecutor <>4__this; public object[] parameters; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__11(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown int num = <>1__state; DelayedExecutor delayedExecutor = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitUntil(condition); <>1__state = 1; return true; case 1: <>1__state = -1; method.Invoke(delayedExecutor.script, parameters); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__8 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public float DelayInSeconds; public Action lambda; public object[] parameters; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(DelayInSeconds); <>1__state = 1; return true; case 1: <>1__state = -1; lambda(parameters); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__9 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public float DelayInSeconds; public MethodInfo method; public DelayedExecutor <>4__this; public object[] parameters; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown int num = <>1__state; DelayedExecutor delayedExecutor = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(DelayInSeconds); <>1__state = 1; return true; case 1: <>1__state = -1; method.Invoke(delayedExecutor.script, parameters); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private object script; private MonoBehaviour mono_script; public DelayedExecutor(object script) { this.script = script; ref MonoBehaviour reference = ref mono_script; object obj = this.script; reference = (MonoBehaviour)((obj is MonoBehaviour) ? obj : null); } public InvokeId DelayExecute(float DelayInSeconds, Action lambda, params object[] parameters) { return new InvokeId(mono_script.StartCoroutine(Delayed(DelayInSeconds, lambda, parameters))); } public InvokeId DelayExecute(float DelayInSeconds, string methodName, params object[] parameters) { MethodInfo[] methods = script.GetType().GetMethods(); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name == methodName) { return new InvokeId(mono_script.StartCoroutine(Delayed(DelayInSeconds, methodInfo, parameters))); } } return null; } public InvokeId ConditionExecute(Func condition, string methodName, params object[] parameters) { MethodInfo[] methods = script.GetType().GetMethods(); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name == methodName) { return new InvokeId(mono_script.StartCoroutine(Delayed(condition, methodInfo, parameters))); } } return null; } public InvokeId ConditionExecute(Func condition, Action lambda, params object[] parameters) { return new InvokeId(mono_script.StartCoroutine(Delayed(condition, lambda, parameters))); } public void StopExecute(InvokeId id) { mono_script.StopCoroutine(id.coroutine); } [IteratorStateMachine(typeof(d__8))] private IEnumerator Delayed(float DelayInSeconds, Action lambda, params object[] parameters) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__8(0) { DelayInSeconds = DelayInSeconds, lambda = lambda, parameters = parameters }; } [IteratorStateMachine(typeof(d__9))] private IEnumerator Delayed(float DelayInSeconds, MethodInfo method, params object[] parameters) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__9(0) { <>4__this = this, DelayInSeconds = DelayInSeconds, method = method, parameters = parameters }; } [IteratorStateMachine(typeof(d__10))] private IEnumerator Delayed(Func condition, Action lambda, params object[] parameters) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__10(0) { condition = condition, lambda = lambda, parameters = parameters }; } [IteratorStateMachine(typeof(d__11))] private IEnumerator Delayed(Func condition, MethodInfo method, params object[] parameters) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__11(0) { <>4__this = this, condition = condition, method = method, parameters = parameters }; } } internal class InvokeId { public readonly Coroutine coroutine; public InvokeId(Coroutine coroutine) { this.coroutine = coroutine; } } public class RunemagicPieceConfig { private static Dictionary nameMap = new Dictionary(); public Biome biome { get; } public string pieceName { get; } public string configName { get; } public RunemagicPieceConfig(Biome biome, string pieceName) : this(biome, pieceName, pieceName) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) public RunemagicPieceConfig(Biome biome, string pieceName, string configNameOverride) { //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.biome = biome; this.pieceName = pieceName; configName = configNameOverride; nameMap[pieceName] = configName; } public static float getEnergyCost(Piece piece) { string prefabName = Utils.GetPrefabName(((Component)piece).gameObject); if (!nameMap.ContainsKey(prefabName)) { return 0f; } string key = "energyCost_" + nameMap[prefabName]; float num = (ConfigLoader.containsKey(key) ? ConfigLoader.getFloat(key) : 0f); if (((Object)((Component)piece).gameObject).name.Equals("runemagic_passive_Decumberance")) { return SE_Decumberance.getCostPerSecond(Player.m_localPlayer); } if (((Object)((Component)piece).gameObject).name.Equals("runemagic_passive_WaterWalking")) { return SE_WaterWalking.getCostPerSecond(Player.m_localPlayer); } if (((Component)piece).gameObject.GetComponent() != null) { float size = ((Component)piece).gameObject.GetComponent().getSize(); num *= size; } return num; } public static bool isPassiveEffect(Piece piece) { return ((Object)((Component)piece).gameObject).name.Contains("_passive_"); } public bool isEnabled() { string text = "enableRune_" + configName; if (!ConfigLoader.containsKey(text)) { LogUtils.LogImportantMessage("Missing key " + text + ", defaulting to disabled"); return false; } return ConfigLoader.getBool(text); } public static bool isEnabled(Piece piece) { string prefabName = Utils.GetPrefabName(((Component)piece).gameObject); if (!nameMap.ContainsKey(prefabName)) { return false; } string text = "enableRune_" + nameMap[prefabName]; if (!ConfigLoader.containsKey(text)) { LogUtils.LogImportantMessage("Missing key " + text + ", defaulting to disabled"); return false; } return ConfigLoader.getBool(text); } } internal class PlayerPatch { [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] private class UpdatePlacementGhost_Patch { private static void Finalizer(Player __instance, GameObject ___m_placementGhost, int ___m_placeRotation) { DoRuneSpecialBehaviors(__instance, ___m_placementGhost, ___m_placeRotation); } private static void DoRuneSpecialBehaviors(Player __instance, GameObject ___m_placementGhost, int ___m_placeRotation) { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Invalid comparison between Unknown and I4 if ((Object)(object)___m_placementGhost == (Object)null || !UnlockManager.isUnlockable(__instance.GetSelectedPiece())) { return; } PlayerRaycast playerRaycast = new PlayerRaycast(__instance, -1, isRunemagicShatterSelected(__instance) || isRunemagicBlastingSelected(__instance)); if (!playerRaycast.hit || ((Object)(object)((RaycastHit)(ref playerRaycast.hitInfo)).collider.attachedRigidbody != (Object)null && (Object)(object)((Component)((RaycastHit)(ref playerRaycast.hitInfo)).collider).GetComponentInParent() == (Object)null)) { return; } PlacementGhostBehavior[] componentsInChildren = ___m_placementGhost.GetComponentsInChildren(); PlacementGhostBehavior[] array = componentsInChildren; foreach (PlacementGhostBehavior placementGhostBehavior in array) { if (!placementGhostBehavior.AdjustPlacementGhost(__instance, ___m_placementGhost, playerRaycast)) { break; } } if (isRunemagicShatterSelected(__instance)) { RunemagicShatterPatch(__instance, ___m_placementGhost); } else if (isResizableEffectSelected(__instance)) { ResizablePiecePatch(__instance, ___m_placementGhost, ___m_placeRotation); } ___m_placementGhost.GetComponent().SetInvalidPlacementHeightlight((int)__instance.m_placementStatus > 0); } private static void RunemagicShatterPatch(Player __instance, GameObject ___m_placementGhost) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) int mask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "terrain", "vehicle" }); PlayerRaycast playerRaycast = new PlayerRaycast(__instance, mask, allowRigidbody: true); if (!playerRaycast.hit || !RockDestroyer.isDestructibleStone(((RaycastHit)(ref playerRaycast.hitInfo)).collider)) { return; } if (RockDestroyer.hasDestructibleHull(((Component)((RaycastHit)(ref playerRaycast.hitInfo)).collider).gameObject)) { RockDestroyer rockDestroyer = RockDestroyer.create(); rockDestroyer.destroyRockWithRaycast(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, mask, onlyHull: true); return; } MeshFilter component = ((Component)((RaycastHit)(ref playerRaycast.hitInfo)).collider).gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { GameObject prefabFromAssetBundle = AssetLoader.GetPrefabFromAssetBundle("vfx_ShatteringRuneHighlight"); GameObject val = Object.Instantiate(prefabFromAssetBundle); val.transform.parent = ((Component)component).gameObject.transform; val.transform.localPosition = new Vector3(0f, 0f, 0f); val.transform.localRotation = Quaternion.identity; val.transform.localScale = new Vector3(1f, 1f, 1f); ShapeModule shape = val.GetComponent().shape; ((ShapeModule)(ref shape)).mesh = component.sharedMesh; ((ShapeModule)(ref shape)).scale = ((Component)component).gameObject.transform.lossyScale; } } private static void ResizablePiecePatch(Player __instance, GameObject ___m_placementGhost, int ___m_placeRotation) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) float @float = ConfigLoader.getFloat("resizablePieceMaxRadius"); float float2 = ConfigLoader.getFloat("resizablePieceMinRadius"); int @int = ConfigLoader.getInt("resizablePieceGranularity"); ___m_placementGhost.transform.rotation = Quaternion.identity; float num = (float)(Mathf.Abs(___m_placeRotation) % @int) / (float)@int; float radius = num * (@float - float2) + float2; setRadius(___m_placementGhost, radius); PieceTable buildPieces = __instance.m_buildPieces; setRadius(((Component)buildPieces.GetSelectedPiece()).gameObject, radius); } private static void setRadius(GameObject resizable, float radius) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) TerrainModifier componentInChildrenAll = ValheimMod.getComponentInChildrenAll(resizable); if ((Object)(object)componentInChildrenAll != (Object)null) { componentInChildrenAll.m_levelRadius = radius; componentInChildrenAll.m_smoothRadius = radius; componentInChildrenAll.m_paintRadius = radius; } ParticleSystem[] componentsInChildren = resizable.GetComponentsInChildren(true); ParticleSystem[] array = componentsInChildren; foreach (ParticleSystem val in array) { ShapeModule shape = val.shape; if (((ShapeModule)(ref shape)).radius != radius) { ((ShapeModule)(ref shape)).radius = radius; } } TerrainOp componentInChildrenAll2 = ValheimMod.getComponentInChildrenAll(resizable); if ((Object)(object)componentInChildrenAll2 != (Object)null) { componentInChildrenAll2.m_settings.m_levelRadius = radius; componentInChildrenAll2.m_settings.m_raiseRadius = radius; componentInChildrenAll2.m_settings.m_smoothRadius = radius; componentInChildrenAll2.m_settings.m_paintRadius = radius; } ValheimMod.getComponentInChildrenAll(resizable)?.setSize(radius); RuneProjector componentInChildrenAll3 = ValheimMod.getComponentInChildrenAll(resizable); if ((Object)(object)componentInChildrenAll3 != (Object)null) { resizable.transform.localScale = new Vector3(radius, 1f, radius); } } } [HarmonyPatch(typeof(Player), "PieceRayTest")] private class PieceRayTest_Patch { private static bool Postfix(bool __result, Player __instance, ref Vector3 point, ref Vector3 normal) { //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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) bool flag = isRunemagicShatterSelected(__instance) || isRunemagicBlastingSelected(__instance); if (__result || !flag) { return __result; } PlayerRaycast playerRaycast = new PlayerRaycast(__instance, -1, allowRigidbody: true); if (!playerRaycast.hit) { return __result; } if ((Object)(object)((RaycastHit)(ref playerRaycast.hitInfo)).collider.attachedRigidbody != (Object)null && (Object)(object)((Component)((RaycastHit)(ref playerRaycast.hitInfo)).collider).GetComponentInParent() == (Object)null) { return __result; } point = ((RaycastHit)(ref playerRaycast.hitInfo)).point; normal = ((RaycastHit)(ref playerRaycast.hitInfo)).normal; return true; } } [HarmonyPatch(typeof(Player), "CheckPlacementGhostVSPlayers")] private class CheckPlacementGhostVSPlayers_Patch { private static bool Postfix(bool __result, Player __instance, GameObject ___m_placementGhost) { if ((Object)(object)___m_placementGhost == (Object)null || (Object)(object)___m_placementGhost.GetComponent() != (Object)null) { return false; } return __result; } } [HarmonyPatch(typeof(Player), "ConsumeResources")] private class ConsumeResources_Patch { private static void Postfix(Player __instance) { PieceTable buildPieces = __instance.m_buildPieces; if (!((Object)(object)buildPieces == (Object)null) && isRuneFocusPieceTable(buildPieces) && !((Object)(object)buildPieces.GetSelectedPiece() == (Object)null)) { ExpendEnergy(__instance, RunemagicPieceConfig.getEnergyCost(buildPieces.GetSelectedPiece())); } } } [HarmonyPatch(typeof(Player), "SetupPlacementGhost")] private class SetupPlacementGhost_Patch { private static bool Prefix() { PlayerCreatingGhost = true; return true; } private static void Postfix(Player __instance, GameObject ___m_placementGhost) { PlayerCreatingGhost = false; if ((Object)(object)___m_placementGhost == (Object)null) { return; } List list = new List(); list.Add(typeof(DryLandRune)); list.Add(typeof(RockDestroyer)); list.Add(typeof(RockAnimator)); list.Add(typeof(CanopyRune)); List list2 = list; foreach (Type item in list2) { Component[] componentsInChildren = ___m_placementGhost.GetComponentsInChildren(item); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } } Piece component = ___m_placementGhost.GetComponent(); if ((Object)(object)component == (Object)null) { return; } if (ConfigLoader.getBool("disableRangeExtensionForLargePieces")) { component.m_extraPlacementDistance = 0; } else { BoundingSphere boundingSphere = BoundingSphere.Calculate(___m_placementGhost); if (boundingSphere != null) { component.m_extraPlacementDistance = (int)Math.Max(0f, 1f + boundingSphere.radius - __instance.m_maxPlaceDistance); } } if (PlaceableBoulderConfig.isPlaceableBoulder(Utils.GetPrefabName(___m_placementGhost))) { LogUtils.LogInfo("Adding magic circle"); BoulderSetupHandler.addRuneCircle(___m_placementGhost); Transform[] componentsInChildren2 = ___m_placementGhost.GetComponentsInChildren(); int layer = LayerMask.NameToLayer("ghost"); Transform[] array = componentsInChildren2; foreach (Transform val in array) { ((Component)val).gameObject.layer = layer; } } } } [HarmonyPatch(typeof(Player), "HaveRequirements", new Type[] { typeof(Piece), typeof(RequirementMode) })] private class HaveRequirements_Patch { private static bool Postfix(bool __result, Player __instance, HashSet ___m_knownRecipes, Piece piece, RequirementMode mode) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 if ((Object)(object)piece == (Object)null || !UnlockManager.isUnlockable(piece)) { return __result; } if ((int)mode == 1 || (int)mode == 2) { if (__result) { return UnlockManager.isUnlocked(__instance, piece); } return false; } if (__result) { return HasEnoughEnergy(__instance, RunemagicPieceConfig.getEnergyCost(piece)); } return false; } } [HarmonyPatch(typeof(Player), "UpdateAvailablePiecesList")] private class UpdateAvailablePiecesList_Patch { private static void Prefix(Player __instance, HashSet ___m_knownRecipes, PieceTable ___m_buildPieces) { if (!((Object)(object)___m_buildPieces != (Object)null) || !isRuneFocusPieceTable(___m_buildPieces)) { return; } foreach (GameObject piece in ___m_buildPieces.m_pieces) { Piece component = piece.GetComponent(); if (UnlockManager.isUnlockable(component) && !UnlockManager.isUnlocked(__instance, component) && ___m_knownRecipes.Contains(component.m_name)) { LogUtils.LogImportantMessage(component.m_name + " isn't unlocked, removing from known recipes list"); ___m_knownRecipes.Remove(component.m_name); } } } } [HarmonyPatch(typeof(Player), "SetPlaceMode")] private class SetPlaceMode_Patch { private static void Postfix(Player __instance, PieceTable buildPieces) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (ConfigLoader.getBool("RuneFocusEyeGlowEnabled") && isRuneFocusPieceTable(buildPieces)) { Vector4 vector = ConfigLoader.getVector4("RuneFocusEyeGlowColor"); Color val = ColorUtils.applyIntensity(new Color(vector.x, vector.y, vector.z), vector.w); PlayerVFXQueue.PlayerEyeVFX vfx = new PlayerVFXQueue.PlayerEyeVFX(new Vector3(val.r, val.g, val.b)); PlayerVFXQueue.enableLocalPlayerVFX(vfx, "RuneFocusEyeGlow", 1); } else { PlayerVFXQueue.disableLocalPlayerVFX("RuneFocusEyeGlow"); } } } [HarmonyPatch(typeof(Player), "TryPlacePiece")] private class TryPlacePiece_Patch { private static void Prefix() { PlayerPlacing = true; } private static bool Postfix(bool __result, Player __instance, Piece piece) { //IL_005e: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) if (__result && ((Object)((Component)piece).gameObject).name.Equals("runemagic_ShatteringRune")) { int mask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "terrain", "vehicle" }); RaycastHit val = default(RaycastHit); if (Physics.Raycast(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, ref val, 50f, mask) && Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider)) { RockDestroyer rockDestroyer = RockDestroyer.create(); rockDestroyer.destroyRockWithRaycast(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, mask); } else { LogUtils.LogInfo("Shatter didn't hit anything"); } } if (__result) { try { ValheimMod.analytics.piecePlaced(Utils.GetPrefabName(((Component)piece).gameObject)); } catch (Exception ex) { ValheimMod.DevModeLog(ex); } } return __result; } private static void Finalizer() { PlayerPlacing = false; } } [HarmonyPatch(typeof(Player), "Update")] private class Update_Patch { private static void Postfix(Player __instance) { //IL_00b3: 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_011d: Unknown result type (might be due to invalid IL or missing references) GracePeriodManager.update(Time.deltaTime); if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer) { handleStatusEffect(__instance, "runemagic_passive_WaterWalking", SE_WaterWalking.WaterWalkingStatusEffect); handleStatusEffect(__instance, "runemagic_passive_Decumberance", SE_Decumberance.DecumberanceStatusEffect); handleStatusEffect(__instance, "runemagic_passive_Alertness", SE_Alertness.AlertnessStatusEffect, extraCondition: true, delegate { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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) if (ConfigLoader.getBool("AlertnessEyeGlowEnabled")) { Vector4 vector = ConfigLoader.getVector4("AlertnessEyeGlowColor"); Color val = ColorUtils.applyIntensity(new Color(vector.x, vector.y, vector.z), vector.w); PlayerVFXQueue.PlayerEyeVFX vfx = new PlayerVFXQueue.PlayerEyeVFX(new Vector3(val.r, val.g, val.b)); PlayerVFXQueue.enableLocalPlayerVFX(vfx, "AlertnessRune", 10); } }, delegate { if (ConfigLoader.getBool("AlertnessEyeGlowEnabled")) { PlayerVFXQueue.disableLocalPlayerVFX("AlertnessRune"); } }); handleStatusEffect(__instance, "runemagic_passive_BoatPropulsion", SE_BoatPropulsion.BoatPropulsionStatusEffect, (Object)(object)__instance.GetControlledShip() != (Object)null); if (WorldGenerator.IsAshlands(((Component)__instance).transform.position.x, ((Component)__instance).transform.position.z)) { bool flag = ((Character)__instance).InLava(); bool flag2 = ((Character)__instance).m_lavaProximity > ((Character)__instance).m_minLavaMaskThreshold; bool flag3 = ((Character)__instance).m_lavaHeightFactor > 0f; if (!flag && flag2 && flag3 && !((Character)__instance).GetSEMan().HaveStatusEffect(SE_WaterWalking.WaterWalkingStatusEffect)) { float protectionFactor = GlobalLavaSolidifier.getProtectionFactor(((Component)__instance).transform.position); ((Character)__instance).m_lavaHeatLevel = ((Character)__instance).m_lavaHeatLevel + Time.deltaTime * ConfigLoader.getFloat("SolidLavaRune-edgeOverheatRate") * (1f - protectionFactor); ((Character)__instance).m_lavaHeatLevel = Mathf.Min(((Character)__instance).m_lavaHeatLevel, ((Character)__instance).m_heatLevelFirstDamageThreshold - ConfigLoader.getFloat("SolidLavaRune-edgeOverheatMargin")); } } } if (ConfigLoader.getBool("AlertnessEyeGlowEnabled")) { PlayerVFXQueue.handlePlayerVFX(__instance); } } private static void handleStatusEffect(Player player, string pieceName, int statusEffectHash, bool extraCondition = true, Action onEnable = null, Action onDisable = null) { PieceTable buildPieces = player.m_buildPieces; SEMan sEMan = ((Character)player).GetSEMan(); if (!Hud.IsPieceSelectionVisible() && (Object)(object)buildPieces != (Object)null && (Object)(object)buildPieces.GetSelectedPiece() != (Object)null && ((Object)buildPieces.GetSelectedPiece()).name.Equals(pieceName) && extraCondition) { if (!sEMan.HaveStatusEffect(statusEffectHash)) { sEMan.AddStatusEffect(ObjectDB.instance.GetStatusEffect(statusEffectHash), true, 0, 0f); onEnable?.Invoke(); } } else if (sEMan.HaveStatusEffect(statusEffectHash)) { sEMan.RemoveStatusEffect(statusEffectHash, false); onDisable?.Invoke(); } } } [HarmonyPatch(typeof(Player), "OnInventoryChanged")] private class OnInventoryChanged_Patch { private static void Postfix(Player __instance, bool ___m_isLoading, Inventory ___m_inventory) { if (___m_isLoading) { return; } foreach (ItemData allItem in ___m_inventory.GetAllItems()) { if (ValheimMod.isRuneFocus(allItem)) { if (!Tutorial.instance.m_texts.Contains(ValheimMod.RuneFocusTutorial)) { Tutorial.instance.m_texts.Add(ValheimMod.RuneFocusTutorial); } __instance.ShowTutorial(ValheimMod.RuneFocusTutorial.m_name, false); } } } } [HarmonyPatch(typeof(Player), "OnDamaged")] private class OnDamaged_Patch { private static void Postfix(Player __instance, HitData hit) { try { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && hit != null && (Object)(object)hit.GetAttacker() != (Object)null && hit.GetAttacker().IsPlayer()) { ValheimMod.analytics.wasPvpDamageTaken = true; ValheimMod.DevModeLog("Pvp damage taken"); } } catch (Exception ex) { ValheimMod.DevModeLog(ex); } } } [HarmonyPatch(typeof(Player), "CheckCanRemovePiece")] private class CheckCanRemovePiece_Patch { private static bool Postfix(bool __result, Player __instance, PieceTable ___m_buildPieces, Piece piece) { if ((Object)(object)piece == (Object)null || (Object)(object)___m_buildPieces == (Object)null) { return __result; } if (!__result) { return false; } bool flag = isRuneFocusPieceTable(___m_buildPieces); bool flag2 = ValheimMod.isPiecePlaceableByRuneFocus(piece); if (flag) { return flag2; } return !flag2; } } public static readonly string PLAYER_EYE_GLOW_KEY = "playerEyeGlow"; public static bool PlayerPlacing = false; public static bool PlayerCreatingGhost = false; private static bool isRuneFocusPieceTable(PieceTable table) { if ((Object)(object)table == (Object)null) { return false; } return ((Object)((Component)table).gameObject).name.Equals("_RuneFocusPieceTable"); } private static bool isPieceInTable(PieceTable table, Piece piece) { if ((Object)(object)table == (Object)null || (Object)(object)piece == (Object)null) { return false; } foreach (GameObject piece2 in table.m_pieces) { Piece component = piece2.GetComponent(); if ((Object)(object)component != (Object)null && component.m_name == piece.m_name) { return true; } } return false; } private static bool isRunemagicShatterSelected(Player __instance) { PieceTable buildPieces = __instance.m_buildPieces; if ((Object)(object)buildPieces == (Object)null || !isRuneFocusPieceTable(buildPieces)) { return false; } if ((Object)(object)buildPieces.GetSelectedPiece() == (Object)null || !((Object)((Component)buildPieces.GetSelectedPiece()).gameObject).name.Equals("runemagic_ShatteringRune")) { return false; } return true; } private static bool isRunemagicBlastingSelected(Player __instance) { PieceTable buildPieces = __instance.m_buildPieces; if ((Object)(object)buildPieces == (Object)null || !isRuneFocusPieceTable(buildPieces)) { return false; } if ((Object)(object)buildPieces.GetSelectedPiece() == (Object)null || !((Object)((Component)buildPieces.GetSelectedPiece()).gameObject).name.Equals("runemagic_BlastingRune")) { return false; } return true; } private static bool isResizableEffectSelected(Player __instance) { PieceTable buildPieces = __instance.m_buildPieces; if ((Object)(object)buildPieces == (Object)null || !isRuneFocusPieceTable(buildPieces)) { return false; } if ((Object)(object)buildPieces.GetSelectedPiece() == (Object)null || !ValheimMod.resizableTerrainModifierNames.Contains(((Object)((Component)buildPieces.GetSelectedPiece()).gameObject).name)) { return false; } return true; } public static void ExpendEnergy(Player player, float amount) { if (!player.NoCostCheat()) { PieceTable buildPieces = player.m_buildPieces; if (!((Object)(object)buildPieces == (Object)null) && isRuneFocusPieceTable(buildPieces)) { ItemData playerRightItem = getPlayerRightItem(player); playerRightItem.m_durability -= amount; playerRightItem.m_durability = Mathf.Clamp(playerRightItem.m_durability, 0f, playerRightItem.GetMaxDurability()); } } } public static bool HasEnoughEnergy(Player player, float amount) { PieceTable buildPieces = player.m_buildPieces; if ((Object)(object)buildPieces == (Object)null || !isRuneFocusPieceTable(buildPieces)) { return false; } return getPlayerRightItem(player).m_durability >= amount; } public static float getAvailableEnergy(Player player) { PieceTable buildPieces = player.m_buildPieces; if ((Object)(object)buildPieces == (Object)null || !isRuneFocusPieceTable(buildPieces)) { return 0f; } return getPlayerRightItem(player).m_durability; } public static ItemData getPlayerRightItem(Player player) { return ((Humanoid)player).m_rightItem; } } internal class TerrainModifierPatch { [HarmonyPatch(typeof(TerrainModifier), "Awake")] private class Awake_Patch { private static bool Prefix(TerrainModifier __instance) { ZNetView component = ((Component)__instance).GetComponent(); if ((Object)(object)component != (Object)null && component.GetZDO() != null && ValheimMod.resizableTerrainModifierNames.Contains(((Object)((Component)__instance).gameObject).name)) { FieldInfo field = ((object)__instance).GetType().GetField("m_triggerOnPlaced", BindingFlags.Static | BindingFlags.NonPublic); if (!(bool)field.GetValue(__instance)) { __instance.m_levelRadius = component.GetZDO().GetFloat("terrainRadius", 3f); __instance.m_smoothRadius = component.GetZDO().GetFloat("terrainRadius", 3f); __instance.m_paintRadius = component.GetZDO().GetFloat("terrainRadius", 3f); LogUtils.LogInfo($"Resizing {((Object)((Component)__instance).gameObject).name} to {__instance.m_levelRadius}"); } else { LogUtils.LogDebug("Attempting to save"); if (component.IsOwner()) { LogUtils.LogDebug("Saving"); component.GetZDO().Set("terrainRadius", __instance.m_levelRadius); } } } return true; } } [HarmonyPatch(typeof(TerrainModifier), "GetRadius")] private class Get_Radius_Patch { private static float Postfix(float __result, TerrainModifier __instance) { if (!__instance.m_level && !__instance.m_smooth && !__instance.m_paintCleared) { return Math.Max(__instance.m_levelRadius, Math.Max(__instance.m_smoothRadius, __instance.m_paintRadius)); } return __result; } } [HarmonyPatch(typeof(TerrainModifier), "OnPlaced")] private class OnPlaced_Patch { private static void Postfix(TerrainModifier __instance, ZNetView ___m_nview) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (!((Object)((Component)__instance).gameObject).name.StartsWith("runemagic_reset")) { return; } List list = new List(); Vector3 position = ((Component)__instance).gameObject.transform.position; float radius = __instance.GetRadius(); TerrainModifier.GetModifiers(position, radius, list, __instance); foreach (TerrainModifier item in list) { ZNetView nview = item.m_nview; if (Object.op_Implicit((Object)(object)nview) && nview.IsValid()) { nview.ClaimOwnership(); nview.Destroy(); } } } } public const string RADIUS_KEY = "terrainRadius"; } internal class BoulderSetupHandler { public static void SetUpCustomBoulderFeatures() { if (!CustomContentSetupHandler.IsObjectDBReady() || (Object)(object)ZNetScene.instance == (Object)null) { return; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("RuneFocus"); ItemDrop component = itemPrefab.GetComponent(); PieceTable buildPieces = component.m_itemData.m_shared.m_buildPieces; foreach (PlaceableBoulderConfig boulderConfig in ValheimMod.BoulderConfigs) { GameObject prefab = ZNetScene.instance.GetPrefab(boulderConfig.prefabName); prefab.layer = LayerMask.NameToLayer("static_solid"); if ((Object)(object)prefab.GetComponent() == (Object)null) { prefab.AddComponent(); setupPieceBehavior(boulderConfig, prefab, buildPieces); makeDoubleSided(prefab); } if ((Object)(object)prefab.GetComponent() == (Object)null) { prefab.AddComponent(); } } } private static void setupPieceBehavior(PlaceableBoulderConfig config, GameObject obj, PieceTable runeFocusTable) { //IL_0047: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown Piece component = obj.GetComponent(); component.m_icon = AssetLoader.GetSpriteFromAssetBundle("BoulderSprites/" + config.prefabName + "-PieceSprite.png"); component.m_name = config.displayName; component.m_description = ""; component.m_enabled = true; component.m_category = (PieceCategory)3; component.m_groundPiece = true; component.m_clipEverything = true; component.m_onlyInBiome = (Biome)0; component.m_comfortGroup = (ComfortGroup)0; component.m_placeEffect = new EffectList(); component.m_resources = (Requirement[])(object)new Requirement[0]; component.m_canBeRemoved = false; if (!runeFocusTable.m_pieces.Contains(obj)) { runeFocusTable.m_pieces.Add(obj); } } private static void makeDoubleSided(GameObject obj) { MeshFilter[] componentsInChildren = obj.GetComponentsInChildren(true); MeshFilter[] array = componentsInChildren; foreach (MeshFilter val in array) { Mesh mesh = val.mesh; mesh.triangles = mesh.triangles.Concat(mesh.triangles.Reverse()).ToArray(); } } public static void addRuneCircle(GameObject obj) { //IL_0006: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) obj.transform.rotation = Quaternion.identity; MeshFilter[] componentsInChildren = obj.GetComponentsInChildren(true); List list = new List(); MeshFilter[] array = componentsInChildren; foreach (MeshFilter val in array) { Vector3[] vertices = val.sharedMesh.vertices; foreach (Vector3 val2 in vertices) { Vector3 val3 = ((Component)val).transform.TransformPoint(val2); list.Add(new Vector2(val3.x, val3.z)); } } BoundingCircle boundingCircle = BoundingCircle.minimumCircle(list); int @int = ConfigLoader.getInt("BoulderSummonCircleSegments", reload: true); for (int k = 0; k < @int; k++) { for (int l = 0; l < @int; l++) { GameObject val4 = generateRuneCircleSegment(obj, l, k, @int); float @float = ConfigLoader.getFloat("BoulderSummonCircleRadius"); float num = boundingCircle.radius / @float; Vector3 localScale = obj.transform.localScale; val4.transform.localScale = new Vector3(num / localScale.x, 1f / localScale.y, num / localScale.z); val4.transform.position = new Vector3(boundingCircle.center.x, obj.transform.position.y + ConfigLoader.getFloat("BoulderSummonCircleHeightOffset"), boundingCircle.center.y); } } } private static GameObject generateRuneCircleSegment(GameObject parent, int x, int z, int segments) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(AssetLoader.GetPrefabFromAssetBundle("StandingStoneBaseRune"), parent.transform, false); MeshFilter componentInChildren = val.GetComponentInChildren(); Mesh mesh = componentInChildren.mesh; Vector3[] vertices = mesh.vertices; float num = 1f / (float)segments; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(num * ((float)x + 0.5f) - 0.5f, num * ((float)z + 0.5f) - 0.5f); num *= 1f + ConfigLoader.getFloat("BoulderSummonCircleOverlapFactor"); for (int i = 0; i < vertices.Length; i++) { vertices[i].x *= num; vertices[i].z *= num; vertices[i].x += val2.x; vertices[i].z += val2.y; } mesh.vertices = vertices; return val; } } public class RunicEnergyAccumulator : MonoBehaviour { private const string EnergyLevelKey = "runic_energyLevel"; private const string SecondsSinceIncreaseKey = "runic_secondsSinceUpdate"; private const string LastUpdateTimeKey = "runic_lastUpdateTime"; private const string RuneUnlockKey = "runic_unlock"; private ZNetView nview; private MeshRenderer runestoneRenderer; private MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock(); private Light pointLight; private float emissionMultiplier; private float maxLightIntensity; public int maxEnergy; public float secondsPerEnergy; public int maxRunesSpawned = 30; private void Awake() { maxEnergy = Math.Max(ConfigLoader.getInt("runestoneMaxStoredEnergy"), 1); secondsPerEnergy = ConfigLoader.getFloat("runestoneSecondsToFullCharge") / (float)maxEnergy; maxRunesSpawned = ConfigLoader.getInt("maxRuneCount"); initGlow(); ((MonoBehaviour)this).InvokeRepeating("initNetView", 0f, 1f); } private void initGlow() { //IL_00ed: Unknown result type (might be due to invalid IL or missing references) runestoneRenderer = ((Component)this).gameObject.GetComponentInChildren(); pointLight = ((Component)this).gameObject.GetComponentInChildren(); emissionMultiplier = 3f; if (((Object)this).name == "RuneStone_DragonQueen") { Transform parent = ((Component)this).gameObject.transform.parent; pointLight = ((Component)parent).GetComponentInChildren(); emissionMultiplier = 1.5f; Transform parent2 = parent.parent; Transform val = parent2.Find("Dragonlocation"); runestoneRenderer = ((Component)val).GetComponentInChildren(); } if ((Object)(object)runestoneRenderer == (Object)null) { LogUtils.LogError("Gameobject " + ((Object)((Component)this).gameObject).name + " doesn't have a MeshRenderer!"); Object.Destroy((Object)(object)this); } if ((Object)(object)pointLight != (Object)null) { maxLightIntensity = pointLight.intensity; pointLight.color = new Color(1f, 0.3676471f, 0.3676471f); } } private void initNetView() { nview = ValheimMod.getComponentInParentAll(((Component)this).gameObject); if ((Object)(object)nview != (Object)null && nview.GetZDO() != null) { ((MonoBehaviour)this).CancelInvoke(); nview.ClaimOwnership(); if (nview.IsOwner() && nview.GetZDO().GetLong("runic_lastUpdateTime", 0L) == 0L) { nview.GetZDO().Set("runic_lastUpdateTime", ZNet.instance.GetTime().Ticks); nview.GetZDO().Set("runic_energyLevel", maxEnergy); } nview.Unregister("Extract"); nview.Unregister("spawnRunes"); nview.Register("Extract", (Action)RPC_Extract); nview.Register("spawnRunes", (Action)RPC_spawnRunes); ((MonoBehaviour)this).InvokeRepeating("UpdateEnergyLevel", 0.1f, secondsPerEnergy); ((MonoBehaviour)this).InvokeRepeating("updateGlow", 0.2f, secondsPerEnergy); } } public bool Interact(Humanoid character, bool repeat) { return false; } public bool UseItem(Humanoid user, ItemData item) { if (!ValheimMod.isRuneFocus(item)) { return false; } Player val = (Player)(object)((user is Player) ? user : null); if (val != null) { unlockRune(val); item.m_durability = Mathf.Clamp(item.m_durability, 0f, item.GetMaxDurability()); int energyLevel = GetEnergyLevel(); int num = Mathf.CeilToInt(item.GetMaxDurability() - item.m_durability); int num2 = Math.Min(energyLevel, num); if (num2 > 0) { try { spawnRunes(val, Math.Max(1, num2 * maxRunesSpawned / maxEnergy)); } catch (Exception ex) { LogUtils.LogWarning("Error while attempting to spawn runes: "); LogUtils.LogException(ex); } ((Character)user).Message((MessageType)1, string.Format(Localization.instance.Localize("$message_runemagic_runestone_extractedrunicenergy"), num2), 0, (Sprite)null); LogUtils.LogInfo($"UseItem added {num2} energy"); item.m_durability = Mathf.Clamp(item.m_durability + (float)num2, 0f, item.GetMaxDurability()); Extract(num2); } else if (energyLevel <= 0) { ((Character)user).Message((MessageType)1, "$message_runemagic_runestone_exhaustedenergy", 0, (Sprite)null); } else if (num <= 0) { ((Character)user).Message((MessageType)1, "$message_runemagic_runefocus_fullenergy", 0, (Sprite)null); } } return true; } private void Extract(int extractedAmount) { nview.InvokeRPC("Extract", new object[1] { extractedAmount }); } private void RPC_Extract(long caller, int extractedAmount) { if (nview.IsOwner()) { int energyLevel = GetEnergyLevel(); int num = Mathf.Clamp(energyLevel - extractedAmount, 0, maxEnergy); nview.GetZDO().Set("runic_energyLevel", num); LogUtils.LogInfo($"RPC_Extract removed {energyLevel - num} energy"); } updateGlow(); } private float GetTimeSinceLastUpdateInSeconds() { DateTime dateTime = new DateTime(nview.GetZDO().GetLong("runic_lastUpdateTime", ZNet.instance.GetTime().Ticks)); DateTime time = ZNet.instance.GetTime(); TimeSpan timeSpan = time - dateTime; nview.GetZDO().Set("runic_lastUpdateTime", time.Ticks); double num = timeSpan.TotalSeconds; if (num < 0.0) { num = 0.0; } return (float)num; } private void IncreaseLevel(int i) { int energyLevel = GetEnergyLevel(); energyLevel += i; energyLevel = Mathf.Clamp(energyLevel, 0, maxEnergy); nview.GetZDO().Set("runic_energyLevel", energyLevel); } private void updateGlow() { //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) ((Renderer)runestoneRenderer).GetPropertyBlock(propertyBlock); float num = (float)GetEnergyLevel() / (float)maxEnergy; propertyBlock.SetColor("_EmissionColor", Color.red * num * emissionMultiplier); ((Renderer)runestoneRenderer).SetPropertyBlock(propertyBlock); if ((Object)(object)pointLight != (Object)null) { pointLight.intensity = Mathf.Lerp(0f, maxLightIntensity, num * ConfigLoader.getFloat("runestonePointlightFactor")); } } private int GetEnergyLevel() { if ((Object)(object)nview != (Object)null && nview.IsValid()) { return nview.GetZDO().GetInt("runic_energyLevel", maxEnergy); } return 0; } private void UpdateEnergyLevel() { if (nview.IsOwner()) { float timeSinceLastUpdateInSeconds = GetTimeSinceLastUpdateInSeconds(); float @float = nview.GetZDO().GetFloat("runic_secondsSinceUpdate", 0f); @float += timeSinceLastUpdateInSeconds; if (@float > secondsPerEnergy) { int i = (int)(@float / secondsPerEnergy); IncreaseLevel(i); @float %= secondsPerEnergy; } nview.GetZDO().Set("runic_secondsSinceUpdate", @float); } } private void unlockRune(Player player) { if (ConfigLoader.getBool("allRunesStartUnlocked")) { return; } if (nview.GetZDO().GetString("runic_unlock", "").Equals("")) { string newRuneUnlock = UnlockManager.getNewRuneUnlock(player, this); if (newRuneUnlock == "runemagic_NoValidUnlock") { return; } nview.GetZDO().Set("runic_unlock", newRuneUnlock); } string text = nview.GetZDO().GetString("runic_unlock", ""); if ((Object)(object)ZNetScene.instance.GetPrefab(text) == (Object)null) { LogUtils.LogImportantMessage("Rune " + text + " is unrecognized, getting new rune unlock"); text = UnlockManager.getNewRuneUnlock(player, this); if (text == "runemagic_NoValidUnlock") { return; } nview.GetZDO().Set("runic_unlock", text); } Piece component = ZNetScene.instance.GetPrefab(text).GetComponent(); if (!RunemagicPieceConfig.isEnabled(component)) { LogUtils.LogImportantMessage("Rune " + text + " is disabled, getting new rune unlock"); text = UnlockManager.getNewRuneUnlock(player, this); if (text == "runemagic_NoValidUnlock") { return; } nview.GetZDO().Set("runic_unlock", text); } UnlockManager.unlockRune(player, text); } public void resetUnlockedRune() { nview.GetZDO().Set("runic_unlock", ""); } public void resetCharge() { Extract(-10000); } private void spawnRunes(Player target, int count) { LogUtils.LogDebug($"Spawning runes for player {target.GetPlayerID()}"); nview.InvokeRPC(ZNetView.Everybody, "spawnRunes", new object[2] { target.GetPlayerID(), count }); } private void RPC_spawnRunes(long caller, long playerId, int count) { if (((Object)this).name == "RuneStone_DragonQueen") { spawnRunesDragonQueen(playerId, count); } else { spawnRunesStandardRunestone(playerId, count); } } private void spawnRunesStandardRunestone(long playerId, int count) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_00e7: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) float @float = ConfigLoader.getFloat("runestoneCenterHeight"); float float2 = ConfigLoader.getFloat("runestoneCenterRadius"); float float3 = ConfigLoader.getFloat("runeBounds"); float float4 = ConfigLoader.getFloat("runeSpawnTime"); Player playerWithId = getPlayerWithId(playerId); if ((Object)(object)playerWithId == (Object)null) { LogUtils.LogInfo("Couldn't find player " + playerId); } else if (canPlayerSeeRunes()) { PoissonDiscSampler poissonDiscSampler = new PoissonDiscSampler(float2 * 2f, float2 * 2f, float3, count); List samples = poissonDiscSampler.getSamples(); List list = new List(); for (int i = 0; i < samples.Count; i++) { Vector3 val = Vector3.Cross(((Component)this).transform.forward, Vector3.up); Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 item = ((Component)this).transform.position + Vector3.up * @float + normalized * samples[i].x + Vector3.up * samples[i].y; list.Add(item); } spawnRunesAtPositions(list, playerWithId); } } private void spawnRunesDragonQueen(long playerId, int count) { //IL_008a: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_00e7: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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) Player playerWithId = getPlayerWithId(playerId); if ((Object)(object)playerWithId == (Object)null) { LogUtils.LogInfo("Couldn't find player " + playerId); } else if (canPlayerSeeRunes()) { float @float = ConfigLoader.getFloat("runestoneDragonQueen_height"); float float2 = ConfigLoader.getFloat("runestoneDragonQueen_radius"); float float3 = ConfigLoader.getFloat("runestoneDragonQueen_angleOffset"); float float4 = ConfigLoader.getFloat("runestoneDragonQueen_angularExtent"); Transform parent = ((Component)this).transform.parent; List list = new List(); for (int i = 0; i < count; i++) { float num = float3 + float4 / (float)count * (float)i; Vector3 val = Vector3.Cross(parent.forward, Vector3.up); Vector3 val2 = ((Vector3)(ref val)).normalized * float2; Vector3 val3 = Quaternion.Euler(0f, num, 0f) * val2; Vector3 item = parent.position + val3 + new Vector3(0f, @float, 0f); list.Add(item); } for (int j = 0; j < list.Count; j++) { Vector3 value = list[j]; int index = Random.Range(j, list.Count); list[j] = list[index]; list[index] = value; } spawnRunesAtPositions(list, playerWithId); } } private Player getPlayerWithId(long playerId) { Player result = null; foreach (Player allPlayer in Player.GetAllPlayers()) { LogUtils.LogDebug($"Checking player {allPlayer.GetPlayerID()}"); if (allPlayer.GetPlayerID() == playerId) { result = allPlayer; break; } } return result; } private bool canPlayerSeeRunes() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0074: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.position - ((Component)GameCamera.instance).transform.position; float num = Mathf.Clamp(((Vector3)(ref val)).magnitude - 4f, 0f, 1000f); val = ((Component)this).transform.position - ((Component)GameCamera.instance).transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; if (Physics.Raycast(((Component)GameCamera.instance).transform.position, normalized, num, LayerMask.GetMask(new string[7] { "Default", "static_solid", "Default_small", "piece", "terrain", "viewblock", "vehicle" }))) { LogUtils.LogDebug("Something is in the way of seeing the runes"); return false; } return true; } private void spawnRunesAtPositions(List positions, Player target) { //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_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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) GameObject prefabFromAssetBundle = AssetLoader.GetPrefabFromAssetBundle("HomingSpawner_Runestone"); float @float = ConfigLoader.getFloat("runeSpawnTime"); for (int i = 0; i < positions.Count; i++) { Vector3 val = positions[i]; GameObject val2 = Object.Instantiate(prefabFromAssetBundle, val, Random.rotation); HomingSpawner component = val2.GetComponent(); GameObject val3 = new GameObject("targetOffset"); val3.transform.parent = ((Component)target).transform; val3.transform.localPosition = ((Character)target).GetCenterPoint() - ((Component)target).transform.position; component.target = val3.transform; component.startDelay = (float)i * @float / (float)positions.Count; } } } public class ItemRecipeConfig { public string itemName; public string stationName; public Dictionary resources; public int quantity; public int minStationLevel; public ItemRecipeConfig(string itemName, string stationName = null, Dictionary requiredResources = null, int quantity = 1, int minStationLevel = 0) { this.itemName = itemName; this.stationName = stationName; resources = requiredResources; this.quantity = quantity; this.minStationLevel = minStationLevel; } } internal class RecipeHandler { public static Dictionary craftingStations; public static void setupItemRecipes(List recipes, bool enabled) { cacheCraftingStations(); foreach (ItemRecipeConfig recipe2 in recipes) { Recipe recipe = createRecipe(recipe2); if ((Object)(object)recipe == (Object)null) { LogUtils.LogError("[RecipeHandler] Recipe creation failed for item " + recipe2.itemName); continue; } int num = ObjectDB.instance.m_recipes.RemoveAll((Recipe x) => ((Object)x).name == ((Object)recipe).name); if (num > 0) { LogUtils.LogInfo($"[RecipeHandler] Removed recipe ({((Object)recipe).name}): {num}"); } if (enabled) { ObjectDB.instance.m_recipes.Add(recipe); LogUtils.LogInfo("[RecipeHandler] Added recipe: " + ((Object)recipe).name); } } } public static void setupPieceRecipes(List recipes, bool enabled) { cacheCraftingStations(); foreach (PieceRecipeConfig recipe in recipes) { Piece component = recipe.prefab.GetComponent(); if ((Object)(object)component == (Object)null) { LogUtils.LogError("Prefab " + ((Object)recipe.prefab).name + " doesn't have a Piece component"); continue; } component.m_resources = constructRequirements(recipe.resources); if (!string.IsNullOrEmpty(recipe.craftingStation)) { if (!craftingStations.ContainsKey(recipe.craftingStation)) { LogUtils.LogWarning("[RecipeHandler] Could not find crafting station for " + ((Object)recipe.prefab).name + ": " + recipe.craftingStation); string text = string.Join(", ", craftingStations.Keys); LogUtils.LogInfo("[RecipeHandler] Available Stations: " + text); } else { component.m_craftingStation = craftingStations[recipe.craftingStation]; } } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(recipe.pieceTableItem); ItemDrop component2 = itemPrefab.GetComponent(); PieceTable buildPieces = component2.m_itemData.m_shared.m_buildPieces; if (enabled && !buildPieces.m_pieces.Contains(recipe.prefab)) { buildPieces.m_pieces.Add(recipe.prefab); } else if (!enabled && buildPieces.m_pieces.Contains(recipe.prefab)) { buildPieces.m_pieces.Remove(recipe.prefab); } } } private static void cacheCraftingStations() { if (craftingStations != null) { return; } craftingStations = new Dictionary(); foreach (Recipe recipe in ObjectDB.instance.m_recipes) { if ((Object)(object)recipe.m_craftingStation != (Object)null && !craftingStations.ContainsKey(((Object)recipe.m_craftingStation).name)) { craftingStations.Add(((Object)recipe.m_craftingStation).name, recipe.m_craftingStation); } } } private static Recipe createRecipe(ItemRecipeConfig recipeConfig) { Recipe val = ScriptableObject.CreateInstance(); GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(recipeConfig.itemName); if ((Object)(object)itemPrefab == (Object)null) { LogUtils.LogWarning("[RecipeHandler] Could not find item prefab (" + recipeConfig.itemName + ")"); return null; } ((Object)val).name = "Recipe_" + recipeConfig.itemName; val.m_item = itemPrefab.GetComponent(); val.m_amount = 1; val.m_enabled = true; val.m_minStationLevel = 2; if (!string.IsNullOrEmpty(recipeConfig.stationName)) { if (!craftingStations.ContainsKey(recipeConfig.stationName)) { LogUtils.LogWarning("[RecipeHandler] Could not find crafting station for " + recipeConfig.itemName + ": " + recipeConfig.stationName); string text = string.Join(", ", craftingStations.Keys); LogUtils.LogInfo("[RecipeHandler] Available Stations: " + text); } else { val.m_craftingStation = craftingStations[recipeConfig.stationName]; } } val.m_resources = constructRequirements(recipeConfig.resources); return val; } private static Requirement[] constructRequirements(Dictionary resources) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown List list = new List(); if (resources != null) { foreach (KeyValuePair resource in resources) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(resource.Key); if ((Object)(object)itemPrefab == (Object)null) { LogUtils.LogError("[RecipeHandler] Could not find requirement (" + resource.Key + ")"); continue; } ItemDrop component = itemPrefab.GetComponent(); component.m_itemData.m_dropPrefab = itemPrefab; list.Add(new Requirement { m_amount = resource.Value, m_amountPerLevel = resource.Value, m_resItem = itemPrefab.GetComponent() }); } } return list.ToArray(); } } internal class RockDestroyer : MonoBehaviour { public float delay; public float intensityAtMax = 1f; public float effectRadius; private float timeSinceSpawn; private RuneProjector projector; private ZNetView netView; private bool isManual; private static bool CreatingManualDestroyer; public static RockDestroyer create() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown CreatingManualDestroyer = true; GameObject val = new GameObject("RockDestroyerObj"); RockDestroyer result = val.AddComponent(); CreatingManualDestroyer = false; return result; } private void Awake() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) projector = ((Component)this).GetComponent(); netView = ((Component)this).GetComponent(); isManual = CreatingManualDestroyer; if ((delay == 0f && !PlayerPatch.PlayerCreatingGhost) || isManual) { Object.Destroy((Object)(object)((Component)this).GetComponentInChildren()); projector = null; return; } Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, 0.5f); Collider[] array2 = array; foreach (Collider val in array2) { Leviathan componentInParent = ((Component)val).gameObject.GetComponentInParent(); if ((Object)(object)val.attachedRigidbody != (Object)null && (Object)(object)componentInParent != (Object)null) { Animator componentInChildren = ((Component)componentInParent).GetComponentInChildren(); ((Component)this).transform.SetParent(((Component)componentInChildren).gameObject.transform, true); break; } } } private void Update() { timeSinceSpawn += Time.deltaTime; if (!isManual) { if ((Object)(object)projector != (Object)null) { projector.setIntensity(Mathf.Lerp(1f, intensityAtMax, timeSinceSpawn / delay)); } if ((Object)(object)netView != (Object)null && netView.IsOwner() && effectRadius > 0f && timeSinceSpawn > delay) { destroyRockAOE(effectRadius); } else if (effectRadius == 0f) { ZNetScene.instance.Destroy(((Component)this).gameObject); } } } public void destroyRockAOE(float radius) { //IL_0081: 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_00d3: 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_0145: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) int mask = LayerMask.GetMask(new string[11] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "character", "character_net", "character_ghost", "hitbox", "character_noenv", "vehicle" }); Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, radius, mask, (QueryTriggerInteraction)0); int num = 0; Collider[] array2 = array; foreach (Collider val in array2) { GameObject val2 = Projectile.FindHitObject(val); IDestructible component = val2.GetComponent(); if (hasDestructibleHull(component)) { ((Component)(Destructible)component).GetComponent().ClaimOwnership(); ((Destructible)component).DestroyNow(); num++; } } if (num > 0) { LogUtils.LogDebug($"Destroyed {num} hulls, scheduling second hit"); DelayedExecutor delayedExecutor = new DelayedExecutor(this); delayedExecutor.DelayExecute(0.1f, delegate { destroyRockAOE(radius); }); } else { DamageTypes damage = default(DamageTypes); damage.m_pickaxe = 100f; hitColliders(array, damage); DamageTypes damage2 = default(DamageTypes); damage2.m_blunt = 10f; hitColliders(Physics.OverlapSphere(((Component)this).transform.position, radius * 2f, mask, (QueryTriggerInteraction)0), damage2); ZNetScene.instance.Destroy(((Component)this).gameObject); } } private void hitColliders(Collider[] colliders, DamageTypes damage) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_00a9: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_00eb: 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_00f5: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(); foreach (Collider val in colliders) { GameObject val2 = Projectile.FindHitObject(val); if (hashSet.Contains(val2) && !((Object)val2).name.Contains("_frac") && !((Object)val2).name.Contains("___MineRock5") && (Object)(object)val2.GetComponent() == (Object)null) { continue; } hashSet.Add(val2); Vector3 val3 = ((!(val is MeshCollider)) ? val.ClosestPoint(((Component)this).transform.position) : val.ClosestPointOnBounds(((Component)this).transform.position)); IDestructible component = val2.GetComponent(); if (component != null) { Vector3 val4 = val3 - ((Component)this).transform.position; Vector3 normalized = ((Vector3)(ref val4)).normalized; if (willBeDamagedBy(val2, damage)) { HitData val5 = new HitData(); val5.m_damage = damage; val5.m_toolTier = 10; val5.m_point = val3; val5.m_dir = normalized; val5.m_skill = (SkillType)0; val5.m_hitCollider = val; component.Damage(val5); } } } } public void destroyRockWithRaycastDelayed(Vector3 pos, Vector3 dir, int layerMask) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) DelayedExecutor delayedExecutor = new DelayedExecutor(this); delayedExecutor.DelayExecute(0.1f, delegate { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) destroyRockWithRaycast(pos, dir, layerMask); }); } public void destroyRockWithRaycast(Vector3 pos, Vector3 dir, int layerMask, bool onlyHull = false) { //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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_00fa: 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_011d: 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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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) RaycastHit val = default(RaycastHit); bool flag = Physics.Raycast(pos, dir, ref val, 50f, layerMask) && Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider); bool flag2 = flag && (Object)(object)((RaycastHit)(ref val)).collider.attachedRigidbody != (Object)null && (Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent() != (Object)null; if (flag && (!Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider.attachedRigidbody) || flag2)) { Vector3 point = ((RaycastHit)(ref val)).point; IDestructible componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent(); LogUtils.LogInfo("hitinfo " + ((Object)((Component)((RaycastHit)(ref val)).collider).gameObject).name); if (componentInParent == null) { return; } if (hasDestructibleHull(componentInParent)) { ((Component)(Destructible)componentInParent).GetComponent().ClaimOwnership(); ((Destructible)componentInParent).DestroyNow(); if (!onlyHull) { LogUtils.LogDebug("Destroyed hull, scheduling second hit"); destroyRockWithRaycastDelayed(pos, dir, layerMask); } return; } if (!onlyHull) { HitData val2 = new HitData(); val2.m_damage = default(DamageTypes); val2.m_damage.m_pickaxe = 1000f; val2.m_toolTier = 10; val2.m_point = point; val2.m_dir = ((Component)GameCamera.instance).transform.forward; val2.m_skill = (SkillType)0; val2.m_hitCollider = ((RaycastHit)(ref val)).collider; componentInParent.Damage(val2); } } else { LogUtils.LogError("destroyRockWithRaycast didn't hit a valid target!"); } ZNetScene.instance.Destroy(((Component)this).gameObject); } public void deleteRockWithRaycast(Vector3 pos, Vector3 dir, int layerMask) { //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_0027: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00d1: 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_00e5: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (Physics.Raycast(pos, dir, ref val, 50f, layerMask) && Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider)) { Vector3 point = ((RaycastHit)(ref val)).point; IDestructible componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent(); LogUtils.LogInfo("hitinfo " + ((Object)((Component)((RaycastHit)(ref val)).collider).gameObject).name); Destructible val2 = (Destructible)(object)((componentInParent is Destructible) ? componentInParent : null); if (val2 != null) { ((Component)val2).GetComponent().ClaimOwnership(); val2.m_spawnWhenDestroyed = null; val2.DestroyNow(); } else { MineRock5 val3 = (MineRock5)(object)((componentInParent is MineRock5) ? componentInParent : null); if (val3 != null) { ((Component)val3).GetComponent().ClaimOwnership(); ZNetScene.instance.Destroy(((Component)val3).gameObject); } else { MineRock val4 = (MineRock)(object)((componentInParent is MineRock) ? componentInParent : null); if (val4 != null) { HitData val5 = new HitData(); val5.m_hitCollider = ((RaycastHit)(ref val)).collider; val5.m_damage = new DamageTypes { m_pickaxe = 10000f }; val5.m_toolTier = 1000; val4.Damage(val5); } } } } else { LogUtils.LogError("deleteRockWithRaycast didn't hit a valid target!"); } ZNetScene.instance.Destroy(((Component)this).gameObject); } public static bool hasDestructibleHull(GameObject obj) { IDestructible componentInParent = obj.GetComponentInParent(); if (componentInParent != null) { return hasDestructibleHull(componentInParent); } return false; } private static bool hasDestructibleHull(IDestructible obj) { Destructible val = (Destructible)(object)((obj is Destructible) ? obj : null); if (val != null) { if (val.m_health == 1f && (Object)(object)val.m_spawnWhenDestroyed != (Object)null) { return ((Object)val.m_spawnWhenDestroyed).name.Contains("_frac"); } return false; } return false; } public static bool isDestructibleStone(Collider col) { //IL_000e: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_008f: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) IDestructible componentInParent = ((Component)col).gameObject.GetComponentInParent(); DamageModifiers val = default(DamageModifiers); Destructible val2 = (Destructible)(object)((componentInParent is Destructible) ? componentInParent : null); if (val2 != null) { val = val2.m_damages; } else { MineRock5 val3 = (MineRock5)(object)((componentInParent is MineRock5) ? componentInParent : null); if (val3 != null) { val = val3.m_damageModifiers; } else { MineRock val4 = (MineRock)(object)((componentInParent is MineRock) ? componentInParent : null); if (val4 != null) { val = val4.m_damageModifiers; if (val4.GetAreaIndex(col) == -1) { return false; } } } } if (!isImmune(val.m_pickaxe) && isImmune(val.m_blunt) && isImmune(val.m_chop) && isImmune(val.m_fire) && isImmune(val.m_frost) && isImmune(val.m_pierce) && isImmune(val.m_poison) && isImmune(val.m_slash)) { return isImmune(val.m_spirit); } return false; } public static bool willBeDamagedBy(GameObject obj, DamageTypes damage) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_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_007c: 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_006c: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00b7: 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_00d3: 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_00c3: 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_00f1: 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) //IL_010a: 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_00fd: 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_0125: 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_013e: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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_0165: Unknown result type (might be due to invalid IL or missing references) IDestructible componentInParent = obj.GetComponentInParent(); DamageModifiers val = default(DamageModifiers); Destructible val2 = (Destructible)(object)((componentInParent is Destructible) ? componentInParent : null); if (val2 != null) { val = val2.m_damages; } else { MineRock5 val3 = (MineRock5)(object)((componentInParent is MineRock5) ? componentInParent : null); if (val3 != null) { val = val3.m_damageModifiers; } else { Character val4 = (Character)(object)((componentInParent is Character) ? componentInParent : null); if (val4 != null) { val = val4.m_damageModifiers; } else { WearNTear val5 = (WearNTear)(object)((componentInParent is WearNTear) ? componentInParent : null); if (val5 != null) { val = val5.m_damages; } } } } if ((isImmune(val.m_blunt) || !(damage.m_blunt > 0f)) && (isImmune(val.m_chop) || !(damage.m_chop > 0f)) && (isImmune(val.m_fire) || !(damage.m_fire > 0f)) && (isImmune(val.m_frost) || !(damage.m_frost > 0f)) && (isImmune(val.m_lightning) || !(damage.m_lightning > 0f)) && (isImmune(val.m_pickaxe) || !(damage.m_pickaxe > 0f)) && (isImmune(val.m_pierce) || !(damage.m_pierce > 0f)) && (isImmune(val.m_poison) || !(damage.m_poison > 0f)) && (isImmune(val.m_slash) || !(damage.m_slash > 0f))) { if (!isImmune(val.m_spirit)) { return damage.m_spirit > 0f; } return false; } return true; } public static bool isImmune(DamageModifier mod) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)mod != 3) { return (int)mod == 4; } return true; } } [HarmonyPatch(typeof(ZoneSystem), "Start")] public static class ZoneSystem_Start_Patch { public static void Postfix() { LogUtils.LogDebug("ZoneSystem_Start_Patch ran"); RuneStonePatch.setAccumulatorOnRuneStones(ValheimMod.isModEnabled); WaterSurfaceManager.addToWaterVolumes(); MaterialReplacer.RegisterMaterials(); Piece[] array = Resources.FindObjectsOfTypeAll(); Piece[] array2 = array; foreach (Piece val in array2) { if (((Object)((Component)val).gameObject).name.Equals("Karve") || ((Object)((Component)val).gameObject).name.Equals("Raft") || ((Object)((Component)val).gameObject).name.Equals("VikingShip")) { val.m_canBeRemoved = true; } } TerrainHolder.determineTerrainHeightBounds(); } } [HarmonyPatch(typeof(ZNetScene), "Awake")] public static class ZNetScene_Awake_Patch { public static bool Prefix(ZNetScene __instance) { LogUtils.LogDebug("ZNetScene_Awake_Patch ran"); CustomContentSetupHandler.TryRegisterPrefabs(__instance); return true; } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] public static class ObjectDB_CopyOtherDB_Patch { public static void Postfix() { LogUtils.LogDebug("ObjectDB_CopyOtherDB_Patch ran"); CustomContentSetupHandler.TryRegisterItems(); CustomContentSetupHandler.TryRegisterRecipes(); CustomContentSetupHandler.TryRegisterStatusEffects(); BoulderSetupHandler.SetUpCustomBoulderFeatures(); } } [HarmonyPatch(typeof(ObjectDB), "Awake")] public static class ObjectDB_Awake_Patch { [HarmonyPriority(600)] public static void Postfix() { LogUtils.LogDebug("ObjectDB_Awake_Patch ran"); CustomContentSetupHandler.TryRegisterItems(); CustomContentSetupHandler.TryRegisterRecipes(); CustomContentSetupHandler.TryRegisterStatusEffects(); BoulderSetupHandler.SetUpCustomBoulderFeatures(); } } public static class CustomContentSetupHandler { public static readonly List RegisteredItemPrefabs = new List(); public static readonly List RegisteredNonItemPrefabs = new List(); public static readonly List RegisteredRecipes = new List(); public static readonly List RegisteredPieceRecipes = new List(); public static readonly List RegisteredStatusEffects = new List(); public static GameObject RegisterItem(string prefabName) { GameObject prefabFromAssetBundle = AssetLoader.GetPrefabFromAssetBundle(prefabName); RegisteredItemPrefabs.Add(prefabFromAssetBundle); return prefabFromAssetBundle; } public static GameObject RegisterPrefab(string prefabName, params Type[] components) { GameObject prefabFromAssetBundle = AssetLoader.GetPrefabFromAssetBundle(prefabName); if ((Object)(object)prefabFromAssetBundle == (Object)null) { throw new Exception("Missing prefab " + prefabName); } foreach (Type type in components) { prefabFromAssetBundle.AddComponent(type); } return RegisterPrefab(prefabFromAssetBundle); } public static GameObject RegisterPrefab(GameObject prefab) { RegisteredNonItemPrefabs.Add(prefab); return prefab; } public static void RegisterRecipe(ItemRecipeConfig recipe) { RegisteredRecipes.Add(recipe); } public static void RegisterRecipe(PieceRecipeConfig recipe) { RegisteredPieceRecipes.Add(recipe); } public static void RegisterStatusEffect(StatusEffect effect) { RegisteredStatusEffects.Add(effect); } public static void TryRegisterPrefabs(ZNetScene zNetScene) { if ((Object)(object)zNetScene == (Object)null) { return; } foreach (GameObject registeredItemPrefab in RegisteredItemPrefabs) { if (!zNetScene.m_prefabs.Contains(registeredItemPrefab)) { zNetScene.m_prefabs.Add(registeredItemPrefab); } } foreach (GameObject registeredNonItemPrefab in RegisteredNonItemPrefabs) { if (zNetScene.m_prefabs.Contains(registeredNonItemPrefab)) { continue; } if (!Application.isBatchMode) { MeshRenderer[] componentsInChildren = registeredNonItemPrefab.GetComponentsInChildren(); MeshRenderer[] array = componentsInChildren; foreach (MeshRenderer val in array) { Material sharedMaterial = ((Renderer)val).sharedMaterial; if (((Object)sharedMaterial.shader).name.Equals("Standard-LocalCopy")) { sharedMaterial.shader = SoftReferenceUtils.StandardShader.getAsset(); } } } zNetScene.m_prefabs.Add(registeredNonItemPrefab); } } public static bool IsObjectDBReady() { if ((Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0) { return (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null; } return false; } public static void TryRegisterItems() { if (!IsObjectDBReady()) { return; } foreach (GameObject registeredItemPrefab in RegisteredItemPrefabs) { ItemDrop component = registeredItemPrefab.GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)ObjectDB.instance.GetItemPrefab(ObjectDB.instance.GetPrefabHash(registeredItemPrefab)) == (Object)null) { ObjectDB.instance.m_items.Add(registeredItemPrefab); } } ObjectDB.instance.UpdateRegisters(); } public static void TryRegisterRecipes() { if (IsObjectDBReady()) { RecipeHandler.setupItemRecipes(RegisteredRecipes, enabled: true); RecipeHandler.setupPieceRecipes(RegisteredPieceRecipes, enabled: true); } } public static void TryUnregisterRecipes() { if (IsObjectDBReady()) { RecipeHandler.setupItemRecipes(RegisteredRecipes, enabled: false); RecipeHandler.setupPieceRecipes(RegisteredPieceRecipes, enabled: false); } } public static void TryRegisterStatusEffects() { if (!IsObjectDBReady()) { return; } foreach (StatusEffect registeredStatusEffect in RegisteredStatusEffects) { if ((Object)(object)ObjectDB.instance.GetStatusEffect(registeredStatusEffect.NameHash()) == (Object)null) { ObjectDB.instance.m_StatusEffects.Add(registeredStatusEffect); } } } public static void DropItems(List loot, Vector3 centerPos, float dropHemisphereRadius = 0.5f) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_007f: 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_00a4: 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_0096: Unknown result type (might be due to invalid IL or missing references) foreach (GameObject item in loot) { Vector3 val = Random.insideUnitSphere * dropHemisphereRadius; val.y = Mathf.Abs(val.y); item.transform.position = centerPos + val; item.transform.rotation = Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f); Rigidbody component = item.GetComponent(); if ((Object)(object)component != (Object)null) { Vector3 insideUnitSphere = Random.insideUnitSphere; if ((double)insideUnitSphere.y < 0.0) { insideUnitSphere.y = 0f - insideUnitSphere.y; } component.AddForce(insideUnitSphere * 5f, (ForceMode)2); } } } } public class BurningEdgeSpawnEffect : MonoBehaviour { public float spawnEffectTime = 3f; public float pause = 2f; public AnimationCurve fadeIn; private float timer; private Renderer _renderer; private int shaderProperty; private void Start() { shaderProperty = Shader.PropertyToID("_cutoff"); Renderer[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren(true); _renderer = componentsInChildren.Single((Renderer r) => ((Object)r.material.shader).name.Equals("Custom/Dissolve")); fadeIn = AnimationCurve.Linear(0f, 1f, 1f, 0f); } private void Update() { if (timer < spawnEffectTime + pause) { timer += Time.deltaTime; } else { timer = 0f; } if ((Object)(object)_renderer != (Object)null) { _renderer.material.SetFloat(shaderProperty, fadeIn.Evaluate(Mathf.InverseLerp(0f, spawnEffectTime, timer))); } } } public class SoftReferenceUtils { public static SoftReferenceByID StandardShader = new SoftReferenceByID("7e6bbee7a32b746cb9396cd890ce7189"); public static SoftReferenceByID stone_mat = new SoftReferenceByID("1a6531f086d8242ee827a56a24141313"); public static SoftReferenceByID rock_med = new SoftReferenceByID("df2b27a7827cc426a8b764b57700cbee"); public static SoftReferenceByID rock_med_n = new SoftReferenceByID("fa882c53597b447759164ff44e1604e5"); public static SoftReferenceByID smoke = new SoftReferenceByID("1f987cf832562498c82881fb8acc45ba"); public static SoftReferenceByID smokeBall = new SoftReferenceByID("93b7ace58e5f44c9287e4399a0f9908d", loadOnServer: true); public static SoftReferenceByID fog = new SoftReferenceByID("f0643a1e00b7f4e52b068fb23f9174aa"); private static List softRefSetupActions = new List(); public static void registerSetupAction(Action act) { if (Runtime.s_assetLoader == null) { softRefSetupActions.Add(act); } else { act(); } } public static void triggerSetup() { if (Runtime.s_assetLoader == null) { ValheimMod.DevModeWarn("SoftRef loader has still not been initialized"); return; } foreach (Action softRefSetupAction in softRefSetupActions) { softRefSetupAction(); } softRefSetupActions.Clear(); } } public class SoftReferenceByID where T : Object { private string assetID; private SoftReference reference; private bool loadOnServer; public SoftReferenceByID(string assetID, bool loadOnServer = false) { this.assetID = assetID; this.loadOnServer = loadOnServer; } public T getAsset() { //IL_003c: 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_005f: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (Application.isBatchMode && !loadOnServer) { return default(T); } if (!ValheimMod.isModAwake) { LogUtils.LogWarning("Attempting to use soft references before Awake complete"); } if (Runtime.s_assetLoader == null) { LogUtils.LogWarning("Attempting to use soft references before the game has initialized the AssetBundleLoader"); } _ = reference; if (!reference.IsValid) { AssetID val = default(AssetID); AssetID.TryParse(assetID, ref val); reference = new SoftReference(val); LoadResult val2 = reference.Load(); if ((int)val2 != 0) { LogUtils.LogError($"Failed to load asset {reference.m_assetID}: {val2}"); } } return reference.Asset; } } public static class StandardShaderUtils { public enum BlendMode { Opaque, Cutout, Fade, Transparent } public enum ParticleColorMode { Multiply, Overlay, Color, Difference, Additive, Subtractive } public static BlendMode GetRenderMode(Material standardShaderMaterial) { float @float = standardShaderMaterial.GetFloat("_Mode"); if (@float == 0f) { return BlendMode.Opaque; } if (@float == 1f) { return BlendMode.Cutout; } if (@float == 2f) { return BlendMode.Fade; } return BlendMode.Transparent; } public static void ChangeRenderMode(Material standardShaderMaterial, BlendMode blendMode) { switch (blendMode) { case BlendMode.Opaque: standardShaderMaterial.SetInt("_SrcBlend", 1); standardShaderMaterial.SetInt("_DstBlend", 0); standardShaderMaterial.SetInt("_ZWrite", 1); standardShaderMaterial.DisableKeyword("_ALPHATEST_ON"); standardShaderMaterial.DisableKeyword("_ALPHABLEND_ON"); standardShaderMaterial.DisableKeyword("_ALPHAPREMULTIPLY_ON"); standardShaderMaterial.SetFloat("_Mode", 0f); standardShaderMaterial.renderQueue = -1; break; case BlendMode.Cutout: standardShaderMaterial.SetInt("_SrcBlend", 1); standardShaderMaterial.SetInt("_DstBlend", 0); standardShaderMaterial.SetInt("_ZWrite", 1); standardShaderMaterial.EnableKeyword("_ALPHATEST_ON"); standardShaderMaterial.DisableKeyword("_ALPHABLEND_ON"); standardShaderMaterial.DisableKeyword("_ALPHAPREMULTIPLY_ON"); standardShaderMaterial.SetFloat("_Mode", 1f); standardShaderMaterial.renderQueue = 2450; break; case BlendMode.Fade: standardShaderMaterial.SetInt("_SrcBlend", 5); standardShaderMaterial.SetInt("_DstBlend", 10); standardShaderMaterial.SetInt("_ZWrite", 0); standardShaderMaterial.DisableKeyword("_ALPHATEST_ON"); standardShaderMaterial.EnableKeyword("_ALPHABLEND_ON"); standardShaderMaterial.DisableKeyword("_ALPHAPREMULTIPLY_ON"); standardShaderMaterial.SetFloat("_Mode", 2f); standardShaderMaterial.renderQueue = 3000; break; case BlendMode.Transparent: standardShaderMaterial.SetInt("_SrcBlend", 1); standardShaderMaterial.SetInt("_DstBlend", 10); standardShaderMaterial.SetInt("_ZWrite", 0); standardShaderMaterial.DisableKeyword("_ALPHATEST_ON"); standardShaderMaterial.DisableKeyword("_ALPHABLEND_ON"); standardShaderMaterial.EnableKeyword("_ALPHAPREMULTIPLY_ON"); standardShaderMaterial.SetFloat("_Mode", 3f); standardShaderMaterial.renderQueue = 3000; break; } } public static ParticleColorMode getColorMode(Material mat) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) bool flag = mat.IsKeywordEnabled("_COLOROVERLAY_ON"); bool flag2 = mat.IsKeywordEnabled("_COLORCOLOR_ON"); if (mat.IsKeywordEnabled("_COLORADDSUBDIFF_ON")) { Vector4 vector = mat.GetVector("_ColorAddSubDiff"); if (vector.y > 0.5f) { return ParticleColorMode.Difference; } if (vector.x > 0.5f) { return ParticleColorMode.Additive; } return ParticleColorMode.Subtractive; } if (flag2) { return ParticleColorMode.Color; } if (flag) { return ParticleColorMode.Overlay; } return ParticleColorMode.Multiply; } public static float DecodeFloatRGBA(Color 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_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 StandardShaderUtils.DecodeFloatRGBA(new Vector4(c.r, c.g, c.b, c.a)); } public static float DecodeFloatRGBA(float r, float g, float b, float a) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) return StandardShaderUtils.DecodeFloatRGBA(new Vector4(r, g, b, a)); } public static float DecodeFloatRGBA(Vector4 rgba) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) Vector4 val = default(Vector4); ((Vector4)(ref val))..ctor(1f, 0.003921569f, 1.53787E-05f, 6.030863E-08f); return Vector4.Dot(rgba, val); } } internal class TerrainHolder { private static float maxTerrainHeight = 8f; private static float minTerrainHeight = -8f; public List affectedTerrain = new List(); public Dictionary heightmaps = new Dictionary(); public Dictionary heightmapBuildData = new Dictionary(); public Dictionary smoothDeltas = new Dictionary(); public Dictionary levelDeltas = new Dictionary(); public Dictionary smoothDeltasOriginal = new Dictionary(); public Dictionary levelDeltasOriginal = new Dictionary(); public Dictionary modifiedHeights = new Dictionary(); public Dictionary heightsWithTerrainMods = new Dictionary(); public TerrainHolder(List hmaps) { foreach (Heightmap hmap in hmaps) { TerrainComp andCreateTerrainCompiler = hmap.GetAndCreateTerrainCompiler(); affectedTerrain.Add(andCreateTerrainCompiler); heightmaps[andCreateTerrainCompiler] = hmap; heightmapBuildData[hmap] = hmap.m_buildData; modifiedHeights[andCreateTerrainCompiler] = andCreateTerrainCompiler.m_modifiedHeight; smoothDeltas[andCreateTerrainCompiler] = andCreateTerrainCompiler.m_smoothDelta; levelDeltas[andCreateTerrainCompiler] = andCreateTerrainCompiler.m_levelDelta; smoothDeltasOriginal[andCreateTerrainCompiler] = (float[])smoothDeltas[andCreateTerrainCompiler].Clone(); levelDeltasOriginal[andCreateTerrainCompiler] = (float[])levelDeltas[andCreateTerrainCompiler].Clone(); } } public void claimOwnership() { foreach (TerrainComp item in affectedTerrain) { ZNetView component = ((Component)item).gameObject.GetComponent(); if (!item.IsOwner()) { component.ClaimOwnership(); } } } public void calculateHeightsWithModifiers() { //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_00f9: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) foreach (TerrainComp item in affectedTerrain) { Heightmap val = heightmaps[item]; List list = new List(val.m_heights); int num = val.m_width + 1; int num2 = num * num; for (int i = 0; i < num2; i++) { val.m_heights[i] = val.m_buildData.m_baseHeights[i]; } List allInstances = TerrainModifier.GetAllInstances(); float[] array = null; float[] array2 = null; foreach (TerrainModifier item2 in allInstances) { if (((Behaviour)item2).enabled && val.TerrainVSModifier(item2)) { if (item2.m_playerModifiction && array == null) { array = val.m_heights.ToArray(); array2 = val.m_heights.ToArray(); } if (item2.m_level) { val.LevelTerrain(((Component)item2).transform.position + Vector3.up * item2.m_levelOffset, item2.m_levelRadius, item2.m_square, array, array2, item2.m_playerModifiction); } if (item2.m_smooth) { val.SmoothTerrain2(((Component)item2).transform.position + Vector3.up * item2.m_levelOffset, item2.m_smoothRadius, item2.m_square, array2, item2.m_smoothPower, item2.m_playerModifiction); } } } heightsWithTerrainMods[item] = val.m_heights.ToArray(); for (int j = 0; j < num2; j++) { val.m_heights[j] = list[j]; } } } public void repaint(TerrainComp comp, Vector3 center, float radius, PaintType type) { //IL_0001: 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) comp.PaintCleared(center, radius, type, false, true); } public void propagateChanges(TerrainComp comp) { Profiler.start("TerrainHolder-saveMethod"); comp.Save(); Profiler.stop("TerrainHolder-saveMethod"); Profiler.start("TerrainHolder-pokeHeightmaps"); heightmaps[comp].Poke(false); Profiler.stop("TerrainHolder-pokeHeightmaps"); } public static void resetGrass(Vector3 position, float radius) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)ClutterSystem.instance)) { ClutterSystem.instance.ResetGrass(position, radius); } } public static void clearClutter(Func clearedAreaFunction) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0144: 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) Profiler.start("TerrainHolder.clearClutter"); GameObject grassRoot = ClutterSystem.instance.m_grassRoot; if ((Object)(object)grassRoot == (Object)null) { return; } Vector3 arg = default(Vector3); foreach (Transform item in grassRoot.transform) { Transform val = item; InstanceRenderer component = ((Component)val).gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { Matrix4x4[] instances = component.m_instances; int instanceCount = component.m_instanceCount; for (int i = 0; i < instanceCount; i++) { ((Vector3)(ref arg))..ctor(((Matrix4x4)(ref instances[i]))[0, 3], ((Matrix4x4)(ref instances[i]))[1, 3], ((Matrix4x4)(ref instances[i]))[2, 3]); bool flag = clearedAreaFunction(arg); if (flag && ((Matrix4x4)(ref instances[i]))[1, 3] > -1000f) { ref Matrix4x4 reference = ref instances[i]; ((Matrix4x4)(ref reference))[1, 3] = ((Matrix4x4)(ref reference))[1, 3] - 100000f; } else if (!flag && ((Matrix4x4)(ref instances[i]))[1, 3] < -1000f) { ref Matrix4x4 reference = ref instances[i]; ((Matrix4x4)(ref reference))[1, 3] = ((Matrix4x4)(ref reference))[1, 3] + 100000f; } } } else { ((Component)val).gameObject.SetActive(!clearedAreaFunction(val.position)); } } Profiler.stop("TerrainHolder.clearClutter"); } public static void removeOldTerrainMods() { List allInstances = TerrainModifier.GetAllInstances(); if (allInstances.Count() > 0) { TerrainComp.UpgradeTerrain(); } } public static Vector3 calcVertex(Heightmap hmap, int x, int y) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_005e: 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) Vector3 val = new Vector3((float)hmap.m_width * hmap.m_scale * -0.5f, 0f, (float)hmap.m_width * hmap.m_scale * -0.5f) + ((Component)hmap).transform.position; return val + new Vector3((float)x * hmap.m_scale, hmap.GetHeight(x, y), (float)y * hmap.m_scale); } public static Heightmap findHeightmap(Vector3 pos) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) int num = default(int); int num2 = default(int); foreach (Heightmap allHeightmap in Heightmap.GetAllHeightmaps()) { allHeightmap.WorldToVertex(pos, ref num, ref num2); if (num >= 0 && num < allHeightmap.m_width && num2 >= 0 && num2 < allHeightmap.m_width) { return allHeightmap; } } return null; } public static float clampTerrainDelta(float delta) { return Mathf.Clamp(delta, getTerrainMinDelta(), getTerrainMaxDelta()); } public static float clampTerrainHeight(float height, float baseHeight) { return Mathf.Clamp(height, baseHeight + getTerrainMinDelta(), baseHeight + getTerrainMaxDelta()); } public static float getTerrainMinDelta() { return minTerrainHeight; } public static float getTerrainMaxDelta() { return maxTerrainHeight; } public float getBaseHeightWithModifiers(TerrainComp comp, int x, int z) { return heightsWithTerrainMods[comp][z * (heightmaps[comp].m_width + 1) + x]; } public static float getBaseHeight(Heightmap hmap, Vector2i xzCoord) { //IL_000b: 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_002c: Unknown result type (might be due to invalid IL or missing references) return hmap.m_buildData.m_baseHeights[xzCoord.y * (hmap.m_width + 1) + xzCoord.x] + ((Component)hmap).transform.position.y; } public static void determineTerrainHeightBounds() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_00ac: 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) try { GameObject val = new GameObject("TerrainHeightTester"); val.SetActive(false); TerrainComp val2 = val.AddComponent(); Heightmap val3 = val.AddComponent(); val3.m_width = 2; int num = (val3.m_width + 1) * (val3.m_width + 1); List heights = val3.m_heights; for (int i = 0; i < num; i++) { heights.Add(0f); } float[] array = new float[num]; float[] array2 = new float[num]; val2.m_hmap = val3; val2.m_width = val3.m_width; val2.m_modifiedHeight = new bool[num]; val2.m_smoothDelta = array2; val2.m_levelDelta = array; array2[0] = 10000f; val2.LevelTerrain(val.transform.position, 1f, true); maxTerrainHeight = array[0]; array2[0] = -10000f; val2.LevelTerrain(val.transform.position, 1f, true); minTerrainHeight = array[0]; } catch (Exception ex) { LogUtils.LogWarning("[Rune Magic] Unable to dynamically check min/max terrain height, using base game defaults"); LogUtils.LogException(ex); maxTerrainHeight = 8f; minTerrainHeight = -8f; } } } public class UnlockManager { public const string NO_VALID_RUNE_UNLOCK = "runemagic_NoValidUnlock"; private const string NUM_FAILED_UNLOCK_ATTEMPTS = "runemagic_numFailedUnlockAttempts"; public static bool isUnlockable(Piece piece) { if ((Object)(object)piece == (Object)null) { return false; } foreach (RunemagicPieceConfig runemagicPieceConfig in ValheimMod.runemagicPieceConfigs) { if (runemagicPieceConfig.pieceName.Equals(((Object)((Component)piece).gameObject).name)) { return true; } } return false; } public static bool isUnlocked(Player player, Piece piece) { if (!RunemagicPieceConfig.isEnabled(piece)) { return false; } if (ConfigLoader.getBool("allRunesStartUnlocked")) { return true; } return player.m_knownMaterial.Contains(((Object)((Component)piece).gameObject).name); } public static bool shouldUnlockNewRune(float unlockChance, int prevFailedUnlocks) { if (unlockChance >= 1f) { return true; } if (unlockChance <= 0f) { return false; } int maxFailedUnlocks = getMaxFailedUnlocks(unlockChance); if (maxFailedUnlocks >= 0 && prevFailedUnlocks >= maxFailedUnlocks) { return true; } return Random.Range(0f, 1f) < unlockChance; } public static int getMaxFailedUnlocks(float unlockChance) { if (unlockChance == 0f) { return -1; } float num = 1f / unlockChance; return Mathf.RoundToInt(num * 2f) - 1; } public static string getNewRuneUnlock(Player player, RunicEnergyAccumulator unlocker) { //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_0017: 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_009c: 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_019e: Unknown result type (might be due to invalid IL or missing references) HashSet knownMaterial = player.m_knownMaterial; Biome val = Heightmap.FindBiome(((Component)unlocker).transform.position); if (!player.m_customData.ContainsKey("runemagic_numFailedUnlockAttempts")) { player.m_customData.Add("runemagic_numFailedUnlockAttempts", "0"); } int num = int.Parse(player.m_customData["runemagic_numFailedUnlockAttempts"]); LogUtils.LogInfo($"Num unsuccessful unlocks: {num}"); float unlockChance = Mathf.Clamp01(ConfigLoader.getFloat("runestoneUnlockNewRuneChance")); HashSet unlockable; if (!shouldUnlockNewRune(unlockChance, num)) { LogUtils.LogInfo("Not unlocking new rune, getting already known one"); unlockable = getUnlockable(knownMaterial, newUnlock: false, new HashSet { val }); if (unlockable.Count() > 0) { player.m_customData["runemagic_numFailedUnlockAttempts"] = (num + 1).ToString(); return randomFromHashSet(unlockable); } } LogUtils.LogInfo("Attempting to unlock new rune for biome " + ((object)(Biome)(ref val)).ToString()); unlockable = getUnlockable(knownMaterial, newUnlock: true, new HashSet { val }); if (unlockable.Count() > 0) { player.m_customData["runemagic_numFailedUnlockAttempts"] = "0"; return randomFromHashSet(unlockable); } LogUtils.LogInfo("Attempting to unlock new rune for any biome up to " + ((object)(Biome)(ref val)).ToString()); unlockable = getUnlockable(knownMaterial, newUnlock: true, getBiomesUpTo(val)); if (unlockable.Count() > 0) { player.m_customData["runemagic_numFailedUnlockAttempts"] = "0"; return randomFromHashSet(unlockable); } LogUtils.LogInfo("Couldn't unlock new rune, getting a known one for " + ((object)(Biome)(ref val)).ToString()); unlockable = getUnlockable(knownMaterial, newUnlock: false, new HashSet { val }); if (unlockable.Count() > 0) { return randomFromHashSet(unlockable); } LogUtils.LogInfo("Couldn't find any runes to unlock, known or unknown"); return "runemagic_NoValidUnlock"; } private static HashSet getUnlockable(HashSet known, bool newUnlock, HashSet biomes) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(); foreach (RunemagicPieceConfig runemagicPieceConfig in ValheimMod.runemagicPieceConfigs) { if (biomes.Contains(runemagicPieceConfig.biome) && runemagicPieceConfig.isEnabled()) { hashSet.Add(runemagicPieceConfig.pieceName); } } if (newUnlock) { hashSet.ExceptWith(known); } else { hashSet.IntersectWith(known); } return hashSet; } private static HashSet getBiomesUpTo(Biome highestBiome) { //IL_004e: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) List list = new List { (Biome)1, (Biome)8, (Biome)2, (Biome)4, (Biome)16, (Biome)512, (Biome)32 }; HashSet hashSet = new HashSet(); foreach (Biome item in list) { hashSet.Add(item); if (item == highestBiome) { break; } } return hashSet; } private static T randomFromHashSet(HashSet set) { List list = new List(set); return list[Random.Range(0, list.Count())]; } public static void unlockRune(Player player, string name) { HashSet knownMaterial = player.m_knownMaterial; GameObject prefab = ZNetScene.instance.GetPrefab(name); Piece val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent() : null); string arg = (((Object)(object)val != (Object)null) ? val.m_name : name); if (!knownMaterial.Contains(name)) { knownMaterial.Add(name); MessageHud.instance.ShowBiomeFoundMsg(string.Format(Localization.instance.Localize("$message_runemagic_unlocknewrune"), arg), true); if (!Tutorial.instance.m_texts.Contains(ValheimMod.RuneDiscoveredTutorial)) { Tutorial.instance.m_texts.Add(ValheimMod.RuneDiscoveredTutorial); } player.ShowTutorial(ValheimMod.RuneDiscoveredTutorial.m_name, false); } else { ((Character)player).Message((MessageType)1, string.Format(Localization.instance.Localize("$message_runemagic_runealreadyknown"), arg), 0, (Sprite)null); } MethodInfo method = ((object)player).GetType().GetMethod("UpdateKnownRecipesList", BindingFlags.Instance | BindingFlags.NonPublic); method.Invoke(player, null); } public static void lockRune(Player player, string name) { HashSet hashSet = Traverse.Create((object)player).Field("m_knownMaterial").GetValue() as HashSet; if (hashSet.Contains(name)) { hashSet.Remove(name); MethodInfo method = ((object)player).GetType().GetMethod("UpdateKnownRecipesList", BindingFlags.Instance | BindingFlags.NonPublic); method.Invoke(player, null); } } public static void unlockAll(Player player) { foreach (RunemagicPieceConfig runemagicPieceConfig in ValheimMod.runemagicPieceConfigs) { unlockRune(player, runemagicPieceConfig.pieceName); } unlockRune(player, "runemagic_debugdelete"); unlockRune(player, "runemagic_debugprintout"); } } [BepInPlugin("hyleanlegend.RuneMagic", "RuneMagic", "1.4.0")] [BepInProcess("valheim.exe")] [BepInProcess("valheim_server.exe")] public class ValheimMod : BaseUnityPlugin { public enum Platform { NEXUS_MODS, THUNDERSTORE } public static readonly Harmony harmony = new Harmony("hyleanlegend.RuneMagic"); public const string VERSION = "1.4.0"; public const string GUID = "hyleanlegend.RuneMagic"; public const string NAME = "RuneMagic"; public static readonly bool DEV_MODE = false; public static readonly Platform PLATFORM = Platform.THUNDERSTORE; public static readonly HashSet resizableTerrainModifierNames = new HashSet { "runemagic_raise", "runemagic_lower", "runemagic_flatten", "runemagic_reset", "runemagic_raise(Clone)", "runemagic_lower(Clone)", "runemagic_flatten(Clone)", "runemagic_LevelTerrain", "runemagic_LevelTerrain(Clone)", "runemagic_LowerTerrain", "runemagic_LowerTerrain(Clone)", "runemagic_LowerTerrainAnimated", "runemagic_LowerTerrainAnimated(Clone)", "runemagic_RaiseTerrain", "runemagic_RaiseTerrain(Clone)", "runemagic_RestoreTerrain", "runemagic_RestoreTerrain(Clone)", "runemagic_RestoreTerrain_fast", "runemagic_RestoreTerrain_fast(Clone)" }; public static readonly List BoulderConfigs = new List { new PlaceableBoulderConfig("MountainGraveStone01", "$piece_runemagic_stone_waystone"), new PlaceableBoulderConfig("Rock_7", "$piece_runemagic_stone_menhir"), new PlaceableBoulderConfig("Rock_3", "$piece_runemagic_stone_boulder"), new PlaceableBoulderConfig("widestone", "$piece_runemagic_stone_capstone"), new PlaceableBoulderConfig("highstone", "$piece_runemagic_stone_monolith"), new PlaceableBoulderConfig("rock4_coast", "$piece_runemagic_stone_slab"), new PlaceableBoulderConfig("rock2_mountain", "$piece_runemagic_stone_tor"), new PlaceableBoulderConfig("rock1_mountain", "$piece_runemagic_stone_batholith"), new PlaceableBoulderConfig("rock3_mountain", "$piece_runemagic_stone_arete"), new PlaceableBoulderConfig("HeathRockPillar", "$piece_runemagic_stone_megalith"), new PlaceableBoulderConfig("cliff_ashlands3_Arch_1", "$piece_runemagic_stone_arch") }; public static readonly List standingStoneNames = new List { "runemagic_StandingStone", "Rock_7", "MountainGraveStone01" }; public const string RuneFocusItemDropName = "$item_runemagic_runefocus"; public static readonly List runemagicPieceConfigs = new List { new RunemagicPieceConfig((Biome)1, "runemagic_RestoreTerrain"), new RunemagicPieceConfig((Biome)1, "runemagic_passive_Alertness"), new RunemagicPieceConfig((Biome)1, "MountainGraveStone01", "runemagic_stone_waystone"), new RunemagicPieceConfig((Biome)1, "Rock_3", "runemagic_stone_boulder"), new RunemagicPieceConfig((Biome)8, "runemagic_LevelTerrain"), new RunemagicPieceConfig((Biome)8, "runemagic_CanopyRune"), new RunemagicPieceConfig((Biome)8, "Rock_7", "runemagic_stone_menhir"), new RunemagicPieceConfig((Biome)8, "widestone", "runemagic_stone_capstone"), new RunemagicPieceConfig((Biome)8, "runemagic_passive_BoatPropulsion"), new RunemagicPieceConfig((Biome)8, "runemagic_ShatteringRune"), new RunemagicPieceConfig((Biome)2, "runemagic_DryLandRune"), new RunemagicPieceConfig((Biome)2, "runemagic_CalmWatersRune"), new RunemagicPieceConfig((Biome)2, "runemagic_BlastingRune"), new RunemagicPieceConfig((Biome)2, "highstone", "runemagic_stone_monolith"), new RunemagicPieceConfig((Biome)4, "runemagic_passive_WaterWalking"), new RunemagicPieceConfig((Biome)4, "runemagic_passive_Decumberance"), new RunemagicPieceConfig((Biome)4, "rock4_coast", "runemagic_stone_slab"), new RunemagicPieceConfig((Biome)4, "rock2_mountain", "runemagic_stone_tor"), new RunemagicPieceConfig((Biome)4, "rock1_mountain", "runemagic_stone_batholith"), new RunemagicPieceConfig((Biome)4, "rock3_mountain", "runemagic_stone_arete"), new RunemagicPieceConfig((Biome)16, "runemagic_RepairRune"), new RunemagicPieceConfig((Biome)16, "HeathRockPillar", "runemagic_stone_megalith"), new RunemagicPieceConfig((Biome)32, "runemagic_ChimneyRune"), new RunemagicPieceConfig((Biome)32, "runemagic_ExtinguishingRune"), new RunemagicPieceConfig((Biome)32, "cliff_ashlands3_Arch_1", "runemagic_stone_arch") }; public static TutorialText RuneFocusTutorial = new TutorialText { m_name = "runeFocusTutorial", m_label = "$item_runemagic_runefocus", m_text = "$tutorial_runemagic_runefocus_text", m_topic = "$tutorial_runemagic_runefocus_topic" }; public static TutorialText RuneDiscoveredTutorial = new TutorialText { m_name = "runeDiscoveredTutorial", m_label = "$tutorial_runemagic_runicmagic_topic", m_text = "$tutorial_runemagic_runicmagic_text", m_topic = "$tutorial_runemagic_runicmagic_topic" }; private static PieceTable runeFocusPieceTable; public static Analytics analytics; private static List analyticsPieceNames = new List(); private static List engravedRunePrefabNames = new List(); private GameObject standingStone; private GameObject ventilationRune; public static bool isModEnabled { get; private set; } = true; public static bool isModAwake { get; private set; } = false; private void Awake() { //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Expected O, but got Unknown //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Expected O, but got Unknown //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Expected O, but got Unknown //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Expected O, but got Unknown //IL_038e: Unknown result type (might be due to invalid IL or missing references) ConfigLoader.UpgradeConfigFiles(); LocalizationManager.LoadTranslations(); Runtime.MakeAllAssetsLoadable(); runeFocusPieceTable = CustomContentSetupHandler.RegisterItem("RuneFocus").GetComponent().m_itemData.m_shared.m_buildPieces; runeFocusPieceTable.m_pieces.Clear(); runeFocusPieceTable.m_pieces.Add(CustomContentSetupHandler.RegisterPrefab("Runes/runemagic_RestoreTerrain")); runeFocusPieceTable.m_pieces.Add(CustomContentSetupHandler.RegisterPrefab("Runes/runemagic_LevelTerrain")); runeFocusPieceTable.m_pieces.Add(CustomContentSetupHandler.RegisterPrefab("Runes/runemagic_ShatteringRune")); runeFocusPieceTable.m_pieces.Add(CustomContentSetupHandler.RegisterPrefab("Runes/runemagic_BlastingRune")); runeFocusPieceTable.m_pieces.Add(CustomContentSetupHandler.RegisterPrefab("Runes/runemagic_passive_Alertness")); runeFocusPieceTable.m_pieces.Add(CustomContentSetupHandler.RegisterPrefab("Runes/runemagic_passive_BoatPropulsion")); runeFocusPieceTable.m_pieces.Add(CustomContentSetupHandler.RegisterPrefab("Runes/runemagic_passive_WaterWalking")); runeFocusPieceTable.m_pieces.Add(CustomContentSetupHandler.RegisterPrefab("Runes/runemagic_passive_Decumberance")); runeFocusPieceTable.m_pieces.Add(CustomContentSetupHandler.RegisterPrefab("Runes/runemagic_CanopyRune")); runeFocusPieceTable.m_pieces.Add(CustomContentSetupHandler.RegisterPrefab("Runes/runemagic_DryLandRune")); runeFocusPieceTable.m_pieces.Add(CustomContentSetupHandler.RegisterPrefab("Runes/runemagic_CalmWatersRune")); runeFocusPieceTable.m_pieces.Add(CustomContentSetupHandler.RegisterPrefab("Runes/runemagic_RepairRune")); ventilationRune = CustomContentSetupHandler.RegisterPrefab("Runes/runemagic_ChimneyRune"); runeFocusPieceTable.m_pieces.Add(ventilationRune); runeFocusPieceTable.m_pieces.Add(CustomContentSetupHandler.RegisterPrefab("Runes/runemagic_ExtinguishingRune")); CustomContentSetupHandler.RegisterPrefab("runemagic_raise"); CustomContentSetupHandler.RegisterPrefab("runemagic_lower"); CustomContentSetupHandler.RegisterPrefab("runemagic_flatten"); CustomContentSetupHandler.RegisterPrefab("runemagic_reset"); CustomContentSetupHandler.RegisterPrefab("vfx_Decumberance"); CustomContentSetupHandler.RegisterPrefab("vfx_OceanCurrents"); CustomContentSetupHandler.RegisterPrefab("LavaSolidifier"); CustomContentSetupHandler.RegisterPrefab("LavaFootstepMeshDecal"); CustomContentSetupHandler.RegisterPrefab("Lava/ManagedSolidArea"); CustomContentSetupHandler.RegisterPrefab("Lava/SolidAreaHole"); CustomContentSetupHandler.RegisterStatusEffect((StatusEffect)AssetLoader.GetScriptableObject("SE_WaterWalking")); CustomContentSetupHandler.RegisterStatusEffect((StatusEffect)AssetLoader.GetScriptableObject("SE_Decumberance")); CustomContentSetupHandler.RegisterStatusEffect((StatusEffect)AssetLoader.GetScriptableObject("SE_Alertness")); CustomContentSetupHandler.RegisterStatusEffect((StatusEffect)AssetLoader.GetScriptableObject("SE_BoatPropulsion")); standingStone = CustomContentSetupHandler.RegisterPrefab("runemagic_StandingStone"); CustomContentSetupHandler.RegisterRecipe(new ItemRecipeConfig("RuneFocus", "piece_workbench", new Dictionary { { "Ruby", 6 }, { "Stone", 1 } })); CustomContentSetupHandler.RegisterRecipe(new PieceRecipeConfig(standingStone, "Hammer", new Dictionary { { "Stone", 8 } }, "piece_stonecutter")); SE_WaterWalking.SetupIcebergs(); cacheDataForAnalytics(); try { analytics = new Analytics(); } catch (Exception ex) { if (DEV_MODE) { LogUtils.LogException(ex); } } ConfigLoader.cacheConfig(); if (ConfigLoader.getBool("enableVerboseLogging")) { LogUtils.logLevel = (LogLevel)63; } harmony.PatchAll(); isModAwake = true; } private void Start() { SoftReferenceUtils.registerSetupAction(delegate { LogUtils.LogInfo("Converting materials"); ConvertStandingStoneMaterial(standingStone); }); } public static void enableMod() { foreach (GameObject piece in runeFocusPieceTable.m_pieces) { piece.GetComponent().m_enabled = true; } foreach (ItemData allRuneFocusReference in getAllRuneFocusReferences()) { allRuneFocusReference.m_shared.m_buildPieces = runeFocusPieceTable; allRuneFocusReference.m_shared.m_icons[0] = AssetLoader.GetSpriteFromAssetBundle("RuneFocusIcon.png"); } CustomContentSetupHandler.TryRegisterRecipes(); RuneStonePatch.setAccumulatorOnRuneStones(active: true); isModEnabled = true; } public static void disableMod() { foreach (GameObject piece in runeFocusPieceTable.m_pieces) { piece.GetComponent().m_enabled = false; } foreach (ItemData allRuneFocusReference in getAllRuneFocusReferences()) { allRuneFocusReference.m_shared.m_buildPieces = null; allRuneFocusReference.m_shared.m_icons[0] = AssetLoader.GetSpriteFromAssetBundle("RuneFocusIconDisabled.png"); } CustomContentSetupHandler.TryUnregisterRecipes(); RuneStonePatch.setAccumulatorOnRuneStones(active: false); isModEnabled = false; } private static List getAllRuneFocusReferences() { List list = new List(); ItemDrop[] array = Resources.FindObjectsOfTypeAll(); ItemDrop[] array2 = array; foreach (ItemDrop val in array2) { if (isRuneFocus(val.m_itemData)) { list.Add(val.m_itemData); } } if ((Object)(object)Player.m_localPlayer != (Object)null) { Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory(); foreach (ItemData allItem in inventory.GetAllItems()) { if (isRuneFocus(allItem)) { list.Add(allItem); } } } return list; } private static void cacheDataForAnalytics() { analyticsPieceNames = new List(); engravedRunePrefabNames = new List(); foreach (GameObject piece in runeFocusPieceTable.m_pieces) { analyticsPieceNames.Add(((Object)piece).name); if ((Object)(object)piece.GetComponentInChildren() != (Object)null && piece.GetComponentInChildren().placementBehavior == RuneProjector.RunePlacementBehavior.StandingStoneOnly) { engravedRunePrefabNames.Add(((Object)piece).name); } } foreach (PlaceableBoulderConfig boulderConfig in BoulderConfigs) { analyticsPieceNames.Add(boulderConfig.prefabName); } analyticsPieceNames.Add("runemagic_StandingStone"); } public static List getAnalyticsPieceNames() { return analyticsPieceNames; } public static List getEngravedRunePrefabNames() { return engravedRunePrefabNames; } public static bool isPiecePlaceableByRuneFocus(Piece piece) { foreach (GameObject piece2 in runeFocusPieceTable.m_pieces) { if (piece.m_name.Equals(piece2.GetComponent().m_name)) { return true; } } return false; } public static bool isRuneFocus(ItemData item) { return item?.m_shared.m_name.Equals("$item_runemagic_runefocus") ?? false; } public static T getComponentInParentAll(GameObject obj) { T[] componentsInParent = obj.GetComponentsInParent(true); if (componentsInParent.Length == 0) { return default(T); } return componentsInParent[0]; } public static T getComponentInChildrenAll(GameObject obj) { T[] componentsInChildren = obj.GetComponentsInChildren(true); if (componentsInChildren.Length == 0) { return default(T); } return componentsInChildren[0]; } public static void DevModeLog(string message) { } public static void DevModeWarn(string message) { } public static void DevModeLog(Exception ex) { try { analytics.exceptions.Add(ex.ToString()); } catch (Exception) { } } public static void addTagRecursively(GameObject obj, string tag) { addTagRecursively(obj.transform, tag); } public static void addTagRecursively(Transform trans, string tag) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown ((Component)trans).gameObject.tag = tag; if (trans.childCount <= 0) { return; } foreach (Transform tran in trans) { Transform trans2 = tran; addTagRecursively(trans2, tag); } } public static bool isChild(Transform parent, Transform child) { while ((Object)(object)child != (Object)null) { if ((Object)(object)child == (Object)(object)parent) { return true; } child = child.parent; } return false; } public static bool anyPrefixInTree(GameObject obj, List prefixes) { return (Object)(object)findPrefixInTree(obj, prefixes) != (Object)null; } public static GameObject findPrefixInTree(GameObject obj, List prefixes) { while ((Object)(object)obj != (Object)null) { if (prefixes.Exists((string v) => ((Object)obj).name.StartsWith(v))) { return obj; } obj = (((Object)(object)obj.transform.parent != (Object)null) ? ((Component)obj.transform.parent).gameObject : null); } return null; } public static void findAssetsInBaseGame(string filter) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) Dictionary allAssetPathsInBundleMappedToAssetID = Runtime.GetAllAssetPathsInBundleMappedToAssetID(); DevModeLog($"Finding assets, dict has {allAssetPathsInBundleMappedToAssetID.Count()} keys"); bool flag = false; foreach (string key in allAssetPathsInBundleMappedToAssetID.Keys) { if (filter.Equals("") || key.Contains(filter)) { DevModeLog($"key {key}, assetId {allAssetPathsInBundleMappedToAssetID[key]}"); flag = true; } } if (!flag) { DevModeLog("No matches (note: search is case sensitive)"); } } private static void ConvertStandingStoneMaterial(GameObject standingStone) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if (!Application.isBatchMode) { MeshRenderer[] componentsInChildren = standingStone.GetComponentsInChildren(true); Material asset = SoftReferenceUtils.stone_mat.getAsset(); Material val = new Material(asset); val.SetTexture("_MainTex", SoftReferenceUtils.rock_med.getAsset()); val.SetTexture("_BumpMap", SoftReferenceUtils.rock_med_n.getAsset()); val.SetFloat("_RippleDistance", 0.001f); val.SetFloat("_RippleFreq", 2f); val.SetFloat("_ValueNoise", 0f); MeshRenderer[] array = componentsInChildren; foreach (MeshRenderer val2 in array) { ((Renderer)val2).sharedMaterial = val; } } } private static void ConvertVentilationRuneParticleMaterial(GameObject ventRune) { if (!Application.isBatchMode) { ParticleSystemRenderer[] componentsInChildren = ventRune.GetComponentsInChildren(true); Material asset = SoftReferenceUtils.fog.getAsset(); ParticleSystemRenderer[] array = componentsInChildren; foreach (ParticleSystemRenderer val in array) { ((Renderer)val).sharedMaterial = asset; } } } } internal interface ZNetViewHook { void PostZNetViewAwake(ZNetView view); } } namespace ValheimMod.Utilities { public class BiDictionary { private Dictionary> keyMap = new Dictionary>(); private Dictionary> valueMap = new Dictionary>(); public void Add(K key, V val) { Get(key).Add(val); Get(val).Add(key); } public void Add(V val, K key) { Get(key).Add(val); Get(val).Add(key); } public void AddAll(K key, ICollection vals) { Get(key).AddRange(vals); foreach (V val in vals) { Get(val).Add(key); } } public void AddAll(V val, ICollection keys) { Get(val).UnionWith(keys); foreach (K key in keys) { Get(key).Add(val); } } public bool Remove(K key, V val) { if (!keyMap.ContainsKey(key)) { ValheimMod.DevModeWarn("BiDict doesn't contain expected key!"); return false; } bool flag = keyMap[key].Remove(val); if (!valueMap.ContainsKey(val)) { ValheimMod.DevModeWarn("BiDict doesn't contain expected value!"); return false; } bool flag2 = valueMap[val].Remove(key); if (flag != flag2) { ValheimMod.DevModeWarn($"Inconsistent removal: key removed {flag}, value removed {flag2}"); } return flag; } public List Get(K key) { if (!keyMap.ContainsKey(key)) { keyMap[key] = new List(); } return keyMap[key]; } public HashSet Get(V val) { if (!valueMap.ContainsKey(val)) { valueMap[val] = new HashSet(); } return valueMap[val]; } } public class IndexedDictionary { private readonly Dictionary map; private readonly List keys; public int Count => keys.Count; public K this[int index] => keys[index]; public V this[K key] { get { return map[key]; } set { Add(key, value); } } public IndexedDictionary() { map = new Dictionary(); keys = new List(); } public void Add(K key, V value) { if (!map.ContainsKey(key)) { keys.Add(key); } map[key] = value; } public void Remove(K key) { map.Remove(key); keys.Remove(key); } public bool ContainsKey(K key) { return map.ContainsKey(key); } } public class LogUtils { private static ManualLogSource LOG; public static LogLevel logLevel; static LogUtils() { //IL_0001: 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: Expected O, but got Unknown logLevel = (LogLevel)8; LOG = new ManualLogSource("RuneMagic"); Logger.Sources.Add((ILogSource)(object)LOG); } public static void LogDebug(object msg) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)logLevel >= 32) { LOG.LogInfo((object)("[TRACE] " + msg)); } } public static void LogInfo(object msg) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)logLevel >= 16) { LOG.LogInfo(msg); } } public static void LogImportantMessage(object msg) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)logLevel >= 8) { LOG.LogMessage(msg); } } public static void LogWarning(object msg) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)logLevel >= 4) { LOG.LogWarning(msg); } } public static void LogError(object msg) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)logLevel >= 2) { LOG.LogError(msg); } } public static void LogException(Exception ex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)logLevel >= 2) { LOG.LogError((object)ex.ToString()); } } public static void LogFatal(object msg) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)logLevel >= 1) { LOG.LogFatal(msg); } } } public class MeshUtils { public static Mesh createBottomlessColumn(Vector3 ul, Vector3 ur, Vector3 ll, Vector3 lr, float height) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //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_0017: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //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_002f: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) Mesh val = new Mesh(); val.vertices = (Vector3[])(object)new Vector3[8] { ul, ur, ll, lr, ul + Vector3.down * height, ur + Vector3.down * height, ll + Vector3.down * height, lr + Vector3.down * height }; int[] array = new int[30] { 0, 2, 1, 1, 2, 3, 0, 4, 2, 4, 6, 2, 2, 6, 3, 3, 6, 7, 3, 7, 1, 1, 7, 5, 1, 5, 4, 0, 1, 4 }; val.SetIndices(array, (MeshTopology)0, 0); return val; } public static Mesh createMeshFromGrid(Vector3[] topVertexGrid, int width, int height) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) Mesh val = new Mesh(); int num = (width - 1) * (height - 1) * 2; int[] array = new int[num * 3]; int num2 = 0; for (int i = 0; i < height - 1; i++) { for (int j = 0; j < width - 1; j++) { int num3 = j + i * width; int num4 = j + 1 + i * width; int num5 = j + (i + 1) * width; int num6 = j + 1 + (i + 1) * width; array[num2] = num3; array[num2 + 1] = num5; array[num2 + 2] = num4; array[num2 + 3] = num4; array[num2 + 4] = num5; array[num2 + 5] = num6; num2 += 6; } } Vector2[] array2 = (Vector2[])(object)new Vector2[topVertexGrid.Length]; for (int k = 0; k < height; k++) { for (int l = 0; l < width; l++) { array2[k * width + l] = new Vector2((float)l / (float)(width - 1), (float)k / (float)(height - 1)); } } val.vertices = topVertexGrid; val.SetUVs(0, array2); val.SetIndices(array, (MeshTopology)0, 0); val.RecalculateNormals(); return val; } public static Vector3[] createGridFromRangeImage(int gridWidth, float centerDistance, Camera cam, Texture2D rangeImg) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) int width = ((Texture)rangeImg).width; float num = (float)width / (float)gridWidth; float num2 = cam.orthographicSize * 2f / (float)width; Vector3[] array = (Vector3[])(object)new Vector3[gridWidth * gridWidth]; for (int i = 0; i < gridWidth; i++) { for (int j = 0; j < gridWidth; j++) { int num3 = (int)((float)j * num); int num4 = (int)((float)i * num); Color pixel = rangeImg.GetPixel(num3, num4); float num5 = Mathf.Lerp(cam.nearClipPlane, cam.farClipPlane, StandardShaderUtils.DecodeFloatRGBA(pixel)); array[i * gridWidth + j] = new Vector3((float)num3 * num2, centerDistance - num5, (float)num4 * num2) + new Vector3(0f - cam.orthographicSize, 0f, 0f - cam.orthographicSize); } } return array; } public static bool hasGeometry(Mesh mesh) { for (int i = 0; i < mesh.subMeshCount; i++) { if (mesh.GetIndexCount(i) != 0) { return true; } } return false; } } public class NetSyncFloat { private ZNetView nView; private string key; private float value; private float targetValue; private float prevStoredTarget; private PeriodicTrigger updateTrigger; private Func deltaFunc; public NetSyncFloat(ZNetView nView, string key, float netUpdateTime, Func deltaFunc, float startValue, bool useStoredValue) { this.nView = nView; this.key = key; this.deltaFunc = deltaFunc; if (nView.IsValid()) { if (nView.IsOwner()) { if (useStoredValue) { targetValue = nView.GetZDO().GetFloat(key, startValue); } else { targetValue = startValue; } nView.GetZDO().Set(key, targetValue); } else { targetValue = nView.GetZDO().GetFloat(key, 0f); } updateTrigger = new PeriodicTrigger(netUpdateTime); value = targetValue; prevStoredTarget = targetValue; } else { LogUtils.LogError("Invalid ZNetView when creating NetSyncFloat"); } } public void updateValue(float dt) { if (!nView.IsValid()) { return; } float num = deltaFunc(value); if (nView.IsOwner()) { value += num; updateTrigger.update(dt); if (updateTrigger.shouldTrigger()) { nView.GetZDO().Set(key, value); targetValue = value; } return; } float @float = nView.GetZDO().GetFloat(key, 0f); if (prevStoredTarget != @float) { prevStoredTarget = @float; targetValue = @float; } value += num; targetValue += num; if (value != targetValue) { ValheimMod.DevModeLog($"Delta for {key}: {value - targetValue}"); value = Mathf.MoveTowards(value, targetValue, Mathf.Max(Mathf.Abs(num), 0.001f) * 0.05f); } } public float get() { return value; } } public class ParallelMeshUtils { public interface FutureMesh { Mesh getMesh(); bool isMeshReady(); void waitForCompletion(); } public class FutureJobMesh : FutureMesh { private JobHandle constructingJob; private MeshDataArray mda; private Mesh mesh; public FutureJobMesh(JobHandle constructingJob, MeshDataArray mda) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) this.constructingJob = constructingJob; this.mda = mda; } public Mesh getMesh() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)mesh == (Object)null) { mesh = new Mesh(); using (new Profiler("ApplyAndDisposeWritableMeshData")) { Mesh.ApplyAndDisposeWritableMeshData(mda, mesh, (MeshUpdateFlags)0); } mesh.RecalculateBounds(); } return mesh; } public bool isMeshReady() { if ((Object)(object)mesh != (Object)null) { return true; } return ((JobHandle)(ref constructingJob)).IsCompleted; } public void waitForCompletion() { if (!isMeshReady()) { ((JobHandle)(ref constructingJob)).Complete(); } } } public class FutureComputeMesh : FutureMesh { private AsyncGPUReadbackRequest bufferReq; private ComputeBuffer computeBuffer; private Mesh mesh; private bool constructed; public FutureComputeMesh(ComputeBuffer computeBuffer, Mesh mesh) { //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) bufferReq = AsyncGPUReadback.Request(computeBuffer, (Action)null); this.mesh = mesh; this.computeBuffer = computeBuffer; } public Mesh getMesh() { //IL_000f: 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_001b: Unknown result type (might be due to invalid IL or missing references) if (!constructed) { NativeArray data = ((AsyncGPUReadbackRequest)(ref bufferReq)).GetData(0); mesh.SetVertexBufferData(data, 0, 0, data.Length, 0, (MeshUpdateFlags)5); mesh.RecalculateBounds(); computeBuffer.Release(); constructed = true; } return mesh; } public bool isMeshReady() { if (constructed) { return true; } return ((AsyncGPUReadbackRequest)(ref bufferReq)).done; } public void waitForCompletion() { if (!isMeshReady()) { ((AsyncGPUReadbackRequest)(ref bufferReq)).WaitForCompletion(); } } } public struct VertexData { public Vector3 position; public Vector3 normal; } private struct R32G32B32A32_SFloat_Color { public float r; public float g; public float b; public float a; } private struct CreateGridFromRangeImageJob : IJobFor { [ReadOnly] public NativeArray rangeImg; [ReadOnly] public int rangeImgSize; [ReadOnly] public int gridWidth; [ReadOnly] public float nearClipPlane; [ReadOnly] public float farClipPlane; [ReadOnly] public float camOrthographicSize; [ReadOnly] public float centerDistance; public NativeArray vertices; public void Execute(int index) { //IL_00be: 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) float num = (float)rangeImgSize / (float)gridWidth; float num2 = camOrthographicSize * 2f / (float)rangeImgSize; int num3 = index % gridWidth; int num4 = index / gridWidth; int num5 = (int)((float)num3 * num); int num6 = (int)((float)num4 * num); float depth = getDepth(num3, num4); depth = Mathf.Min(depth, getDepth(num3 - 1, num4)); depth = Mathf.Min(depth, getDepth(num3 + 1, num4)); depth = Mathf.Min(depth, getDepth(num3, num4 - 1)); depth = Mathf.Min(depth, getDepth(num3, num4 + 1)); vertices[num4 * gridWidth + num3] = new Vector3((float)num5 * num2, centerDistance - depth, (float)num6 * num2) + new Vector3(0f - camOrthographicSize, 0f, 0f - camOrthographicSize); } private float getDepth(int i, int j) { if (i < 0 || i >= gridWidth || j < 0 || j >= gridWidth) { return 100000f; } int num = j * gridWidth + i; R32G32B32A32_SFloat_Color r32G32B32A32_SFloat_Color = rangeImg[num]; return Mathf.Lerp(nearClipPlane, farClipPlane, StandardShaderUtils.DecodeFloatRGBA(r32G32B32A32_SFloat_Color.r, r32G32B32A32_SFloat_Color.g, r32G32B32A32_SFloat_Color.b, r32G32B32A32_SFloat_Color.a)); } } private struct CalculateGridNormalsJob : IJobFor { [ReadOnly] public int gridWidth; [ReadOnly] [NativeDisableContainerSafetyRestriction] public NativeArray vertices; [NativeDisableContainerSafetyRestriction] public NativeArray normals; private Vector3 getVertex(int i, int j) { //IL_001a: 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) if (i < 0 || i >= gridWidth || j < 0 || j >= gridWidth) { return Vector3.zero; } return vertices[i + j * gridWidth]; } public void Execute(int index) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_0082: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00f8: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) int num = index % gridWidth; int num2 = index / gridWidth; Vector3 vertex = getVertex(num, num2); Vector3[] array = (Vector3[])(object)new Vector3[4] { getVertex(num - 1, num2), getVertex(num, num2 - 1), getVertex(num + 1, num2), getVertex(num, num2 + 1) }; for (int i = 0; i < array.Length; i++) { if (array[i] == Vector3.zero) { array[i] = vertex; } } Vector3 val = Vector3.zero; int num3 = array.Length; for (int j = 0; j < array.Length; j++) { int num4 = (j + 1) % array.Length; if (array[j] == Vector3.zero || array[num4] == Vector3.zero) { num3--; } else { val += Vector3.Cross(array[j] - vertex, array[num4] - vertex); } } normals[index] = -val / (float)num3; } } public static FutureMesh createMeshWithComputeShader(int gridWidth, Camera cam, RenderTexture rangeImg, ComputeShader cs) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown int num = gridWidth * gridWidth; Mesh val = new Mesh(); VertexAttributeDescriptor[] array = (VertexAttributeDescriptor[])(object)new VertexAttributeDescriptor[2] { new VertexAttributeDescriptor((VertexAttribute)0, (VertexAttributeFormat)0, 3, 0), new VertexAttributeDescriptor((VertexAttribute)1, (VertexAttributeFormat)0, 3, 0) }; val.SetVertexBufferParams(num, array); int num2 = 24; ComputeBuffer val2 = new ComputeBuffer(num, num2); int num3 = cs.FindKernel("CSMain"); uint num4 = default(uint); uint num5 = default(uint); uint num6 = default(uint); cs.GetKernelThreadGroupSizes(num3, ref num4, ref num5, ref num6); int num7 = Mathf.CeilToInt((float)gridWidth / (float)num4); cs.SetBuffer(num3, "_VertexBuffer", val2); cs.SetTexture(num3, "terrainImg", rangeImg, 0, (RenderTextureSubElement)0); cs.SetFloat("_TerrainDepthCamNearPlane", cam.nearClipPlane); cs.SetFloat("_TerrainDepthCamFarPlane", cam.farClipPlane); cs.SetInt("gridResolution", gridWidth); cs.SetFloat("gridSpacing", cam.orthographicSize * 2f / (float)gridWidth); cs.Dispatch(num3, num7, 1, num7); Profiler.start("ParallelMeshUtils.createMeshWithComputeShader-indicies"); int num8 = (gridWidth - 1) * (gridWidth - 1) * 2; int[] array2 = new int[num8 * 3]; int num9 = 0; for (int i = 0; i < gridWidth - 1; i++) { for (int j = 0; j < gridWidth - 1; j++) { int num10 = j + i * gridWidth; int num11 = j + 1 + i * gridWidth; int num12 = j + (i + 1) * gridWidth; int num13 = j + 1 + (i + 1) * gridWidth; array2[num9] = num10; array2[num9 + 1] = num12; array2[num9 + 2] = num11; array2[num9 + 3] = num11; array2[num9 + 4] = num12; array2[num9 + 5] = num13; num9 += 6; } } Profiler.stop("ParallelMeshUtils.createMeshWithComputeShader-indicies"); val.SetIndices(array2, (MeshTopology)0, 0); return new FutureComputeMesh(val2, val); } public static FutureMesh createMeshFromRangeImageParallel(int gridWidth, float centerDistance, Camera cam, Texture2D rangeImg) { //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_0008: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00a8: 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_00f5: 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_0112: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: 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_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) NativeArray rawTextureData = rangeImg.GetRawTextureData(); MeshDataArray mda = Mesh.AllocateWritableMeshData(1); MeshData val = ((MeshDataArray)(ref mda))[0]; ((MeshData)(ref val)).SetVertexBufferParams(gridWidth * gridWidth, (VertexAttributeDescriptor[])(object)new VertexAttributeDescriptor[2] { new VertexAttributeDescriptor((VertexAttribute)0, (VertexAttributeFormat)0, 3, 0), new VertexAttributeDescriptor((VertexAttribute)1, (VertexAttributeFormat)0, 3, 1) }); int num = (gridWidth - 1) * (gridWidth - 1) * 2; int num2 = num * 3; ((MeshData)(ref val)).SetIndexBufferParams(num2, (IndexFormat)1); ((MeshData)(ref val)).subMeshCount = 1; SubMeshDescriptor val2 = default(SubMeshDescriptor); ((SubMeshDescriptor)(ref val2))..ctor(0, num2, (MeshTopology)0); ((SubMeshDescriptor)(ref val2)).vertexCount = gridWidth * gridWidth; ((MeshData)(ref val)).SetSubMesh(0, val2, (MeshUpdateFlags)9); NativeArray vertexData = ((MeshData)(ref val)).GetVertexData(0); NativeArray vertexData2 = ((MeshData)(ref val)).GetVertexData(1); CreateGridFromRangeImageJob createGridFromRangeImageJob = default(CreateGridFromRangeImageJob); createGridFromRangeImageJob.rangeImg = rawTextureData; createGridFromRangeImageJob.rangeImgSize = ((Texture)rangeImg).width; createGridFromRangeImageJob.gridWidth = gridWidth; createGridFromRangeImageJob.nearClipPlane = cam.nearClipPlane; createGridFromRangeImageJob.farClipPlane = cam.farClipPlane; createGridFromRangeImageJob.camOrthographicSize = cam.orthographicSize; createGridFromRangeImageJob.centerDistance = centerDistance; createGridFromRangeImageJob.vertices = vertexData; CreateGridFromRangeImageJob createGridFromRangeImageJob2 = createGridFromRangeImageJob; CalculateGridNormalsJob calculateGridNormalsJob = default(CalculateGridNormalsJob); calculateGridNormalsJob.gridWidth = gridWidth; calculateGridNormalsJob.vertices = vertexData; calculateGridNormalsJob.normals = vertexData2; CalculateGridNormalsJob calculateGridNormalsJob2 = calculateGridNormalsJob; NativeArray indexData = ((MeshData)(ref val)).GetIndexData(); int num3 = 0; for (int i = 0; i < gridWidth - 1; i++) { for (int j = 0; j < gridWidth - 1; j++) { int num4 = j + i * gridWidth; int num5 = j + 1 + i * gridWidth; int num6 = j + (i + 1) * gridWidth; int num7 = j + 1 + (i + 1) * gridWidth; indexData[num3] = num4; indexData[num3 + 1] = num6; indexData[num3 + 2] = num5; indexData[num3 + 3] = num5; indexData[num3 + 4] = num6; indexData[num3 + 5] = num7; num3 += 6; } } Profiler.start("ParallelMeshUtils.ScheduleParallel"); JobHandle val3 = IJobForExtensions.ScheduleParallel(createGridFromRangeImageJob2, gridWidth * gridWidth, 32, default(JobHandle)); JobHandle constructingJob = IJobForExtensions.ScheduleParallel(calculateGridNormalsJob2, gridWidth * gridWidth, 32, val3); Profiler.stop("ParallelMeshUtils.ScheduleParallel"); return new FutureJobMesh(constructingJob, mda); } } public class PeriodicTrigger { private float timeSinceTrigger; private float timeBetweenTriggers; public PeriodicTrigger(float delay) { timeBetweenTriggers = delay; } public void update(float dt) { timeSinceTrigger += dt; } public bool shouldTrigger() { if (timeSinceTrigger > timeBetweenTriggers) { timeSinceTrigger = 0f; return true; } return false; } public bool shouldTrigger(float intervalOverride) { if (timeSinceTrigger > intervalOverride) { timeSinceTrigger = 0f; return true; } return false; } } public class PSData { private MinMaxCurve emissionRate; private MinMaxCurve emissionDistanceRate; private MinMaxCurve startLifetime; private MinMaxGradient startColor; public PSData(ParticleSystem ps) { //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_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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) EmissionModule emission = ps.emission; emissionRate = ((EmissionModule)(ref emission)).rateOverTime; emissionDistanceRate = ((EmissionModule)(ref emission)).rateOverDistance; MainModule main = ps.main; startLifetime = ((MainModule)(ref main)).startLifetime; startColor = ((MainModule)(ref main)).startColor; } public void applyScale(ParticleSystem ps, float scale) { //IL_0006: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if ((int)((MinMaxCurve)(ref emissionRate)).mode != 0 || ((MinMaxCurve)(ref emissionRate)).constant != 0f) { EmissionModule emission = ps.emission; ((EmissionModule)(ref emission)).rateOverTime = getScaledEmissionRate(scale); ((EmissionModule)(ref emission)).rateOverDistance = getScaled(emissionDistanceRate, scale); } } public MinMaxCurve getScaledEmissionRate(float scale) { //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) return getScaled(emissionRate, scale); } public MinMaxCurve getScaledLifetime(float scale) { //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) return getScaled(startLifetime, scale); } private MinMaxCurve getScaled(MinMaxCurve original, float scale) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_001c: 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_004a: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) if ((int)((MinMaxCurve)(ref original)).mode == 3) { return new MinMaxCurve(((MinMaxCurve)(ref original)).constantMin * scale, ((MinMaxCurve)(ref original)).constantMax * scale); } if ((int)((MinMaxCurve)(ref original)).mode == 1) { return new MinMaxCurve(((MinMaxCurve)(ref original)).curveMultiplier * scale, ((MinMaxCurve)(ref original)).curve); } if ((int)((MinMaxCurve)(ref original)).mode == 2) { return new MinMaxCurve(((MinMaxCurve)(ref original)).curveMultiplier * scale, ((MinMaxCurve)(ref original)).curveMin, ((MinMaxCurve)(ref original)).curveMax); } return new MinMaxCurve(((MinMaxCurve)(ref original)).constant * scale); } } public class TestUtils { } public class TranspilerUtils { public static void logAll(IEnumerable instructions) { List list = instructions.ToList(); for (int i = 0; i < list.Count; i++) { logInstr(list[i], i); } } public static void logInstructionsAroundCursor(CodeMatcher matcher, int count) { for (int i = -count; i < 0; i++) { logInstr(matcher.InstructionAt(i), -1); } logInstr(matcher.InstructionAt(0), 0); for (int j = 1; j <= count; j++) { logInstr(matcher.InstructionAt(j), 1); } } public static CodeInstruction logInstr(CodeInstruction instr, int count) { string text = $"{instr.operand}"; if (instr.operand is Label) { text = "Label:" + ((Label)instr.operand).GetHashCode(); } if (instr.labels.Count == 0) { ValheimMod.DevModeLog($"Transpiling {count:x}: Opcode: {instr.opcode} Operand: {text}"); } else { string text2 = GeneralExtensions.Join(instr.labels.Select((Label label) => "L-" + label.GetHashCode()), (Func)null, ","); ValheimMod.DevModeLog($"Transpiling {count:x} label {text2}: Opcode: {instr.opcode} Operand: {text}"); } return instr; } } } namespace ValheimMod.Setup { public class ConfigLoader { public static readonly string InternalConfigName = "runemagic_internal_config.cfg"; public static readonly string ServerConfigName = "runemagic_server_config.cfg"; public static readonly string ClientConfigName = "runemagic_player_config.cfg"; public static readonly string ConfigPath; private static Dictionary oldKeyRemap; private static readonly object lockObj; private static Dictionary serverConfig; private static Dictionary clientConfig; private static Dictionary boolConfig; private static Dictionary floatConfig; private static Dictionary intConfig; private static Dictionary vec4Config; public static void setupFileWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(ConfigPath, ServerConfigName); fileSystemWatcher.Changed += NotifyConfigChanged; fileSystemWatcher.Created += NotifyConfigChanged; fileSystemWatcher.Renamed += NotifyConfigChanged; fileSystemWatcher.IncludeSubdirectories = false; fileSystemWatcher.SynchronizingObject = null; fileSystemWatcher.EnableRaisingEvents = true; } private static void NotifyConfigChanged(object sender, FileSystemEventArgs e) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) ValheimMod.DevModeLog("Reloading config"); cacheConfig(); LogUtils.logLevel = (LogLevel)(getBool("enableVerboseLogging") ? 63 : 8); } public static void cacheConfig() { lock (lockObj) { clientConfig = parseConfig(AssetLoader.ReadEmbeddedResource(InternalConfigName).Split(new char[2] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)); mergeDictionaries(clientConfig, loadConfigFiles(ClientConfigName, ServerConfigName)); if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { cacheServerConfig(); } mergeServerConfig(); } } private static void cacheServerConfig() { LogUtils.LogInfo("Caching server config"); serverConfig = parseConfig(AssetLoader.ReadEmbeddedResource(InternalConfigName).Split(new char[2] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)); mergeDictionaries(serverConfig, loadConfigFiles(ServerConfigName)); ZNetPatch.sendConfigFromServer(serializeServerConfig()); } private static Dictionary loadConfigFiles(params string[] filenames) { Dictionary dictionary = new Dictionary(); if (Application.isEditor) { return dictionary; } foreach (string text in filenames) { string[] lines = File.ReadAllLines(ConfigPath + text); mergeDictionaries(dictionary, parseConfig(lines)); } return dictionary; } private static Dictionary parseConfig(string[] lines) { Dictionary dictionary = new Dictionary(); foreach (string text in lines) { string text2 = text; if (text2.IndexOf("#") != -1) { text2 = text2.Substring(0, text2.IndexOf("#")); } if (text2.StartsWith("[") || Utility.IsNullOrWhiteSpace(text2)) { continue; } int num = text2.IndexOf('='); if (num == -1) { LogUtils.LogWarning("Unparsable config line " + text2 + ", regenerating"); continue; } string key = text2.Substring(0, num).Trim(); string text3 = text2.Substring(num + 1).RemoveWhitespace(); if (!(text3 == "")) { if (text3.Contains("=")) { LogUtils.LogWarning("Invalid config value " + text3 + ", regenerating"); } else { dictionary[key] = text3; } } } return dictionary; } public static void UpgradeConfigFiles() { upgradeConfig(ClientConfigName); upgradeConfig(ServerConfigName); } private static void upgradeConfig(string filename) { if (!File.Exists(ConfigPath + filename)) { File.WriteAllText(ConfigPath + filename, AssetLoader.ReadEmbeddedResource(filename)); return; } Dictionary existingConfig = loadConfigFiles(filename); string templateFileContents = AssetLoader.ReadEmbeddedResource(filename); string upgradedConfig = getUpgradedConfig(existingConfig, templateFileContents); File.WriteAllText(ConfigPath + filename, upgradedConfig); } private static string getUpgradedConfig(Dictionary existingConfig, string templateFileContents) { string text = templateFileContents; convertOldConfigEntries(existingConfig); HashSet hashSet = new HashSet(); foreach (string key in existingConfig.Keys) { string pattern = "^" + Regex.Escape(key) + "=([^ #\r\n]+)"; Match match = Regex.Match(text, pattern, RegexOptions.Multiline); if (match.Success) { string text2 = existingConfig[key]; string value = match.Groups[1].Captures[0].Value; if (!doConfigValueTypesMatch(value, text2)) { text2 = value + " # Found existing invalid entry: " + text2; } text = Regex.Replace(text, pattern, key + "=" + text2, RegexOptions.Multiline); } else { hashSet.Add(key); } } if (hashSet.Count > 0) { text += "\n\n# Keys not in config template, preserved from existing config: "; foreach (string item in hashSet) { text = text + "\n" + item + "=" + existingConfig[item]; } } return text; } private static bool doConfigValueTypesMatch(string authoritative, string toVerify) { if (float.TryParse(authoritative, out var result) && !float.TryParse(toVerify, out result)) { return false; } if (bool.TryParse(authoritative, out var result2) && !bool.TryParse(toVerify, out result2)) { return false; } if (isVector(authoritative) && !isVector(toVerify)) { return false; } return true; } private static void convertOldConfigEntries(Dictionary existingConfig) { if (existingConfig.ContainsKey("canopyRune_forcefieldVisible")) { if (existingConfig["canopyRune_forcefieldVisible"] == "true") { existingConfig["canopyRune_visualQuality"] = "2"; existingConfig.Remove("canopyRune_forcefieldVisible"); } else if (existingConfig["canopyRune_forcefieldVisible"] == "false") { existingConfig["canopyRune_visualQuality"] = "0"; existingConfig.Remove("canopyRune_forcefieldVisible"); } } foreach (KeyValuePair item in oldKeyRemap) { if (existingConfig.ContainsKey(item.Key)) { existingConfig[item.Value] = existingConfig[item.Key]; existingConfig.Remove(item.Key); } } } private static ZPackage serializeServerConfig() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown ZPackage val = new ZPackage(); val.Write(serverConfig.Count); foreach (string key in serverConfig.Keys) { val.Write(key); val.Write(serverConfig[key]); } return val; } public static void deserializeServerConfig(ZPackage package) { serverConfig = new Dictionary(); int num = package.ReadInt(); for (int i = 0; i < num; i++) { string key = package.ReadString(); string value = package.ReadString(); serverConfig[key] = value; } mergeServerConfig(); } private static void mergeServerConfig() { boolConfig = new Dictionary(); floatConfig = new Dictionary(); intConfig = new Dictionary(); vec4Config = new Dictionary(); mergeDictionaries(clientConfig, serverConfig); } private static void mergeDictionaries(Dictionary existing, Dictionary toMerge) { foreach (string key in toMerge.Keys) { existing[key] = toMerge[key]; } } public static bool containsKey(string key, bool reload = false) { if (clientConfig == null || reload) { cacheConfig(); } lock (lockObj) { return clientConfig.ContainsKey(key); } } public static string getString(string key, bool reload = false) { if (clientConfig == null || reload) { cacheConfig(); } return getOrError(key); } public static float getFloat(string key, bool reload = false) { if (clientConfig == null || reload) { cacheConfig(); } lock (lockObj) { if (!floatConfig.ContainsKey(key)) { floatConfig[key] = float.Parse(getOrError(key), CultureInfo.InvariantCulture); } return floatConfig[key]; } } public static float getBoundedFloat(string key, float min, float max, bool reload = false) { return Mathf.Clamp(getFloat(key, reload), min, max); } public static int getInt(string key, bool reload = false) { if (clientConfig == null || reload) { cacheConfig(); } lock (lockObj) { if (!intConfig.ContainsKey(key)) { intConfig[key] = int.Parse(getOrError(key), CultureInfo.InvariantCulture); } return intConfig[key]; } } public static bool getBool(string key, bool reload = false) { if (clientConfig == null || reload) { cacheConfig(); } lock (lockObj) { if (!boolConfig.ContainsKey(key)) { boolConfig[key] = bool.Parse(getOrError(key)); } return boolConfig[key]; } } public static Vector4 getVector4(string key, bool reload = false) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (clientConfig == null || reload) { cacheConfig(); } lock (lockObj) { if (!vec4Config.ContainsKey(key)) { vec4Config[key] = parseVector(getOrError(key)); } return vec4Config[key]; } } public static Vector3 getVector3(string key, bool reload = false) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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) if (clientConfig == null || reload) { cacheConfig(); } lock (lockObj) { if (!vec4Config.ContainsKey(key)) { vec4Config[key] = parseVector(getOrError(key)); } Vector4 val = vec4Config[key]; return new Vector3(val.x, val.y, val.z); } } public static void tempOverrideKey(string key, object value) { //IL_0089: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) lock (lockObj) { clientConfig[key] = value.ToString(); if (value is int) { intConfig[key] = (int)value; } if (!(value is int num)) { if (!(value is float value2)) { if (!(value is double num2)) { if (!(value is bool value3)) { if (!(value is Vector3 val)) { if (!(value is Vector4 value4)) { throw new Exception($"Attempted to store unrecognized type {value.GetType()} with key {key}"); } vec4Config[key] = value4; } else { vec4Config[key] = Vector4.op_Implicit(val); } } else { boolConfig[key] = value3; } } else { floatConfig[key] = (float)num2; } } else { floatConfig[key] = value2; } } else { intConfig[key] = num; floatConfig[key] = num; } } } private static Vector4 parseVector(string input) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) string[] array = input.Split(new char[1] { ',' }); float[] array2 = new float[4]; for (int i = 0; i < 4; i++) { array2[i] = ((i < array.Length) ? float.Parse(array[i], CultureInfo.InvariantCulture) : 0f); } return new Vector4(array2[0], array2[1], array2[2], array2[3]); } private static bool isVector(string input) { string[] array = input.Split(new char[1] { ',' }); for (int i = 0; i < array.Length; i++) { if (!float.TryParse(array[i], out var _)) { return false; } } return true; } private static string getOrError(string key) { if (clientConfig.ContainsKey(key)) { return clientConfig[key]; } throw new Exception("No configuration entry found for key " + key); } static ConfigLoader() { string? directoryName = Path.GetDirectoryName(Paths.BepInExConfigPath); char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigPath = directoryName + directorySeparatorChar; oldKeyRemap = new Dictionary { { "enableRune_MountainGraveStone01", "enableRune_runemagic_stone_waystone" }, { "enableRune_Rock_7", "enableRune_runemagic_stone_menhir" }, { "enableRune_Rock_3", "enableRune_runemagic_stone_boulder" }, { "enableRune_widestone", "enableRune_runemagic_stone_capstone" }, { "enableRune_highstone", "enableRune_runemagic_stone_monolith" }, { "enableRune_rock4_coast", "enableRune_runemagic_stone_slab" }, { "enableRune_rock2_mountain", "enableRune_runemagic_stone_tor" }, { "enableRune_rock1_mountain", "enableRune_runemagic_stone_batholith" }, { "enableRune_rock3_mountain", "enableRune_runemagic_stone_arete" }, { "enableRune_HeathRockPillar", "enableRune_runemagic_stone_megalith" }, { "energyCost_MountainGraveStone01", "energyCost_runemagic_stone_waystone" }, { "energyCost_Rock_7", "energyCost_runemagic_stone_menhir" }, { "energyCost_Rock_3", "energyCost_runemagic_stone_boulder" }, { "energyCost_widestone", "energyCost_runemagic_stone_capstone" }, { "energyCost_highstone", "energyCost_runemagic_stone_monolith" }, { "energyCost_rock4_coast", "energyCost_runemagic_stone_slab" }, { "energyCost_rock2_mountain", "energyCost_runemagic_stone_tor" }, { "energyCost_rock1_mountain", "energyCost_runemagic_stone_batholith" }, { "energyCost_rock3_mountain", "energyCost_runemagic_stone_arete" }, { "energyCost_HeathRockPillar", "energyCost_runemagic_stone_megalith" } }; lockObj = new object(); serverConfig = new Dictionary(); } } public class PieceRecipeConfig { public GameObject prefab; public string pieceTableItem; public string craftingStation; public Dictionary resources; public PieceRecipeConfig(GameObject prefab, string pieceTableItem, Dictionary resources, string craftingStation = "") { this.prefab = prefab; this.pieceTableItem = pieceTableItem; this.resources = resources; this.craftingStation = craftingStation; } } public class PlaceableBoulderConfig { public string prefabName; public string displayName; public PlaceableBoulderConfig(string prefabName, string displayName) { this.prefabName = prefabName; this.displayName = displayName; } public static bool isPlaceableBoulder(string prefabName) { foreach (PlaceableBoulderConfig boulderConfig in ValheimMod.BoulderConfigs) { if (boulderConfig.prefabName.Equals(prefabName)) { return true; } } return false; } } } namespace ValheimMod.ScriptableObjects { internal class GracePeriodManager { private const float GRACE_PERIOD_SECONDS = 2f; private static float timeSinceGracePeriodUsed; private static float expendedGracePeriod; public static void update(float dt) { timeSinceGracePeriodUsed += dt; if (timeSinceGracePeriodUsed > 2f) { expendedGracePeriod = 0f; } } public static void drainGracePeriod(StatusEffect se, float dt) { timeSinceGracePeriodUsed = 0f; expendedGracePeriod += dt; try { ValheimMod.analytics.updatePassiveRuneTime(se, dt); } catch (Exception ex) { ValheimMod.DevModeLog(ex); } } public static bool inGracePeriod() { return expendedGracePeriod <= 2f; } } public class LavaSolidifier : MonoBehaviour { private const float terrainQuadScale = 1f; private static HashSet allInstances = new HashSet(); private GameObject root; private GridMap colliders = new GridMap(1f, zeroCentered: false); private int collisionRadius; private float effectRadius; public void Awake() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown LogUtils.LogDebug("LavaSolidifier Awake"); allInstances.Add(this); collisionRadius = 1; effectRadius = 1.2f; root = new GameObject(); } public void Update() { //IL_0015: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: 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_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) Profiler.start("LavaSolidifier.update"); _ = root.transform.position.y; _ = 0f; HashSet hashSet = new HashSet(colliders.GetKeys()); Heightmap heightmap = HeightmapPatch.getHeightmap(((Component)this).transform.position); if ((Object)(object)heightmap == (Object)null) { return; } float num = default(float); heightmap.GetWorldHeight(((Component)this).transform.position, ref num); Vector2 xZVector = ((Component)this).transform.position.GetXZVector(); if (((Component)this).transform.position.y - num <= 8f + (float)collisionRadius) { Vector2 val = default(Vector2); for (int i = -collisionRadius; i <= collisionRadius; i++) { for (int j = -collisionRadius; j <= collisionRadius; j++) { ((Vector2)(ref val))..ctor(((Component)this).transform.position.x - (float)j * 1f, ((Component)this).transform.position.z - (float)i * 1f); if (collisionRadius > 1) { Vector2 val2 = xZVector - val; if (((Vector2)(ref val2)).sqrMagnitude > (float)(collisionRadius * collisionRadius)) { continue; } } Vector2i coord = colliders.GetCoord(val); hashSet.Remove(coord); if (colliders.ContainsKey(coord)) { continue; } GameObject val3 = createCollider(colliders, root, coord); colliders.Add(coord, val3.transform); if (j == 0 && i == 0 && (Object)(object)Player.m_localPlayer != (Object)null && Utils.DistanceSqr(((Component)Player.m_localPlayer).transform.position, ((Component)this).transform.position) < 0.1f) { float num2 = val3.transform.position.y - (((Character)Player.m_localPlayer).GetCenterPoint().y - ((Character)Player.m_localPlayer).GetHeight() / 2f); if (num2 > 0f) { Transform transform = ((Component)Player.m_localPlayer).transform; transform.position += Vector3.up * num2; Physics.SyncTransforms(); } } } } } foreach (Vector2i item in hashSet) { destroyCollider(item); colliders.Remove(item); } Profiler.stop("LavaSolidifier.update"); } public void OnDestroy() { LogUtils.LogDebug("LavaSolidifier destroyed"); resetColliders(); allInstances.Remove(this); } private void resetColliders() { //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_001b: Unknown result type (might be due to invalid IL or missing references) foreach (Vector2i key in colliders.GetKeys()) { destroyCollider(key); } colliders.Clear(); } private void destroyCollider(Vector2i coord) { //IL_0006: 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) MeshCollider component = ((Component)colliders.Get(coord)).GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component.sharedMesh); } Object.Destroy((Object)(object)((Component)colliders.Get(coord)).gameObject); } public static GameObject createCollider(GridMap colliderGrid, GameObject sharedRoot, Vector2i coord) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_000e: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00ae: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_0120: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_015c: Unknown result type (might be due to invalid IL or missing references) Vector3 center = colliderGrid.GetCenter(coord); GameObject val = new GameObject(); Heightmap heightmap = HeightmapPatch.getHeightmap(center); if ((Object)(object)heightmap == (Object)null) { LogUtils.LogError("Heightmap for lava was null"); return val; } val.transform.position = ((Component)heightmap).transform.position; WorldToVertexFloor(heightmap, center, out var x, out var y); float num = 0.05f; if (getLavaFactor(heightmap, x, y) <= num && getLavaFactor(heightmap, x + 1, y) <= num && getLavaFactor(heightmap, x, y + 1) <= num && getLavaFactor(heightmap, x + 1, y + 1) <= num) { return val; } Vector3 val2 = CalcVertexWithLava(heightmap, x, y); Vector3 val3 = CalcVertexWithLava(heightmap, x + 1, y); Vector3 val4 = CalcVertexWithLava(heightmap, x, y + 1); Vector3 val5 = CalcVertexWithLava(heightmap, x + 1, y + 1); Vector3 val6 = (val2 + val3 + val4 + val5) / 4f; Transform transform = val.transform; transform.position += val6; val2 -= val6; val3 -= val6; val4 -= val6; val5 -= val6; val6 -= val6; val6.y -= 1f; val.layer = LayerMask.NameToLayer("static_solid"); Mesh sharedMesh = MeshUtils.createBottomlessColumn(val2, val3, val4, val5, 5f); MeshCollider val7 = val.AddComponent(); val7.sharedMesh = sharedMesh; val7.convex = true; val.transform.SetParent(sharedRoot.transform, false); return val; } public static void notifyHeightmapChanged(Heightmap hmap) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hmap == (Object)null) { return; } foreach (LavaSolidifier allInstance in allInstances) { if (hmap.IsPointInside(((Component)allInstance).transform.position, (float)allInstance.collisionRadius)) { allInstance.resetColliders(); } } } public static bool isPointInRangeOfAny(Vector3 pos) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) foreach (LavaSolidifier allInstance in allInstances) { if (Utils.DistanceXZ(((Component)allInstance).transform.position, pos) <= allInstance.effectRadius) { return true; } } return false; } public static void WorldToVertexFloor(Heightmap hmap, Vector3 worldPos, out int x, out int y) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) Vector3 val = worldPos - ((Component)hmap).transform.position; int num = hmap.m_width / 2; x = Mathf.FloorToInt(val.x / hmap.m_scale) + num; y = Mathf.FloorToInt(val.z / hmap.m_scale) + num; } public static Vector3 CalcVertexWithLava(Heightmap hmap, int x, int z) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) Vector3 result = hmap.CalcVertex(x, z); float @float = ConfigLoader.getFloat("pathOfIce-lavaTransitionPoint"); float lavaFactor = getLavaFactor(hmap, x, z); float num = Heightmap.GetGroundMaterialOffset((GroundMaterial)2048) * ConfigLoader.getFloat("pathOfIce-solidLavaTransitionOffset"); float num2 = ((!(lavaFactor < @float)) ? Mathf.Lerp(num, Heightmap.GetGroundMaterialOffset((GroundMaterial)2048) * ConfigLoader.getFloat("pathOfIce-solidLavaYOffset"), Mathf.InverseLerp(@float, 1f, lavaFactor)) : Mathf.Lerp(ConfigLoader.getFloat("pathOfIce-ashOffset"), num, Mathf.InverseLerp(0f, @float, lavaFactor))); result.y += num2; return result; } public static float getLavaFactor(Heightmap hmap, int x, int z) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) return hmap.m_paintMask.GetPixel(x, z).a; } } [CreateAssetMenu(fileName = "SE_BoatPropulsion", menuName = "ScriptableObjects/SE_BoatPropulsion", order = 2)] internal class SE_BoatPropulsion : StatusEffect { public static readonly int BoatPropulsionStatusEffect = StringExtensionMethods.GetStableHashCode("SE_BoatPropulsion"); private Ship currentShip; private Rigidbody shipBody; private float originalBackwardForce; private float originalSailForce; private float originalSideDrag; private GameObject vfx; public GameObject vfxPrefab; public override void UpdateStatusEffect(float dt) { //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0149: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) ((StatusEffect)this).UpdateStatusEffect(dt); Character character = base.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val == null) { return; } if ((Object)(object)val.GetControlledShip() != (Object)null && (Object)(object)currentShip == (Object)null) { currentShip = val.GetControlledShip(); ref Rigidbody reference = ref shipBody; object value = Traverse.Create((object)val.GetControlledShip()).Field("m_body").GetValue(); reference = (Rigidbody)((value is Rigidbody) ? value : null); originalBackwardForce = currentShip.m_backwardForce; originalSailForce = currentShip.m_sailForceFactor; originalSideDrag = currentShip.m_dampingSideway; Ship obj = currentShip; obj.m_dampingSideway /= 2f; object value2 = Traverse.Create((object)currentShip).Field("m_nview").GetValue(); ZNetView val2 = (ZNetView)((value2 is ZNetView) ? value2 : null); val2.ClaimOwnership(); } else if ((Object)(object)val.GetControlledShip() == (Object)null && (Object)(object)currentShip != (Object)null) { endEffect(); } if ((Object)(object)currentShip != (Object)null) { GracePeriodManager.drainGracePeriod((StatusEffect)(object)this, dt); if (!GracePeriodManager.inGracePeriod()) { float @float = ConfigLoader.getFloat("energyCost_runemagic_passive_BoatPropulsion"); PlayerPatch.ExpendEnergy(val, dt * @float); } Vector3 val3 = ((Component)GameCamera.instance).transform.forward; Vector3 normalized = ((Vector3)(ref val3)).normalized; normalized.y = 0f; float strength = Mathf.Clamp01(((Vector3)(ref normalized)).magnitude * 1.3f); normalized = ((Vector3)(ref normalized)).normalized; ensureMinimumVelocity(normalized, strength); addForceInLookDirection(normalized); if ((Object)(object)vfx == (Object)null) { vfx = Object.Instantiate(vfxPrefab); } vfx.transform.rotation = Quaternion.LookRotation(normalized); vfx.transform.position = ((Component)currentShip).transform.position + new Vector3(0f, ConfigLoader.getFloat("oceanCurrentDepth"), 0f); float float2 = ConfigLoader.getFloat("oceanCurrentRuneSpeed"); val3 = shipBody.linearVelocity; float num = float2 + ((Vector3)(ref val3)).magnitude; vfx.GetComponent().GetZDO().Set(LineRuneEmitter.SPEED_KEY, num); } } private void ensureMinimumVelocity(Vector3 targetDir, float strength) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Dot(shipBody.linearVelocity, targetDir); float @float = ConfigLoader.getFloat("oceanCurrentMinVelocity"); if (num < @float * strength) { shipBody.linearVelocity += targetDir * ConfigLoader.getFloat("oceanCurrentForceFactor"); } } private void addForceInLookDirection(Vector3 targetDir) { //IL_0000: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 float num = Vector3.Dot(targetDir, ((Component)currentShip).transform.forward); if ((int)currentShip.GetSpeedSetting() == 1) { num *= -1f; } currentShip.m_backwardForce = originalBackwardForce + num * ConfigLoader.getFloat("oceanCurrentBackwardForceModifier"); currentShip.m_sailForceFactor = originalSailForce + num * ConfigLoader.getFloat("oceanCurrentSailForceModifier"); } private void endEffect() { ConfigLoader.getFloat("oceanCurrentForceFactor"); if ((Object)(object)currentShip != (Object)null) { currentShip.m_backwardForce = originalBackwardForce; currentShip.m_sailForceFactor = originalSailForce; currentShip.m_dampingSideway = originalSideDrag; shipBody = null; currentShip = null; } if ((Object)(object)vfx != (Object)null) { ZNetScene.instance.Destroy(vfx); vfx = null; } } public override void Stop() { ((StatusEffect)this).Stop(); endEffect(); } } [CreateAssetMenu(fileName = "SE_Alertness", menuName = "ScriptableObjects/SE_Alertness", order = 4)] public class SE_Alertness : StatusEffect { public static readonly int AlertnessStatusEffect = StringExtensionMethods.GetStableHashCode("SE_Alertness"); private static readonly Dictionary CustomTrophies = new Dictionary { { "Ghost", "vfx_TrophyGhost" }, { "Hare", "vfx_TrophyHare" }, { "Dverger", "vfx_TrophyDverger" }, { "SeekerBrood", "vfx_TrophySeekerBrood" } }; private static readonly Dictionary EnemyMap = new Dictionary { { "Greyling", "Greydwarf" }, { "Boar_piggy", "Boar" }, { "DraugrRanged", "Draugr_0" }, { "Wolf_cub", "Wolf" }, { "GoblinArcher", "Goblin" }, { "GoblinShaman_Hildir", "GoblinShaman" }, { "GoblinShaman_Hildir_nochest", "GoblinShaman" }, { "GoblinBrute_Hildir", "GoblinBruteBros" }, { "Lox_Calf", "Lox" }, { "DvergerMage", "Dverger" }, { "DvergerMageFire", "Dverger" }, { "DvergerMageIce", "Dverger" }, { "DvergerMageSupport", "Dverger" }, { "Charred_Twitcher", "Charred_Melee" }, { "Charred_Twitcher_Summoned", "Charred_Melee" }, { "Charred_Melee_Fader", "Charred_Melee" }, { "Charred_Melee_Dyrnwyn", "Charred_Melee" }, { "Charred_Archer_Fader", "Charred_Archer" }, { "Asksvin_hatchling", "Asksvin" }, { "Morgen_NonSleeping", "Morgen" }, { "DvergerAshlands", "Dverger" } }; private Dictionary trackedTrophies = new Dictionary(); private Dictionary indicators = new Dictionary(); private GameObject vfxPrefab; private float hoverRadiusMin; private float hoverRadiusMax; private float maxDistance; private float trophyMaxScale; public override void UpdateStatusEffect(float dt) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_0108: Expected O, but got Unknown ((StatusEffect)this).UpdateStatusEffect(dt); if ((Object)(object)vfxPrefab == (Object)null) { vfxPrefab = AssetLoader.GetPrefabFromAssetBundle("vfx_AlertnessIndicator"); } hoverRadiusMin = ConfigLoader.getFloat("AlertnessHoverRadiusMin"); hoverRadiusMax = ConfigLoader.getFloat("AlertnessHoverRadiusMax"); maxDistance = ConfigLoader.getFloat("AlertnessMaxDistance"); trophyMaxScale = ConfigLoader.getFloat("AlertnessMaxTrophyScale"); List allCharacters = Character.GetAllCharacters(); foreach (Character item in allCharacters) { if (!trackedTrophies.ContainsKey(item)) { Vector3 val = ((Component)item).transform.position - ((Component)base.m_character).transform.position; if (((Vector3)(ref val)).magnitude < maxDistance && isTrackable(item)) { trackNewChar(item); } } } updateTrophies(); GracePeriodManager.drainGracePeriod((StatusEffect)(object)this, dt); if (!GracePeriodManager.inGracePeriod()) { Player player = (Player)base.m_character; PlayerPatch.ExpendEnergy(player, dt * ConfigLoader.getFloat("energyCost_runemagic_passive_Alertness")); } } private void trackNewChar(Character npc) { //IL_00d0: 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_00c0: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_010e: 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_016d: 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_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_0155: Unknown result type (might be due to invalid IL or missing references) string text = ((Object)npc).name.Replace("(Clone)", ""); LogUtils.LogInfo("Tracking new target: " + text); if (EnemyMap.ContainsKey(text)) { text = EnemyMap[text]; } float num = (ConfigLoader.containsKey("AlertnessScaleOverride-" + text) ? ConfigLoader.getFloat("AlertnessScaleOverride-" + text) : 1f); float num2 = (ConfigLoader.containsKey("AlertnessOffsetOverride-" + text) ? ConfigLoader.getFloat("AlertnessOffsetOverride-" + text) : 0f); float num3 = ConfigLoader.getFloat("AlertnessIndicatorYOffset") + num2; Vector3 localPosition = (Vector3)(ConfigLoader.containsKey("AlertnessTrophyPosOverride-" + text) ? ConfigLoader.getVector3("AlertnessTrophyPosOverride-" + text) : default(Vector3)); GameObject val = new GameObject(); GameObject val2 = Object.Instantiate(getTrophy(npc)); removeNonMeshComponents(val2); val2.transform.parent = val.transform; val2.transform.localPosition = localPosition; val2.transform.localRotation = Quaternion.identity; if (ConfigLoader.containsKey("AlertnessRotationOverride-" + text)) { Vector3 vector = ConfigLoader.getVector3("AlertnessRotationOverride-" + text); val2.transform.localRotation = Quaternion.Euler(vector); } val2.transform.localScale = val2.transform.localScale * num * findTrophyScale(val2); Vector3 val3 = findIndicatorOffset(val2); GameObject val4 = createIndicator(); val4.transform.parent = val.transform; val4.transform.localPosition = val3 + new Vector3(0f, num3, 0f); trackedTrophies[npc] = val; indicators[npc] = val4; } private bool isTrackable(Character npc) { return (Object)(object)getTrophy(npc) != (Object)null; } private GameObject getTrophy(Character npc) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown string text = ((Object)npc).name.Replace("(Clone)", ""); if (EnemyMap.ContainsKey(text)) { GameObject prefab = ZNetScene.instance.GetPrefab(EnemyMap[text]); npc = prefab.GetComponentInChildren(); text = ((Object)npc).name.Replace("(Clone)", ""); } if (CustomTrophies.ContainsKey(text)) { return AssetLoader.GetPrefabFromAssetBundle(CustomTrophies[text]); } if (text.Equals("BlobLava")) { GameObject prefab2 = ZNetScene.instance.GetPrefab(text); GameObject gameObject = ((Component)GameObjectUtils.getChildByPath(prefab2, "Visual", "blob", "Cube.004")).gameObject; GameObject val = new GameObject("LavaBlobTrophy"); MeshRenderer val2 = val.AddComponent(); MeshFilter val3 = val.AddComponent(); ((Renderer)val2).sharedMaterials = ((Renderer)gameObject.GetComponent()).sharedMaterials; ((Renderer)val2).sharedMaterial = ((Renderer)gameObject.GetComponent()).sharedMaterial; val3.sharedMesh = gameObject.GetComponent().sharedMesh; return val; } if (text.Equals("BlobFrost")) { GameObject prefab3 = ZNetScene.instance.GetPrefab(text); GameObject gameObject2 = ((Component)GameObjectUtils.getChildByPath(prefab3, "Visual", "blob", "Cube")).gameObject; GameObject val4 = new GameObject("FrostBlobTrophy"); MeshRenderer val5 = val4.AddComponent(); MeshFilter val6 = val4.AddComponent(); ((Renderer)val5).sharedMaterials = ((Renderer)gameObject2.GetComponent()).sharedMaterials; ((Renderer)val5).sharedMaterial = ((Renderer)gameObject2.GetComponent()).sharedMaterial; val6.sharedMesh = gameObject2.GetComponent().sharedMesh; return val4; } CharacterDrop component = ((Component)npc).gameObject.GetComponent(); if ((Object)(object)component == (Object)null || component.m_drops == null) { return null; } foreach (Drop drop in component.m_drops) { if ((Object)(object)drop.m_prefab != (Object)null && ((Object)drop.m_prefab).name.Contains("Trophy")) { if ((Object)(object)drop.m_prefab.transform.Find("attach") == (Object)null) { LogUtils.LogInfo("Trophy for " + npc.m_name + " missing attach point"); return null; } return ((Component)drop.m_prefab.transform.Find("attach")).gameObject; } } return null; } private void removeNonMeshComponents(GameObject obj) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown Component[] components = obj.GetComponents(); foreach (Component val in components) { if (!(val is MeshFilter) && !(val is MeshRenderer) && !(val is Transform) && !((Object)val).name.Equals("_TrophyOverride")) { Object.Destroy((Object)(object)val); } } foreach (Transform item in obj.transform) { Transform val2 = item; removeNonMeshComponents(((Component)val2).gameObject); } } private void updateTrophies() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0081: 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_0091: 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_00b2: 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_00ee: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (KeyValuePair trackedTrophy in trackedTrophies) { if ((Object)(object)trackedTrophy.Key == (Object)null) { list.Add(trackedTrophy.Key); continue; } Character key = trackedTrophy.Key; GameObject value = trackedTrophy.Value; Player val = (Player)base.m_character; Vector3 eyePoint = ((Character)val).GetEyePoint(); Vector3 val2 = key.GetCenterPoint() - eyePoint; float magnitude = ((Vector3)(ref val2)).magnitude; val2 = ((Vector3)(ref val2)).normalized; value.transform.position = eyePoint + val2 * Mathf.Lerp(hoverRadiusMin, hoverRadiusMax, magnitude / maxDistance); float num = Mathf.Lerp(trophyMaxScale, 0f, magnitude / maxDistance); value.transform.localScale = new Vector3(num, num, num); if (val2 != Vector3.zero) { value.transform.rotation = Quaternion.LookRotation(val2 * -1f, Vector3.up); } setIndicatorColor(key); } foreach (Character item in list) { Object.Destroy((Object)(object)trackedTrophies[item]); trackedTrophies.Remove(item); indicators.Remove(item); } } private Vector3 findIndicatorOffset(GameObject trophy) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00ca: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) if (ConfigLoader.containsKey("AlertnessIndicatorPosOverride-" + ((Object)trophy).name)) { ValheimMod.DevModeLog("Overriding indicator position on " + ((Object)trophy).name); return ConfigLoader.getVector3("AlertnessIndicatorPosOverride-" + ((Object)trophy).name); } MeshFilter[] componentsInChildren = trophy.GetComponentsInChildren(); Vector3 val = Quaternion.Euler(ConfigLoader.getFloat("AlertnessIndicatorAngle"), 0f, 0f) * Vector3.up; MathUtils.MeshRaycastHit meshRaycastHit = MathUtils.findRayMeshIntersection(new Ray(trophy.transform.position + val * 20f, -val), componentsInChildren); if (!meshRaycastHit.hit) { ValheimMod.DevModeLog("No mesh hit on " + ((Object)trophy).name); return default(Vector3); } return ((RaycastHit)(ref meshRaycastHit.closest)).point - trophy.transform.position; } private float findTrophyScale(GameObject trophy) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_004d: 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_0073: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) MeshFilter[] componentsInChildren = trophy.GetComponentsInChildren(); Vector3 val = Quaternion.Euler(ConfigLoader.getFloat("AlertnessIndicatorAngle"), 0f, 0f) * Vector3.up; MathUtils.MeshRaycastHit meshRaycastHit = MathUtils.findRayMeshIntersection(new Ray(trophy.transform.position + val * 20f, -val), componentsInChildren); bool flag = false; float num = trophy.transform.position.y; float y = trophy.transform.position.y; MeshFilter[] array = componentsInChildren; foreach (MeshFilter val2 in array) { Mesh sharedMesh = val2.sharedMesh; if (!sharedMesh.isReadable) { continue; } flag = true; Vector3[] vertices = sharedMesh.vertices; Vector3[] array2 = vertices; foreach (Vector3 val3 in array2) { Vector3 val4 = ((Component)val2).transform.TransformPoint(val3); if (val4.y > num) { num = val4.y; } if (val4.y < y) { y = val4.y; } } } if (!flag) { return 1f; } if (meshRaycastHit.hit) { num = Mathf.Lerp(((RaycastHit)(ref meshRaycastHit.closest)).point.y, num, ConfigLoader.getFloat("AlertnessAntlerAdjustment")); } float num2 = num - y; float @float = ConfigLoader.getFloat("AlertnessTargetTrophyHeight"); return @float / num2; } private GameObject createIndicator() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) float @float = ConfigLoader.getFloat("AlertnessIndicatorScale"); GameObject val = Object.Instantiate(vfxPrefab); val.transform.localScale = new Vector3(@float, @float, @float); return val; } private void setIndicatorColor(Character npc) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_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) float @float = ConfigLoader.getFloat("AlertnessIndicatorEmissiveBrightness"); Color val = Color.green; if (npc.GetBaseAI().IsAlerted()) { val = Color.yellow; } if (BaseAIPatch.isTargetingPlayer(npc.GetBaseAI())) { ((Color)(ref val))..ctor(1f, 0.30588f, 0f); } if (BaseAIPatch.isTargetingLocalPlayer(npc.GetBaseAI())) { val = Color.red; } indicators[npc].SetActive(val != Color.green); MaterialPropertyBlock val2 = new MaterialPropertyBlock(); val2.SetColor("_EmissionColor", ColorUtils.applyIntensity(val, @float)); ((Renderer)indicators[npc].GetComponentInChildren()).SetPropertyBlock(val2); } private void endEffect() { foreach (KeyValuePair trackedTrophy in trackedTrophies) { Object.Destroy((Object)(object)trackedTrophy.Value); } trackedTrophies.Clear(); indicators.Clear(); } public override void Stop() { ((StatusEffect)this).Stop(); endEffect(); } } [CreateAssetMenu(fileName = "SE_Decumberance", menuName = "ScriptableObjects/SE_Decumberance", order = 3)] public class SE_Decumberance : StatusEffect { public static readonly int DecumberanceStatusEffect = StringExtensionMethods.GetStableHashCode("SE_Decumberance"); private GameObject vfx; private static bool CalculateCarryWeightWithoutDecumberance = false; public override void UpdateStatusEffect(float dt) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) ((StatusEffect)this).UpdateStatusEffect(dt); Player player = (Player)base.m_character; if ((Object)(object)vfx == (Object)null && getAmountAboveMaxWeight(player) > 0f) { LogUtils.LogDebug("Creating decumberance VFX"); GameObject prefabFromAssetBundle = AssetLoader.GetPrefabFromAssetBundle("vfx_Decumberance"); vfx = Object.Instantiate(prefabFromAssetBundle); } else if ((Object)(object)vfx != (Object)null && getAmountAboveMaxWeight(player) == 0f) { endEffect(); } if ((Object)(object)vfx != (Object)null) { vfx.transform.position = ((Component)base.m_character).transform.position; } GracePeriodManager.drainGracePeriod((StatusEffect)(object)this, dt); if (!GracePeriodManager.inGracePeriod()) { PlayerPatch.ExpendEnergy(player, dt * getCostPerSecond(player)); } } public static float getCostPerSecond(Player player) { float @float = ConfigLoader.getFloat("energyCost_runemagic_passive_Decumberance"); float amountAboveMaxWeight = getAmountAboveMaxWeight(player); return @float * amountAboveMaxWeight; } public static float getAmountAboveMaxWeight(Player player) { float maxCarryWeightWithoutDecumberance = GetMaxCarryWeightWithoutDecumberance(player); return Mathf.Max(0f, ((Humanoid)player).GetInventory().GetTotalWeight() - maxCarryWeightWithoutDecumberance); } private static float GetMaxCarryWeightWithoutDecumberance(Player player) { CalculateCarryWeightWithoutDecumberance = true; try { return player.GetMaxCarryWeight(); } finally { CalculateCarryWeightWithoutDecumberance = false; } } public override void ModifyMaxCarryWeight(float baseLimit, ref float limit) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (!CalculateCarryWeightWithoutDecumberance) { float num = getAmountAboveMaxWeight((Player)base.m_character) + 1f; limit += num; } } private void endEffect() { LogUtils.LogDebug("Ending Decumberance effect"); if ((Object)(object)vfx != (Object)null) { ZNetScene.instance.Destroy(vfx); } vfx = null; } public override void Stop() { ((StatusEffect)this).Stop(); endEffect(); } } [CreateAssetMenu(fileName = "SE_WaterWalking", menuName = "ScriptableObjects/SE_WaterWalking", order = 1)] internal class SE_WaterWalking : StatusEffect { public static readonly int WaterWalkingStatusEffect = StringExtensionMethods.GetStableHashCode("SE_WaterWalking"); private const int iceCellScale = 15; private const float iceBorderScale = 1.04f; private const float iceThicknessScale = 2f; private static int frameCycleLength = 4; private int frameCycle; private static List icebergCenters = new List(); public static float latestHotWaterFactor; public static float latestColdWaterFactor; private GameObject lavaSolidifier; private HashSet dryCells = new HashSet(); public override void UpdateStatusEffect(float dt) { //IL_0026: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_00d8: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_011f: 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_0129: 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_015b: 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_016e: 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_0178: 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_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028c: 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_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) ((StatusEffect)this).UpdateStatusEffect(dt); if ((Object)(object)base.m_character.GetStandingOnShip() != (Object)null) { return; } latestHotWaterFactor = Mathf.Max(WorldGenerator.GetAshlandsOceanGradient(((Component)base.m_character).transform.position), 0f); latestColdWaterFactor = Mathf.Max(GetDeepNorthOceanGradient(((Component)base.m_character).transform.position), 0f); if (latestHotWaterFactor >= 1f) { HandleLavaWalking(dt); } Player val = (Player)base.m_character; GracePeriodManager.drainGracePeriod((StatusEffect)(object)this, dt); if (!GracePeriodManager.inGracePeriod() && shouldChargeEnergy(val)) { float costPerSecond = getCostPerSecond(val); PlayerPatch.ExpendEnergy(val, dt * costPerSecond); } float maxRadius = getMaxRadius(latestHotWaterFactor, latestColdWaterFactor); frameCycle = (frameCycle + 1) % frameCycleLength; int num = 15; Vector2Int cell = getCell(base.m_character.GetCenterPoint()); Vector3 val4 = default(Vector3); for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (dryCells.Contains(cell + new Vector2Int(i, j))) { continue; } Vector2Int val2 = cell + new Vector2Int(i + 1, j) * num; bool flag = false; for (int k = frameCycle; k < icebergCenters.Count; k += frameCycleLength) { Vector3 val3 = new Vector3((float)((Vector2Int)(ref val2)).x, base.m_character.GetCenterPoint().y, (float)((Vector2Int)(ref val2)).y) + icebergCenters[k] * (float)num; float waterHeight; float landHeight; bool flag2 = hitUnfrozenWater(val3, k, out waterHeight, out landHeight); if (waterHeight + 2f > landHeight) { flag = true; } if (!(Utils.DistanceXZ(val3, ((Component)base.m_character).transform.position) > maxRadius) && flag2 && waterHeight - ConfigLoader.getFloat("iceSpawnDepth") > landHeight) { float num2 = Math.Min(waterHeight, ((Component)base.m_character).transform.position.y) - ConfigLoader.getFloat("iceSpawnDepth"); ((Vector3)(ref val4))..ctor(val3.x, num2, val3.z); if (!(IceTimedDestruction.calculateScaleFromPlayer(Player.m_localPlayer, val4, latestHotWaterFactor, latestColdWaterFactor) <= 0f)) { GameObject prefab = ZNetScene.instance.GetPrefab("iceberg" + k); GameObject val5 = Object.Instantiate(prefab, val4, Quaternion.identity); } } } if (!flag) { dryCells.Add(cell + new Vector2Int(i, j)); } } } } public void HandleLavaWalking(float dt) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)lavaSolidifier == (Object)null) { lavaSolidifier = Object.Instantiate(AssetLoader.GetPrefabFromAssetBundle("LavaSolidifier"), ((Component)base.m_character).transform.position, Quaternion.identity); ((Component)base.m_character).gameObject.AddComponent(); } } public override void Stop() { ((StatusEffect)this).Stop(); dryCells.Clear(); if ((Object)(object)lavaSolidifier != (Object)null) { ZNetScene.instance.Destroy(lavaSolidifier); } if ((Object)(object)base.m_character != (Object)null && (Object)(object)((Component)base.m_character).gameObject.GetComponent() != (Object)null) { Object.Destroy((Object)(object)((Component)base.m_character).gameObject.GetComponent()); } } private bool shouldChargeEnergy(Player p) { //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_0046: 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) if (IceTimedDestruction.anyInstancesActiveForPlayer(p)) { return true; } if (LavaFootstep.isPlayerNearLava(p)) { List solidAreasInSector = GlobalLavaSolidifier.getSolidAreasInSector(HeightmapPatch.getTerrainCoord(((Component)p).transform.position)); foreach (SolidLavaArea item in solidAreasInSector) { float shaderRadius = item.getShaderRadius(); if (MathUtils.distanceXZSqr(item.getTransform().position, ((Component)p).transform.position) <= shaderRadius * shaderRadius) { return false; } } return true; } return false; } public static float getMaxRadius(float hotFactor, float coldFactor) { return IceTimedDestruction.getKeepAliveRadius(hotFactor, coldFactor); } public static float getCostPerSecond(Player player) { //IL_0006: 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) float num = Mathf.Max(WorldGenerator.GetAshlandsOceanGradient(((Component)player).transform.position), 0f); float num2 = Mathf.Max(GetDeepNorthOceanGradient(((Component)player).transform.position), 0f); float @float = ConfigLoader.getFloat("energyCost_runemagic_passive_WaterWalking"); if (num > 0f) { if (num >= 1f && LavaFootstep.isPlayerNearLava(player)) { float float2 = ConfigLoader.getFloat("energyCost_runemagic_passive_WaterWalking-lavaCostMultiplier"); return @float * float2; } float float3 = ConfigLoader.getFloat("energyCost_runemagic_passive_WaterWalking-hotWaterCostMultiplier"); return Mathf.Lerp(@float, @float * float3, num); } if (num2 > 0f) { float float4 = ConfigLoader.getFloat("energyCost_runemagic_passive_WaterWalking-coldWaterCostMultiplier"); return Mathf.Lerp(@float, @float * float4, num2); } return @float; } private bool hitUnfrozenWater(Vector3 point, int icebergIndex, out float waterHeight, out float landHeight) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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) waterHeight = 0f; landHeight = 0f; Vector2Int cell = getCell(point); if (IceTimedDestruction.doesIcebergExist(((Vector2Int)(ref cell)).x, ((Vector2Int)(ref cell)).y, icebergIndex)) { return false; } Heightmap heightmap = HeightmapPatch.getHeightmap(point); if ((Object)(object)heightmap == (Object)null) { return false; } WaterVolume volume = WaterVolumePatch.getVolume(heightmap); if ((Object)(object)volume == (Object)null) { return false; } float num = default(float); bool worldHeight = heightmap.GetWorldHeight(point, ref num); landHeight = num; waterHeight = volume.GetWaterSurface(point, 1f); if (!worldHeight || waterHeight <= num) { return false; } return true; } public static float GetDeepNorthOceanGradient(Vector3 pos) { //IL_0000: 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) float x = pos.x; float z = pos.z; double num = (double)WorldGenerator.WorldAngle(x, z + 4000f) * 100.0; return (float)(((double)DUtils.Length(x, z + 4000f) - (12000.0 + num)) / 300.0); } public static Vector2Int getCell(Vector3 position) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) int num = 15; int num2 = (int)(Math.Floor(position.x / (float)num) * (double)num); int num3 = (int)(Math.Floor(position.z / (float)num) * (double)num); return new Vector2Int(num2, num3); } public static void SetupIcebergs() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) int num = 0; GameObject prefabFromAssetBundle = AssetLoader.GetPrefabFromAssetBundle("Icebergs/iceberg" + num); while ((Object)(object)prefabFromAssetBundle != (Object)null) { Mesh sharedMesh = prefabFromAssetBundle.GetComponentInChildren().sharedMesh; Vector3[] vertices = sharedMesh.vertices; Vector3 val = default(Vector3); Vector3[] array = vertices; foreach (Vector3 val2 in array) { val += val2; } val /= (float)sharedMesh.vertexCount; icebergCenters.Add(val); ((Component)prefabFromAssetBundle.GetComponentInChildren()).transform.position = -val; float num2 = 15f; float num3 = num2 * 1.04f; prefabFromAssetBundle.transform.localScale = Vector3.Scale(prefabFromAssetBundle.transform.localScale, new Vector3(num3, 2f, num3)); CustomContentSetupHandler.RegisterPrefab(prefabFromAssetBundle); num++; prefabFromAssetBundle = AssetLoader.GetPrefabFromAssetBundle("Icebergs/iceberg" + num); } LogUtils.LogInfo($"Calculated centers for {num} icebergs"); } } } namespace ValheimMod.Profiling { public class CSV { private List header = new List(); private List> rows = new List>(); public void addRow(Dictionary row) { rows.Add(row); foreach (string key in row.Keys) { if (!header.Contains(key)) { header.Add(key); } } } public void addBlankRow() { rows.Add(new Dictionary()); } public override string ToString() { string text = ""; foreach (string item in header) { text = text + item + ","; } text += "\n"; foreach (Dictionary row in rows) { foreach (string item2 in header) { text = text + row.GetValueOrDefault(item2, "") + ","; } text += "\n"; } return text; } } public class Measurement { private int count; private double total; private double max = double.MinValue; private double min = double.MaxValue; public Measurement() { } public Measurement(Measurement other) { count = other.count; total = other.total; max = other.max; min = other.min; } public void addMeasurement(double value) { total += value; max = Math.Max(max, value); min = Math.Min(min, value); count++; } public double Avg() { return total / (double)count; } public double Max() { return max; } public double Min() { return min; } public void Merge(Measurement other) { if (other != null) { count += other.count; total += other.total; max = Math.Max(max, other.max); min = Math.Min(min, other.min); } } } public class MultiValueProfiler { public static readonly string ProfilingPath; private string streamName; private static string filename; private List measurements = new List(); public MultiValueProfiler(string name) { } public void add(T measurement) { measurements.Add(measurement); } public void writeData(string label) { } public void reset() { measurements = new List(); } static MultiValueProfiler() { string bepInExRootPath = Paths.BepInExRootPath; char directorySeparatorChar = Path.DirectorySeparatorChar; string text = directorySeparatorChar.ToString(); directorySeparatorChar = Path.DirectorySeparatorChar; ProfilingPath = bepInExRootPath + text + "profiling" + directorySeparatorChar; } } internal class RestorationRuneBenchmark : MonoBehaviour { } public class SolidLavaBenchmark : MonoBehaviour { } public class SolidLavaDecalBenchmark : MonoBehaviour { } } namespace ValheimMod.Patches { public class CinderSpawnerPatch { [HarmonyPatch(typeof(CinderSpawner), "CanSpawnCinder", new Type[] { })] private class CanSpawnCinder_Patch { private static bool Postfix(bool __result, CinderSpawner __instance) { if (!__result) { return __result; } if (PieceExtinguisher.allInstances.TryGetValue(((Component)__instance).gameObject, out var value)) { return !value.isFullyExtinguished(); } return __result; } } } public class CookingStationPatch { [HarmonyPatch(typeof(CookingStation), "Awake")] private class Awake_Patch { private static void Postfix(CookingStation __instance) { if (!((Object)(object)__instance.m_haveFireObject == (Object)null) && ExtinguishingRune.anyActive() && (Object)(object)((Component)__instance).gameObject.GetComponent() == (Object)null) { ValheimMod.DevModeLog("Attaching PieceExtinguisher to CookingStation during awake patch"); ((Component)__instance).gameObject.AddComponent(); } } } [HarmonyPatch(typeof(CookingStation), "UpdateCooking")] private class UpdateCooking_Patch { public static bool inProgress; private static void Prefix() { inProgress = true; } private static void Postfix(CookingStation __instance) { inProgress = false; } } [HarmonyPatch(typeof(CookingStation), "UpdateVisual")] private class UpdateVisual_Patch { public static bool inProgress; private static void Prefix() { inProgress = true; } private static void Postfix(CookingStation __instance) { inProgress = false; } } [HarmonyPatch(typeof(CookingStation), "GetFuel")] private class GetFuel_Patch { private static float Postfix(float __result, CookingStation __instance) { if (PieceExtinguisher.allInstances.TryGetValue(((Component)__instance).gameObject, out var value) && value.isFullyExtinguished() && UpdateCooking_Patch.inProgress && !UpdateVisual_Patch.inProgress) { return 0f; } return __result; } } [HarmonyPatch(typeof(CookingStation), "OnAddFuelSwitch")] private class OnAddFuelSwitch_Patch { private static void Postfix(CookingStation __instance) { if (PieceExtinguisher.allInstances.TryGetValue(((Component)__instance).gameObject, out var value)) { value.resetEffect(); } } } } public class EntryPointSceneLoaderPatch { [HarmonyPatch(typeof(EntryPointSceneLoader), "Start")] public static class Start_Patch { public static void Postfix() { SoftReferenceUtils.triggerSetup(); } } } public class FirePatch { [HarmonyPatch(typeof(Fire), "Awake")] private class Awake_Patch { private static void Postfix(Fire __instance) { if (ExtinguishingRune.anyActive() && (Object)(object)((Component)__instance).gameObject.GetComponentInParent() == (Object)null) { ValheimMod.DevModeLog("Attaching PieceExtinguisher to Fire during awake patch"); PieceExtinguisher pieceExtinguisher = ((Component)__instance).gameObject.AddComponent(); pieceExtinguisher.killOnExtinguish = true; } } } } public class FireplacePatch { [HarmonyPatch(typeof(Fireplace), "Awake")] private class Awake_Patch { private static void Postfix(Fireplace __instance) { if (ExtinguishingRune.anyActive() && (Object)(object)((Component)__instance).gameObject.GetComponent() == (Object)null) { ValheimMod.DevModeLog("Attaching PieceExtinguisher to Fireplace during awake patch"); ((Component)__instance).gameObject.AddComponent(); } } } [HarmonyPatch(typeof(Fireplace), "IsBurning")] private class IsBurning_Patch { private static bool Postfix(bool __result, Fireplace __instance) { if (!__result) { return __result; } if (PieceExtinguisher.allInstances.TryGetValue(((Component)__instance).gameObject, out var value)) { return !value.isFullyExtinguished(); } return __result; } } [HarmonyPatch(typeof(Fireplace), "Interact")] private class Interact_Patch { private static void Postfix(Fireplace __instance) { if (PieceExtinguisher.allInstances.TryGetValue(((Component)__instance).gameObject, out var value) && __instance.m_nview.GetZDO().GetFloat(ZDOVars.s_fuel, 1f) > 0f) { value.resetEffect(); } } } } public class HeightmapPatch { [HarmonyPatch(typeof(Heightmap), "OnEnable")] private class OnEnable_Patch { private static void Postfix(Heightmap __instance) { if (isValid(__instance)) { activeHeightmaps.Add(__instance); } } } [HarmonyPatch(typeof(Heightmap), "OnDisable")] private class OnDisable_Patch { private static void Postfix(Heightmap __instance) { if (isValid(__instance)) { activeHeightmaps.Remove(__instance); GlobalLavaSolidifier.notifyHeightmapDestroyed(__instance); } } } [HarmonyPatch(typeof(Heightmap), "RebuildRenderMesh")] private class RebuildRenderMesh_Patch { private static void Postfix(Heightmap __instance) { if (isValid(__instance)) { LavaSolidifier.notifyHeightmapChanged(__instance); GlobalLavaSolidifier.notifyHeightmapChanged(__instance); GlobalLavaVisualsHandler.notifyHeightmapChanged(__instance); } } } [HarmonyPatch(typeof(Heightmap), "IsLava")] private class IsLava_Patch { private static bool Postfix(bool __result, Vector3 worldPos) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) if (__result) { return GlobalLavaSolidifier.getProtectionFactor(worldPos) < 0.05f; } return __result; } } public const int heightmapWidth = 64; public const float heightmapScale = 1f; public const float heightmapSideLength = 64f; private static GridMap activeHeightmaps = new GridMap(64f, zeroCentered: true); private static bool isValid(Heightmap __instance) { if (__instance.m_width == 64) { return __instance.m_scale == 1f; } return false; } public static Heightmap getAdjacent(Heightmap hmap, int dx, int dz) { return activeHeightmaps.GetAdjacent(hmap, dx, dz); } public static Heightmap getHeightmap(Vector3 worldPos) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return activeHeightmaps.Get(worldPos); } public static Heightmap getHeightmap(Vector2i coord) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return activeHeightmaps.Get(coord); } public static Vector2i getTerrainCoord(Vector3 pos) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return activeHeightmaps.GetCoord(pos); } public static HashSet getAffectedHeightmapCoords(Vector2 center, float radius, bool inclusive) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return activeHeightmaps.GetGridCellsOverlappingArea(center, radius, inclusive); } } public class LeviathanPatch { [HarmonyPatch(typeof(Leviathan), "OnHit")] private class OnHit_Patch { private static void Prefix(Leviathan __instance, out float __state) { __state = __instance.m_hitReactionChance; if (ManagedSolidLavaArea.anyActive() && !canSink(__instance)) { LogUtils.LogInfo("Preventing leviathan in hardened lava from beginning to sink"); __instance.m_hitReactionChance = -1f; } } private static void Postfix(Leviathan __instance, float __state) { __instance.m_hitReactionChance = __state; } } [HarmonyPatch(typeof(Leviathan), "Leave")] private class Leave_Patch { private static bool Prefix(Leviathan __instance) { if (!ManagedSolidLavaArea.anyActive()) { return true; } if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.m_nview == (Object)null || !__instance.m_nview.IsValid() || !__instance.m_nview.IsOwner() || __instance.m_left) { return true; } if (!canSink(__instance)) { LogUtils.LogInfo("Preventing leviathan in hardened lava from sinking"); return false; } return true; } } private const float LEVIATHAN_RADIUS = 12f; private static bool canSink(Leviathan lev) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) List solidAreasInSector = GlobalLavaSolidifier.getSolidAreasInSector(HeightmapPatch.getTerrainCoord(((Component)lev).transform.position)); foreach (SolidLavaArea item in solidAreasInSector) { float num = item.getShaderRadius() + 12f; if (MathUtils.distanceXZSqr(((Component)lev).transform.position, item.getTransform().position) < num * num) { return false; } } return true; } } internal class LocationPatch { [HarmonyPatch(typeof(Location), "Awake")] private class Awake_Patch { private static void Postfix(Location __instance) { RuneStone componentInChildren = ((Component)__instance).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { RuneStonePatch.addRunicEnergyAccumulator(((Component)componentInChildren).gameObject); } } } } public class MonsterAIPatch { [HarmonyPatch(typeof(MonsterAI), "Awake")] private class Awake_Patch { private static void Postfix(MonsterAI __instance) { if (ExtinguishingRune.anyActive() && ExtinguishingRune.isFireEnemy(((Component)__instance).gameObject) && (Object)(object)((Component)__instance).gameObject.GetComponent() == (Object)null) { ValheimMod.DevModeLog("Attaching DamageFireEnemies during awake patch"); ((Component)__instance).gameObject.AddComponent(); } } } } public class OfferingBowlPatch { [HarmonyPatch(typeof(OfferingBowl), "Awake")] private class Awake_Patch { private static void Postfix(OfferingBowl __instance) { object obj; if (__instance == null) { obj = null; } else { Transform transform = ((Component)__instance).transform; if (transform == null) { obj = null; } else { Transform parent = transform.parent; obj = ((parent != null) ? ((Object)parent).name : null); } } if (!((string?)obj != "offeraltar_gdking")) { GameObject gameObject = ((Component)((Component)__instance).transform.parent).gameObject; if ((Object)(object)gameObject.GetComponent() == (Object)null) { ValheimMod.DevModeLog("Attaching PieceExtinguisher to OfferingBowl during awake patch"); gameObject.AddComponent(); } } } } [HarmonyPatch(typeof(OfferingBowl), "UseItem")] private class UseItem_Patch { private static void Postfix(OfferingBowl __instance) { object obj; if (__instance == null) { obj = null; } else { Transform transform = ((Component)__instance).transform; if (transform == null) { obj = null; } else { Transform parent = transform.parent; obj = ((parent != null) ? ((Object)parent).name : null); } } if (!((string?)obj != "offeraltar_gdking")) { GameObject gameObject = ((Component)((Component)__instance).transform.parent).gameObject; if (PieceExtinguisher.allInstances.TryGetValue(gameObject, out var value)) { value.resetEffect(); } } } } [HarmonyPatch(typeof(OfferingBowl), "Interact")] private class Interact_Patch { private static void Postfix(OfferingBowl __instance) { object obj; if (__instance == null) { obj = null; } else { Transform transform = ((Component)__instance).transform; if (transform == null) { obj = null; } else { Transform parent = transform.parent; obj = ((parent != null) ? ((Object)parent).name : null); } } if (!((string?)obj != "offeraltar_gdking")) { GameObject gameObject = ((Component)((Component)__instance).transform.parent).gameObject; if (PieceExtinguisher.allInstances.TryGetValue(gameObject, out var value)) { value.resetEffect(); } } } } } public class SE_BurningPatch { [HarmonyPatch(typeof(SE_Burning), "UpdateStatusEffect")] private class UpdateStatusEffect_Patch { private static void Prefix(SE_Burning __instance, float dt) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (ExtinguishingRune.anyActive() && ExtinguishingRune.anyInRange(((Component)((StatusEffect)__instance).m_character).transform.position)) { ((StatusEffect)__instance).m_time = ((StatusEffect)__instance).m_time + dt * 3f; } } } } public class SmelterPatch { [HarmonyPatch(typeof(Smelter), "Awake")] private class Awake_Patch { private static void Postfix(Smelter __instance) { if (ExtinguishingRune.anyActive() && (Object)(object)((Component)__instance).gameObject.GetComponentInParent() == (Object)null) { ValheimMod.DevModeLog("Attaching PieceExtinguisher to Smelter during awake patch"); ((Component)__instance).gameObject.AddComponent(); } } } [HarmonyPatch(typeof(Smelter), "IsActive")] private class IsActive_Patch { private static bool Postfix(bool __result, Smelter __instance) { if (!__result) { return false; } if (PieceExtinguisher.allInstances.TryGetValue(((Component)__instance).gameObject, out var value)) { return !value.isFullyExtinguished(); } return __result; } } [HarmonyPatch(typeof(Smelter), "GetAccumulator")] private class GetAccumulator_Patch { private static float Postfix(float __result, Smelter __instance) { if (PieceExtinguisher.allInstances.TryGetValue(((Component)__instance).gameObject, out var value)) { if (!value.isFullyExtinguished()) { return Mathf.Max(__result, 0f); } return -10f; } return __result; } } [HarmonyPatch(typeof(Smelter), "OnAddFuel")] private class OnAddFuel_Patch { private static void Postfix(Smelter __instance) { if (PieceExtinguisher.allInstances.TryGetValue(((Component)__instance).gameObject, out var value)) { value.resetEffect(); } } } [HarmonyPatch(typeof(Smelter), "OnAddOre")] private class OnAddOre_Patch { private static void Postfix(Smelter __instance) { if (PieceExtinguisher.allInstances.TryGetValue(((Component)__instance).gameObject, out var value)) { value.resetEffect(); } } } } public class SmokePatch { [HarmonyPatch(typeof(Smoke), "Awake")] private class Awake_Patch { private static void Postfix(Smoke __instance, ref float ___m_fadeTimer) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!VentilationRune.isVentilationRuneSpawning && !((Object)(object)__instance == (Object)null)) { VentilationRune ventilationRune = VentilationRune.findNearestInRange(((Component)__instance).transform.position); if ((Object)(object)ventilationRune != (Object)null && !ventilationRune.isBlocked) { Object.Destroy((Object)(object)((Component)__instance).gameObject); } } } } } public class SmokeSpawnerPatch { [HarmonyPatch(typeof(SmokeSpawner), "OnEnable")] private class OnEnable_Patch { [HarmonyPriority(600)] private static void Prefix(SmokeSpawner __instance) { if (VentilationRune.anyActive()) { LogUtils.LogDebug("SmokeSpawnerPatch OnEnable prefix"); setupSmokeTracker(__instance); } } } public static void setupSmokeTracker(SmokeSpawner target) { if (!((Object)(object)target == (Object)null)) { Piece componentInParent = ((Component)target).gameObject.GetComponentInParent(); GameObject val = (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).gameObject : ((Component)target).gameObject); if ((Object)(object)((Component)target).gameObject.GetComponentInParent() == (Object)null && (Object)(object)val.GetComponent() == (Object)null) { val.AddComponent(); } } } } public class SpawnSystemPatch { } public class TerrainOpPatch { [HarmonyPatch(typeof(TerrainOp), "OnPlaced")] private class OnPlaced_Patch { private static void Prefix(TerrainOp __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (WorldGenerator.IsAshlands(((Component)__instance).transform.position.x, ((Component)__instance).transform.position.z)) { SolidLavaHole.spawnHole(((Component)__instance).transform.position, __instance.m_settings.GetRadius()); } } } } public class VisEquipmentPatch { [HarmonyPatch(typeof(VisEquipment), "AttachItem")] private class AttachItem_Patch { private static void Postfix(GameObject __result, VisEquipment __instance, bool enableEquipEffects, int itemHash) { if ((itemHash == 795277336 || itemHash == 1923162683) && !((Object)(object)__result == (Object)null) && enableEquipEffects && ExtinguishingRune.anyActive() && (Object)(object)__result.GetComponent() == (Object)null) { ItemExtinguisher itemExtinguisher = __result.AddComponent(); itemExtinguisher.equipment = __instance; itemExtinguisher.heldItemHash = itemHash; Humanoid value; if ((Object)(object)__instance == (Object)(object)((Humanoid)(Player.m_localPlayer?)).m_visEquipment) { itemExtinguisher.holder = (Humanoid)(object)Player.m_localPlayer; } else if (HumanoidPatch.visEquipmentMap.TryGetValue(__instance, out value)) { ValheimMod.DevModeLog("Attaching holder from visEquipmentMap"); itemExtinguisher.holder = value; } } } } private const int torchHash = 795277336; private const int goblinTorchHash = 1923162683; public static void setupItemExtinguishers(VisEquipment equipment, Humanoid holder) { if (!((Object)(object)equipment == (Object)null) && !((Object)(object)holder == (Object)null)) { GameObject val = null; int heldItemHash = 0; if (equipment.m_currentLeftItemHash == 795277336 || equipment.m_currentLeftItemHash == 1923162683) { val = equipment.m_leftItemInstance; heldItemHash = equipment.m_currentLeftItemHash; } else if (equipment.m_currentRightItemHash == 795277336 || equipment.m_currentRightItemHash == 1923162683) { val = equipment.m_rightItemInstance; heldItemHash = equipment.m_currentRightItemHash; } if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponent() == (Object)null) { ValheimMod.DevModeLog("ExtinguishingRune setup item extinguisher on " + ((Object)holder).name); ItemExtinguisher itemExtinguisher = val.AddComponent(); itemExtinguisher.equipment = equipment; itemExtinguisher.heldItemHash = heldItemHash; itemExtinguisher.holder = holder; } } } } public class BaseAIPatch { [HarmonyPatch(typeof(BaseAI), "SetTargetInfo")] private class SetTargetInfo_Patch { private static void Postfix(BaseAI __instance, ZNetView ___m_nview, ZDOID targetID) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) foreach (Player allPlayer in Player.GetAllPlayers()) { if (((Character)allPlayer).GetZDOID() == targetID) { ___m_nview.GetZDO().Set(IS_TARGETING_PLAYER_KEY, true); ___m_nview.GetZDO().Set(PLAYER_ID_KEY, allPlayer.GetPlayerID()); return; } } ___m_nview.GetZDO().Set(IS_TARGETING_PLAYER_KEY, false); ___m_nview.GetZDO().Set(PLAYER_ID_KEY, -1L); } } [HarmonyPatch(typeof(BaseAI), "FindClosestStaticPriorityTarget")] private class FindClosestStaticPriorityTarget_Patch { private static void Postfix(BaseAI __instance, ref StaticTarget __result) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (ExtinguishingRune.isFireEnemy(((Component)__instance).gameObject)) { ExtinguishingRune extinguishingRune = ExtinguishingRune.closestInRange(((Component)__instance).transform.position); if (!((Object)(object)extinguishingRune == (Object)null)) { __result = extinguishingRune.getStaticTarget(); } } } } private static readonly string IS_TARGETING_PLAYER_KEY = "targetingPlayer"; private static readonly string PLAYER_ID_KEY = "playerId"; public static bool isTargetingPlayer(BaseAI ai) { ZNetView component = ((Component)ai).GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid()) { return component.GetZDO().GetBool(IS_TARGETING_PLAYER_KEY, false); } return false; } public static bool isTargetingLocalPlayer(BaseAI ai) { ZNetView component = ((Component)ai).GetComponent(); if ((Object)(object)component != (Object)null && component.IsValid()) { return component.GetZDO().GetLong(PLAYER_ID_KEY, -1L) == Player.m_localPlayer.GetPlayerID(); } return false; } } public class DestructiblePatch { [HarmonyPatch(typeof(Destructible), "Destroy")] private class Destroy_Patch { private static void Prefix(Destructible __instance) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance == (Object)null) && ValheimMod.anyPrefixInTree(((Component)__instance).gameObject, ValheimMod.standingStoneNames)) { RuneProjector.checkSupportDestroyedNearPosition(((Component)__instance).gameObject.transform.position); } } } } internal class EnvManPatch { [HarmonyPatch(typeof(EnvMan), "InterpolateEnvironment", new Type[] { typeof(float) })] private class InterpolateEnvironment_Patch { private static void Postfix(EnvMan __instance, float ___m_transitionTimer, string ___m_forceEnv, EnvSetup ___m_prevEnv) { timeSinceTransitionStart = ___m_transitionTimer; transitionFraction = Mathf.Clamp01(___m_transitionTimer / __instance.m_transitionDuration); isTransitioning = ___m_transitionTimer < __instance.m_transitionDuration; if (___m_prevEnv != null) { activeParticlesEnv = ___m_prevEnv; } else { activeParticlesEnv = __instance.GetCurrentEnvironment(); } if (getOriginalEnv(___m_forceEnv) != null) { transitionFraction = 1f; isTransitioning = false; } } } [HarmonyPatch(typeof(EnvMan), "SetEnv")] private class SetEnv_Patch { private static void Postfix(EnvMan __instance, float ___m_transitionTimer, float dt, EnvSetup env) { float num = ConfigLoader.getFloat("canopyRune_activeTransitionTimeMult") * __instance.m_transitionDuration; float num2 = ((num > 0f) ? (dt / num) : 1f); EnvSetup originalEnv = getOriginalEnv(env.m_name); bool flag = CanopyRune.doesEnvironmentNeedCanopy(originalEnv); canopyActiveFactor = Shader.GetGlobalFloat("_CanopyActiveFactor"); canopyActiveFactor = Mathf.MoveTowards(canopyActiveFactor, flag ? 1f : 0f, num2); Shader.SetGlobalFloat("_CanopyActiveFactor", canopyActiveFactor); CanopyRune.addParticlesForAll(originalEnv); } } public static Dictionary envs = new Dictionary(); public static float timeSinceTransitionStart { get; private set; } public static float transitionFraction { get; private set; } public static bool isTransitioning { get; private set; } public static float canopyActiveFactor { get; private set; } public static EnvSetup activeParticlesEnv { get; private set; } public static EnvSetup getOriginalEnv(string name) { if (!envs.ContainsKey(name)) { envs[name] = null; foreach (EnvSetup environment in EnvMan.instance.m_environments) { envs[environment.m_name] = environment; } } if (envs.ContainsKey(name)) { return envs[name]; } return null; } } internal class FejdStartupPatch { [HarmonyPatch(typeof(FejdStartup), "ShowConnectError")] private class ShowConnectError_Patch { private static void Postfix(FejdStartup __instance) { if (connectionErrorMessageOverride != null) { __instance.m_connectionFailedError.text = connectionErrorMessageOverride; connectionErrorMessageOverride = null; } } } public static string connectionErrorMessageOverride; } internal class GamePatch { [HarmonyPatch(typeof(Game), "SpawnPlayer")] public static class SpawnPlayer_Patch { public static void Postfix(Player __result) { LocalizationManager.FixPlayerKnowledge(__result); } } [HarmonyPatch(typeof(Game), "Shutdown")] public static class Shutdown_Patch { public static void Prefix(bool ___m_shuttingDown) { if (!___m_shuttingDown) { try { ValheimMod.analytics.sendAnalytics(); } catch (Exception ex) { ValheimMod.DevModeLog(ex); } } } } } internal class MonoUpdatersPatch { } internal class TerminalPatch { [HarmonyPatch(typeof(Terminal), "InitTerminal")] private class InputText_Patch { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__0_0; public static ConsoleEvent <>9__0_1; public static ConsoleEvent <>9__0_2; public static ConsoleEvent <>9__0_3; public static ConsoleEvent <>9__0_4; internal void b__0_0(ConsoleEventArgs ) { ZNetPatch.TriggerServerConfigRefresh(); } internal void b__0_1(ConsoleEventArgs ) { ConfigLoader.UpgradeConfigFiles(); } internal void b__0_2(ConsoleEventArgs args) { if (args.Length <= 1) { args.Context.AddString("Usage: discoverRune [rune name]"); return; } try { ValheimMod.analytics.terminalCommandRun("discoverRune", args.FullLine.Substring(12).Trim()); } catch (Exception ex) { ValheimMod.DevModeLog(ex); } string text = TranslateCommandToId(args); if (text != null) { UnlockManager.unlockRune(Player.m_localPlayer, text); } else { args.Context.AddString("Error: Rune name is invalid or the rune is currently disabled"); } } internal void b__0_3(ConsoleEventArgs args) { if (args.Length <= 1) { args.Context.AddString("Usage: forgetRune [rune name]"); return; } try { ValheimMod.analytics.terminalCommandRun("forgetRune", args.FullLine.Substring(10).Trim()); } catch (Exception ex) { ValheimMod.DevModeLog(ex); } string text = TranslateCommandToId(args); if (text != null) { UnlockManager.lockRune(Player.m_localPlayer, text); } else { args.Context.AddString("Error: Rune name is invalid or the rune is currently disabled"); } } internal void b__0_4(ConsoleEventArgs args) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) if (args.Length > 1) { args.Context.AddString("Usage: cleanupNearbyRunes"); return; } LogUtils.LogImportantMessage("Cleaning up nearby runes"); List list = new List { typeof(DryLandRune), typeof(RepairRune), typeof(CalmWatersRune), typeof(CanopyRune) }; foreach (Type item in list) { Object[] array = Resources.FindObjectsOfTypeAll(item); Object[] array2 = array; foreach (Object val in array2) { MonoBehaviour val2 = (MonoBehaviour)val; if (Utils.DistanceXZ(((Component)val2).gameObject.transform.position, ((Component)Player.m_localPlayer).transform.position) < 7f) { LogUtils.LogImportantMessage("Cleaning up " + item.Name); Object.Destroy((Object)(object)((Component)val2).gameObject); } } } } } private static void Postfix(Terminal __instance) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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_011f: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate { ZNetPatch.TriggerServerConfigRefresh(); }; <>c.<>9__0_0 = val; obj = (object)val; } new ConsoleCommand("refreshServerConfig", "Refresh Rune Magic config from server", (ConsoleEvent)obj, false, true, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj2 = <>c.<>9__0_1; if (obj2 == null) { ConsoleEvent val2 = delegate { ConfigLoader.UpgradeConfigFiles(); }; <>c.<>9__0_1 = val2; obj2 = (object)val2; } new ConsoleCommand("forceConfigUpgrade", "Rebuilds the Rune Magic config files (also happens automatically on startup)", (ConsoleEvent)obj2, false, true, false, true, false, (ConsoleOptionsFetcher)null, false, false, false); object obj3 = <>c.<>9__0_2; if (obj3 == null) { ConsoleEvent val3 = delegate(ConsoleEventArgs args) { if (args.Length <= 1) { args.Context.AddString("Usage: discoverRune [rune name]"); } else { try { ValheimMod.analytics.terminalCommandRun("discoverRune", args.FullLine.Substring(12).Trim()); } catch (Exception ex2) { ValheimMod.DevModeLog(ex2); } string text2 = TranslateCommandToId(args); if (text2 != null) { UnlockManager.unlockRune(Player.m_localPlayer, text2); } else { args.Context.AddString("Error: Rune name is invalid or the rune is currently disabled"); } } }; <>c.<>9__0_2 = val3; obj3 = (object)val3; } new ConsoleCommand("discoverRune", "Unlock a specific rune", (ConsoleEvent)obj3, true, false, false, false, false, new ConsoleOptionsFetcher(GetRuneList), false, false, false); object obj4 = <>c.<>9__0_3; if (obj4 == null) { ConsoleEvent val4 = delegate(ConsoleEventArgs args) { if (args.Length <= 1) { args.Context.AddString("Usage: forgetRune [rune name]"); } else { try { ValheimMod.analytics.terminalCommandRun("forgetRune", args.FullLine.Substring(10).Trim()); } catch (Exception ex) { ValheimMod.DevModeLog(ex); } string text = TranslateCommandToId(args); if (text != null) { UnlockManager.lockRune(Player.m_localPlayer, text); } else { args.Context.AddString("Error: Rune name is invalid or the rune is currently disabled"); } } }; <>c.<>9__0_3 = val4; obj4 = (object)val4; } new ConsoleCommand("forgetRune", "Remove a specific rune from the player's list of known runes", (ConsoleEvent)obj4, true, false, false, false, false, new ConsoleOptionsFetcher(GetRuneList), false, false, false); object obj5 = <>c.<>9__0_4; if (obj5 == null) { ConsoleEvent val5 = delegate(ConsoleEventArgs args) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) if (args.Length > 1) { args.Context.AddString("Usage: cleanupNearbyRunes"); return; } LogUtils.LogImportantMessage("Cleaning up nearby runes"); List list = new List { typeof(DryLandRune), typeof(RepairRune), typeof(CalmWatersRune), typeof(CanopyRune) }; foreach (Type item in list) { Object[] array = Resources.FindObjectsOfTypeAll(item); Object[] array2 = array; foreach (Object val6 in array2) { MonoBehaviour val7 = (MonoBehaviour)val6; if (Utils.DistanceXZ(((Component)val7).gameObject.transform.position, ((Component)Player.m_localPlayer).transform.position) < 7f) { LogUtils.LogImportantMessage("Cleaning up " + item.Name); Object.Destroy((Object)(object)((Component)val7).gameObject); } } } }; <>c.<>9__0_4 = val5; obj5 = (object)val5; } new ConsoleCommand("cleanupNearbyRunes", "Deletes any engraved runes in a small radius around the player", (ConsoleEvent)obj5, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } private static string TranslateCommandToId(ConsoleEventArgs args) { if (args.Args.Length <= 1) { return null; } string key = args.FullLine.Substring(args.FullLine.IndexOf(' ') + 1).ToLower(); Dictionary dictionary = new Dictionary(); foreach (RunemagicPieceConfig runemagicPieceConfig in ValheimMod.runemagicPieceConfigs) { GameObject prefab = ZNetScene.instance.GetPrefab(runemagicPieceConfig.pieceName); Piece val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent() : null); if (!((Object)(object)val == (Object)null) && UnlockManager.isUnlockable(val)) { dictionary[val.m_name.ToLower().Replace("$piece_runemagic_", "")] = runemagicPieceConfig.pieceName; dictionary[runemagicPieceConfig.pieceName.ToLower()] = runemagicPieceConfig.pieceName; } } if (dictionary.ContainsKey(key)) { return dictionary[key]; } return null; } private static List GetRuneList() { List list = new List(); foreach (RunemagicPieceConfig runemagicPieceConfig in ValheimMod.runemagicPieceConfigs) { GameObject prefab = ZNetScene.instance.GetPrefab(runemagicPieceConfig.pieceName); Piece val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent() : null); if (!((Object)(object)val == (Object)null) && UnlockManager.isUnlockable(val)) { list.Add(val.m_name.ToLower().Replace("$piece_runemagic_", "")); } } return list.Distinct().ToList(); } } [HarmonyPatch(typeof(Terminal), "IsCheatsEnabled")] private class IsCheatsEnabled_Patch { private static bool Postfix(bool __result) { if (ValheimMod.DEV_MODE) { return true; } return __result; } } [HarmonyPatch(typeof(ConsoleCommand), "IsValid")] private class IsValid_Patch { private static bool Postfix(bool __result) { if (ValheimMod.DEV_MODE) { return true; } return __result; } } } public class ZNetPatch { [HarmonyPatch(typeof(ZNet), "Awake")] private class Awake_Patch { private static void Postfix(ZNet __instance, World ___m_world) { recordWorldUID(___m_world); } } [HarmonyPatch(typeof(ZNet), "OnNewConnection")] private class OnNewConnection_Patch { private static void Finalizer(Exception __exception, ZNet __instance, bool ___m_isServer, ZNetPeer peer) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown try { LogUtils.LogDebug("ZNet.OnNewConnection patch started"); peer.m_rpc.Register("hyleanlegend.RuneMagicVersionCheck", (Action)VersionCheck); ZPackage val = new ZPackage(); val.Write("1.4.0"); LogUtils.LogDebug("ZNet.OnNewConnection calling peer to check version"); peer.m_rpc.Invoke("hyleanlegend.RuneMagicVersionCheck", new object[1] { val }); if (___m_isServer) { LogUtils.LogDebug("ZNet.OnNewConnection registered RPC to refresh config"); peer.m_rpc.Register("hyleanlegend.RuneMagicTriggerServerConfigRefresh", new Method(TriggerServerConfigRefresh)); try { ValheimMod.analytics.otherPlayersConnected = true; return; } catch (Exception ex) { ValheimMod.DevModeLog(ex); return; } } LogUtils.LogDebug("ZNet.OnNewConnection registered RPC to update config from server"); peer.m_rpc.Register("hyleanlegend.RuneMagicUpdateConfigFromServer", (Action)UpdateConfigFromServer); } catch (Exception ex2) { if (__exception == null) { ValheimMod.DevModeLog(ex2); throw; } LogUtils.LogError(ex2); } } } [HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")] public static class RPC_PeerInfo_Patch { private static void Prefix(ZRpc rpc, ZPackage pkg, ref ZNet __instance) { LogUtils.LogDebug("ZNet.RPC_PeerInfo patch started"); if (!ValidatedPeers.Contains(rpc)) { LogUtils.LogDebug("ZNet.RPC_PeerInfo peer isn't validated"); if (__instance.IsServer()) { ZLog.LogError((object)"RuneMagic - Peer doesn't have mod installed, or it failed to load for them on game startup. Disconnecting."); rpc.Invoke("Error", new object[1] { (object)(ConnectionStatus)3 }); rpc.Invoke("Disconnect", Array.Empty()); } else { failLogin("Error: Server doesn't have mod RuneMagic, or it failed to load during server startup."); } } } private static void Postfix(ref ZNet __instance, World ___m_world, ZRpc rpc) { LogUtils.LogDebug("ZNet.RPC_PeerInfo postfix started"); ConfigLoader.cacheConfig(); recordWorldUID(___m_world); } } [HarmonyPatch(typeof(ZNet), "Disconnect")] private class Disconnect_Patch { private static void Postfix(ZNet __instance, bool ___m_isServer, ZNetPeer peer) { LogUtils.LogDebug("ZNet.Disconnect patch removing peer"); ValidatedPeers.Remove(peer.m_rpc); } } private static HashSet ValidatedPeers = new HashSet(); public static long CurrentWorldUID; private static void VersionCheck(ZRpc rpc, ZPackage zPackage) { string text = zPackage.ReadString(); LogUtils.LogImportantMessage("RuneMagic version check: theirs " + text + " mine 1.4.0"); if (!extractMajorMinor(text).Equals(extractMajorMinor("1.4.0"))) { LogUtils.LogWarning("Version mismatch found"); if (ZNet.instance.IsServer()) { rpc.Invoke("Error", new object[1] { (object)(ConnectionStatus)3 }); } else { failLogin("Invalid version for mod RuneMagic: local version 1.4.0, server version " + text); } } else { LogUtils.LogImportantMessage("Version matched"); ValidatedPeers.Add(rpc); } } private static void failLogin(string errorMessage) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) LogUtils.LogInfo("Forced login failure: " + errorMessage); ZNet.m_connectionStatus = (ConnectionStatus)3; FejdStartupPatch.connectionErrorMessageOverride = errorMessage; Game.instance.Logout(true, true); } private static string extractMajorMinor(string version) { string[] array = version.Split(new char[1] { '.' }); if (array.Length < 2 || array.Length > 3) { throw new Exception("Invalid version string: " + version); } return array[0] + "." + array[1]; } public static void sendConfigFromServer(ZPackage serverConfigPackage) { if (!ZNet.instance.IsServer()) { return; } LogUtils.LogInfo($"Sending server config to {ZNet.instance.GetPeers().Count} clients"); foreach (ZNetPeer peer in ZNet.instance.GetPeers()) { peer.m_rpc.Invoke("hyleanlegend.RuneMagicUpdateConfigFromServer", new object[1] { serverConfigPackage }); } } private static void UpdateConfigFromServer(ZRpc rpc, ZPackage zPackage) { LogUtils.LogInfo("Received updated config from server"); ConfigLoader.deserializeServerConfig(zPackage); } public static void TriggerServerConfigRefresh() { ZNetPeer serverPeer = ZNet.instance.GetServerPeer(); if (serverPeer != null) { serverPeer.m_rpc.Invoke("hyleanlegend.RuneMagicTriggerServerConfigRefresh", Array.Empty()); } } private static void TriggerServerConfigRefresh(ZRpc rpc) { ConfigLoader.cacheConfig(); } private static void recordWorldUID(World world) { try { if (world != null) { CurrentWorldUID = world.m_uid; ValheimMod.DevModeLog("Current world uid: " + CurrentWorldUID); } } catch (Exception ex) { ValheimMod.DevModeLog(ex); } } } internal class CoverPatch { [HarmonyPatch(typeof(Cover), "IsUnderRoof")] private class IsUnderRoof_Patch { private static bool Postfix(bool __result, Vector3 startPos) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) if (!__result) { return CanopyRune.isPointInRangeOfAny(startPos); } return true; } } } internal class HudPatch { [HarmonyPatch(typeof(Hud), "SetupPieceInfo")] private class SetupPieceInfo_Patch { private static void Postfix(Hud __instance, Piece piece) { if ((Object)(object)piece == (Object)null) { return; } float energyCost = RunemagicPieceConfig.getEnergyCost(piece); if (!(energyCost > 0f)) { return; } for (int i = 0; i < __instance.m_requirementItems.Length; i++) { if (!__instance.m_requirementItems[i].activeInHierarchy) { __instance.m_requirementItems[i].SetActive(true); SetupRequirement(__instance.m_requirementItems[i].transform, Player.m_localPlayer, energyCost, RunemagicPieceConfig.isPassiveEffect(piece)); break; } } } public static bool SetupRequirement(Transform elementRoot, Player player, float amount, bool costOverTime) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_0193: 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) Image component = ((Component)((Component)elementRoot).transform.Find("res_icon")).GetComponent(); TMP_Text component2 = ((Component)((Component)elementRoot).transform.Find("res_name")).GetComponent(); TMP_Text component3 = ((Component)((Component)elementRoot).transform.Find("res_amount")).GetComponent(); UITooltip component4 = ((Component)elementRoot).GetComponent(); if (baseFontSize < 0f) { baseFontSize = component2.fontSize; } ((Component)component).gameObject.SetActive(true); ((Component)component2).gameObject.SetActive(true); ((Component)component3).gameObject.SetActive(true); component.sprite = AssetLoader.GetSpriteFromAssetBundle("RunicEnergySprite.png"); ((Graphic)component).color = Color.white; component4.m_text = "Runic Energy"; component2.text = "Runic Energy"; int num = Mathf.FloorToInt(PlayerPatch.getAvailableEnergy(player)); component3.fontSizeMin = 5f; component3.fontSizeMax = baseFontSize; component3.enableAutoSizing = true; component3.textWrappingMode = (TextWrappingModes)0; if (costOverTime) { string text = "sec."; if (amount < 1f) { amount *= 60f; text = "min."; } string text2 = "F1"; if (amount.ToString(text2).EndsWith("0")) { text2 = "F0"; } component3.text = amount.ToString(text2) + "/" + text; } else { amount = Mathf.CeilToInt(amount); component3.text = $"{num}/{amount}"; } if ((float)num < amount) { ((Graphic)component3).color = ((Mathf.Sin(Time.time * 10f) > 0f) ? Color.red : Color.white); } else { ((Graphic)component3).color = Color.white; } return true; } } private static float baseFontSize = -1f; } public class WaterVolumePatch { [HarmonyPatch(typeof(WaterVolume), "Start")] private class OnEnable_Patch { private static void Postfix(WaterVolume __instance) { if (isValid(__instance)) { waterVolumeMap[__instance.m_heightmap] = __instance; } } } [HarmonyPatch(typeof(WaterVolume), "OnDisable")] private class OnDisable_Patch { private static void Postfix(WaterVolume __instance) { if (isValid(__instance)) { waterVolumeMap.Remove(__instance.m_heightmap); } } } public class GetWaterSurface_Patch { public static float Postfix(float __result, WaterVolume __instance, Vector3 point) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) __result += getSurfaceDeviation(__instance, point); return __result; } private static float getSurfaceDeviation(WaterVolume volume, Vector3 point) { //IL_0050: 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_0056: 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_005f: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00a6: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) if (!WaterSurfaceManager.managers.TryGetValue(volume, out var value) || (Object)(object)value == (Object)null || !value.isSurfaceAltered()) { return 0f; } MeshFilter waterSurface = value.waterSurface; if ((Object)(object)waterSurface == (Object)null) { return 0f; } Vector3[] latestWaterSurface = value.getLatestWaterSurface(); Vector3 val = ((Component)waterSurface).gameObject.transform.InverseTransformPoint(point); Vector3 val2 = val * 31f / 2f + new Vector3(15.5f, 0f, 15.5f); Vector3 vertexForCoord = getVertexForCoord((int)Math.Floor(val2.x), (int)Math.Floor(val2.z), latestWaterSurface); Vector3 vertexForCoord2 = getVertexForCoord((int)Math.Ceiling(val2.x), (int)Math.Floor(val2.z), latestWaterSurface); Vector3 vertexForCoord3 = getVertexForCoord((int)Math.Ceiling(val2.x), (int)Math.Ceiling(val2.z), latestWaterSurface); Vector3 vertexForCoord4 = getVertexForCoord((int)Math.Floor(val2.x), (int)Math.Ceiling(val2.z), latestWaterSurface); Vector3 b = interpolateX(vertexForCoord2, vertexForCoord, val); Vector3 a = interpolateX(vertexForCoord3, vertexForCoord4, val); Vector3 val3 = interpolateZ(a, b, val); return val3.y; } private static Vector3 interpolateX(Vector3 a, Vector3 b, Vector3 pos) { //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_0018: 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_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_0043: 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_0050: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.InverseLerp(a.x, b.x, pos.x); float num2 = Mathf.Lerp(a.y, b.y, num); if (a.z != b.z) { LogUtils.LogWarning("interpolateX inputs have mismatched Z"); } return new Vector3(pos.x, num2, a.z); } private static Vector3 interpolateZ(Vector3 a, Vector3 b, Vector3 pos) { //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_0018: 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_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_0043: 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_0050: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.InverseLerp(a.z, b.z, pos.z); float num2 = Mathf.Lerp(a.y, b.y, num); if (a.x != b.x) { LogUtils.LogWarning("interpolateZ inputs have mismatched X"); } return new Vector3(a.x, num2, pos.z); } } private static int[][] coordMap; public static float localToWorldDistanceScaleFactor; public static float surfaceSideLength; private static Dictionary waterVolumeMap = new Dictionary(); private static bool isValid(WaterVolume vol) { return (Object)(object)vol.m_heightmap != (Object)null; } public static WaterVolume getVolume(Heightmap hmap) { if (!waterVolumeMap.ContainsKey(hmap)) { return null; } return waterVolumeMap[hmap]; } public static Vector3 getVertexForCoord(int x, int z, Vector3[] vertices) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) x = Mathf.Clamp(x, 0, 31); z = Mathf.Clamp(z, 0, 31); return vertices[coordMap[x][z]]; } public static void precalculateVertices(MeshFilter waterSurface) { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_0129: Unknown result type (might be due to invalid IL or missing references) if (coordMap != null) { return; } Vector3[] vertices = waterSurface.sharedMesh.vertices; coordMap = new int[32][]; for (int i = 0; i < coordMap.Length; i++) { coordMap[i] = new int[32]; } for (int j = 0; j < vertices.Length; j++) { if (vertices[j].y == 0f) { float num = vertices[j].x + 1f; float num2 = vertices[j].z + 1f; num = num * 31f / 2f; num2 = num2 * 31f / 2f; coordMap[Mathf.RoundToInt(num)][Mathf.RoundToInt(num2)] = j; } } Vector3 vertexForCoord = getVertexForCoord(0, 0, vertices); Vector3 vertexForCoord2 = getVertexForCoord(0, 31, vertices); Vector3 val = ((Component)waterSurface).gameObject.transform.TransformPoint(vertexForCoord); Vector3 val2 = ((Component)waterSurface).gameObject.transform.TransformPoint(vertexForCoord2); Vector3 val3 = val - val2; surfaceSideLength = ((Vector3)(ref val3)).magnitude; float num3 = surfaceSideLength; val3 = vertexForCoord - vertexForCoord2; localToWorldDistanceScaleFactor = num3 / ((Vector3)(ref val3)).magnitude; LogUtils.LogInfo("Cached water surface vertex order"); } } internal class WearNTearPatch { [HarmonyPatch(typeof(WearNTear), "Awake")] private class Awake_Patch { private static void Postfix(WearNTear __instance) { GlobalRepairManager.wearNTearNotify(__instance); } } [HarmonyPatch(typeof(WearNTear), "RPC_HealthChanged")] private class RPC_HealthChanged_Patch { private static void Postfix(WearNTear __instance) { GlobalRepairManager.wearNTearNotify(__instance); } } [HarmonyPatch(typeof(WearNTear), "OnDestroy")] private class OnDestroy_Patch { private static void Postfix(WearNTear __instance) { GlobalRepairManager.wearNTearDestroyed(__instance); } } [HarmonyPatch(typeof(WearNTear), "SetupColliders")] private class SetupColliders_Patch { private static bool Prefix(WearNTear __instance, out ParentChild[] __state) { Collider[] componentsInChildren = ((Component)__instance).GetComponentsInChildren(true); Collider[] array = Array.FindAll(componentsInChildren, (Collider c) => ((Object)c).name.Contains("_WearNTearIgnore")); __state = new ParentChild[array.Length]; if (array.Length != 0) { for (int i = 0; i < array.Length; i++) { __state[i] = new ParentChild(((Component)array[i]).gameObject); __state[i].detach(); } } return true; } private static void Postfix(WearNTear __instance, ParentChild[] __state) { if (__state != null && __state.Length != 0) { foreach (ParentChild parentChild in __state) { parentChild.attach(); } } } } [HarmonyPatch(typeof(WearNTear), "HaveRoof")] private class HaveRoof_Patch { private static bool Postfix(bool __result, WearNTear __instance) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null) { return __result; } if (!__result) { return CanopyRune.isPointInRangeOfAny(((Component)__instance).transform.position); } return true; } } [HarmonyPatch(typeof(WearNTear), "UpdateWear")] private class UpdateWear_Patch { [UsedImplicitly] public static IEnumerable Transpiler(IEnumerable instructions, ILGenerator ilGenerator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown CodeMatcher val = new CodeMatcher(instructions, ilGenerator); CodeMatch[] array = (CodeMatch[])(object)new CodeMatch[6] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Bge_Un, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Brtrue, (object)null, (string)null) }; val.MatchEndForward(array).ThrowIfInvalid("Could not find conditional for WearNTear lava damage"); CodeInstruction instruction = val.Instruction; val.Advance(1); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), CodeInstruction.Call(typeof(GlobalLavaSolidifier), "isWearNTearProtected", (Type[])null, (Type[])null), new CodeInstruction(OpCodes.Brtrue, instruction.operand) }); val.MatchEndForward(array); if (val.IsValid) { throw new Exception("WearNTear lava transpile ambiguous, matched multiple sections"); } return val.Instructions(); } } [HarmonyPatch(typeof(WearNTear), "Remove")] private class Remove_Patch { private static void Postfix(WearNTear __instance) { if ((Object)(object)__instance == (Object)null) { return; } Piece component = ((Component)__instance).gameObject.GetComponent(); if ((Object)(object)component == (Object)null) { LogUtils.LogInfo(((Object)((Component)__instance).gameObject).name + " is not a piece, skipping"); return; } float energyToRefund = RunemagicPieceConfig.getEnergyCost(component); if (!(energyToRefund > 0f)) { return; } LogUtils.LogImportantMessage($"Refunding {energyToRefund} energy"); List list = ((Humanoid)Player.m_localPlayer).GetInventory().GetAllItems().FindAll((ItemData id) => ValheimMod.isRuneFocus(id)); list.Reverse(); ItemData playerRightItem = PlayerPatch.getPlayerRightItem(Player.m_localPlayer); if (playerRightItem != null && ValheimMod.isRuneFocus(playerRightItem)) { chargeRuneFocus(playerRightItem, ref energyToRefund); } foreach (ItemData item in list) { chargeRuneFocus(item, ref energyToRefund); if (energyToRefund <= 0f) { break; } } } private static void chargeRuneFocus(ItemData runeFocus, ref float energyToRefund) { float val = runeFocus.GetMaxDurability() - runeFocus.m_durability; float num = Math.Min(val, energyToRefund); LogUtils.LogInfo($"Refunding {num} energy to runestone <{runeFocus.m_gridPos.x},{runeFocus.m_gridPos.y}>"); runeFocus.m_durability += num; energyToRefund -= num; } } [HarmonyPatch(typeof(WearNTear), "Destroy")] private class Destroy_Patch { private static void Prefix(WearNTear __instance) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance == (Object)null)) { try { ValheimMod.analytics.engravedRuneRemoved(Utils.GetPrefabName(((Component)__instance).gameObject)); } catch (Exception ex) { ValheimMod.DevModeLog(ex); } if (ValheimMod.anyPrefixInTree(((Component)__instance).gameObject, ValheimMod.standingStoneNames)) { RuneProjector.checkSupportDestroyedNearPosition(((Component)__instance).transform.position); } } } } private class ParentChild { public GameObject parent; public GameObject child; public ParentChild(GameObject child) { this.child = child; parent = ((Component)child.transform.parent).gameObject; } public void detach() { child.transform.parent = null; } public void attach() { child.transform.parent = parent.transform; } } } internal class ZNetScenePatch { [HarmonyPatch(typeof(ZNetScene), "CreateDestroyObjects")] private class CreateDestroyObjects_Patch { private static bool Prefix() { ChangingLoadedObjects = true; return true; } private static void Postfix() { ChangingLoadedObjects = false; } } public static bool ChangingLoadedObjects; } internal class ZNetViewPatch { [HarmonyPatch(typeof(ZNetView), "Awake")] private class Awake_Patch { private static void Postfix(ZNetView __instance) { if (!ZNetView.m_forceDisableInit) { ZNetViewHook[] componentsInChildren = ((Component)__instance).GetComponentsInChildren(); ZNetViewHook[] array = componentsInChildren; foreach (ZNetViewHook zNetViewHook in array) { zNetViewHook.PostZNetViewAwake(__instance); } } } } } internal class ZoneSystemPatch { [HarmonyPatch(typeof(ZoneSystem), "SpawnZone")] private class SpawnZone_Patch { private static bool Prefix() { ZoneSpawning = true; return true; } private static void Postfix() { ZoneSpawning = false; } } public static bool ZoneSpawning; } internal class HumanoidPatch { [HarmonyPatch(typeof(Humanoid), "Awake")] private class Awake_Patch { private static void Postfix(Humanoid __instance) { if ((Object)(object)__instance?.m_visEquipment != (Object)null) { visEquipmentMap[__instance.m_visEquipment] = __instance; } } } [HarmonyPatch(typeof(Humanoid), "OnDestroy")] private class OnDestroy_Patch { private static void Postfix(Humanoid __instance) { if ((Object)(object)__instance.m_visEquipment != (Object)null) { visEquipmentMap.Remove(__instance.m_visEquipment); } } } [HarmonyPatch(typeof(Humanoid), "DrainEquipedItemDurability")] private class DrainEquipedItemDurability_Patch { private static bool Prefix(Humanoid __instance, ItemData item, float dt) { if (!ValheimMod.isRuneFocus(item)) { return true; } if (item.m_durability <= 0f) { ((Character)__instance).Message((MessageType)1, "$message_runemagic_runefocus_exhaustedenergy", 0, item.GetIcon()); __instance.UnequipItem(item, false); item.m_durability = 0f; } return false; } } [HarmonyPatch(typeof(Humanoid), "HideHandItems")] private class HideHandItems_Patch { private static bool Prefix(Humanoid __instance, ItemData ___m_rightItem) { bool flag = ((Character)__instance).IsSwimming() && !((Character)__instance).IsOnGround(); bool flag2 = ___m_rightItem != null && ValheimMod.isRuneFocus(___m_rightItem); bool @bool = ConfigLoader.getBool("RuneFocusEquippableInWater"); if (@bool && flag && flag2) { return false; } return true; } } [HarmonyPatch(typeof(Humanoid), "EquipItem")] private class EquipItem_Patch { private static void Prefix(Humanoid __instance, ref float ___m_swimTimer, ItemData item, out float __state) { __state = ___m_swimTimer; bool flag = item != null && ValheimMod.isRuneFocus(item); if (((Character)__instance).IsPlayer() && flag && ConfigLoader.getBool("RuneFocusEquippableInWater")) { ___m_swimTimer = 100f; } } private static void Postfix(Humanoid __instance, ref float ___m_swimTimer, float __state) { ___m_swimTimer = __state; } } public static Dictionary visEquipmentMap = new Dictionary(); } internal class InventoryGuiPatch { [HarmonyPatch(typeof(InventoryGui), "UpdateRecipe")] private class UpdateRecipe_Patch { private static void Prefix(InventoryGui __instance, Player player) { foreach (ItemData allItem in ((Humanoid)player).GetInventory().GetAllItems()) { inventoryDurabilities[allItem] = allItem.m_durability; } } private static void Postfix() { inventoryDurabilities.Clear(); } } [HarmonyPatch(typeof(InventoryGui), "DoCrafting")] private class DoCrafting_Patch { private static void Prefix(InventoryGui __instance, Player player, out UpgradeState __state, ItemData ___m_craftUpgradeItem) { __state = null; if (___m_craftUpgradeItem != null && ValheimMod.isRuneFocus(___m_craftUpgradeItem)) { List otherItems = ((Humanoid)player).GetInventory().GetAllItems().FindAll((ItemData id) => id.m_shared.m_name.Equals(___m_craftUpgradeItem.m_shared.m_name) && id != ___m_craftUpgradeItem); inventoryDurabilities.TryGetValue(___m_craftUpgradeItem, out var value); __state = new UpgradeState(___m_craftUpgradeItem, value, otherItems); } } private static void Postfix(InventoryGui __instance, Player player, UpgradeState __state, ItemData ___m_craftUpgradeItem) { if (___m_craftUpgradeItem != null && __state != null && ValheimMod.isRuneFocus(___m_craftUpgradeItem)) { LogUtils.LogInfo($"Setting new Rune Focus durability to {__state.upgradingItem.m_durability}"); ItemData itemAfterUpgrade = __state.getItemAfterUpgrade(((Humanoid)player).GetInventory()); if (itemAfterUpgrade != null) { itemAfterUpgrade.m_durability = __state.durability; } } } } private static Dictionary inventoryDurabilities = new Dictionary(); } internal class UpgradeState { public ItemData upgradingItem; public float durability; public List otherItems; public UpgradeState(ItemData upgradingItem, float durability, List otherItems) { this.upgradingItem = upgradingItem; this.durability = durability; this.otherItems = otherItems; } public ItemData getItemAfterUpgrade(Inventory inventory) { return inventory.GetAllItems().Find((ItemData id) => id.m_shared.m_name.Equals(upgradingItem.m_shared.m_name) && !otherItems.Contains(id)); } } internal class InventoryPatch { [HarmonyPatch(typeof(Inventory), "AddItem", new Type[] { typeof(string), typeof(int), typeof(int), typeof(int), typeof(long), typeof(string), typeof(Vector2i), typeof(bool) })] private class AddItem_Patch { private static ItemData Postfix(ItemData __result, Inventory __instance) { if (ValheimMod.isRuneFocus(__result) && __result.m_quality == 1) { LogUtils.LogInfo("Creating uncharged Rune Focus"); __result.m_durability = 0f; } return __result; } } } internal class RuneStonePatch { public static void setAccumulatorOnRuneStones(bool active) { RuneStone[] array = Resources.FindObjectsOfTypeAll(); RuneStone[] array2 = array; foreach (RuneStone val in array2) { addRunicEnergyAccumulator(((Component)val).gameObject); } } public static RunicEnergyAccumulator addRunicEnergyAccumulator(GameObject runestone) { //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //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_00e4: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_0137: Unknown result type (might be due to invalid IL or missing references) if (((Object)runestone.gameObject).name.Contains("BossStone_")) { LogUtils.LogInfo("Skipping " + ((Object)runestone.gameObject).name); return null; } if (((Object)runestone.gameObject).name == "RuneStone_DragonQueen") { LogUtils.LogInfo("Replacing textures for the dragonqueen altar"); Transform parent = runestone.gameObject.transform.parent.parent; Transform val = parent.Find("Dragonlocation"); MeshRenderer componentInChildren = ((Component)val).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)((Renderer)componentInChildren).sharedMaterial != (Object)null && (Object)(object)((Renderer)componentInChildren).sharedMaterial.mainTexture != (Object)null) { Texture2D val2 = ColorUtils.duplicateTexture((Texture2D)((Renderer)componentInChildren).sharedMaterial.mainTexture); for (int i = 0; i < ((Texture)val2).height; i++) { for (int j = 0; j < ((Texture)val2).width; j++) { Color pixel = val2.GetPixel(j, i); float num = (pixel.g + pixel.b) / 2f; float num2 = (pixel.r + pixel.g + pixel.b) / 3f; if (pixel.r > num * 1.15f) { val2.SetPixel(j, i, new Color(num2, num2, num2)); } } } val2.Apply(true, true); ((Renderer)componentInChildren).sharedMaterial.mainTexture = (Texture)(object)val2; } } RunicEnergyAccumulator componentInParentAll = ValheimMod.getComponentInParentAll(runestone.gameObject); if (ValheimMod.isModEnabled && (Object)(object)componentInParentAll == (Object)null) { runestone.gameObject.AddComponent(); } else if (!ValheimMod.isModEnabled && (Object)(object)componentInParentAll != (Object)null) { Object.Destroy((Object)(object)componentInParentAll); return null; } return componentInParentAll; } } [HarmonyPatch(typeof(RuneStone), "UseItem")] internal class UseItem_Patch { private static bool Postfix(bool __result, RuneStone __instance, Humanoid user, ItemData item) { if (!ValheimMod.isRuneFocus(item)) { LogUtils.LogInfo("Runestone interaction with wrong item: " + item.m_shared.m_name); return false; } RunicEnergyAccumulator component = ((Component)__instance).gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { component.UseItem(user, item); } return true; } } } namespace ValheimMod.External { public class FormUrlEncoder { public static byte[] GetContentByteArray(IEnumerable> nameValueCollection) { if (nameValueCollection == null) { throw new ArgumentNullException("nameValueCollection"); } StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair item in nameValueCollection) { if (stringBuilder.Length > 0) { stringBuilder.Append('&'); } stringBuilder.Append(Encode(item.Key)); stringBuilder.Append('='); stringBuilder.Append(Encode(item.Value)); } return Encoding.GetEncoding("iso-8859-1").GetBytes(stringBuilder.ToString()); } private static string Encode(string data) { if (string.IsNullOrEmpty(data)) { return string.Empty; } return Uri.EscapeDataString(data).Replace("%20", "+"); } } } namespace ValheimMod.External.MiniJSON { public static class Json { private sealed class Parser : IDisposable { private enum TOKEN { NONE, CURLY_OPEN, CURLY_CLOSE, SQUARED_OPEN, SQUARED_CLOSE, COLON, COMMA, STRING, NUMBER, TRUE, FALSE, NULL } private const string WORD_BREAK = "{}[],:\""; private StringReader json; private char PeekChar => Convert.ToChar(json.Peek()); private char NextChar => Convert.ToChar(json.Read()); private string NextWord { get { StringBuilder stringBuilder = new StringBuilder(); while (!IsWordBreak(PeekChar)) { stringBuilder.Append(NextChar); if (json.Peek() == -1) { break; } } return stringBuilder.ToString(); } } private TOKEN NextToken { get { EatWhitespace(); if (json.Peek() == -1) { return TOKEN.NONE; } switch (PeekChar) { case '{': return TOKEN.CURLY_OPEN; case '}': json.Read(); return TOKEN.CURLY_CLOSE; case '[': return TOKEN.SQUARED_OPEN; case ']': json.Read(); return TOKEN.SQUARED_CLOSE; case ',': json.Read(); return TOKEN.COMMA; case '"': return TOKEN.STRING; case ':': return TOKEN.COLON; case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': return TOKEN.NUMBER; default: return NextWord switch { "false" => TOKEN.FALSE, "true" => TOKEN.TRUE, "null" => TOKEN.NULL, _ => TOKEN.NONE, }; } } } public static bool IsWordBreak(char c) { if (!char.IsWhiteSpace(c)) { return "{}[],:\"".IndexOf(c) != -1; } return true; } private Parser(string jsonString) { json = new StringReader(jsonString); } public static object Parse(string jsonString) { using Parser parser = new Parser(jsonString); return parser.ParseValue(); } public void Dispose() { json.Dispose(); json = null; } private Dictionary ParseObject() { Dictionary dictionary = new Dictionary(); json.Read(); while (true) { switch (NextToken) { case TOKEN.COMMA: continue; case TOKEN.NONE: return null; case TOKEN.CURLY_CLOSE: return dictionary; } string text = ParseString(); if (text == null) { return null; } if (NextToken != TOKEN.COLON) { return null; } json.Read(); dictionary[text] = ParseValue(); } } private List ParseArray() { List list = new List(); json.Read(); bool flag = true; while (flag) { TOKEN nextToken = NextToken; switch (nextToken) { case TOKEN.NONE: return null; case TOKEN.SQUARED_CLOSE: flag = false; break; default: { object item = ParseByToken(nextToken); list.Add(item); break; } case TOKEN.COMMA: break; } } return list; } private object ParseValue() { TOKEN nextToken = NextToken; return ParseByToken(nextToken); } private object ParseByToken(TOKEN token) { return token switch { TOKEN.STRING => ParseString(), TOKEN.NUMBER => ParseNumber(), TOKEN.CURLY_OPEN => ParseObject(), TOKEN.SQUARED_OPEN => ParseArray(), TOKEN.TRUE => true, TOKEN.FALSE => false, TOKEN.NULL => null, _ => null, }; } private string ParseString() { StringBuilder stringBuilder = new StringBuilder(); json.Read(); bool flag = true; while (flag) { if (json.Peek() == -1) { flag = false; break; } char nextChar = NextChar; switch (nextChar) { case '"': flag = false; break; case '\\': if (json.Peek() == -1) { flag = false; break; } nextChar = NextChar; switch (nextChar) { case '"': case '/': case '\\': stringBuilder.Append(nextChar); break; case 'b': stringBuilder.Append('\b'); break; case 'f': stringBuilder.Append('\f'); break; case 'n': stringBuilder.Append('\n'); break; case 'r': stringBuilder.Append('\r'); break; case 't': stringBuilder.Append('\t'); break; case 'u': { char[] array = new char[4]; for (int i = 0; i < 4; i++) { array[i] = NextChar; } stringBuilder.Append((char)Convert.ToInt32(new string(array), 16)); break; } } break; default: stringBuilder.Append(nextChar); break; } } return stringBuilder.ToString(); } private object ParseNumber() { string nextWord = NextWord; if (nextWord.IndexOf('.') == -1) { long.TryParse(nextWord, out var result); return result; } double.TryParse(nextWord, out var result2); return result2; } private void EatWhitespace() { while (char.IsWhiteSpace(PeekChar)) { json.Read(); if (json.Peek() == -1) { break; } } } } private sealed class Serializer { private StringBuilder builder; private Serializer() { builder = new StringBuilder(); } public static string Serialize(object obj) { Serializer serializer = new Serializer(); serializer.SerializeValue(obj); return serializer.builder.ToString(); } private void SerializeValue(object value) { if (value == null) { builder.Append("null"); } else if (value is string str) { SerializeString(str); } else if (value is bool) { builder.Append(((bool)value) ? "true" : "false"); } else if (value is IList anArray) { SerializeArray(anArray); } else if (value is IDictionary obj) { SerializeObject(obj); } else if (value is char) { SerializeString(new string((char)value, 1)); } else { SerializeOther(value); } } private void SerializeObject(IDictionary obj) { bool flag = true; builder.Append('{'); foreach (object key in obj.Keys) { if (!flag) { builder.Append(','); } SerializeString(key.ToString()); builder.Append(':'); SerializeValue(obj[key]); flag = false; } builder.Append('}'); } private void SerializeArray(IList anArray) { builder.Append('['); bool flag = true; foreach (object item in anArray) { if (!flag) { builder.Append(','); } SerializeValue(item); flag = false; } builder.Append(']'); } private void SerializeString(string str) { builder.Append('"'); char[] array = str.ToCharArray(); char[] array2 = array; foreach (char c in array2) { switch (c) { case '"': builder.Append("\\\""); continue; case '\\': builder.Append("\\\\"); continue; case '\b': builder.Append("\\b"); continue; case '\f': builder.Append("\\f"); continue; case '\n': builder.Append("\\n"); continue; case '\r': builder.Append("\\r"); continue; case '\t': builder.Append("\\t"); continue; } int num = Convert.ToInt32(c); if (num >= 32 && num <= 126) { builder.Append(c); continue; } builder.Append("\\u"); builder.Append(num.ToString("x4")); } builder.Append('"'); } private void SerializeOther(object value) { if (value is float) { builder.Append(((float)value).ToString("R")); } else if (value is int || value is uint || value is long || value is sbyte || value is byte || value is short || value is ushort || value is ulong) { builder.Append(value); } else if (value is double || value is decimal) { builder.Append(Convert.ToDouble(value).ToString("R")); } else { SerializeString(value.ToString()); } } } public static object Deserialize(string json) { if (json == null) { return null; } return Parser.Parse(json); } public static string Serialize(object obj) { return Serializer.Serialize(obj); } } } namespace ValheimMod.Monobehaviours { public class Decal : MonoBehaviour { public enum DecalType { DiffuseOnly, NormalsOnly, Both } public Material m_Material; public Mesh renderVolume; private Dictionary shaderMap = new Dictionary { { "Decal/DecalShader", DecalType.DiffuseOnly }, { "Decal/DecalShader Normals", DecalType.NormalsOnly }, { "Decal/DecalShader Diffuse+Normals", DecalType.Both } }; private Dictionary m_Cameras = new Dictionary(); private void DrawGizmo(bool selected) { //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_0047: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) Color color = default(Color); ((Color)(ref color))..ctor(0f, 0.7f, 1f, 1f); color.a = (selected ? 0.3f : 0.1f); Gizmos.color = color; Gizmos.matrix = ((Component)this).transform.localToWorldMatrix; Gizmos.DrawCube(Vector3.zero, Vector3.one); color.a = (selected ? 0.5f : 0.2f); Gizmos.color = color; Gizmos.DrawWireCube(Vector3.zero, Vector3.one); } public void OnDrawGizmos() { DrawGizmo(selected: false); } public void OnDrawGizmosSelected() { DrawGizmo(selected: true); } private void OnDisable() { } public void OnWillRenderObject() { //IL_007a: 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) Camera current = Camera.current; if (Object.op_Implicit((Object)(object)current) && !Object.op_Implicit((Object)(object)current)) { DecalManager.registerCamera(current); CommandBuffer buffer = DecalManager.getBuffer(current); buffer.Clear(); if (((Component)this).gameObject.activeInHierarchy && ((Behaviour)this).enabled) { DecalType decalType = shaderMap[((Object)m_Material.shader).name]; int num = Shader.PropertyToID("_NormalsCopy"); buffer.GetTemporaryRT(num, -1, -1); buffer.Blit(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)12), RenderTargetIdentifier.op_Implicit(num)); buffer.ReleaseTemporaryRT(num); } } } } internal class Bobbing : MonoBehaviour { public float cycleTime = 2f; public float maxOffset = 1f; private Vector3 centralPos; private Vector3 prevPos; private float elapsedTime; private float currentOffset; private float offsetTransitionSpeed; private void Awake() { //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_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) centralPos = ((Component)this).transform.localPosition; prevPos = centralPos; currentOffset = maxOffset; elapsedTime = Random.Range(0f, cycleTime); } private void Update() { //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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0099: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.localPosition - prevPos; centralPos += val; if (currentOffset != maxOffset) { currentOffset = Mathf.MoveTowards(currentOffset, maxOffset, offsetTransitionSpeed * Time.deltaTime); } elapsedTime += Time.deltaTime; float num = Mathf.Sin(elapsedTime * 2f * (float)Math.PI / cycleTime) * currentOffset; ((Component)this).transform.localPosition = centralPos + Vector3.up * num; prevPos = ((Component)this).transform.localPosition; } private void OnDrawGizmosSelected() { //IL_0000: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) Gizmos.color = Color.white; Gizmos.DrawLine(((Component)this).transform.position, ((Component)this).transform.position + Vector3.up * maxOffset); Gizmos.DrawLine(((Component)this).transform.position, ((Component)this).transform.position + Vector3.down * maxOffset); Gizmos.DrawWireSphere(((Component)this).transform.position + Vector3.up * maxOffset, maxOffset / 10f); Gizmos.DrawWireSphere(((Component)this).transform.position + Vector3.down * maxOffset, maxOffset / 10f); } public void setTargetOffset(float target, float transitionTime) { if (target != maxOffset) { offsetTransitionSpeed = Mathf.Abs(currentOffset - target) / transitionTime; maxOffset = target; } } } internal class BoundingCircleGizmo : MonoBehaviour { private void Awake() { } private void OnDrawGizmos() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_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_0049: 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_0053: 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_0093: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_0104: 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_0128: Unknown result type (might be due to invalid IL or missing references) MeshFilter[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); List list = new List(); MeshFilter[] array = componentsInChildren; foreach (MeshFilter val in array) { Vector3[] vertices = val.sharedMesh.vertices; foreach (Vector3 val2 in vertices) { Vector3 val3 = ((Component)val).transform.TransformPoint(val2); list.Add(new Vector2(val3.x, val3.z)); } } HashSet hashSet = new HashSet(list); foreach (Vector2 item in list) { Gizmos.color = Color.green; Gizmos.DrawWireSphere(new Vector3(item.x, ((Component)this).transform.position.y, item.y), 0.1f); } BoundingCircle boundingCircle = BoundingCircle.minimumCircle(list); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(boundingCircle.center.x, ((Component)this).transform.position.y, boundingCircle.center.y); Gizmos.color = Color.blue; Gizmos.DrawWireSphere(val4, boundingCircle.radius); } } public class CanopyForcefieldVFXHandler : MonoBehaviour { private static HashSet allInstances = new HashSet(); private MeshRenderer[] rends; private float radius; public Shader m_canopyShader; public Material blurMaterialHorizontal; public Material blurMaterialVertical; private RenderTexture canopyRenderTexture; private RenderTexture intermediateTexture; private RenderTexture blurredCanopyRenderTexture; private List innerAdjustingSurfaces = new List(); private List outerAdjustingSurfaces = new List(); public Camera camera; public MeshRenderer rainBlockerRenderer; private float randomFactor; private void Start() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_00b8: 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_010f: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown if (PlayerPatch.PlayerCreatingGhost) { Object.Destroy((Object)(object)this); return; } LogUtils.LogDebug("CanopyForcefieldVFXHandler Starting"); allInstances.Add(this); GameObject gameObject = ((Component)((Component)this).transform.parent).gameObject; MaterialPropertyBlock val = new MaterialPropertyBlock(); val.SetFloat("_VisibilityOverride", 0f); rends = gameObject.GetComponentsInChildren(true); MeshRenderer[] array = rends; foreach (MeshRenderer val2 in array) { ((Renderer)val2).SetPropertyBlock(val); } randomFactor = Random.Range(0f, 1f); radius = ConfigLoader.getFloat("canopyRuneEffectRadius"); gameObject.transform.localScale = new Vector3(radius, radius, radius); camera.orthographicSize = radius + 1f; findAdjustingSurfaces(); if (innerAdjustingSurfaces.Count != 0 || outerAdjustingSurfaces.Count != 0) { Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnPreCullCallback)); } ((MonoBehaviour)this).InvokeRepeating("render", 1f, 1f); } private void OnDestroy() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown if (innerAdjustingSurfaces.Count != 0 || outerAdjustingSurfaces.Count != 0) { Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnPreCullCallback)); } if ((Object)(object)canopyRenderTexture != (Object)null) { Object.Destroy((Object)(object)canopyRenderTexture); } if ((Object)(object)intermediateTexture != (Object)null) { Object.Destroy((Object)(object)intermediateTexture); } if ((Object)(object)blurredCanopyRenderTexture != (Object)null) { Object.Destroy((Object)(object)blurredCanopyRenderTexture); } if (allInstances.Remove(this)) { LogUtils.LogDebug("CanopyForcefieldVFXHandler OnDestroy"); } } private void Update() { } private void OnPreCullCallback(Camera cam) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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: 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) Vector3 val = ((Component)cam).gameObject.transform.position - ((Component)this).transform.parent.position; Vector3 normalized = ((Vector3)(ref val)).normalized; float @float = ConfigLoader.getFloat("canopyRune_visOffset"); for (int i = 0; i < innerAdjustingSurfaces.Count; i++) { innerAdjustingSurfaces[i].transform.localPosition = normalized * (float)(i + 1) * (0f - @float); } for (int j = 1; j < outerAdjustingSurfaces.Count; j++) { outerAdjustingSurfaces[j].transform.localPosition = normalized * (float)(j + 1) * @float; } } private void findAdjustingSurfaces() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown Queue queue = new Queue(); queue.Enqueue(((Component)this).transform.parent); while (queue.Count > 0) { Transform val = queue.Dequeue(); if (((Object)val).name.StartsWith("innerAdj-")) { innerAdjustingSurfaces.Add(((Component)val).gameObject); continue; } if (((Object)val).name.StartsWith("outerAdj-")) { outerAdjustingSurfaces.Add(((Component)val).gameObject); continue; } foreach (Transform item2 in val) { Transform item = item2; queue.Enqueue(item); } } } private void createTextures() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown int @int = ConfigLoader.getInt("canopyRune_rainshadowTexSize"); if ((Object)(object)canopyRenderTexture == (Object)null) { canopyRenderTexture = new RenderTexture(@int, @int, 24, (RenderTextureFormat)12); } if ((Object)(object)intermediateTexture == (Object)null) { intermediateTexture = new RenderTexture(canopyRenderTexture); } if ((Object)(object)blurredCanopyRenderTexture == (Object)null) { blurredCanopyRenderTexture = new RenderTexture(canopyRenderTexture); } } private void setRainBlock(bool active) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown MaterialPropertyBlock val = new MaterialPropertyBlock(); val.SetFloat("_ActiveRainBlocker", (float)(active ? 1 : 0)); ((Renderer)rainBlockerRenderer).SetPropertyBlock(val); } private void render() { createTextures(); float lodBias = QualitySettings.lodBias; QualitySettings.lodBias = 10f; camera.targetTexture = canopyRenderTexture; setRainBlock(active: true); camera.RenderWithShader(m_canopyShader, ""); setRainBlock(active: false); QualitySettings.lodBias = lodBias; Graphics.Blit((Texture)(object)canopyRenderTexture, intermediateTexture, blurMaterialHorizontal); Graphics.Blit((Texture)(object)intermediateTexture, blurredCanopyRenderTexture, blurMaterialVertical); setShaderOverrides(); } private void setShaderOverrides() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_005f: 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) MaterialPropertyBlock val = new MaterialPropertyBlock(); val.SetFloat("_VisibilityOverride", 0f); val.SetTexture("_RuneMagicSkyCanopiesTexture", (Texture)(object)canopyRenderTexture); val.SetTexture("_RuneMagicSkyCanopiesTextureLowRes", (Texture)(object)blurredCanopyRenderTexture); val.SetFloat("_RuneMagicSkyCameraOrthoSize", camera.orthographicSize); val.SetVector("_RuneMagicSkyCameraPos", Vector4.op_Implicit(((Component)camera).transform.position)); val.SetFloat("_RandomFactor", randomFactor); val.SetFloat("_ActiveRangeLow", ConfigLoader.getFloat("canopyRune_activeLow")); val.SetFloat("_ActiveRangeHigh", ConfigLoader.getFloat("canopyRune_activeHigh")); val.SetFloat("_NoiseSharpness", ConfigLoader.getFloat("canopyRune_noiseSharpness")); val.SetFloat("_VerticalFadeScale", ConfigLoader.getFloat("canopyRune_bottomFade")); MeshRenderer[] array = rends; foreach (MeshRenderer val2 in array) { ((Renderer)val2).SetPropertyBlock(val); } } } public class Documentation : MonoBehaviour { public string comment; } public class FinishParticleEmission : MonoBehaviour { private ParticleSystem[] pSystems; private void OnEnable() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) pSystems = ((Component)this).GetComponentsInChildren(); ParticleSystem[] array = pSystems; foreach (ParticleSystem val in array) { EmissionModule emission = val.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f); } } private void Update() { bool flag = false; ParticleSystem[] array = pSystems; foreach (ParticleSystem val in array) { flag |= val.particleCount > 0; } if (!flag) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } public class GlobalRepairManager : MonoBehaviour { [CompilerGenerated] private sealed class d__31 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public GlobalRepairManager <>4__this; private int 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__31(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; GlobalRepairManager globalRepairManager = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; LogUtils.LogDebug("Starting RepairRune.FastRecheckLoop."); 5__2 = 0; goto IL_003e; case 1: <>1__state = -1; goto IL_0070; case 2: <>1__state = -1; break; case 3: { <>1__state = -1; if (globalRepairManager.shouldCleanUp()) { if (5__2 >= 20) { LogUtils.LogInfo("No more RepairRunes exist and all VFX removed, cleaning up"); destroySingleton(); } 5__2++; } else { 5__2 = 0; } goto IL_003e; } IL_0070: if (globalRepairManager.destroyedWnTs.Count > 0) { <>2__current = globalRepairManager.doRuneChecksForKnownWnTs(globalRepairManager.destroyedWnTs, 10, singleUseList: true); <>1__state = 2; return true; } break; IL_003e: if (globalRepairManager.mobileWnTs.Count > 0) { <>2__current = globalRepairManager.doRuneChecksForKnownWnTs(globalRepairManager.mobileWnTs, 1, singleUseList: false); <>1__state = 1; return true; } goto IL_0070; } <>2__current = globalRepairManager.wait1Second; <>1__state = 3; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__34 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public GlobalRepairManager <>4__this; private int 5__2; private int 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__34(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; GlobalRepairManager globalRepairManager = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; LogUtils.LogDebug($"Starting RepairRune.HealingLoop with {globalRepairManager.lastHealTimes.Count} damaged WnTs active."); 5__2 = 1; goto IL_004f; case 1: <>1__state = -1; break; case 2: { <>1__state = -1; goto IL_004f; } IL_004f: 5__3 = globalRepairManager.lastHealTimes.Count - 1; break; } if (5__3 >= 0) { for (int i = 0; i < 5__2; i++) { int count = globalRepairManager.lastHealTimes.Count; if (5__3 >= count) { 5__3 = count - 1; } if (5__3 < 0) { break; } WearNTear val = globalRepairManager.lastHealTimes[5__3]; 5__3--; if ((Object)(object)val == (Object)null) { if (!GameObjectUtils.isTrueNull((Component)(object)val)) { globalRepairManager.unassignOwnership(val); } } else if (val.GetHealthPercentage() >= 1f) { globalRepairManager.unassignOwnership(val); } else if (!((Object)(object)val.m_nview == (Object)null) && val.m_nview.IsOwner()) { RepairRune repairRune = globalRepairManager.allDamagedWnTs[val]; if (!((Object)(object)repairRune == (Object)null)) { double timeSeconds = ZNet.instance.GetTimeSeconds(); double num2 = globalRepairManager.lastHealTimes[val]; float num3 = repairRune.healRate * (float)(timeSeconds - num2); float num4 = val.m_health * val.m_healthPercentage; num3 = Mathf.Min(num3, val.m_health - num4); val.ApplyDamage(0f - num3, (HitData)null); globalRepairManager.lastHealTimes[val] = timeSeconds; } } } <>2__current = null; <>1__state = 1; return true; } LogUtils.LogDebug($"Finished iteration of RepairRune.HealingLoop with {globalRepairManager.lastHealTimes.Count} damaged WnTs active."); <>2__current = globalRepairManager.wait2Seconds; <>1__state = 2; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__29 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public GlobalRepairManager <>4__this; private int 5__2; private float 5__3; private int 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__29(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; GlobalRepairManager globalRepairManager = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; 5__2 = 10; LogUtils.LogDebug($"Starting RepairRune.InitialSetupCoroutine with {WearNTear.s_allInstances.Count} WnTs active."); 5__3 = Time.time; 5__4 = WearNTear.s_allInstances.Count - 1; goto IL_0103; case 1: <>1__state = -1; goto IL_0103; case 2: { <>1__state = -1; ((MonoBehaviour)globalRepairManager).StartCoroutine(globalRepairManager.FastRecheckLoop()); return false; } IL_0103: if (5__4 >= 0) { for (int i = 0; i < 5__2; i++) { int count = WearNTear.GetAllInstances().Count; if (5__4 >= count) { 5__4 = count - 1; } if (5__4 < 0) { break; } WearNTear val = WearNTear.s_allInstances[5__4]; 5__4--; if (!((Object)(object)val == (Object)null) && !(val.GetHealthPercentage() >= 1f)) { globalRepairManager.checkRuneAssignment(val); } } <>2__current = null; <>1__state = 1; return true; } LogUtils.LogDebug($"Finished RepairRune.InitialSetupCoroutine (took {Time.time - 5__3} seconds)"); globalRepairManager.ownershipLoop = ((MonoBehaviour)globalRepairManager).StartCoroutine(globalRepairManager.OwnershipLoop()); <>2__current = null; <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__30 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public GlobalRepairManager <>4__this; private int 5__2; private float 5__3; private int 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__30(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown int num = <>1__state; GlobalRepairManager globalRepairManager = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; LogUtils.LogDebug($"Starting RepairRune.OwnershipLoop with {WearNTear.s_allInstances.Count} WnTs active."); 5__2 = 1; goto IL_004e; case 1: <>1__state = -1; break; case 2: { <>1__state = -1; goto IL_004e; } IL_004e: 5__3 = Time.time; 5__4 = WearNTear.s_allInstances.Count - 1; break; } if (5__4 >= 0) { for (int i = 0; i < 5__2; i++) { int count = WearNTear.s_allInstances.Count; if (5__4 >= count) { 5__4 = count - 1; } if (5__4 < 0) { break; } WearNTear val = WearNTear.s_allInstances[5__4]; 5__4--; if ((Object)(object)val == (Object)null) { continue; } if (val.GetHealthPercentage() >= 1f) { if (globalRepairManager.allDamagedWnTs.ContainsKey(val)) { globalRepairManager.unassignOwnership(val); } } else { globalRepairManager.checkRuneAssignment(val); } } <>2__current = globalRepairManager.wait100Millis; <>1__state = 1; return true; } LogUtils.LogDebug($"Finished iteration of RepairRune.OwnershipLoop with {WearNTear.s_allInstances.Count} damaged WnTs active (took {Time.time - 5__3} seconds)."); <>2__current = (object)new WaitForSeconds(5f); <>1__state = 2; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__32 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public IEnumerable damagedWnTs; public GlobalRepairManager <>4__this; private List 5__2; private float 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__32(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; GlobalRepairManager globalRepairManager = <>4__this; switch (num) { default: return false; case 0: { <>1__state = -1; int checksPerFrame = 10; 5__2 = new List(damagedWnTs); LogUtils.LogDebug($"Starting RepairRune.RecheckDamagedWnTOwnership with {5__2.Count} WnTs."); 5__3 = Time.time; <>2__current = globalRepairManager.doRuneChecksForKnownWnTs(5__2, checksPerFrame, singleUseList: false); <>1__state = 1; return true; } case 1: <>1__state = -1; LogUtils.LogDebug($"Finished RepairRune.RecheckDamagedWnTOwnership with {5__2.Count} WnTs (took {Time.time - 5__3} seconds)."); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__42 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public GlobalRepairManager <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__42(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; GlobalRepairManager globalRepairManager = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; LogUtils.LogDebug("Setup queue start"); break; case 1: <>1__state = -1; if (globalRepairManager.vfxSetupQueue.Count == 0) { <>2__current = globalRepairManager.WaitForNotEmpty(globalRepairManager.vfxSetupQueue, 20); <>1__state = 2; return true; } goto IL_00bb; case 2: { <>1__state = -1; goto IL_00bb; } IL_00bb: if (globalRepairManager.allRunes.Count == 0) { globalRepairManager.vfxSetupQueue.Clear(); } break; } while (globalRepairManager.vfxSetupQueue.Count > 0) { WearNTear val = globalRepairManager.vfxSetupQueue.First(); globalRepairManager.vfxSetupQueue.Remove(val); if (!((Object)(object)val == (Object)null)) { ((Component)val).gameObject.AddComponent(); globalRepairManager.wntWithVFX.Add(val); <>2__current = null; <>1__state = 1; return true; } } LogUtils.LogDebug("Setup queue finished"); globalRepairManager.vfxSetupRunning = false; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__43 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public GlobalRepairManager <>4__this; private int 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__43(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; GlobalRepairManager globalRepairManager = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; 5__2 = 5; LogUtils.LogDebug("Teardown queue start"); break; case 1: <>1__state = -1; if (globalRepairManager.vfxTeardownQueue.Count == 0) { <>2__current = globalRepairManager.WaitForNotEmpty(globalRepairManager.vfxTeardownQueue, 20); <>1__state = 2; return true; } break; case 2: <>1__state = -1; break; } if (globalRepairManager.vfxTeardownQueue.Count > 0) { for (int i = 0; i < 5__2; i++) { if (globalRepairManager.vfxTeardownQueue.Count == 0) { break; } WearNTear val = globalRepairManager.vfxTeardownQueue.First(); globalRepairManager.vfxTeardownQueue.Remove(val); if ((Object)(object)val == (Object)null) { globalRepairManager.wntWithVFX.Remove(val); continue; } RepairVFXHandler component = ((Component)val).gameObject.GetComponent(); if (!((Object)(object)component == (Object)null)) { Object.Destroy((Object)(object)component); globalRepairManager.wntWithVFX.Remove(val); } } <>2__current = null; <>1__state = 1; return true; } LogUtils.LogDebug("Teardown queue finished"); globalRepairManager.vfxTeardownRunning = false; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__44 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public HashSet set; public GlobalRepairManager <>4__this; public int iterCount; private int 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__44(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; GlobalRepairManager globalRepairManager = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; 5__2 = 0; break; case 1: <>1__state = -1; 5__2++; break; } if (5__2 < iterCount && set.Count <= 0) { <>2__current = globalRepairManager.wait100Millis; <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__33 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public List targetList; public bool singleUseList; public GlobalRepairManager <>4__this; public int checksPerFrame; private int 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__33(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; GlobalRepairManager globalRepairManager = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; 5__2 = targetList.Count - 1; break; case 1: <>1__state = -1; break; } if (5__2 >= 0) { for (int i = 0; i < checksPerFrame; i++) { int count = targetList.Count; if (5__2 >= count) { 5__2 = count - 1; } if (5__2 < 0) { break; } WearNTear val = targetList[5__2]; if (singleUseList) { targetList.RemoveAt(5__2); } 5__2--; if ((Object)(object)val == (Object)null) { if (!GameObjectUtils.isTrueNull((Component)(object)val)) { globalRepairManager.unassignOwnership(val); } } else if (val.GetHealthPercentage() >= 1f) { globalRepairManager.unassignOwnership(val); } else { globalRepairManager.checkRuneAssignment(val); } } <>2__current = null; <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static GlobalRepairManager SINGLETON; private HashSet allRunes = new HashSet(); private Coroutine setupCoroutine; private Coroutine ownershipLoop; private Coroutine mobileWnTLoop; private Coroutine healLoop; private Coroutine vfxSetupCoroutine; private Coroutine vfxTeardownCoroutine; private bool vfxSetupRunning; private bool vfxTeardownRunning; private HashSet vfxSetupQueue = new HashSet(); private HashSet vfxTeardownQueue = new HashSet(); private HashSet wntWithVFX = new HashSet(); private Dictionary allDamagedWnTs = new Dictionary(); private Dictionary> runeOwnershipMap = new Dictionary>(); private IndexedDictionary lastHealTimes = new IndexedDictionary(); private List mobileWnTs = new List(); private List destroyedWnTs = new List(); private WaitForSeconds wait100Millis = new WaitForSeconds(0.1f); private WaitForSeconds wait1Second = new WaitForSeconds(1f); private WaitForSeconds wait2Seconds = new WaitForSeconds(2f); public void Awake() { if ((Object)(object)SINGLETON != (Object)null && (Object)(object)SINGLETON != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } setupCoroutine = ((MonoBehaviour)this).StartCoroutine(InitialSetupCoroutine()); healLoop = ((MonoBehaviour)this).StartCoroutine(HealingLoop()); } private static GlobalRepairManager getSingleton() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if ((Object)(object)SINGLETON == (Object)null) { LogUtils.LogDebug("GlobalRepairManager created"); GameObject val = new GameObject("GlobalRepairManager"); SINGLETON = val.AddComponent(); } return SINGLETON; } public static void destroySingleton() { if ((Object)(object)SINGLETON != (Object)null) { LogUtils.LogDebug("GlobalRepairManager destroyed"); Object.Destroy((Object)(object)((Component)SINGLETON).gameObject); SINGLETON = null; } } public static void registerRune(RepairRune rune) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) LogUtils.LogDebug($"Registering Repair Rune at {((Component)rune).transform.position}"); bool flag = (Object)(object)SINGLETON == (Object)null; GlobalRepairManager singleton = getSingleton(); singleton.allRunes.Add(rune); if (!flag) { ((MonoBehaviour)singleton).StartCoroutine(singleton.RecheckDamagedWnTOwnership(singleton.allDamagedWnTs.Keys)); } } public static void unregisterRune(RepairRune rune) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)SINGLETON == (Object)null) { return; } GlobalRepairManager singleton = getSingleton(); if (singleton.allRunes.Remove(rune)) { LogUtils.LogDebug($"Unregistering Repair Rune at {((Component)rune).transform.position}"); if (singleton.runeOwnershipMap.ContainsKey(rune)) { ((MonoBehaviour)singleton).StartCoroutine(singleton.RecheckDamagedWnTOwnership(singleton.runeOwnershipMap[rune])); } } } public static bool hasAssignedWnTs(RepairRune rune) { if ((Object)(object)SINGLETON == (Object)null) { return false; } GlobalRepairManager singleton = getSingleton(); singleton.runeOwnershipMap.TryGetValue(rune, out var value); if (value != null) { return value.Count > 0; } return false; } public static void wearNTearNotify(WearNTear wnt) { if (!((Object)(object)SINGLETON == (Object)null) && !(wnt.GetHealthPercentage() >= 1f)) { GlobalRepairManager singleton = getSingleton(); if (!singleton.allDamagedWnTs.ContainsKey(wnt)) { singleton.checkRuneAssignment(wnt); } } } public static void wearNTearDestroyed(WearNTear wnt) { if (!((Object)(object)SINGLETON == (Object)null)) { GlobalRepairManager singleton = getSingleton(); if (singleton.allDamagedWnTs.ContainsKey(wnt)) { singleton.destroyedWnTs.Add(wnt); } } } [IteratorStateMachine(typeof(d__29))] private IEnumerator InitialSetupCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__29(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__30))] private IEnumerator OwnershipLoop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__30(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__31))] private IEnumerator FastRecheckLoop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__31(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__32))] private IEnumerator RecheckDamagedWnTOwnership(IEnumerable damagedWnTs) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__32(0) { <>4__this = this, damagedWnTs = damagedWnTs }; } [IteratorStateMachine(typeof(d__33))] private IEnumerator doRuneChecksForKnownWnTs(List targetList, int checksPerFrame, bool singleUseList) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__33(0) { <>4__this = this, targetList = targetList, checksPerFrame = checksPerFrame, singleUseList = singleUseList }; } [IteratorStateMachine(typeof(d__34))] private IEnumerator HealingLoop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__34(0) { <>4__this = this }; } private bool shouldCleanUp() { if (allRunes.Count == 0 && wntWithVFX.Count == 0) { return !vfxTeardownRunning; } return false; } private void checkRuneAssignment(WearNTear wnt) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)wnt == (Object)null) { unassignOwnership(wnt); return; } RepairRune repairRune = findNearestRune(((Component)wnt).transform.position); allDamagedWnTs.TryGetValue(wnt, out var value); if (!GameObjectUtils.isTrueNull((Component)(object)value)) { if ((Object)(object)repairRune == (Object)null || wnt.GetHealthPercentage() >= 1f) { unassignOwnership(wnt); } else if ((Object)(object)value != (Object)(object)repairRune) { transferOwnership(wnt, value, repairRune); } } else if (wnt.GetHealthPercentage() < 1f) { assignOwnership(wnt, repairRune); } } private void assignOwnership(WearNTear wnt, RepairRune owner) { bool flag = allDamagedWnTs.ContainsKey(wnt); allDamagedWnTs[wnt] = owner; if (!flag && !wnt.m_staticPosition) { mobileWnTs.Add(wnt); } if ((Object)(object)owner != (Object)null) { HashSet valueOrDefault = runeOwnershipMap.GetValueOrDefault(owner, new HashSet()); valueOrDefault.Add(wnt); runeOwnershipMap[owner] = valueOrDefault; lastHealTimes.Add(wnt, ZNet.instance.GetTimeSeconds()); queueVFXSetup(wnt); owner.assignedWnTsChanged(); } } private void unassignOwnership(WearNTear wnt) { RepairRune valueOrDefault = allDamagedWnTs.GetValueOrDefault(wnt, null); if ((Object)(object)wnt == (Object)null || wnt.GetHealthPercentage() >= 1f) { allDamagedWnTs.Remove(wnt); lastHealTimes.Remove(wnt); mobileWnTs.Remove(wnt); } else { allDamagedWnTs[wnt] = null; lastHealTimes.Remove(wnt); } if (!GameObjectUtils.isTrueNull((Component)(object)valueOrDefault) && runeOwnershipMap.ContainsKey(valueOrDefault)) { runeOwnershipMap[valueOrDefault].Remove(wnt); if (runeOwnershipMap[valueOrDefault].Count == 0) { runeOwnershipMap.Remove(valueOrDefault); } if ((Object)(object)valueOrDefault != (Object)null) { valueOrDefault.assignedWnTsChanged(); } } queueVFXTeardown(wnt); } private void transferOwnership(WearNTear wnt, RepairRune prevOwner, RepairRune newOwner) { if (!((Object)(object)prevOwner == (Object)(object)newOwner)) { allDamagedWnTs[wnt] = newOwner; runeOwnershipMap[prevOwner].Remove(wnt); if (runeOwnershipMap[prevOwner].Count == 0) { runeOwnershipMap.Remove(prevOwner); } HashSet valueOrDefault = runeOwnershipMap.GetValueOrDefault(newOwner, new HashSet()); valueOrDefault.Add(wnt); runeOwnershipMap[newOwner] = valueOrDefault; if ((Object)(object)prevOwner != (Object)null) { prevOwner.assignedWnTsChanged(); } newOwner.assignedWnTsChanged(); } } private void queueVFXSetup(WearNTear wnt) { if (vfxTeardownQueue.Remove(wnt)) { return; } if ((Object)(object)((Component)wnt).gameObject.GetComponent() != (Object)null) { LogUtils.LogWarning("WnT already has VFX"); return; } vfxSetupQueue.Add(wnt); if (!vfxSetupRunning) { vfxSetupRunning = true; ((MonoBehaviour)this).StartCoroutine(SetupVFX()); } } private void queueVFXTeardown(WearNTear wnt) { if (vfxSetupQueue.Remove(wnt)) { return; } if ((Object)(object)wnt == (Object)null) { wntWithVFX.Remove(wnt); return; } vfxTeardownQueue.Add(wnt); if (!vfxTeardownRunning) { vfxTeardownRunning = true; ((MonoBehaviour)this).StartCoroutine(TeardownVFX()); } } [IteratorStateMachine(typeof(d__42))] private IEnumerator SetupVFX() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__42(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__43))] private IEnumerator TeardownVFX() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__43(0) { <>4__this = this }; } [IteratorStateMachine(typeof(d__44<>))] private IEnumerator WaitForNotEmpty(HashSet set, int iterCount) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__44(0) { <>4__this = this, set = set, iterCount = iterCount }; } private RepairRune findNearestRune(Vector3 pos) { //IL_001e: 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) float num = float.MaxValue; RepairRune result = null; foreach (RepairRune allRune in allRunes) { float num2 = MathUtils.distanceXZSqr(pos, ((Component)allRune).transform.position); if (num2 < num && num2 < allRune.effectRadius * allRune.effectRadius) { num = num2; result = allRune; } } return result; } } public class GlobalWaterSurfaceManager : MonoBehaviour { private static GlobalWaterSurfaceManager SINGLETON; private HashSet managers = new HashSet(); private bool isWaterSurfacePatched; private float timeSinceNoDryLandActive; public void Awake() { if ((Object)(object)SINGLETON != (Object)null && (Object)(object)SINGLETON != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } } public static GlobalWaterSurfaceManager getSingleton() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if ((Object)(object)SINGLETON == (Object)null) { GameObject val = new GameObject("GlobalWaterSurfaceManager"); SINGLETON = val.AddComponent(); LogUtils.LogDebug("Creating GlobalWaterSurfaceManager"); } return SINGLETON; } public void Update() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown bool flag = false; foreach (WaterSurfaceManager manager in managers) { if ((Object)(object)manager != (Object)null) { flag |= manager.isSurfaceAltered(); manager.InternalUpdate(); } } if (!isWaterSurfacePatched && flag) { LogUtils.LogDebug("Patching WaterVolume.GetWaterSurface"); ValheimMod.harmony.Patch((MethodBase)AccessTools.Method(typeof(WaterVolume), "GetWaterSurface", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(WaterVolumePatch.GetWaterSurface_Patch), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); isWaterSurfacePatched = true; timeSinceNoDryLandActive = 0f; } else if (isWaterSurfacePatched && !flag) { timeSinceNoDryLandActive += Time.deltaTime; if (timeSinceNoDryLandActive > 10f) { LogUtils.LogDebug("Unpatching WaterVolume.GetWaterSurface"); ValheimMod.harmony.Unpatch((MethodBase)AccessTools.Method(typeof(WaterVolume), "GetWaterSurface", (Type[])null, (Type[])null), (HarmonyPatchType)2, ValheimMod.harmony.Id); isWaterSurfacePatched = false; } } } public static void registerWaterSurfaceManager(WaterSurfaceManager man) { getSingleton().managers.Add(man); } public static void unregisterWaterSurfaceManager(WaterSurfaceManager man) { if ((Object)(object)SINGLETON != (Object)null) { getSingleton().managers.Remove(man); } } } public class CylindricalSolidLavaArea : MonoBehaviour, SolidLavaArea { public float height; public float radius; private void Awake() { GlobalLavaSolidifier.registerArea(this, radius); } private void OnDestroy() { GlobalLavaSolidifier.unregisterArea(this); } public HashSet getAffectedCells(GridMap grid) where T : Component { //IL_0006: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_007f: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) Heightmap heightmap = HeightmapPatch.getHeightmap(((Component)this).transform.position); if ((Object)(object)heightmap == (Object)null) { return new HashSet(); } LavaSolidifier.WorldToVertexFloor(heightmap, ((Component)this).transform.position, out var x, out var y); Vector3 val = LavaSolidifier.CalcVertexWithLava(heightmap, x, y); Vector3 val2 = LavaSolidifier.CalcVertexWithLava(heightmap, x + 1, y); Vector3 val3 = LavaSolidifier.CalcVertexWithLava(heightmap, x, y + 1); Vector3 val4 = LavaSolidifier.CalcVertexWithLava(heightmap, x + 1, y + 1); float num = Mathf.Max(new float[4] { val.y, val2.y, val3.y, val4.y }); if (((Component)this).transform.position.y - height > num) { return new HashSet(); } return grid.GetGridCellsOverlappingArea(((Component)this).transform.position.GetXZVector(), radius, inclusive: true); } public float getShaderRadius() { return 0f; } public float getCollisionRadius() { return radius; } public float getFullySolidRadius() { return radius; } public Transform getTransform() { return ((Component)this).transform; } public void notifyHeightmapChanged(Heightmap hmap) { } public long getIndex() { return -1L; } public float getCollapse() { return 0f; } } public class GlobalLavaSolidifier : MonoBehaviour { private const float terrainQuadScale = 1f; private static GlobalLavaSolidifier SINGLETON; private GridMap colliders = new GridMap(1f, zeroCentered: false); private Dictionary heightmapHeights = new Dictionary(); private HashSet ephemeralAreas = new HashSet(); private BiDictionary lastingAreas = new BiDictionary(); private BiDictionary holes = new BiDictionary(); private Dictionary activeAreas = new Dictionary(); private HashSet dirtyAreas = new HashSet(); private Dictionary heightmapColliders = new Dictionary(); private Dictionary heightmapProtectionFactors = new Dictionary(); private Dictionary inProgressMeshes = new Dictionary(); public void Awake() { if ((Object)(object)SINGLETON != (Object)null && (Object)(object)SINGLETON != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); } } private static GlobalLavaSolidifier getSingleton() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if ((Object)(object)SINGLETON == (Object)null) { GameObject val = new GameObject("GlobalLavaSolidifier"); SINGLETON = val.AddComponent(); LogUtils.LogDebug("Creating GlobalLavaSolidifier"); } return SINGLETON; } public static void destroySingleton() { if ((Object)(object)SINGLETON != (Object)null) { LogUtils.LogDebug("Destroying GlobalLavaSolidifier"); Object.Destroy((Object)(object)((Component)SINGLETON).gameObject); SINGLETON = null; } } public static void registerArea(SolidLavaArea area, float maxVisualRadius) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_009f: Unknown result type (might be due to invalid IL or missing references) GlobalLavaSolidifier singleton = getSingleton(); if (area.getIndex() == -1) { singleton.ephemeralAreas.Add(area); return; } HashSet affectedHeightmapCoords = HeightmapPatch.getAffectedHeightmapCoords(area.getTransform().position.GetXZVector(), maxVisualRadius, inclusive: true); LogUtils.LogDebug($"Area collider registered, covering {affectedHeightmapCoords.Count} coords based on a max radius of {maxVisualRadius}"); singleton.lastingAreas.AddAll(area, affectedHeightmapCoords); foreach (Vector2i item in affectedHeightmapCoords) { singleton.activeAreas[item] = singleton.activeAreas.GetValueOrDefault(item, 0) + 1; List list = singleton.lastingAreas.Get(item); if (list.Count < 2) { continue; } long index = list[list.Count - 2].getIndex(); if (index > area.getIndex()) { ValheimMod.DevModeWarn("Invalid index order when registering collider area, resorting"); list.Sort((SolidLavaArea a, SolidLavaArea b) => (int)(b.getIndex() - a.getIndex())); } } } public static void unregisterArea(SolidLavaArea area) { //IL_005f: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)SINGLETON == (Object)null) { return; } GlobalLavaSolidifier singleton = getSingleton(); if (area.getIndex() == -1) { singleton.ephemeralAreas.Remove(area); return; } HashSet hashSet = new HashSet(singleton.lastingAreas.Get(area)); if (hashSet.Count == 0) { ValheimMod.DevModeWarn("lastingAreas doesn't contain expected area!"); } foreach (Vector2i item in hashSet) { if (singleton.lastingAreas.Remove(item, area)) { singleton.activeAreas[item] = singleton.activeAreas.GetValueOrDefault(item, 0) - 1; } if (singleton.activeAreas[item] == 0) { singleton.activeAreas.Remove(item); } singleton.dirtyAreas.Add(item); } } public static void registerHole(SolidLavaHole hole, float maxVisualRadius) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)SINGLETON == (Object)null) { ValheimMod.DevModeWarn("Attempted to register hole with no global lava solidifier active!"); return; } GlobalLavaSolidifier singleton = getSingleton(); HashSet affectedHeightmapCoords = HeightmapPatch.getAffectedHeightmapCoords(((Component)hole).transform.position.GetXZVector(), maxVisualRadius, inclusive: true); LogUtils.LogDebug($"Hole collider registered, covering {affectedHeightmapCoords.Count} coords based on a max radius of {maxVisualRadius}"); singleton.holes.AddAll(hole, affectedHeightmapCoords); foreach (Vector2i item in affectedHeightmapCoords) { SINGLETON.activeAreas[item] = SINGLETON.activeAreas.GetValueOrDefault(item, 0) + 1; List list = singleton.holes.Get(item); if (list.Count < 2) { continue; } long index = list[list.Count - 2].getIndex(); if (index > hole.getIndex()) { ValheimMod.DevModeWarn("Invalid index order when registering collider hole, resorting"); list.Sort((SolidLavaHole a, SolidLavaHole b) => (int)(b.getIndex() - a.getIndex())); } } } public static void unregisterHole(SolidLavaHole hole) { //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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)SINGLETON == (Object)null) { return; } GlobalLavaSolidifier singleton = getSingleton(); HashSet hashSet = new HashSet(singleton.holes.Get(hole)); if (hashSet.Count == 0) { ValheimMod.DevModeWarn("holeToHmapCoord doesn't contain expected hole!"); } foreach (Vector2i item in hashSet) { singleton.activeAreas[item] = singleton.activeAreas.GetValueOrDefault(item, 0) - 1; if (singleton.activeAreas[item] == 0) { singleton.activeAreas.Remove(item); } singleton.holes.Remove(item, hole); singleton.dirtyAreas.Add(item); } } public static void recalculateColliders(Vector3 pos, float radius) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0037: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)SINGLETON == (Object)null) { return; } HashSet affectedHeightmapCoords = HeightmapPatch.getAffectedHeightmapCoords(pos.GetXZVector(), radius, inclusive: true); foreach (Vector2i item in affectedHeightmapCoords) { SINGLETON.dirtyAreas.Add(item); } } public void Update() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) if (ephemeralAreas.Count > 0 || colliders.Count() > 0) { recalculateQuadColliders(); } if (dirtyAreas.Count > 0) { rebuildHeightmapCollidersAsync(); } if (inProgressMeshes.Count > 0) { completeAsyncColliders(); } if (ephemeralAreas.Count != 0 || activeAreas.Count != 0 || inProgressMeshes.Count != 0) { return; } foreach (Vector2i key in heightmapColliders.Keys) { Object.Destroy((Object)(object)heightmapColliders[key].sharedMesh); Object.Destroy((Object)(object)((Component)heightmapColliders[key]).gameObject); heightmapColliders.Remove(key); heightmapProtectionFactors.Remove(key); } destroySingleton(); } private void recalculateQuadColliders() { //IL_008a: 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_009d: 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_00c1: 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_00ed: 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_0118: 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_0159: 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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: 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) HashSet hashSet = new HashSet(); foreach (SolidLavaArea ephemeralArea in ephemeralAreas) { if (ephemeralArea != null) { hashSet.UnionWith(ephemeralArea.getAffectedCells(colliders)); } } HashSet hashSet2 = new HashSet(colliders.GetKeys()); HashSet hashSet3 = new HashSet(hashSet); hashSet3.ExceptWith(hashSet2); HashSet hashSet4 = new HashSet(hashSet2); hashSet4.ExceptWith(hashSet); foreach (Vector2i item in hashSet3) { GameObject val = LavaSolidifier.createCollider(colliders, ((Component)this).gameObject, item); colliders.Add(item, val.transform); recordHeightmapHeights(HeightmapPatch.getHeightmap(colliders.GetCenter(item)), overwrite: false); if ((Object)(object)Player.m_localPlayer != (Object)null && Utils.DistanceXZ(((Component)Player.m_localPlayer).transform.position, val.transform.position) <= colliders.getCellBoundingCircleRadius(inclusive: true)) { float num = val.transform.position.y - (((Character)Player.m_localPlayer).GetCenterPoint().y - ((Character)Player.m_localPlayer).GetHeight() / 2f); if (num > 0f) { Transform transform = ((Component)Player.m_localPlayer).transform; transform.position += Vector3.up * num; Physics.SyncTransforms(); } } } foreach (Vector2i item2 in hashSet4) { destroyCollider(item2); } } private void recordHeightmapHeights(Heightmap hmap, bool overwrite) { if (!heightmapHeights.ContainsKey(hmap) || overwrite) { heightmapHeights[hmap] = hmap.m_heights.ToArray(); } } private void rebuildHeightmapCollidersAsync() { //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_0025: 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_002e: 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_0050: 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_008a: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(); foreach (Vector2i dirtyArea in dirtyAreas) { if (inProgressMeshes.ContainsKey(dirtyArea)) { hashSet.Add(dirtyArea); continue; } Heightmap heightmap = HeightmapPatch.getHeightmap(dirtyArea); if ((Object)(object)heightmap == (Object)null || lastingAreas.Get(dirtyArea).Count == 0) { if (heightmapColliders.ContainsKey(dirtyArea)) { Object.Destroy((Object)(object)heightmapColliders[dirtyArea].sharedMesh); Object.Destroy((Object)(object)((Component)heightmapColliders[dirtyArea]).gameObject); heightmapColliders.Remove(dirtyArea); heightmapProtectionFactors.Remove(dirtyArea); } continue; } HeightmapLavaColliderGenerator.AreaData[] array = new HeightmapLavaColliderGenerator.AreaData[lastingAreas.Get(dirtyArea).Count + holes.Get(dirtyArea).Count]; int num = 0; foreach (SolidLavaArea item in lastingAreas.Get(dirtyArea)) { array[num] = new HeightmapLavaColliderGenerator.AreaData(item.getTransform().position.GetXZVector(), item.getFullySolidRadius(), item.getCollisionRadius(), item.getIndex(), solid: true); num++; } foreach (SolidLavaHole item2 in holes.Get(dirtyArea)) { array[num] = new HeightmapLavaColliderGenerator.AreaData(((Component)item2).transform.position.GetXZVector(), item2.getSolidRadius(), item2.getCollisionRadius(), item2.getIndex(), solid: false); num++; } inProgressMeshes.Add(dirtyArea, HeightmapLavaColliderGenerator.createHeightmapColliderAsync(dirtyArea, array)); } dirtyAreas = hashSet; } private void completeAsyncColliders() { //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_002b: 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_0064: 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_0075: 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_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_00c0: 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_00da: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_0137: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(inProgressMeshes.Keys); foreach (Vector2i item in hashSet) { if (!inProgressMeshes[item].isMeshReady()) { continue; } Heightmap heightmap = HeightmapPatch.getHeightmap(item); if ((Object)(object)heightmap == (Object)null || lastingAreas.Get(item).Count == 0) { if (heightmapColliders.ContainsKey(item)) { Object.Destroy((Object)(object)heightmapColliders[item].sharedMesh); Object.Destroy((Object)(object)((Component)heightmapColliders[item]).gameObject); heightmapColliders.Remove(item); heightmapProtectionFactors.Remove(item); } continue; } Mesh mesh = inProgressMeshes[item].getMesh(); heightmapProtectionFactors[item] = inProgressMeshes[item].getProtectionFactors(); if (heightmapColliders.ContainsKey(item)) { Object.Destroy((Object)(object)heightmapColliders[item].sharedMesh); heightmapColliders[item].sharedMesh = mesh; } else { GameObject val = new GameObject(); val.transform.position = ((Component)heightmap).transform.position; val.layer = LayerMask.NameToLayer("static_solid"); val.AddComponent(); MeshCollider val2 = val.AddComponent(); val2.convex = false; val2.cookingOptions = (MeshColliderCookingOptions)16; val2.sharedMesh = mesh; heightmapColliders[item] = val2; } inProgressMeshes.Remove(item); } } private void rebuildHeightmapColliders() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_00f0: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: 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_0223: Expected O, but got Unknown //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: 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) foreach (Vector2i dirtyArea in dirtyAreas) { Heightmap heightmap = HeightmapPatch.getHeightmap(dirtyArea); if ((Object)(object)heightmap == (Object)null) { if (heightmapColliders.ContainsKey(dirtyArea)) { Object.Destroy((Object)(object)heightmapColliders[dirtyArea].sharedMesh); Object.Destroy((Object)(object)((Component)heightmapColliders[dirtyArea]).gameObject); heightmapColliders.Remove(dirtyArea); } continue; } if (lastingAreas.Get(dirtyArea).Count == 0) { if (heightmapColliders.ContainsKey(dirtyArea)) { Object.Destroy((Object)(object)heightmapColliders[dirtyArea].sharedMesh); Object.Destroy((Object)(object)((Component)heightmapColliders[dirtyArea]).gameObject); heightmapColliders.Remove(dirtyArea); } continue; } Profiler.start("GlobalLavaSolidifier.createHeightmapCollider"); List list = new List(); foreach (SolidLavaArea item in lastingAreas.Get(dirtyArea)) { list.Add(new HeightmapLavaColliderGenerator.AreaData(item.getTransform().position.GetXZVector(), item.getFullySolidRadius(), item.getCollisionRadius(), item.getIndex(), solid: true)); } foreach (SolidLavaHole item2 in holes.Get(dirtyArea)) { list.Add(new HeightmapLavaColliderGenerator.AreaData(((Component)item2).transform.position.GetXZVector(), item2.getSolidRadius(), item2.getCollisionRadius(), item2.getIndex(), solid: false)); } Mesh sharedMesh = HeightmapLavaColliderGenerator.createHeightmapCollider(dirtyArea, list); Profiler.stop("GlobalLavaSolidifier.createHeightmapCollider"); if (heightmapColliders.ContainsKey(dirtyArea)) { Object.Destroy((Object)(object)heightmapColliders[dirtyArea].sharedMesh); Profiler.start("GlobalLavaSolidifier.rebuildHeightmapColliders-resetSharedMesh"); heightmapColliders[dirtyArea].sharedMesh = sharedMesh; Profiler.stop("GlobalLavaSolidifier.rebuildHeightmapColliders-resetSharedMesh"); continue; } GameObject val = new GameObject(); val.transform.position = ((Component)heightmap).transform.position; val.layer = LayerMask.NameToLayer("static_solid"); val.AddComponent(); MeshCollider val2 = val.AddComponent(); val2.convex = false; val2.cookingOptions = (MeshColliderCookingOptions)16; Profiler.start("GlobalLavaSolidifier.rebuildHeightmapColliders-setSharedMesh"); val2.sharedMesh = sharedMesh; Profiler.stop("GlobalLavaSolidifier.rebuildHeightmapColliders-setSharedMesh"); heightmapColliders[dirtyArea] = val2; } dirtyAreas.Clear(); } private Rect getChangedArea(Heightmap hmap) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_010a: 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_012a: 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) if (!heightmapHeights.ContainsKey(hmap)) { return default(Rect); } int num = hmap.m_width + 1; List list = new List(); float[] array = heightmapHeights[hmap]; float[] array2 = hmap.m_heights.ToArray(); for (int i = 0; i < array.Length; i++) { if (array[i] != array2[i]) { int num2 = i % num; int num3 = i / num; Vector3 item = hmap.CalcVertex(num2, num3) + ((Component)hmap).transform.position; list.Add(item); } } if (list.Count == 0) { return default(Rect); } heightmapHeights[hmap] = array2; float num4 = list[0].x; float num5 = list[0].x; float num6 = list[0].z; float num7 = list[0].z; foreach (Vector3 item2 in list) { num4 = Mathf.Min(num4, item2.x); num5 = Mathf.Max(num5, item2.x); num6 = Mathf.Max(num6, item2.z); num7 = Mathf.Min(num7, item2.z); } return new Rect(num4, num7, num5 - num4, num6 - num7); } public static void notifyHeightmapDestroyed(Heightmap hmap) { if (!((Object)(object)hmap == (Object)null) && !((Object)(object)SINGLETON == (Object)null)) { SINGLETON.heightmapHeights[hmap] = null; } } public static void notifyHeightmapChanged(Heightmap hmap) { //IL_0027: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hmap == (Object)null || (Object)(object)SINGLETON == (Object)null) { return; } SINGLETON.dirtyAreas.Add(HeightmapPatch.getTerrainCoord(((Component)hmap).transform.position)); if (!SINGLETON.heightmapHeights.ContainsKey(hmap)) { return; } Rect changedArea = SINGLETON.getChangedArea(hmap); Rect val = default(Rect); foreach (SolidLavaArea ephemeralArea in SINGLETON.ephemeralAreas) { Vector3 position = ephemeralArea.getTransform().position; float collisionRadius = ephemeralArea.getCollisionRadius(); ((Rect)(ref val))..ctor(position.x - collisionRadius, position.z - collisionRadius, collisionRadius * 2f, collisionRadius * 2f); if (((Rect)(ref changedArea)).Overlaps(val)) { ephemeralArea.notifyHeightmapChanged(hmap); } } List list = new List(); foreach (Vector2i key in SINGLETON.colliders.GetKeys()) { Rect boundingRect = SINGLETON.colliders.GetBoundingRect(key); if (((Rect)(ref changedArea)).Overlaps(boundingRect)) { list.Add(key); } } foreach (Vector2i item in list) { SINGLETON.destroyCollider(item); } SINGLETON.recalculateQuadColliders(); } private void destroyCollider(Vector2i coord) { //IL_0006: 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_0042: Unknown result type (might be due to invalid IL or missing references) MeshCollider component = ((Component)colliders.Get(coord)).GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component.sharedMesh); } Object.Destroy((Object)(object)((Component)colliders.Get(coord)).gameObject); colliders.Remove(coord); } public static int getColliderCount() { if ((Object)(object)SINGLETON == (Object)null) { return 0; } return SINGLETON.colliders.GetKeys().Count; } private float getEphemeralProtectionFactor(Vector3 pos) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)colliders.Get(pos) != (Object)null) { return 1f; } return 0f; } private float getLastingProtectionFactor(Vector3 pos) { //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_0006: 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_0021: 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_002f: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0089: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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) Vector2i terrainCoord = HeightmapPatch.getTerrainCoord(pos); if (!heightmapProtectionFactors.ContainsKey(terrainCoord)) { return 0f; } float[] array = heightmapProtectionFactors[terrainCoord]; Heightmap heightmap = HeightmapPatch.getHeightmap(terrainCoord); pos -= ((Component)heightmap).transform.position - new Vector3((float)(heightmap.m_width / 2), 0f, (float)(heightmap.m_width / 2)); Vector2i coord = colliders.GetCoord(pos); int num = 65; if (coord.x >= num || coord.y >= num) { return array[coord.y * num + coord.x]; } pos -= new Vector3((float)coord.x, 0f, (float)coord.y); float num2 = Mathf.Lerp(array[coord.y * num + coord.x], array[coord.y * num + coord.x + 1], pos.x); coord.y++; float num3 = Mathf.Lerp(array[coord.y * num + coord.x], array[coord.y * num + coord.x + 1], pos.x); return Mathf.Lerp(num2, num3, pos.z); } public static float getProtectionFactor(Vector3 pos) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)SINGLETON == (Object)null) { return 0f; } return Mathf.Max(SINGLETON.getEphemeralProtectionFactor(pos), SINGLETON.getLastingProtectionFactor(pos)); } public static bool isWearNTearProtected(WearNTear wnt) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return getProtectionFactor(((Component)wnt).transform.position) > 0.1f; } public static List getHolesInSector(Vector2i coord) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)SINGLETON == (Object)null) { return new List(); } return SINGLETON.holes.Get(coord); } public static List getSolidAreasInSector(Vector2i coord) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)SINGLETON == (Object)null) { return new List(); } return SINGLETON.lastingAreas.Get(coord); } public static void showDebugProtectionFactor(Vector3 pos) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0069: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_0099: 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) if ((Object)(object)SINGLETON == (Object)null) { return; } int num = 40; float num2 = 0.25f; for (int i = -num; i < num; i++) { for (int j = -num; j < num; j++) { Vector3 val = pos + new Vector3((float)j * num2, 0f, (float)i * num2); Profiler.start("getProtectionFactor"); float protectionFactor = getProtectionFactor(val); Profiler.stop("getProtectionFactor"); if (protectionFactor == 1f) { DebugUtils.DrawRay(val, Vector3.up, new Color(0f, 0.5f, 0f), 2f); } else if (protectionFactor == 0f) { DebugUtils.DrawRay(val, Vector3.up, new Color(0f, 0f, 0.5f), 2f); } else { DebugUtils.DrawRay(val, Vector3.up, new Color(protectionFactor, 0f, 0f), 2f); } } } } } public class LavaFootstep : MonoBehaviour { private Player player; private FootStep footstep; private Animator animator; private float prevStep; private void Awake() { player = ((Component)this).GetComponent(); footstep = ((Component)this).GetComponent(); animator = ((Component)this).GetComponentInChildren(); if ((Object)(object)player == (Object)null || (Object)(object)footstep == (Object)null || (Object)(object)animator == (Object)null) { Object.Destroy((Object)(object)this); } } private void OnDestroy() { } private void Update() { float @float = animator.GetFloat(FootStep.s_footstepID); if (((Vector3)(ref ((Character)player).m_moveDir)).magnitude <= 0.0001f) { spawnFootstep(((Component)player).transform); } else if (((Character)player).IsOnGround() && Utils.SignDiffers(prevStep, @float)) { Transform foot = footstep.FindActiveFoot(); spawnFootstep(foot); } prevStep = @float; } private void spawnFootstep(Transform foot) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (isPlayerNearLava(player) && !SolidLavaDecal.anyInRange(foot.position, onlyLocal: true)) { GameObject val = Object.Instantiate(AssetLoader.GetPrefabFromAssetBundle("LavaFootstepMeshDecal"), foot.position, Quaternion.identity); SolidLavaDecal component = val.GetComponent(); component.spawningPlayer = player; component.spawningTransform = foot; } } public static bool isPlayerNearLava(Player player) { if (((Character)player).AboveOrInLava()) { return ((Character)player).m_lavaHeightFactor > 0f; } return false; } } public class MeshDecal : MonoBehaviour { public enum ConstructionType { FlatMesh, SingleThreadedCPU, MultiThreadedCPU, MultiThreadedCPU_ShowWhenComplete, ComputeShader, ComputeShader_ShowWhenComplete } private static Mesh flatMesh; private static float oldDecalSideLength; private static float oldResolution; public Material depthToColor; public LayerMask targetLayers; private Mesh constructedDecal; private MaterialPropertyBlock block; private RenderTexture depthTarget; private Texture2D extractedDepth; public float decalSideLength; private int resolution; public float perUnitResolution; public float meshOffset; private Camera cam; private Vector3 prevPos; private GameObject meshHolder; public ComputeShader meshConstructor; private ParallelMeshUtils.FutureMesh futureMesh; public ConstructionType constructionType = ConstructionType.MultiThreadedCPU_ShowWhenComplete; public void Awake() { block = getMaterialPropertyBlock(); } public void Start() { //IL_0090: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) cam = ((Component)this).gameObject.GetComponentInChildren(); cam.cullingMask = ((LayerMask)(ref targetLayers)).value; cam.orthographicSize = decalSideLength / 2f; resolution = (int)(perUnitResolution * decalSideLength); if (constructionType == ConstructionType.FlatMesh) { LogUtils.LogWarning("FlatMesh construction requires a material with the correct keyword set."); } meshHolder = ((Component)((Component)this).transform.Find("MeshHolder")).gameObject; Transform transform = ((Component)cam).gameObject.transform; transform.position += new Vector3(0f, 0f - meshOffset, 0f); prevPos = ((Component)this).transform.position; if (!Application.isBatchMode) { Profiler.start("MeshDecal.Start"); realignToGrid(); orthoRender(); recalculateMesh(); Profiler.stop("MeshDecal.Start"); } } public void OnDestroy() { if ((Object)(object)depthTarget != (Object)null) { Object.Destroy((Object)(object)depthTarget); } if ((Object)(object)extractedDepth != (Object)null) { Object.Destroy((Object)(object)extractedDepth); } if ((Object)(object)constructedDecal != (Object)null) { Object.Destroy((Object)(object)constructedDecal); } } public void LateUpdate() { if ((constructionType == ConstructionType.MultiThreadedCPU || constructionType == ConstructionType.ComputeShader) && futureMesh != null) { futureMesh.waitForCompletion(); MeshFilter componentInChildren = ((Component)this).gameObject.GetComponentInChildren(); constructedDecal = futureMesh.getMesh(); componentInChildren.sharedMesh = constructedDecal; futureMesh = null; } else if ((constructionType == ConstructionType.ComputeShader_ShowWhenComplete || constructionType == ConstructionType.MultiThreadedCPU_ShowWhenComplete) && futureMesh != null && futureMesh.isMeshReady()) { MeshFilter componentInChildren2 = ((Component)this).gameObject.GetComponentInChildren(); constructedDecal = futureMesh.getMesh(); componentInChildren2.sharedMesh = constructedDecal; futureMesh = null; } } private void realignToGrid() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) float edgeLength = cam.orthographicSize * 2f / (float)resolution; Vector2 pos = snapToGrid(edgeLength); setWorldXZ(((Component)cam).gameObject.transform, pos); setWorldXZ(meshHolder.transform, pos); } private void recalculateMesh() { MeshFilter componentInChildren = ((Component)this).gameObject.GetComponentInChildren(); if ((Object)(object)constructedDecal != (Object)null) { Object.Destroy((Object)(object)constructedDecal); } if (constructionType == ConstructionType.FlatMesh) { componentInChildren.sharedMesh = getFlatMesh(); return; } if (constructionType == ConstructionType.SingleThreadedCPU) { int num = resolution; float num2 = cam.orthographicSize * 2f / (float)num; Vector3[] array = (Vector3[])(object)new Vector3[num * num]; Profiler.start("MeshUtils.createGridFromRangeImage"); array = MeshUtils.createGridFromRangeImage(num, getCenterDistance(extractedDepth), cam, extractedDepth); Profiler.stop("MeshUtils.createGridFromRangeImage"); constructedDecal = MeshUtils.createMeshFromGrid(array, num, num); componentInChildren.sharedMesh = constructedDecal; return; } if (constructionType == ConstructionType.MultiThreadedCPU || constructionType == ConstructionType.MultiThreadedCPU_ShowWhenComplete) { using (new Profiler("ParallelMeshUtils.createMeshFromRangeImageParallel")) { futureMesh = ParallelMeshUtils.createMeshFromRangeImageParallel(resolution, getCenterDistance(extractedDepth), cam, extractedDepth); return; } } if (constructionType != ConstructionType.ComputeShader && constructionType != ConstructionType.ComputeShader_ShowWhenComplete) { return; } using (new Profiler("ParallelMeshUtils.createMeshWithComputeShader")) { futureMesh = ParallelMeshUtils.createMeshWithComputeShader(resolution, cam, depthTarget, meshConstructor); } } private Mesh getFlatMesh() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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) if ((Object)(object)flatMesh == (Object)null || decalSideLength != oldDecalSideLength || (float)resolution != oldResolution) { int num = resolution; float num2 = cam.orthographicSize * 2f / (float)num; Vector3[] array = (Vector3[])(object)new Vector3[num * num]; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { array[i * num + j] = new Vector3((float)j * num2, 0f, (float)i * num2) + new Vector3(0f - cam.orthographicSize, 0f, 0f - cam.orthographicSize); } } flatMesh = MeshUtils.createMeshFromGrid(array, num, num); oldDecalSideLength = decalSideLength; oldResolution = resolution; } return flatMesh; } private float getCenterDistance(Texture2D distanceTex) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) Color pixel = distanceTex.GetPixel(resolution / 2, resolution / 2); return Mathf.Lerp(cam.nearClipPlane, cam.farClipPlane, StandardShaderUtils.DecodeFloatRGBA(pixel)); } private Vector2 snapToGrid(float edgeLength) { //IL_0008: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_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_004b: 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_006f: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0091: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(((Component)this).transform.position.x, ((Component)this).transform.position.z); val -= new Vector2(edgeLength / 2f, edgeLength / 2f); val /= edgeLength; val.x = Mathf.FloorToInt(val.x); val.y = Mathf.FloorToInt(val.y); val += new Vector2(edgeLength / 2f, edgeLength / 2f); val *= edgeLength; return val; } private void setWorldXZ(Transform xform, Vector2 pos) { //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_0016: 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) Vector3 position = xform.position; position.x = pos.x; position.z = pos.y; xform.position = position; } private void orthoRender() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: 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_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) using (new Profiler(string.Format("MeshDecal.orthoRender-sideLen{0}-res{1}", decalSideLength.ToString("0.0"), perUnitResolution))) { RenderTexture temporary = RenderTexture.GetTemporary(resolution, resolution, 32, (GraphicsFormat)52, 1, (RenderTextureMemoryless)1); if ((Object)(object)depthTarget == (Object)null) { if (constructionType == ConstructionType.SingleThreadedCPU || constructionType == ConstructionType.MultiThreadedCPU || constructionType == ConstructionType.MultiThreadedCPU_ShowWhenComplete) { depthTarget = RenderTexture.GetTemporary(resolution, resolution, 0, (GraphicsFormat)52, 1); } else { depthTarget = new RenderTexture(resolution, resolution, (GraphicsFormat)52, (GraphicsFormat)0, 0); } } RenderTexture active = RenderTexture.active; cam.targetTexture = temporary; cam.depthTextureMode = (DepthTextureMode)1; Profiler.start("MeshDecal.orthoRender.Render"); cam.Render(); Profiler.stop("MeshDecal.orthoRender.Render"); Profiler.start("MeshDecal.orthoRender.Blit"); Graphics.Blit((Texture)(object)temporary, depthTarget, depthToColor); Profiler.stop("MeshDecal.orthoRender.Blit"); RenderTexture.active = active; Profiler.start("MeshDecal.orthoRender.ReleaseTemporary"); RenderTexture.ReleaseTemporary(temporary); Profiler.stop("MeshDecal.orthoRender.ReleaseTemporary"); if ((Object)(object)extractedDepth != (Object)null) { Object.Destroy((Object)(object)extractedDepth); } if (constructionType == ConstructionType.SingleThreadedCPU || constructionType == ConstructionType.MultiThreadedCPU || constructionType == ConstructionType.MultiThreadedCPU_ShowWhenComplete) { using (new Profiler("MeshDecal.orthoRender-copyFromGPU")) { extractedDepth = ColorUtils.GetRenderTexturePixels(depthTarget); } float centerDistance = getCenterDistance(extractedDepth); Vector3 localPosition = meshHolder.transform.localPosition; localPosition.y = 0f - centerDistance; meshHolder.transform.localPosition = localPosition; RenderTexture.ReleaseTemporary(depthTarget); depthTarget = null; } else { Vector3 localPosition2 = meshHolder.transform.localPosition; localPosition2.y = 0f; meshHolder.transform.localPosition = localPosition2; } } setMaterialBlockData(); } private void setMaterialBlockData() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)this).transform.position; block.SetVector("_WorldCenterXZ", Vector4.op_Implicit(new Vector2(position.x, position.z))); block.SetFloat("_TerrainVertexSpacing", cam.orthographicSize * 2f / (float)resolution); if (constructionType == ConstructionType.FlatMesh) { float y = ((Component)((Component)this).GetComponentInChildren()).transform.localPosition.y; block.SetTexture("_TerrainDepthImage", depthTarget, (RenderTextureSubElement)0); block.SetFloat("_TerrainDepthImageWidth", cam.orthographicSize * 2f); block.SetFloat("_TerrainDepthCamNearPlane", cam.nearClipPlane + y); block.SetFloat("_TerrainDepthCamFarPlane", cam.farClipPlane + y); } } public MaterialPropertyBlock getMaterialPropertyBlock() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown if (block == null) { block = new MaterialPropertyBlock(); } return block; } } public interface SolidLavaArea { float getShaderRadius(); float getCollisionRadius(); float getFullySolidRadius(); Transform getTransform(); HashSet getAffectedCells(GridMap grid) where T : Component; void notifyHeightmapChanged(Heightmap hmap); long getIndex(); float getCollapse(); } internal class MovementListener : SlowUpdate { public delegate void OnMovementDetected(GameObject source, Vector3 prevPos, Vector3 newPos); private Vector3 position; private List listeners = new List(); public override void Awake() { //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) ((SlowUpdate)this).Awake(); position = ((Component)this).transform.position; } public override void OnDestroy() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) ((SlowUpdate)this).OnDestroy(); foreach (OnMovementDetected listener in listeners) { listener(null, position, position); } } public override void SUpdate(float time, Vector2i referenceZone) { //IL_0002: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) ((SlowUpdate)this).SUpdate(time, referenceZone); if (!(((Component)this).transform.position != position)) { return; } foreach (OnMovementDetected listener in listeners) { listener(((Component)this).gameObject, position, ((Component)this).transform.position); } position = ((Component)this).transform.position; } public void addListener(OnMovementDetected listener) { listeners.Add(listener); } } public class RangefindingChasmController : MonoBehaviour { public Camera orthoCam; public MeshRenderer chasmRenderer; public Texture2D sdfTex; public Texture2D normalsTex; public Material rangefindingMaterial; private RenderTexture rangeTex; private RenderTexture substrateNormalsTex; private CommandBuffer buff; public List substrates = new List(); public void generateRangeTexture(bool substrateChanged) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown if ((Object)(object)rangeTex != (Object)null && (((Texture)sdfTex).width != ((Texture)rangeTex).width || ((Texture)sdfTex).height != ((Texture)rangeTex).height)) { Object.Destroy((Object)(object)rangeTex); rangeTex = null; Object.Destroy((Object)(object)substrateNormalsTex); substrateNormalsTex = null; } if ((Object)(object)rangeTex == (Object)null) { rangeTex = new RenderTexture(((Texture)sdfTex).width, ((Texture)sdfTex).height, 16, (RenderTextureFormat)11); substrateChanged = true; } if ((Object)(object)substrateNormalsTex == (Object)null) { substrateNormalsTex = new RenderTexture(((Texture)sdfTex).width, ((Texture)sdfTex).height, 16, (RenderTextureFormat)11); substrateChanged = true; } orthoCam.aspect = ((Texture)sdfTex).width / ((Texture)sdfTex).height; orthoCam.orthographicSize = ((Component)this).transform.localScale.x / 2f; orthoCam.cullingMask = 0; if (buff == null || substrateChanged) { setupCommandBuffer(); } orthoCam.Render(); } private void setupCommandBuffer() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_005e: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00d1: Unknown result type (might be due to invalid IL or missing references) if (buff != null) { orthoCam.RemoveAllCommandBuffers(); buff.Dispose(); } buff = new CommandBuffer(); buff.name = "Chasm substrate rangefinder"; MaterialPropertyBlock val = new MaterialPropertyBlock(); val.SetTexture("_SDFTex", (Texture)(object)sdfTex); RenderTargetIdentifier[] array = (RenderTargetIdentifier[])(object)new RenderTargetIdentifier[2] { RenderTargetIdentifier.op_Implicit((Texture)(object)rangeTex), RenderTargetIdentifier.op_Implicit((Texture)(object)substrateNormalsTex) }; buff.SetRenderTarget(array, RenderTargetIdentifier.op_Implicit((Texture)(object)rangeTex)); buff.ClearRenderTarget(true, true, Color.black); foreach (MeshFilter substrate in substrates) { buff.DrawMesh(substrate.sharedMesh, ((Component)substrate).gameObject.transform.localToWorldMatrix, rangefindingMaterial, 0, 0, val); } orthoCam.AddCommandBuffer((CameraEvent)20, buff); } public void setTexturesOnRenderer() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown if (Application.isEditor) { MaterialPropertyBlock val = new MaterialPropertyBlock(); ((Renderer)chasmRenderer).GetPropertyBlock(val); val.SetTexture("_MainTex_SDF", (Texture)(object)rangeTex); val.SetTexture("_SubstrateNormals", (Texture)(object)substrateNormalsTex); val.SetTexture("_MainTex_Normals", (Texture)(object)normalsTex); ((Renderer)chasmRenderer).SetPropertyBlock(val); } else { Material material = ((Renderer)chasmRenderer).material; material.SetTexture("_MainTex_SDF", (Texture)(object)rangeTex); material.SetTexture("_SubstrateNormals", (Texture)(object)substrateNormalsTex); material.SetTexture("_MainTex_Normals", (Texture)(object)normalsTex); } } } public class RepairVFXHandler : MonoBehaviour { private class VFX { public GameObject obj; public MeshFilter filter; public MeshRenderer rend; public ParticleSystem ps; public VFX(GameObject obj, MeshFilter filter, MeshRenderer rend) { this.obj = obj; this.filter = filter; this.rend = rend; } public VFX(GameObject obj, ParticleSystem ps) { this.obj = obj; this.ps = ps; } } private const int PARTICLE_VFX_QUALITY = 2; private GameObject particlesVFXPrefab; private GameObject meshVFXPrefab; private WearNTear owner; private MaterialPropertyBlock propBlock; private List vfxHolders = new List(); private Dictionary originalLODs = new Dictionary(); private int visualQuality; private float particleVFXOffset; private void Awake() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown owner = ((Component)this).GetComponent(); if ((Object)(object)owner == (Object)null) { LogUtils.LogWarning("RepairVFXHandler attached to non WearNTear"); Object.Destroy((Object)(object)this); return; } particlesVFXPrefab = AssetLoader.GetPrefabFromAssetBundle("vfx_RepairRuneParticles"); meshVFXPrefab = AssetLoader.GetPrefabFromAssetBundle("vfx_RepairRuneMeshOverlay"); propBlock = new MaterialPropertyBlock(); MaterialMan.instance.RegisterRenderers(((Component)owner).gameObject); propBlock.SetFloat("_SetupTimestamp", Time.timeSinceLevelLoad); propBlock.SetInteger("_useStaticNoise", (!owner.m_staticPosition) ? 1 : 0); visualQuality = ConfigLoader.getInt("repairRune_visualQuality"); particleVFXOffset = ConfigLoader.getFloat("RepairRune_ParticleVFXOffset"); setupVFXOnLODs(); } private void OnDestroy() { foreach (VFX vfxHolder in vfxHolders) { destroyVFX(vfxHolder); } foreach (LODGroup key in originalLODs.Keys) { key.SetLODs(originalLODs[key]); } } private void setupParticleVFX() { //IL_0091: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) MeshFilter[] componentsInChildren = ((Component)owner).gameObject.GetComponentsInChildren(true); MeshFilter[] array = componentsInChildren; foreach (MeshFilter val in array) { if (!((Object)(object)((val != null) ? val.sharedMesh : null) == (Object)null) && val.sharedMesh.isReadable && val.sharedMesh.triangles.Length != 0) { GameObject val2 = Object.Instantiate(particlesVFXPrefab); val2.transform.parent = ((Component)val).gameObject.transform; val2.transform.localPosition = new Vector3(0f, 0f, 0f); val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = new Vector3(1f, 1f, 1f); ParticleSystem component = val2.GetComponent(); ShapeModule shape = component.shape; ((ShapeModule)(ref shape)).mesh = val.sharedMesh; ((ShapeModule)(ref shape)).scale = ((Component)val).gameObject.transform.lossyScale; ((ShapeModule)(ref shape)).normalOffset = particleVFXOffset; float num = (((ShapeModule)(ref shape)).scale.x + ((ShapeModule)(ref shape)).scale.y + ((ShapeModule)(ref shape)).scale.z) / 3f; ((ShapeModule)(ref shape)).normalOffset = ((ShapeModule)(ref shape)).normalOffset / num; vfxHolders.Add(new VFX(val2, component)); } } } private void setupVFXOnLODs() { //IL_0081: 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_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) LODGroup[] componentsInChildren = ((Component)owner).gameObject.GetComponentsInChildren(true); if (componentsInChildren.Length == 0) { LogUtils.LogInfo("No LOD groups on " + ((Object)owner).name); if (visualQuality == 2) { setupParticleVFX(); } else { setupPureMeshVFX(); } return; } LODGroup[] array = componentsInChildren; foreach (LODGroup val in array) { LOD[] lODs = val.GetLODs(); originalLODs.Add(val, lODs); LOD[] array2 = (LOD[])(object)new LOD[lODs.Length]; for (int j = 0; j < lODs.Length; j++) { LOD val2 = lODs[j]; List list = new List(); Renderer[] renderers = val2.renderers; foreach (Renderer val3 in renderers) { if (!((Object)(object)val3 == (Object)null)) { MeshFilter component = ((Component)val3).gameObject.GetComponent(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.sharedMesh == (Object)null) && MeshUtils.hasGeometry(component.sharedMesh) && !((Object)(object)val3.sharedMaterial == (Object)null) && !((Object)(object)val3.sharedMaterial.shader == (Object)null) && !(((Object)val3.sharedMaterial.shader).name == "Custom/WaterMask")) { VFX vFX = ((visualQuality == 2 && j == 0 && component.sharedMesh.isReadable) ? setupSingleParticleVFX(component) : setupSingleMeshVFX(component)); vfxHolders.Add(vFX); list.Add((Renderer)(object)vFX.rend); } } } list.AddRange(val2.renderers); val2.renderers = list.ToArray(); array2[j] = val2; } val.SetLODs(array2); } } private void setupPureMeshVFX() { MeshFilter[] componentsInChildren = ((Component)owner).gameObject.GetComponentsInChildren(true); MeshFilter[] array = componentsInChildren; foreach (MeshFilter val in array) { if (!((Object)(object)((val != null) ? val.sharedMesh : null) == (Object)null) && (!val.sharedMesh.isReadable || val.sharedMesh.triangles.Length != 0)) { VFX item = setupSingleMeshVFX(val); vfxHolders.Add(item); } } } private VFX setupSingleMeshVFX(MeshFilter filter) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(meshVFXPrefab); val.transform.SetParent(((Component)filter).gameObject.transform, false); val.transform.localPosition = new Vector3(0f, 0f, 0f); MeshFilter component = val.GetComponent(); component.sharedMesh = filter.sharedMesh; MeshRenderer component2 = val.GetComponent(); ((Renderer)component2).SetPropertyBlock(propBlock); return new VFX(val, component, component2); } private VFX setupSingleParticleVFX(MeshFilter filter) { //IL_0037: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_00b1: 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_00ca: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(particlesVFXPrefab); val.transform.parent = ((Component)filter).gameObject.transform; val.transform.localPosition = new Vector3(0f, 0f, 0f); val.transform.localRotation = Quaternion.identity; val.transform.localScale = new Vector3(1f, 1f, 1f); ParticleSystem component = val.GetComponent(); ShapeModule shape = component.shape; ((ShapeModule)(ref shape)).mesh = filter.sharedMesh; ((ShapeModule)(ref shape)).scale = ((Component)filter).gameObject.transform.lossyScale; ((ShapeModule)(ref shape)).normalOffset = particleVFXOffset; float num = (((ShapeModule)(ref shape)).scale.x + ((ShapeModule)(ref shape)).scale.y + ((ShapeModule)(ref shape)).scale.z) / 3f; ((ShapeModule)(ref shape)).normalOffset = ((ShapeModule)(ref shape)).normalOffset / num; return new VFX(val, component); } private void destroyVFX(VFX holder) { ParticleSystem ps = holder.ps; if ((Object)(object)ps != (Object)null) { ps.Stop(); } MeshRenderer rend = holder.rend; if ((Object)(object)rend != (Object)null) { propBlock.SetFloat("_TeardownTimestamp", Time.timeSinceLevelLoad); ((Renderer)rend).SetPropertyBlock(propBlock); } Object.Destroy((Object)(object)holder.obj, (float)Random.Range(10, 15)); } } public class CalmWatersRune : MonoBehaviour, ZNetViewHook { public static HashSet allInstances = new HashSet(); private const string CreationTimeKey = "creationTime"; private float effectRadius = 141.23999f; private float minGlow; private float maxGlow; private ZNetView netView; private void Awake() { if (PlayerPatch.PlayerCreatingGhost) { Object.Destroy((Object)(object)this); } allInstances.Add(this); minGlow = ConfigLoader.getFloat("calmWatersGlowFactorOff"); maxGlow = ConfigLoader.getFloat("calmWatersGlowFactorOn"); } public void PostZNetViewAwake(ZNetView view) { netView = ((Component)this).GetComponent(); if (PlayerPatch.PlayerPlacing) { netView.GetZDO().Set("creationTime", (long)ZNet.instance.GetTimeSeconds()); } } private void Start() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) HashSet managers = WaterSurfaceManager.getManagers(((Component)this).transform.position, effectRadius); bool wasPlacedByPlayer = Math.Abs((long)ZNet.instance.GetTimeSeconds() - netView.GetZDO().GetLong("creationTime", 0L)) < 10; foreach (WaterSurfaceManager item in managers) { item.registerRune(this, wasPlacedByPlayer); } } private void OnDestroy() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) allInstances.Remove(this); if (PlayerPatch.PlayerCreatingGhost) { return; } HashSet managers = WaterSurfaceManager.getManagers(((Component)this).transform.position, effectRadius); foreach (WaterSurfaceManager item in managers) { if ((Object)(object)item != (Object)null) { item.unregisterRune(this); } } } private void Update() { float windIntensity = EnvMan.instance.GetWindIntensity(); ((Component)this).gameObject.GetComponentInChildren().setIntensity(Mathf.Lerp(minGlow, maxGlow, windIntensity)); } } public class CanopyRune_OldNoRainshadow : MonoBehaviour { [CompilerGenerated] private sealed class d__26 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public CanopyRune_OldNoRainshadow <>4__this; private List 5__2; private int 5__3; private int 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__26(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_007b: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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) int num = <>1__state; CanopyRune_OldNoRainshadow canopyRune_OldNoRainshadow = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; goto IL_0029; case 1: <>1__state = -1; break; case 2: { <>1__state = -1; 5__2 = null; goto IL_0029; } IL_0029: 5__2 = new List(canopyRune_OldNoRainshadow.forcefields.Keys); 5__3 = 1; 5__4 = 0; break; } if (5__4 < 5__2.Count) { for (int i = 0; i < 5__3; i++) { if (5__4 >= 5__2.Count) { break; } Vector3 val = 5__2[5__4]; if (!EnvMan.IsWet() && !canopyRune_OldNoRainshadow.doesEnvironmentNeedCanopy()) { canopyRune_OldNoRainshadow.forcefields[val].SetActive(false); } else if (isPointInRangeOfAny(val, canopyRune_OldNoRainshadow)) { canopyRune_OldNoRainshadow.forcefields[val].SetActive(false); } else if (Cover.IsUnderRoof(val)) { canopyRune_OldNoRainshadow.forcefields[val].SetActive(false); } else { canopyRune_OldNoRainshadow.forcefields[val].SetActive(true); } 5__4++; } <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 2; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static Particle[] particles = (Particle[])(object)new Particle[256]; private static List allInstances = new List(); public static HashSet relevantEnvSetups = new HashSet { "SnowStorm", "WhirlWind", "Snow", "AshRain", "LightRain", "Rain" }; public static HashSet relevantParticleSystems = new HashSet { "snow (1)", "snow", "ash", "zinder", "Rain", "splash spawner", "RainTest" }; private HashSet modifiedObjects = new HashSet(); private Dictionary forcefields = new Dictionary(); private Coroutine forcefieldCoroutine; private int layerMask; private int _Wet = Shader.PropertyToID("_Wet"); private float minGlow; private float maxGlow; private float minFogDissipationRadius; private ParticleSystemForceField demisterField; public float effectRadius = 10f; private void Awake() { if (PlayerPatch.PlayerCreatingGhost) { Object.Destroy((Object)(object)this); } allInstances.Add(this); effectRadius = ConfigLoader.getFloat("canopyRuneEffectRadius"); minFogDissipationRadius = ConfigLoader.getFloat("canopyRune_FogMinDissipationRadius"); demisterField = ((Component)this).GetComponentInChildren(); layerMask = LayerMask.GetMask(new string[10] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "vehicle", "character", "character_net", "item" }); minGlow = ConfigLoader.getFloat("canopyRune_GlowFactorOff"); maxGlow = ConfigLoader.getFloat("canopyRune_GlowFactorOn"); ((MonoBehaviour)this).InvokeRepeating("checkNearbyColliders", 0f, 2f); if (ConfigLoader.getInt("canopyRune_visualQuality") > 0) { forcefields = generateForcefields(generateSurfacePoints()); forcefieldCoroutine = ((MonoBehaviour)this).StartCoroutine(ForcefieldUpdateCoroutine()); } } private void OnDestroy() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) readdRainEffect(modifiedObjects); foreach (Vector3 key in forcefields.Keys) { Object.Destroy((Object)(object)forcefields[key]); } if (forcefieldCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(forcefieldCoroutine); } allInstances.Remove(this); } private void Update() { ((Component)this).gameObject.GetComponentInChildren().setIntensity(Mathf.Lerp(minGlow, maxGlow, EnvManPatch.canopyActiveFactor)); if ((Object)(object)demisterField != (Object)null) { demisterField.endRange = Mathf.Lerp(minFogDissipationRadius, effectRadius, EnvManPatch.canopyActiveFactor); } } private void FixedUpdate() { //IL_008a: Unknown result type (might be due to invalid IL or missing references) Profiler.start("CanopyRuneOld_particleDelete"); EnvSetup currentEnvironment = EnvMan.instance.GetCurrentEnvironment(); GameObject[] psystems = currentEnvironment.m_psystems; foreach (GameObject val in psystems) { if (!relevantEnvSetups.Contains(((Object)val).name)) { continue; } ParticleSystem[] componentsInChildren = val.GetComponentsInChildren(); ParticleSystem[] array = componentsInChildren; foreach (ParticleSystem val2 in array) { if (!relevantParticleSystems.Contains(((Object)val2).name)) { continue; } int num = val2.GetParticles(particles); for (int k = 0; k < num; k++) { if (isPointInRange(((Particle)(ref particles[k])).position, ((Particle)(ref particles[k])).startSize / 2f)) { ((Particle)(ref particles[k])).remainingLifetime = 0f; } } val2.SetParticles(particles, num); } } Profiler.stop("CanopyRuneOld_particleDelete"); } private void checkNearbyColliders() { //IL_0010: 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_009e: Expected O, but got Unknown Profiler.start("checkNearbyColliders-OverlapSphere"); Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, effectRadius, layerMask); Profiler.stop("checkNearbyColliders-OverlapSphere"); Profiler.start("checkNearbyColliders-vfx"); HashSet hashSet = new HashSet(); Collider[] array2 = array; foreach (Collider val in array2) { GameObject val2 = findRenderableParent(((Component)val).gameObject); hashSet.Add(val2); if ((Object)(object)val2.GetComponent() != (Object)null) { hashSet.UnionWith(getEquipment(val2.GetComponent())); } } MaterialPropertyBlock val3 = new MaterialPropertyBlock(); foreach (GameObject item in hashSet) { modifiedObjects.Remove(item); modifiedObjects.Add(item); Renderer[] componentsInChildren = item.GetComponentsInChildren(true); Renderer[] array3 = componentsInChildren; foreach (Renderer val4 in array3) { val4.GetPropertyBlock(val3); val3.SetFloat("_AddRain", 0f); val4.SetPropertyBlock(val3); } } HashSet hashSet2 = new HashSet(modifiedObjects.Except(hashSet)); readdRainEffect(hashSet2); modifiedObjects.ExceptWith(hashSet2); Profiler.stop("checkNearbyColliders-vfx"); } private void readdRainEffect(HashSet objects) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) MaterialPropertyBlock val = new MaterialPropertyBlock(); foreach (GameObject @object in objects) { if (!((Object)(object)@object == (Object)null) && !isPointInRangeOfAny(@object.transform.position, this)) { Renderer[] componentsInChildren = @object.GetComponentsInChildren(true); Renderer[] array = componentsInChildren; foreach (Renderer val2 in array) { val2.GetPropertyBlock(val); val.SetFloat("_AddRain", 1f); val2.SetPropertyBlock(val); } } } } private List getEquipment(Humanoid entity) { object value = Traverse.Create((object)entity).Field("m_visEquipment").GetValue(); VisEquipment val = (VisEquipment)((value is VisEquipment) ? value : null); List list = new List(); object value2 = Traverse.Create((object)val).Field("m_leftItemInstance").GetValue(); addIfNotNull(list, (GameObject)((value2 is GameObject) ? value2 : null)); object value3 = Traverse.Create((object)val).Field("m_rightItemInstance").GetValue(); addIfNotNull(list, (GameObject)((value3 is GameObject) ? value3 : null)); object value4 = Traverse.Create((object)val).Field("m_helmetItemInstance").GetValue(); addIfNotNull(list, (GameObject)((value4 is GameObject) ? value4 : null)); object value5 = Traverse.Create((object)val).Field("m_leftBackItemInstance").GetValue(); addIfNotNull(list, (GameObject)((value5 is GameObject) ? value5 : null)); object value6 = Traverse.Create((object)val).Field("m_rightBackItemInstance").GetValue(); addIfNotNull(list, (GameObject)((value6 is GameObject) ? value6 : null)); addIfNotNull(list, Traverse.Create((object)val).Field("m_chestItemInstances").GetValue() as List); addIfNotNull(list, Traverse.Create((object)val).Field("m_legItemInstances").GetValue() as List); addIfNotNull(list, Traverse.Create((object)val).Field("m_shoulderItemInstances").GetValue() as List); addIfNotNull(list, Traverse.Create((object)val).Field("m_utilityItemInstances").GetValue() as List); return list; } private void addIfNotNull(List list, T obj) { if (obj != null) { list.Add(obj); } } private void addIfNotNull(List list, List toAdd) { if (toAdd != null) { list.AddRange(toAdd); } } private GameObject findRenderableParent(GameObject obj) { while ((Object)(object)obj.GetComponentInChildren() == (Object)null && (Object)(object)obj.transform.root != (Object)(object)obj.transform) { obj = ((Component)obj.transform.parent).gameObject; } return obj; } public bool isPointInRange(Vector3 location, float pointRadius = 0f) { //IL_0000: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0066: 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_0087: 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_00aa: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) if (location.y - pointRadius > ((Component)this).transform.position.y + effectRadius || location.x + pointRadius < ((Component)this).transform.position.x - effectRadius || location.x - pointRadius > ((Component)this).transform.position.x + effectRadius || location.z + pointRadius < ((Component)this).transform.position.z - effectRadius || location.z - pointRadius > ((Component)this).transform.position.z + effectRadius) { return false; } Vector3 val = location - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude < (effectRadius + pointRadius) * (effectRadius + pointRadius)) { return true; } return location.y <= ((Component)this).transform.position.y && Utils.DistanceXZ(location, ((Component)this).transform.position) < effectRadius; } public static bool isPointInRangeOfAny(Vector3 location, CanopyRune_OldNoRainshadow except = null) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) foreach (CanopyRune_OldNoRainshadow allInstance in allInstances) { if (!((Object)(object)allInstance == (Object)(object)except) && !((Object)(object)allInstance == (Object)null) && allInstance.isPointInRange(location)) { return true; } } return false; } [IteratorStateMachine(typeof(d__26))] private IEnumerator ForcefieldUpdateCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__26(0) { <>4__this = this }; } private bool doesEnvironmentNeedCanopy() { EnvSetup currentEnvironment = EnvMan.instance.GetCurrentEnvironment(); GameObject[] psystems = currentEnvironment.m_psystems; foreach (GameObject val in psystems) { if (relevantEnvSetups.Contains(((Object)val).name)) { return true; } } return false; } private HashSet generateSurfacePoints() { //IL_006a: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_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_0099: 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_00a6: 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) HashSet hashSet = new HashSet(); int @int = ConfigLoader.getInt("canopyRune_forceSegmentsAround"); int int2 = ConfigLoader.getInt("canopyRune_forceSegmentsUp"); Vector3 val = default(Vector3); for (int i = 0; i < int2; i++) { for (int j = 0; j < @int; j++) { float num = 360f / (float)@int * (float)j; float num2 = 180f / (float)int2 * (float)i; ((Vector3)(ref val))..ctor(1f, 0f, 0f); val = Quaternion.Euler(0f, 0f, num2) * val; val = Quaternion.Euler(0f, num, 0f) * val; hashSet.Add(((Component)this).transform.position + val * effectRadius); } } return hashSet; } private Dictionary generateForcefields(HashSet points) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0042: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); foreach (Vector3 point in points) { Vector3 val = point - ((Component)this).transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; GameObject val2 = Object.Instantiate(AssetLoader.GetPrefabFromAssetBundle("ForcefieldImpact"), ((Component)this).transform.position, Quaternion.LookRotation(normalized, Vector3.up)); val2.transform.localScale = new Vector3(effectRadius, effectRadius, effectRadius); val2.SetActive(false); dictionary.Add(point, val2); } return dictionary; } } public class CanopyRune : MonoBehaviour { private static Particle[] particles = (Particle[])(object)new Particle[3000]; private static List allInstances = new List(); private static HashSet relevantEnvSetupParticleHolders = new HashSet { "SnowStorm", "WhirlWind", "Snow", "AshRain", "LightRain", "Rain", "SlimeRain", "Ashlands_AshRain", "Ashlands_storm", "Ashlands_MeteorShower", "Ashlands_Misty", "Ashlands_CinderRain" }; private static HashSet relevantParticleSystems = new HashSet { "snow (1)", "snow", "ash", "Rain", "splash spawner", "RainTest" }; private static HashSet alwaysBlockParticleSystems = new HashSet { "zinder" }; public List forcefieldPrefab; private GameObject forcefieldObj; [HideInInspector] public GameObject envParticlesHolder; private float minGlow; private float maxGlow; private float minFogDissipationRadius; private ParticleSystemForceField demisterField; public float effectRadius = 10f; private void Awake() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) if (PlayerPatch.PlayerCreatingGhost) { Object.Destroy((Object)(object)this); return; } envParticlesHolder = new GameObject("EnvParticlesHolder"); allInstances.Add(this); effectRadius = ConfigLoader.getFloat("canopyRuneEffectRadius"); minFogDissipationRadius = ConfigLoader.getFloat("canopyRune_FogMinDissipationRadius"); demisterField = ((Component)this).GetComponentInChildren(); minGlow = ConfigLoader.getFloat("canopyRune_GlowFactorOff"); maxGlow = ConfigLoader.getFloat("canopyRune_GlowFactorOn"); int num = ConfigLoader.getInt("canopyRune_visualQuality"); if (num < 0 || num >= forcefieldPrefab.Count) { LogUtils.LogWarning($"Invalid canopy quality {num}, defaulting to 1"); num = 1; } forcefieldObj = Object.Instantiate(forcefieldPrefab[num]); forcefieldObj.transform.position = ((Component)this).transform.position; } private void OnDestroy() { if ((Object)(object)forcefieldObj != (Object)null) { Object.Destroy((Object)(object)forcefieldObj); } if ((Object)(object)envParticlesHolder != (Object)null) { Object.Destroy((Object)(object)envParticlesHolder); } allInstances.Remove(this); } private void Update() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_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) ((Component)this).gameObject.GetComponentInChildren().setIntensity(Mathf.Lerp(minGlow, maxGlow, EnvManPatch.canopyActiveFactor)); if ((Object)(object)demisterField != (Object)null) { demisterField.endRange = Mathf.Lerp(minFogDissipationRadius, effectRadius + 0.5f, EnvManPatch.canopyActiveFactor); } if ((Object)(object)forcefieldObj != (Object)null) { envParticlesHolder.transform.position = ((Component)this).transform.position; forcefieldObj.SetActive(EnvManPatch.canopyActiveFactor > 0f); } if ((Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)Utils.GetMainCamera() != (Object)null) { Vector3 val = (GameCamera.InFreeFly() ? ((Component)Utils.GetMainCamera()).transform.position : ((Component)Player.m_localPlayer).transform.position); float num = Utils.DistanceXZ(((Component)this).transform.position, val); if (num < ConfigLoader.getFloat("CanopyRune-weatherParticleActiveRange") + effectRadius) { setParticlesActive(isActive: true); } else { setParticlesActive(isActive: false); } } } public bool isPointInRange(Vector3 location, float pointRadius = 0f) { //IL_0000: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0066: 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_0087: 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_00aa: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) if (location.y - pointRadius > ((Component)this).transform.position.y + effectRadius || location.x + pointRadius < ((Component)this).transform.position.x - effectRadius || location.x - pointRadius > ((Component)this).transform.position.x + effectRadius || location.z + pointRadius < ((Component)this).transform.position.z - effectRadius || location.z - pointRadius > ((Component)this).transform.position.z + effectRadius) { return false; } Vector3 val = location - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude < (effectRadius + pointRadius) * (effectRadius + pointRadius)) { return true; } return location.y <= ((Component)this).transform.position.y && Utils.DistanceXZ(location, ((Component)this).transform.position) < effectRadius; } public static bool isPointInRangeOfAny(Vector3 location, CanopyRune except = null) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) foreach (CanopyRune allInstance in allInstances) { if (!((Object)(object)allInstance == (Object)(object)except) && !((Object)(object)allInstance == (Object)null) && allInstance.isPointInRange(location)) { return true; } } return false; } public static CanopyRune getClosest(Vector3 location) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) float num = float.MaxValue; CanopyRune result = null; foreach (CanopyRune allInstance in allInstances) { float num2 = Utils.DistanceSqr(((Component)allInstance).transform.position, location); if (num2 < num) { result = allInstance; num = num2; } } return result; } public static bool doesEnvironmentNeedCanopy(EnvSetup environment) { if (environment == null) { return false; } if (environment.m_isWet) { return true; } GameObject[] psystems = environment.m_psystems; foreach (GameObject val in psystems) { if (!((Object)(object)val == (Object)null) && relevantEnvSetupParticleHolders.Contains(((Object)val).name)) { return true; } } return false; } private void setParticlesActive(bool isActive) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) string name = EnvManPatch.activeParticlesEnv.m_name; ParticleSystem[] componentsInChildren = envParticlesHolder.GetComponentsInChildren(true); foreach (ParticleSystem val in componentsInChildren) { if ((Object)(object)val == (Object)null) { continue; } Transform parent = ((Component)val).transform.parent; if (isActive && (Object)(object)parent != (Object)null && ((Object)parent).name == name + "(Clone)") { if (val.isStopped) { EmissionModule emission = val.emission; ((EmissionModule)(ref emission)).enabled = true; val.Play(); } } else if (!val.isStopped) { val.Stop(false, (ParticleSystemStopBehavior)1); } } } public static void addParticlesForAll(EnvSetup env) { if (env == null) { return; } foreach (CanopyRune allInstance in allInstances) { allInstance.addParticles(env); } } private void addParticles(EnvSetup env) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0182: 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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)envParticlesHolder.transform.Find(env.m_name))) { return; } Profiler.start("AddParticles"); HashSet hashSet = new HashSet { "SnowStorm", "Snow" }; HashSet hashSet2 = new HashSet { "snow (1)", "snow" }; GameObject val = new GameObject(env.m_name); val.transform.parent = envParticlesHolder.transform; val.transform.localPosition = new Vector3(0f, 0f, 0f); GameObject[] psystems = env.m_psystems; foreach (GameObject val2 in psystems) { if ((Object)(object)val2 == (Object)null || !hashSet.Contains(((Object)val2).name)) { continue; } GameObject val3 = Object.Instantiate(val2, val.transform, false); val3.transform.localPosition = val2.transform.localPosition; ParticleSystem[] componentsInChildren = val3.GetComponentsInChildren(true); foreach (ParticleSystem val4 in componentsInChildren) { if (!((Object)(object)val4 == (Object)null)) { ((Component)val4).transform.localPosition = new Vector3(0f, ConfigLoader.getFloat("CanopyRune-snowVerticalOffset"), 0f); val4.Stop(); if (((Component)val4).gameObject.activeSelf && hashSet2.Contains(((Object)val4).name)) { ShapeModule shape = val4.shape; EmissionModule emission = val4.emission; float num = MathUtils.hemisphereVolume(((ShapeModule)(ref shape)).radius) * ((ShapeModule)(ref shape)).scale.x * ((ShapeModule)(ref shape)).scale.y * ((ShapeModule)(ref shape)).scale.z; MinMaxCurve rateOverTime = ((EmissionModule)(ref emission)).rateOverTime; float num2 = ((MinMaxCurve)(ref rateOverTime)).constant / num; float @float = ConfigLoader.getFloat("CanopyRune-snowRadiusThickness"); float float2 = ConfigLoader.getFloat("CanopyRune-snowRadiusOffset"); ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = effectRadius + float2 + @float; ((ShapeModule)(ref shape)).radiusThickness = @float / ((ShapeModule)(ref shape)).radius; ((ShapeModule)(ref shape)).scale = new Vector3(1f, 1f, 1f); float num3 = MathUtils.sphereVolume(((ShapeModule)(ref shape)).radius) - MathUtils.sphereVolume(effectRadius + float2); ((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(num2 * num3); } else { ((Component)val4).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)val4).gameObject); } } } } Profiler.stop("AddParticles"); } } public class DryLandRune : MonoBehaviour, ZNetViewHook { private const string CreationTimeKey = "creationTime"; private float effectRadius; private float radius = 10f; private float depth = 5f; private float slope = 1f; public static HashSet allInstances = new HashSet(); private float minGlow; private float maxGlow; private float currentGlowFactor; private float targetGlowFactor; private RuneProjector projector; private Coroutine depthCalculationLoop; private Color baseColor; private ZNetView netView; private void Awake() { allInstances.Add(this); radius = ConfigLoader.getFloat("dryLand_radius"); depth = ConfigLoader.getFloat("dryLand_depth"); slope = ConfigLoader.getFloat("dryLand_slope"); effectRadius = (5f + 0.1f * depth + radius * slope) / slope; } public void PostZNetViewAwake(ZNetView view) { netView = ((Component)this).GetComponent(); if (PlayerPatch.PlayerPlacing) { netView.GetZDO().Set("creationTime", (long)ZNet.instance.GetTimeSeconds()); } } private void Start() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) HashSet managers = WaterSurfaceManager.getManagers(((Component)this).transform.position, effectRadius); bool shouldAnimate = Math.Abs((long)ZNet.instance.GetTimeSeconds() - netView.GetZDO().GetLong("creationTime", 0L)) < 10; foreach (WaterSurfaceManager item in managers) { item.registerRune(this, shouldAnimate); } minGlow = ConfigLoader.getFloat("dryLand_GlowFactorOff"); maxGlow = ConfigLoader.getFloat("dryLand_GlowFactorOn"); projector = ((Component)this).gameObject.GetComponentInChildren(); currentGlowFactor = 0f; targetGlowFactor = currentGlowFactor; baseColor = new Color(projector.runeColor.r, projector.runeColor.g, projector.runeColor.b, projector.runeColor.a); projector.setIntensity(minGlow); } private void OnDestroy() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) allInstances.Remove(this); if (depthCalculationLoop != null) { ((MonoBehaviour)this).StopCoroutine(depthCalculationLoop); } if (PlayerPatch.PlayerCreatingGhost) { return; } HashSet managers = WaterSurfaceManager.getManagers(((Component)this).transform.position, effectRadius); foreach (WaterSurfaceManager item in managers) { if ((Object)(object)item != (Object)null) { item.unregisterRune(this); } } } public float calculateVerticalOffset(float distance) { return (float)Math.Tanh((distance - radius) * slope) * depth - depth; } public float getMaxEffectRadius() { return effectRadius; } public static float GetOceanDepthAll(Vector3 worldPos) { //IL_0000: 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) Heightmap val = Heightmap.FindHeightmap(worldPos); if (Object.op_Implicit((Object)(object)val)) { return val.GetOceanDepth(worldPos); } return 0f; } } internal class FollowOwningPlayer : MonoBehaviour { public bool m_lockYPos = true; public float lockYAt; private ZNetView netView; private void Awake() { netView = ((Component)this).GetComponent(); } private void LateUpdate() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (netView.IsOwner() && (Object)(object)Player.m_localPlayer != (Object)null) { Vector3 position = ((Component)Player.m_localPlayer).transform.position; if (m_lockYPos) { position.y = lockYAt; } ((Component)this).transform.position = position; } } } internal class FoundationRune : MonoBehaviour, ZNetViewHook, ResizableRune { private class ColumnArc { public float start; public float max; public float end; public ColumnArc(float start, float max, float end) { this.start = start; this.max = max; this.end = end; } public float getHeight(float t) { if ((double)t < 0.5) { return (0f - (max - start)) * Mathf.Pow(2f * t - 1f, 2f) + max; } return (0f - (max - end)) * Mathf.Pow(2f * t - 1f, 2f) + max; } } public class TerrainQuad { public float[,] baseHeights = new float[2, 2]; public float[,] currentHeights = new float[2, 2]; public float[,] adjustedHeights = new float[2, 2]; public TerrainQuad(FoundationRune parent, Heightmap hmap, int x, int y) { for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { baseHeights[j, i] = parent.GetBaseHeight(hmap, x + j, y + i); currentHeights[j, i] = hmap.GetHeight(x + j, y + i); adjustedHeights[j, i] = currentHeights[j, i]; } } } public void adjustHeight(float height, int i, int j) { adjustedHeights[i, j] = TerrainHolder.clampTerrainHeight(height, baseHeights[i, j]); } public void getExtrema(out float minCurrentHeight, out float maxCurrentHeight, out float minAdjustedHeight, out float maxAdjustedHeight) { minCurrentHeight = float.MaxValue; maxCurrentHeight = float.MinValue; minAdjustedHeight = float.MaxValue; maxAdjustedHeight = float.MinValue; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { minCurrentHeight = Math.Min(minCurrentHeight, currentHeights[j, i]); maxCurrentHeight = Math.Max(maxCurrentHeight, currentHeights[j, i]); minAdjustedHeight = Math.Min(minAdjustedHeight, adjustedHeights[j, i]); maxAdjustedHeight = Math.Max(maxAdjustedHeight, adjustedHeights[j, i]); } } } } private const string BASE_RADIUS_KEY = "effectRadius"; private const string EFFECT_DISTANCE_KEY = "currentRadius"; private const string EFFECT_DIR_KEY = "effectDirection"; public float effectRadius; private TerrainHolder terrainHolder; private ProgressiveAlteration alteration; private ZNetView nview; private GameObject vfxPrefab; private List columns = new List(); private Dictionary columnArcs = new Dictionary(); private Dictionary columnToTerrainMap = new Dictionary(); private float columnWidth; private float clearanceAtMax; private float clearanceRandomness; private float clearanceAtMin; private float fadeOutPercent; private void Awake() { if (PlayerPatch.PlayerCreatingGhost) { Object.Destroy((Object)(object)this); return; } LogUtils.LogDebug($"Starting foundation with radius {effectRadius}"); RuneProjectorBlocker runeProjectorBlocker = ((Component)this).gameObject.AddComponent(); runeProjectorBlocker.radius = 128f; Object.Destroy((Object)(object)((Component)this).GetComponent()); nview = ((Component)this).GetComponent(); } public void PostZNetViewAwake(ZNetView view) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00de: 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_00f6: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) if (PlayerPatch.PlayerCreatingGhost) { return; } if (ConfigLoader.getBool("foundationRune_isRadial")) { alteration = new RadialProgressiveAlteration(((Component)this).transform.position, ConfigLoader.getFloat("foundationRune_waveSpeed"), ConfigLoader.getFloat("foundationRune_waveWidth")); } else if (view.IsOwner()) { Vector3 val = Utils.DirectionXZ(((Component)this).transform.position - ((Component)Player.m_localPlayer).transform.position); Vector2 direction = default(Vector2); ((Vector2)(ref direction))..ctor(val.x, val.z); view.GetZDO().Set("effectDirection", val); alteration = new LinearProgressiveAlteration(((Component)this).transform.position, ConfigLoader.getFloat("foundationRune_waveSpeed"), ConfigLoader.getFloat("foundationRune_waveWidth"), direction); } else { Vector3 vec = view.GetZDO().GetVec3("effectDirection", Vector3.forward); Vector2 direction2 = default(Vector2); ((Vector2)(ref direction2))..ctor(vec.x, vec.z); alteration = new LinearProgressiveAlteration(((Component)this).transform.position, ConfigLoader.getFloat("foundationRune_waveSpeed"), ConfigLoader.getFloat("foundationRune_waveWidth"), direction2); } if (view.IsOwner()) { view.GetZDO().Set("effectRadius", effectRadius); view.GetZDO().Set("currentRadius", alteration.currentDistance); if (ConfigLoader.getBool("foundationRune_useHeightAtPlayerLocation")) { float y = 0f; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(((Character)Player.m_localPlayer).GetCenterPoint(), Vector3.down, ref val2, 200f, LayerMask.GetMask(new string[1] { "terrain" }))) { y = ((RaycastHit)(ref val2)).point.y; } else { Heightmap.GetHeight(((Character)Player.m_localPlayer).GetCenterPoint(), ref y); } Vector3 position = ((Component)this).transform.position; position.y = y; ((Component)this).transform.position = position; } float heightOffset = Heightmap.FindHeightmap(((Component)this).transform.position).GetHeightOffset(((Component)this).transform.position); ((Component)this).transform.position = ((Component)this).transform.position + Vector3.up * heightOffset; List list = new List(); Heightmap.FindHeightmap(((Component)this).transform.position, effectRadius + alteration.effectWidth, list); terrainHolder = new TerrainHolder(list); terrainHolder.calculateHeightsWithModifiers(); setupVFX(); terrainHolder.claimOwnership(); } else { effectRadius = view.GetZDO().GetFloat("effectRadius", 0f); alteration.currentDistance = view.GetZDO().GetFloat("currentRadius", 0f); List list2 = new List(); Heightmap.FindHeightmap(((Component)this).transform.position, effectRadius + alteration.effectWidth, list2); terrainHolder = new TerrainHolder(list2); terrainHolder.calculateHeightsWithModifiers(); setupVFX(); ((Component)this).transform.localScale = new Vector3(effectRadius, 1f, effectRadius); } } private void OnDestroy() { foreach (GameObject column in columns) { Object.Destroy((Object)(object)column); } } private void Update() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) if (nview.IsOwner()) { updateOwner(Time.deltaTime); } else { alteration.currentDistance = nview.GetZDO().GetFloat("currentRadius", 0f); } foreach (GameObject column in columns) { Vector3 position = column.transform.position; float fractionOfWaveCrossed = alteration.getFractionOfWaveCrossed(position); position.y = columnArcs[column].getHeight(fractionOfWaveCrossed); column.transform.position = position; } TerrainHolder.resetGrass(((Component)this).transform.position, effectRadius); } private void updateOwner(float dt) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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) alteration.update(dt); nview.GetZDO().Set("currentRadius", alteration.currentDistance); foreach (TerrainComp item in terrainHolder.affectedTerrain) { if (item.IsOwner()) { float num = Mathf.Min(alteration.currentDistance, effectRadius); bool flag = adjustTerrain(item); if (flag && WorldGenerator.IsAshlands(((Component)this).transform.position.x, ((Component)this).transform.position.z)) { SolidLavaHole.spawnHole(((Component)this).transform.position, num); } if (flag) { terrainHolder.repaint(item, ((Component)this).transform.position, num, (PaintType)0); terrainHolder.propagateChanges(item); } } } if (alteration.currentDistance > effectRadius * (1f + fadeOutPercent) + alteration.effectWidth) { ZNetScene.instance.Destroy(((Component)this).gameObject); } } private bool adjustTerrain(TerrainComp comp) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_009e: 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_00cf: 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) Vector3 position = ((Component)this).transform.position; Heightmap val = terrainHolder.heightmaps[comp]; int num = default(int); int num2 = default(int); val.WorldToVertex(position, ref num, ref num2); float num3 = effectRadius / val.m_scale; int num4 = Mathf.CeilToInt(num3); int num5 = val.m_width + 1; bool result = false; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor((float)num, (float)num2); for (int i = Mathf.Max(num2 - num4, 0); i < Mathf.Min(num2 + num4 + 1, num5); i++) { for (int j = Mathf.Max(num - num4, 0); j < Mathf.Min(num + num4 + 1, num5); j++) { if (!(Vector2.Distance(val2, new Vector2((float)j, (float)i)) <= num3)) { continue; } Vector3 val3 = TerrainHolder.calcVertex(val, j, i); if (alteration.isPointInsideCenterEdge(val3)) { int num6 = i * num5 + j; float num7 = terrainHolder.getBaseHeightWithModifiers(comp, j, i); float lava = val.GetLava(val3); if (lava > 0f) { num7 += lava * ConfigLoader.getFloat("foundationRune_LavaMultiplier"); } float num8 = TerrainHolder.clampTerrainDelta(((Component)this).transform.position.y - num7); if (terrainHolder.smoothDeltas[comp][num6] != 0f || terrainHolder.levelDeltas[comp][num6] != num8) { result = true; } terrainHolder.smoothDeltas[comp][num6] = 0f; terrainHolder.levelDeltas[comp][num6] = num8; terrainHolder.modifiedHeights[comp][num6] = true; } } } return result; } private float GetBaseHeight(Heightmap hmap, int x, int y) { int num = hmap.m_width + 1; if (x < 0 || y < 0 || x >= num || y >= num) { return 0f; } return terrainHolder.heightmapBuildData[hmap].m_baseHeights[y * num + x]; } public void setSize(float size) { effectRadius = size; } public float getSize() { return effectRadius; } private void setupVFX() { //IL_007a: 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_0101: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: 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_0176: 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_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Expected O, but got Unknown //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) LogUtils.LogDebug("Setting up Foundation VFX"); columnWidth = ConfigLoader.getFloat("foundationRune_columnWidth"); clearanceAtMax = ConfigLoader.getFloat("foundationRune_clearanceAtMax"); clearanceAtMin = ConfigLoader.getFloat("foundationRune_clearanceAtMin"); clearanceRandomness = ConfigLoader.getFloat("foundationRune_clearanceRandomness"); vfxPrefab = AssetLoader.GetPrefabFromAssetBundle("vfx_FoundationColumn"); vfxPrefab.transform.localScale = new Vector3(columnWidth, 1f, columnWidth); float @float = ConfigLoader.getFloat("foundationRune_colorRangeMin"); float float2 = ConfigLoader.getFloat("foundationRune_colorRangeMax"); fadeOutPercent = ConfigLoader.getFloat("foundationRune_fadeOutPercent"); Heightmap val = Heightmap.GetAllHeightmaps()[0]; float scale = val.m_scale; float num = effectRadius * (1f + fadeOutPercent) + scale; int num2 = Mathf.CeilToInt(num / columnWidth); Heightmap val2 = TerrainHolder.findHeightmap(((Component)this).transform.position); int x = default(int); int y = default(int); val2.WorldToVertex(((Component)this).transform.position - new Vector3(scale / 2f, 0f, scale / 2f), ref x, ref y); Vector3 val3 = TerrainHolder.calcVertex(val2, x, y) + new Vector3(scale / 2f - 0.001f, 0f, scale / 2f - 0.001f); for (int i = -num2; i <= num2; i++) { for (int j = -num2; j <= num2; j++) { Vector3 val4 = val3 + new Vector3(scale * (float)j, -100f, scale * (float)i); if (Utils.DistanceXZ(val4, ((Component)this).transform.position) < num) { Heightmap val5 = TerrainHolder.findHeightmap(val4); GameObject val6 = Object.Instantiate(vfxPrefab, val4, Quaternion.Euler(0f, (float)(90 * Random.Range(0, 4)), 0f)); columns.Add(val6); columnToTerrainMap[val6] = val5.GetAndCreateTerrainCompiler(); MeshRenderer componentInChildren = val6.GetComponentInChildren(); MaterialPropertyBlock val7 = new MaterialPropertyBlock(); val7.SetColor("_Color", new Color(1f, 1f, 1f) * Random.Range(@float, float2)); ((Renderer)componentInChildren).SetPropertyBlock(val7); columnArcs[val6] = GetColumnArcAligned(val6); Transform val8 = val6.transform.Find("HeathRockPillarInverted"); float float3 = ConfigLoader.getFloat("foundationRune_PillarHeight"); float num3 = Math.Max(columnArcs[val6].max - columnArcs[val6].start, columnArcs[val6].max - columnArcs[val6].end); if (num3 > float3) { val8.localScale = new Vector3(1f, num3 / float3, 1f); } } } } } private ColumnArc GetColumnArcAligned(GameObject column) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) Vector3 position = column.transform.position; if (!terrainHolder.heightmaps.ContainsKey(columnToTerrainMap[column])) { LogUtils.LogWarning("TerrainHolder missing heightmap for terrain"); return new ColumnArc(0f, 0f, 0f); } Heightmap val = terrainHolder.heightmaps[columnToTerrainMap[column]]; int num = default(int); int num2 = default(int); val.WorldToVertex(position, ref num, ref num2); int num3 = default(int); int num4 = default(int); val.WorldToVertex(((Component)this).transform.position, ref num3, ref num4); float num5 = effectRadius / val.m_scale; TerrainQuad terrainQuad = new TerrainQuad(this, val, num, num2); for (int i = 0; i <= 1; i++) { for (int j = 0; j <= 1; j++) { if (Vector2.Distance(new Vector2((float)num3, (float)num4), new Vector2((float)(num + j), (float)(num2 + i))) <= num5) { terrainQuad.adjustHeight(((Component)this).transform.position.y, j, i); } } } terrainQuad.getExtrema(out var minCurrentHeight, out var maxCurrentHeight, out var minAdjustedHeight, out var maxAdjustedHeight); float num6 = Mathf.Max(maxCurrentHeight, maxAdjustedHeight) + clearanceAtMax + Random.Range(0f, clearanceRandomness); if (fadeOutPercent > 0f) { num6 = Mathf.Lerp(num6, minAdjustedHeight - clearanceAtMin, (Utils.DistanceXZ(((Component)this).transform.position, position) - effectRadius) / (effectRadius * fadeOutPercent)); } return new ColumnArc(minCurrentHeight - clearanceAtMin, num6, minAdjustedHeight - clearanceAtMin); } private ColumnArc getColumnArc(GameObject column) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0089: 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_00a6: Unknown result type (might be due to invalid IL or missing references) Vector3 position = column.transform.position; if (!terrainHolder.heightmaps.ContainsKey(columnToTerrainMap[column])) { LogUtils.LogWarning("TerrainHolder missing heightmap for terrain"); return new ColumnArc(0f, 0f, 0f); } Heightmap val = terrainHolder.heightmaps[columnToTerrainMap[column]]; int x = default(int); int y = default(int); val.WorldToVertex(position, ref x, ref y); getHeight(val, x, y, position, out var currentHeight, out var baseHeight); float num = currentHeight; float num2 = Utils.DistanceXZ(((Component)this).transform.position, position); if (num2 <= effectRadius) { num = TerrainHolder.clampTerrainHeight(((Component)this).transform.position.y, baseHeight); } float num3 = clearanceAtMax + Random.Range(0f, clearanceRandomness); num3 = Mathf.Lerp(num3, 0f - clearanceAtMin, (num2 - effectRadius) / (effectRadius * fadeOutPercent)); return new ColumnArc(currentHeight - clearanceAtMin, Mathf.Max(currentHeight, num) + num3, num - clearanceAtMin); } private void getHeight(Heightmap hmap, int x, int y, Vector3 pos, out float currentHeight, out float baseHeight) { //IL_0000: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) Vector3 val = pos - ((Component)hmap).transform.position; float tX = val.x / hmap.m_scale + 0.5f + (float)(hmap.m_width / 2) - (float)x; float tY = val.z / hmap.m_scale + 0.5f + (float)(hmap.m_width / 2) - (float)y; currentHeight = MathUtils.quadLerp(hmap.GetHeight(x, y), hmap.GetHeight(x + 1, y), hmap.GetHeight(x, y + 1), hmap.GetHeight(x + 1, y + 1), tX, tY); baseHeight = MathUtils.quadLerp(GetBaseHeight(hmap, x, y), GetBaseHeight(hmap, x + 1, y), GetBaseHeight(hmap, x, y + 1), GetBaseHeight(hmap, x + 1, y + 1), tX, tY); } } internal class HomingSpawner : MonoBehaviour { public Transform target; public float startDelay; public float speed = 7f; public float emissionDistance = 1f; public bool lockToHorizontal; public int activeRunes = 4; public GameObject runePrefab; private float distanceSinceLastEmission; private string rune; private void Update() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_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_005f: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) float deltaTime = Time.deltaTime; if ((Object)(object)target == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } startDelay -= deltaTime; if (startDelay > 0f) { emitParticle(); return; } Vector3 position = target.position; Vector3 val = position - ((Component)this).gameObject.transform.position; float num = Math.Min(((Vector3)(ref val)).magnitude, deltaTime * speed); if (distanceSinceLastEmission + num > emissionDistance) { move(emissionDistance - distanceSinceLastEmission); emitParticle(); num -= emissionDistance - distanceSinceLastEmission; distanceSinceLastEmission = 0f; } while (num > emissionDistance) { move(emissionDistance); emitParticle(); num -= emissionDistance; } move(num); distanceSinceLastEmission += num; Vector3 val2 = position - ((Component)this).gameObject.transform.position; if ((double)((Vector3)(ref val2)).magnitude < 0.1) { Object.Destroy((Object)(object)((Component)this).gameObject); } } private void move(float distance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) Vector3 position = target.position; Vector3 val = position - ((Component)this).gameObject.transform.position; Transform transform = ((Component)this).transform; transform.position += ((Vector3)(ref val)).normalized * distance; } private void emitParticle() { emitParticle(facing: true); if (!isText()) { emitParticle(facing: false); } } private void emitParticle(bool facing) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_0089: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_0082: Unknown result type (might be due to invalid IL or missing references) if (rune == null) { if (isText()) { rune = getRandomRune(); } else { rune = "RunesSheet_" + Random.Range(0, 19); } } Vector3 val = target.position - ((Component)this).gameObject.transform.position; if (lockToHorizontal) { val.y = 0f; } if (!facing) { val *= -1f; } Quaternion val2 = Quaternion.LookRotation(val, Vector3.up); GameObject val3 = Object.Instantiate(runePrefab, ((Component)this).transform.position, val2); SpriteFadeInOut spriteFadeInOut = val3.AddComponent(); spriteFadeInOut.lifeTime = (float)activeRunes * emissionDistance / speed; spriteFadeInOut.fadeInTime = spriteFadeInOut.lifeTime * 0.5f; spriteFadeInOut.fadeOutTime = spriteFadeInOut.lifeTime * 0.5f; if (isText()) { TextMesh componentInChildrenAll = ValheimMod.getComponentInChildrenAll(val3); componentInChildrenAll.text = rune; componentInChildrenAll.characterSize = ConfigLoader.getFloat("floatingTextRuneSize"); } else { SpriteRenderer componentInChildrenAll2 = ValheimMod.getComponentInChildrenAll(val3); componentInChildrenAll2.sprite = AssetLoader.GetSpriteFromAssetBundle("RunesSheet.png", rune); } } private string getRandomRune() { char[] array = "abdfghjklmnpsxyz".ToCharArray(); return array[Random.Range(0, array.Length)].ToString(); } private bool isText() { return (Object)(object)runePrefab.GetComponent() == (Object)null; } } public class IceTimedDestruction : MonoBehaviour { private readonly string ScaleKey = "PlayerScale-"; private ZNetView m_nview; public float balancingForce = 0.02f; public float decayRate; public float growRate; private Vector3 maxScale; private float currentScaleFactor; private static HashSet allInstances = new HashSet(); private static Dictionary cellMapping = new Dictionary(); private int cellX; private int cellZ; private int icebergIndex; private GameObject steam; private ParticleSystem steamSystem; private float baseSteamSize; private float sizeVariance; private BoundingCircle bounds; private void Awake() { //IL_0012: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_009c: 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_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_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Expected O, but got Unknown //IL_01f7: Unknown result type (might be due to invalid IL or missing references) m_nview = ((Component)this).GetComponent(); float num = Mathf.Max(WorldGenerator.GetAshlandsOceanGradient(((Component)this).transform.position), 0f); float coldFactor = Mathf.Max(SE_WaterWalking.GetDeepNorthOceanGradient(((Component)this).transform.position), 0f); decayRate = calculateDecayRate(num, coldFactor); growRate = ConfigLoader.getFloat("pathOfIceGrowRate"); List list = new List(); MeshFilter componentInChildren = ((Component)this).GetComponentInChildren(); Vector3[] vertices = componentInChildren.sharedMesh.vertices; Vector3[] array = vertices; foreach (Vector3 val in array) { Vector3 val2 = ((Component)this).transform.TransformPoint(val); list.Add(new Vector2(val2.x, val2.z)); } bounds = BoundingCircle.minimumCircle(list); if (num > 0f) { steam = Object.Instantiate(AssetLoader.GetPrefabFromAssetBundle("vfx_icebergSteam"), ((Component)this).transform); sizeVariance = ConfigLoader.getFloat("pathOfIce-steamSizeVariance"); float num2 = Mathf.Max(sizeVariance / 2f + 0.05f, bounds.radius); baseSteamSize = num2 * 2f; steamSystem = steam.GetComponentInChildren(); EmissionModule emission = steamSystem.emission; ((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(ConfigLoader.getFloat("pathOfIce-steamEmissionMult")); ((EmissionModule)(ref emission)).burstCount = 0; MainModule main = steamSystem.main; ((MainModule)(ref main)).startSize = new MinMaxCurve(baseSteamSize - sizeVariance, baseSteamSize + sizeVariance); ParticleSystemRenderer componentInChildren2 = steam.GetComponentInChildren(); ((Renderer)componentInChildren2).sharedMaterial = SoftReferenceUtils.smoke.getAsset(); MaterialPropertyBlock val3 = new MaterialPropertyBlock(); val3.SetColor("_Color", new Color(1f, 1f, 1f, Mathf.Clamp01(num * ConfigLoader.getFloat("pathOfIce-steamAlphaMult")))); ((Renderer)componentInChildren2).SetPropertyBlock(val3); } maxScale = ((Component)this).transform.localScale; ((Component)this).transform.localScale = new Vector3(0f, 0f, 0f); currentScaleFactor = 0f; allInstances.Add(this); ensureUniqueness(); } private void OnDestroy() { allInstances.Remove(this); string key = $"{cellX} {cellZ} {icebergIndex}"; if (cellMapping.ContainsKey(key) && (Object)(object)cellMapping[key] == (Object)(object)this) { cellMapping.Remove(key); } } private void ensureUniqueness() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) Vector2Int cell = SE_WaterWalking.getCell(((Component)this).transform.position); cellX = ((Vector2Int)(ref cell)).x; cellZ = ((Vector2Int)(ref cell)).y; string prefabName = Utils.GetPrefabName(((Component)this).gameObject); icebergIndex = int.Parse(prefabName.Substring("iceberg".Length)); string text = $"{cellX} {cellZ} {icebergIndex}"; if (cellMapping.ContainsKey(text)) { LogUtils.LogInfo("Duplicate iceberg found at " + text + ", destroying"); DestroyNow(); } else { cellMapping[text] = this; } } public static bool doesIcebergExist(int cellX, int cellZ, int icebergIndex) { string key = $"{cellX} {cellZ} {icebergIndex}"; return cellMapping.ContainsKey(key); } private void Update() { //IL_004f: 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_007d: 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_00ad: Unknown result type (might be due to invalid IL or missing references) updateLocalPlayerScale(); float scaleDueToPlayers = getScaleDueToPlayers(); float num = Math.Min(currentScaleFactor + growRate * Time.deltaTime, scaleDueToPlayers); float num2 = currentScaleFactor - decayRate * Time.deltaTime; currentScaleFactor = Mathf.Max(num, num2); ((Component)this).transform.localScale = maxScale * Mathf.Clamp01(currentScaleFactor); if ((Object)(object)steamSystem != (Object)null) { MainModule main = steamSystem.main; ((MainModule)(ref main)).startSize = new MinMaxCurve(baseSteamSize * currentScaleFactor - sizeVariance, baseSteamSize * currentScaleFactor + sizeVariance); } if (currentScaleFactor <= 0f) { DestroyNow(); } } private void updateLocalPlayerScale() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Player.m_localPlayer == (Object)null)) { float hotWaterFactor = Mathf.Max(WorldGenerator.GetAshlandsOceanGradient(((Component)Player.m_localPlayer).transform.position), 0f); float coldWaterFactor = Mathf.Max(SE_WaterWalking.GetDeepNorthOceanGradient(((Component)Player.m_localPlayer).transform.position), 0f); float num = calculateScaleFromPlayer(Player.m_localPlayer, ((Component)this).transform.position, hotWaterFactor, coldWaterFactor); if ((Object)(object)Player.m_localPlayer != (Object)null && ((Character)Player.m_localPlayer).GetCenterPoint().y < ((Component)this).transform.position.y && Utils.DistanceXZ(((Component)Player.m_localPlayer).transform.position, ((Component)this).transform.position) < Math.Max(bounds.radius * ConfigLoader.getFloat("pathOfIce-underIceRadiusMult"), 0.5f)) { num = 0f; } if ((Object)(object)m_nview != (Object)null && m_nview.IsValid()) { m_nview.GetZDO().Set(ScaleKey + Player.m_localPlayer.GetPlayerID(), num); } } } public static float calculateScaleFromPlayer(Player player, Vector3 iceBasePosition, float hotWaterFactor, float coldWaterFactor) { //IL_0033: 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_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) if ((Object)(object)player != (Object)null && ((Character)player).GetSEMan() != null && ((Character)player).GetSEMan().HaveStatusEffect(SE_WaterWalking.WaterWalkingStatusEffect)) { float fullScaleRadius = getFullScaleRadius(hotWaterFactor, coldWaterFactor); float keepAliveRadius = getKeepAliveRadius(hotWaterFactor, coldWaterFactor); Vector3 val = iceBasePosition - ((Component)Player.m_localPlayer).transform.position; float magnitude = ((Vector3)(ref val)).magnitude; float num = magnitude - fullScaleRadius; return 1f - Mathf.Clamp01(num / (keepAliveRadius - fullScaleRadius)); } return 0f; } private static float getFullScaleRadius(float hotFactor, float coldFactor) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_001a: Unknown result type (might be due to invalid IL or missing references) Vector3 vector = ConfigLoader.getVector3("pathOfIceFullScaleRadius"); float x = vector.x; float y = vector.y; float z = vector.z; if (hotFactor > 0f) { return Mathf.Lerp(y, z, hotFactor); } if (coldFactor > 0f) { return Mathf.Lerp(y, x, coldFactor); } return y; } public static float getKeepAliveRadius(float hotFactor, float coldFactor) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_001a: Unknown result type (might be due to invalid IL or missing references) Vector3 vector = ConfigLoader.getVector3("pathOfIceFreezeRadius"); float x = vector.x; float y = vector.y; float z = vector.z; if (hotFactor > 0f) { return Mathf.Lerp(y, z, hotFactor); } if (coldFactor > 0f) { return Mathf.Lerp(y, x, coldFactor); } return y; } private float calculateDecayRate(float hotFactor, float coldFactor) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_001a: Unknown result type (might be due to invalid IL or missing references) Vector3 vector = ConfigLoader.getVector3("pathOfIceDecayRate"); float x = vector.x; float y = vector.y; float z = vector.z; if (hotFactor > 0f) { return Mathf.Lerp(y, z, hotFactor); } if (coldFactor > 0f) { return Mathf.Lerp(y, x, coldFactor); } return y; } private float getScaleDueToPlayers() { float num = 0f; if ((Object)(object)m_nview != (Object)null && m_nview.IsValid()) { foreach (Player allPlayer in Player.GetAllPlayers()) { num = Math.Max(num, getScaleDueToPlayer(allPlayer)); } } return num; } private float getScaleDueToPlayer(Player player) { return m_nview.GetZDO().GetFloat(ScaleKey + player.GetPlayerID(), 0f); } private void OnCollisionEnter(Collision collision) { //IL_005e: 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) if (Utils.GetPrefabName(collision.gameObject).Equals("Player")) { return; } if (collision.gameObject.layer == LayerMask.NameToLayer("terrain") || collision.gameObject.layer == LayerMask.NameToLayer("static_solid")) { Object.Destroy((Object)(object)((Component)this).GetComponent()); Object.Destroy((Object)(object)((Component)this).GetComponent()); return; } Vector3 impulse = collision.impulse; if (((Vector3)(ref impulse)).magnitude > ConfigLoader.getFloat("iceImpulseMax")) { Object.Destroy((Object)(object)((Component)this).GetComponent()); Object.Destroy((Object)(object)((Component)this).GetComponent()); } } private void DestroyNow() { //IL_002c: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)steamSystem != (Object)null) { steam.transform.SetParent((Transform)null, true); GameObject obj = steam; MainModule main = steamSystem.main; MinMaxCurve startLifetime = ((MainModule)(ref main)).startLifetime; Object.Destroy((Object)(object)obj, ((MinMaxCurve)(ref startLifetime)).constantMax + 0.2f); } if ((Object)(object)m_nview != (Object)null && m_nview.IsValid()) { ZNetScene.instance.Destroy(((Component)this).gameObject); } else { Object.Destroy((Object)(object)((Component)this).gameObject); } } public static bool anyInstancesActiveForPlayer(Player player) { if ((Object)(object)player == (Object)null) { return false; } foreach (IceTimedDestruction allInstance in allInstances) { if (allInstance.getScaleDueToPlayer(player) > 0f) { return true; } } return false; } } internal class LineRuneEmitter : MonoBehaviour { public static readonly string SPEED_KEY = "emittedRuneSpeed"; public float length = 1f; public float emissionRate = 1f; public float distance = 1f; public float emittedRuneSpeed; public GameObject spawnerPrefab; private float countSinceLastEmission; private void Awake() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) emissionRate = ConfigLoader.getFloat("oceanCurrentRuneEmission"); float @float = ConfigLoader.getFloat("oceanCurrentRuneScale"); ((Component)this).transform.localScale = new Vector3(@float, @float, @float); } private void Update() { //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_0050: 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_0064: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) countSinceLastEmission += emissionRate * Time.deltaTime; while (countSinceLastEmission > 1f) { countSinceLastEmission -= 1f; Vector3 val = Random.Range(-0.5f, 0.5f) * length * Vector3.left; GameObject val2 = Object.Instantiate(spawnerPrefab, ((Component)this).transform.TransformPoint(val - distance * Vector3.forward / 2f), Quaternion.identity); HomingSpawner component = val2.GetComponent(); GameObject val3 = new GameObject("targetOffset"); val3.transform.position = ((Component)this).transform.TransformPoint(val + distance * Vector3.forward / 2f); component.target = val3.transform; component.startDelay = 0f; component.speed = ((Component)this).GetComponent().GetZDO().GetFloat(SPEED_KEY, 7f); component.emissionDistance = ConfigLoader.getFloat("emissionDistance"); component.activeRunes = ConfigLoader.getInt("oceanCurrentActiveRunes"); Color val4 = ColorUtils.applyIntensity(new Color(0f, 0.5098f, 1f), ConfigLoader.getFloat("oceanCurrentRuneIntensity")); ((Renderer)component.runePrefab.GetComponent()).material.SetColor("_EmissionColor", val4); component.runePrefab.transform.localScale = new Vector3(1f, 1f, 1f) * ConfigLoader.getFloat("oceanCurrentRuneSize"); } } private void OnDrawGizmos() { //IL_0006: 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_001a: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_006e: Unknown result type (might be due to invalid IL or missing references) Gizmos.matrix = ((Component)this).transform.localToWorldMatrix; Gizmos.color = Color.blue; Gizmos.DrawWireCube(Vector3.forward * distance / 2f, new Vector3(length, 0.1f, distance)); Gizmos.color = Color.white; Gizmos.DrawWireCube(Vector3.zero, new Vector3(length, 0.1f, 0.1f)); } } internal class MatchSurfaceHeight : MonoBehaviour { private int layerMask; private float heightOffset; private Vector3 localCenter = new Vector3(0f, 0f, 0f); private void Awake() { layerMask = LayerMask.GetMask(new string[1] { "terrain" }); float @float = ConfigLoader.getFloat("BoulderSummonCircleHeightAdjustRate", reload: true); heightOffset = ConfigLoader.getFloat("BoulderSummonCircleHeightOffset"); float num = Random.Range(0f, @float); ((MonoBehaviour)this).InvokeRepeating("moveToSurfaceHeight", num, @float); } public void setLocalCenter(Vector3 offset) { //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) localCenter = offset; } public void moveToSurfaceHeight() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.TransformPoint(localCenter); RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val + Vector3.up * 100f, Vector3.down, ref val2, 200f, layerMask) && (Object)(object)((RaycastHit)(ref val2)).collider != (Object)null) { Vector3 position = ((Component)this).gameObject.transform.position; position.y = ((RaycastHit)(ref val2)).point.y + heightOffset; ((Component)this).gameObject.transform.position = position; } } } public class MaterialReplacer : MonoBehaviour { private static Dictionary materials = new Dictionary(); public string materialName = ""; private void Awake() { Renderer component = ((Component)this).GetComponent(); if (materials.TryGetValue(materialName, out var value)) { component.sharedMaterial = value; } else { LogUtils.LogInfo($"Couldn't find material with name {materialName} in mapping {materials}"); } } public static void RegisterMaterial(Material mat) { materials[((Object)mat).name] = mat; } public static void RegisterMaterials() { Material[] array = Resources.FindObjectsOfTypeAll(); Material[] array2 = array; foreach (Material mat in array2) { RegisterMaterial(mat); } } public static Material getMaterial(string name) { return materials[name]; } } internal class MisdirectionRune : MonoBehaviour { public static List allInstances = new List(); } internal class ParticleToRuneConverter : MonoBehaviour { private static Particle[] particles = (Particle[])(object)new Particle[256]; private ParticleSystem psystem; public GameObject spawnerPrefab; private void Awake() { psystem = ((Component)this).GetComponent(); if ((Object)(object)psystem == (Object)null) { LogUtils.LogInfo("ParticleToRuneConverter didn't have a particle system attached, destroying"); Object.Destroy((Object)(object)this); } } private void Update() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_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) int num = psystem.GetParticles(particles); for (int i = 0; i < num; i++) { ((Particle)(ref particles[i])).remainingLifetime = 0f; GameObject val = Object.Instantiate(spawnerPrefab); HomingSpawner component = val.GetComponent(); val.transform.position = ((Particle)(ref particles[i])).position; component.startDelay = 0f; Vector3 totalVelocity = ((Particle)(ref particles[i])).totalVelocity; component.speed = ((Vector3)(ref totalVelocity)).magnitude; component.emissionDistance = 0.15f; component.activeRunes = 10; component.lockToHorizontal = false; GameObject val2 = new GameObject("targetOffset"); val2.transform.position = val.transform.position + ((Particle)(ref particles[i])).totalVelocity * ((Particle)(ref particles[i])).startLifetime; component.target = val2.transform; } psystem.SetParticles(particles, num); } } internal class LoweringRune : MonoBehaviour, ZNetViewHook, ResizableRune { private const string BASE_RADIUS_KEY = "effectRadius"; public float effectRadius; private long framesSincePropagatingTerrain; private TerrainHolder terrainHolder; private ZNetView nview; private ProgressiveAlteration alteration; private Dictionary finalStates = new Dictionary(); private Dictionary collisionMeshes = new Dictionary(); private Dictionary renderMeshes = new Dictionary(); private void Awake() { if (PlayerPatch.PlayerCreatingGhost) { Object.Destroy((Object)(object)this); return; } LogUtils.LogDebug($"Starting Lowering with radius {effectRadius}"); RuneProjectorBlocker runeProjectorBlocker = ((Component)this).gameObject.AddComponent(); runeProjectorBlocker.radius = 128f; Object.Destroy((Object)(object)((Component)this).GetComponent()); nview = ((Component)this).GetComponent(); } public void PostZNetViewAwake(ZNetView view) { //IL_000f: 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_00db: 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) if (PlayerPatch.PlayerCreatingGhost) { return; } alteration = new RadialProgressiveAlteration(((Component)this).transform.position, ConfigLoader.getFloat("loweringRune_waveSpeed"), ConfigLoader.getFloat("loweringRune_waveWidth")); if (view.IsOwner()) { view.GetZDO().Set("effectRadius", effectRadius); List list = new List(); Heightmap.FindHeightmap(((Component)this).transform.position, effectRadius + 1f, list); terrainHolder = new TerrainHolder(list); terrainHolder.claimOwnership(); TerrainHolder.removeOldTerrainMods(); } else { effectRadius = view.GetZDO().GetFloat("effectRadius", 0f); ((Component)this).transform.localScale = new Vector3(effectRadius, 1f, effectRadius); List list2 = new List(); Heightmap.FindHeightmap(((Component)this).transform.position, effectRadius + 1f, list2); terrainHolder = new TerrainHolder(list2); } float @float = ConfigLoader.getFloat("loweringRune_depthScaling"); Profiler.start("calculateFinalState"); foreach (TerrainComp item in terrainHolder.affectedTerrain) { finalStates[item] = calculateFinalState(item, @float, ConfigLoader.getFloat("loweringRune_curvePower")); Dictionary dictionary = collisionMeshes; object value = Traverse.Create((object)terrainHolder.heightmaps[item]).Field("m_collisionMesh").GetValue(); dictionary[item] = (Mesh)((value is Mesh) ? value : null); Dictionary dictionary2 = renderMeshes; object value2 = Traverse.Create((object)terrainHolder.heightmaps[item]).Field("m_renderMesh").GetValue(); dictionary2[item] = (Mesh)((value2 is Mesh) ? value2 : null); } Profiler.stop("calculateFinalState"); } private void OnDestroy() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Profiler.print(); Profiler.reset(); TerrainHolder.resetGrass(((Component)this).transform.position, effectRadius); } private void Update() { Profiler.start("LoweringRuneUpdate"); alteration.update(Time.deltaTime); framesSincePropagatingTerrain++; int @int = ConfigLoader.getInt("loweringRune_framesPerUpdate"); bool flag = true; foreach (TerrainComp item in terrainHolder.affectedTerrain) { Profiler.start("adjustTerrain"); bool flag2 = adjustTerrain(item); Profiler.stop("adjustTerrain"); Profiler.start("propagateChanges"); if (framesSincePropagatingTerrain % @int == 0L) { Profiler.start("pokeNow"); terrainHolder.heightmaps[item].Poke(false); Profiler.stop("pokeNow"); } else { Profiler.start("pokeDelayed"); terrainHolder.heightmaps[item].Poke(true); Profiler.stop("pokeDelayed"); } Profiler.stop("propagateChanges"); Profiler.start("resetGrass"); if (framesSincePropagatingTerrain == 1 || @int == 1 || framesSincePropagatingTerrain % @int == 1) { TerrainHolder.clearClutter((Vector3 pos) => Utils.DistanceXZ(((Component)this).transform.position, pos) < effectRadius); } Profiler.stop("resetGrass"); if (flag2) { flag = false; } } if (nview.IsOwner() && alteration.currentDistance >= effectRadius + alteration.effectWidth / 2f && flag) { foreach (TerrainComp item2 in terrainHolder.affectedTerrain) { terrainHolder.propagateChanges(item2); } LogUtils.LogDebug("Cleaning up LoweringRune"); ZNetScene.instance.Destroy(((Component)this).gameObject); } Profiler.stop("LoweringRuneUpdate"); } private bool adjustTerrain(TerrainComp comp) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)this).transform.position; Heightmap val = terrainHolder.heightmaps[comp]; int num = default(int); int num2 = default(int); val.WorldToVertex(position, ref num, ref num2); float num3 = effectRadius / val.m_scale; int num4 = Mathf.CeilToInt(num3); int num5 = val.m_width + 1; bool flag = false; float @float = ConfigLoader.getFloat("loweringRune_adjustmentEpsilon"); Vector3[] vertices = collisionMeshes[comp].vertices; Vector3[] vertices2 = renderMeshes[comp].vertices; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor((float)num, (float)num2); for (int i = Mathf.Max(num2 - num4, 0); i < Mathf.Min(num2 + num4 + 1, num5); i++) { for (int j = Mathf.Max(num - num4, 0); j < Mathf.Min(num + num4 + 1, num5); j++) { if (!(Vector2.Distance(val2, new Vector2((float)j, (float)i)) <= num3)) { continue; } Vector3 pos = TerrainHolder.calcVertex(val, j, i); float fractionOfWaveCrossed = alteration.getFractionOfWaveCrossed(pos); if (fractionOfWaveCrossed >= 0f && fractionOfWaveCrossed <= 1.2f) { int num6 = i * num5 + j; float num7 = Mathf.Lerp(terrainHolder.smoothDeltasOriginal[comp][num6], 0f, fractionOfWaveCrossed); float num8 = terrainHolder.levelDeltasOriginal[comp][num6] - finalStates[comp][num6]; float num9 = finalStates[comp][num6]; if (Mathf.Abs(num8) > @float) { num9 = Mathf.Lerp(terrainHolder.levelDeltasOriginal[comp][num6], finalStates[comp][num6], fractionOfWaveCrossed); } float num10 = num7 - terrainHolder.smoothDeltas[comp][num6]; float num11 = num9 - terrainHolder.levelDeltas[comp][num6]; if (terrainHolder.smoothDeltas[comp][num6] != num7 || terrainHolder.levelDeltas[comp][num6] != num9) { flag = true; vertices[num6].y += num10 + num11; vertices2[num6].y += num10 + num11; } terrainHolder.smoothDeltas[comp][num6] = num7; terrainHolder.levelDeltas[comp][num6] = num9; terrainHolder.modifiedHeights[comp][num6] = true; } } } if (flag) { Profiler.start("settingVertices"); collisionMeshes[comp].SetVertices(vertices); renderMeshes[comp].SetVertices(vertices2); Profiler.stop("settingVertices"); Profiler.start("RecalculateNormals"); renderMeshes[comp].RecalculateNormals(); Profiler.stop("RecalculateNormals"); } return flag; } private float[] calculateFinalState(TerrainComp comp, float delta, float power) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_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_00cc: 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_0126: Unknown result type (might be due to invalid IL or missing references) float[] array = (float[])terrainHolder.levelDeltas[comp].Clone(); Heightmap val = terrainHolder.heightmaps[comp]; int num = default(int); int num2 = default(int); val.WorldToVertex(((Component)this).transform.position, ref num, ref num2); Vector3 val2 = ((Component)this).transform.position - ((Component)comp).transform.position; float num3 = effectRadius / val.m_scale; int num4 = Mathf.CeilToInt(num3); int num5 = val.m_width + 1; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor((float)num, (float)num2); for (int i = num2 - num4; i <= num2 + num4; i++) { for (int j = num - num4; j <= num + num4; j++) { if (j < 0 || i < 0 || j >= num5 || i >= num5) { continue; } float num6 = 1f; float num7 = Vector2.Distance(val3, new Vector2((float)j, (float)i)); if (num7 > num3) { continue; } if (power > 0f) { num6 = num7 / num3; num6 = 1f - num6; if (power != 1f) { num6 = Mathf.Pow(num6, power); } } float height = val.GetHeight(j, i); float num8 = delta * num6; float num9 = val2.y + num8; if (delta < 0f && num9 > height) { continue; } if (delta > 0f) { if (num9 < height) { continue; } if (num9 > height + num8) { num9 = height + num8; } } int num10 = i * num5 + j; float num11 = num9 - height + terrainHolder.smoothDeltas[comp][num10]; array[num10] += num11; array[num10] = Mathf.Clamp(array[num10], -8f, 8f); } } return array; } public float getSize() { return effectRadius; } public void setSize(float size) { effectRadius = size; } } public class RepairRune : MonoBehaviour { [CompilerGenerated] private sealed class d__12 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public RepairRune <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0030: 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) int num = <>1__state; RepairRune repairRune = <>4__this; bool flag2; switch (num) { default: return false; case 0: <>1__state = -1; repairRune.projectorUpdaterRunning = true; LogUtils.LogInfo($"UpdateProjector start {((Component)repairRune).transform.position}"); flag2 = false; break; case 1: { <>1__state = -1; bool flag = GlobalRepairManager.hasAssignedWnTs(repairRune); float num2 = Time.deltaTime / repairRune.glowChangeTime; if (flag) { repairRune.currentGlowFactor = Mathf.Clamp01(repairRune.currentGlowFactor + num2); flag2 = repairRune.currentGlowFactor == 1f; } else { repairRune.currentGlowFactor = Mathf.Clamp01(repairRune.currentGlowFactor - num2); flag2 = repairRune.currentGlowFactor == 0f; } if ((Object)(object)repairRune.projector != (Object)null) { repairRune.projector.setIntensity(Mathf.Lerp(repairRune.minGlow, repairRune.maxGlow, repairRune.currentGlowFactor)); } break; } } if (!flag2) { <>2__current = null; <>1__state = 1; return true; } LogUtils.LogInfo($"UpdateProjector end {((Component)repairRune).transform.position}"); repairRune.projectorUpdaterRunning = false; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public float effectRadius; public float healRate; private static List allRunes = new List(); private float minGlow; private float maxGlow; private float glowChangeTime; private float currentGlowFactor; private RuneProjector projector; private bool projectorUpdaterRunning; private void Awake() { if (PlayerPatch.PlayerCreatingGhost) { Object.Destroy((Object)(object)this); return; } minGlow = ConfigLoader.getFloat("RepairRune_GlowFactorOff"); maxGlow = ConfigLoader.getFloat("RepairRune_GlowFactorOn"); glowChangeTime = ConfigLoader.getFloat("RepairRune_GlowChangeTime"); healRate = ConfigLoader.getFloat("RepairRune_HealRate"); effectRadius = ConfigLoader.getFloat("RepairRune_EffectRadius"); currentGlowFactor = 0f; projector = ((Component)this).GetComponent(); projector.setIntensity(minGlow); allRunes.Add(this); GlobalRepairManager.registerRune(this); } private void OnDestroy() { allRunes.Remove(this); GlobalRepairManager.unregisterRune(this); } public void assignedWnTsChanged() { if (projectorUpdaterRunning || (Object)(object)projector == (Object)null) { return; } bool flag = GlobalRepairManager.hasAssignedWnTs(this); if ((!flag || currentGlowFactor != 1f) && (flag || currentGlowFactor != 0f)) { if (((Behaviour)this).enabled && ((Component)this).gameObject.activeInHierarchy) { ((MonoBehaviour)this).StartCoroutine(UpdateProjector()); return; } currentGlowFactor = (flag ? 1 : 0); projector?.setIntensity(Mathf.Lerp(minGlow, maxGlow, currentGlowFactor)); } } [IteratorStateMachine(typeof(d__12))] private IEnumerator UpdateProjector() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__12(0) { <>4__this = this }; } private bool isInRange(WearNTear wear) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) return Utils.DistanceXZ(((Component)wear).transform.position, ((Component)this).transform.position) <= effectRadius; } } internal class VentilationSmokeTracker : MonoBehaviour { [CompilerGenerated] private sealed class d__15 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public VentilationSmokeTracker <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__15(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown int num = <>1__state; VentilationSmokeTracker ventilationSmokeTracker = <>4__this; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; } else { <>1__state = -1; } float time = Time.time; if (time - ventilationSmokeTracker.lastOwnershipCheckTime > ventilationSmokeTracker.ownershipCheckDelay) { ventilationSmokeTracker.lastOwnershipCheckTime = time; ventilationSmokeTracker.checkOwnership(); if ((Object)(object)ventilationSmokeTracker.owningRune != (Object)null) { ventilationSmokeTracker.recalculateFireSize(); } } bool flag = (Object)(object)ventilationSmokeTracker.owningRune != (Object)null && !ventilationSmokeTracker.owningRune.isBlocked; ventilationSmokeTracker.vfx.setVisuals((!flag) ? 1 : 0); <>2__current = (object)new WaitForSeconds(0.2f); <>1__state = 1; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static HashSet allInstances = new HashSet(); private static Dictionary spawnerMap = new Dictionary(); private HashSet baseSmokeSystems = new HashSet(); private HashSet baseFireSystems = new HashSet(); private SmokeSpawner spawner; private SmokeVFX vfx; private VentilationRune owningRune; private bool hasOwner; private float lastOwnershipCheckTime; private float ownershipCheckDelay = 1f; public float fireSize; private Coroutine updateLoop; private void Awake() { allInstances.Add(this); LogUtils.LogDebug("VentilationSmokeTracker Awake"); spawner = ((Component)this).GetComponentInChildren(); spawnerMap.Add(spawner, this); findParticleVFX(); } private void OnEnable() { updateLoop = ((MonoBehaviour)this).StartCoroutine(UpdateLoop()); } private void OnDestroy() { allInstances.Remove(this); LogUtils.LogDebug("VentilationSmokeTracker OnDestroy"); spawnerMap.Remove(spawner); } [IteratorStateMachine(typeof(d__15))] private IEnumerator UpdateLoop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__15(0) { <>4__this = this }; } public VentilationRune getOwningRune() { return owningRune; } public void checkOwnership() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) VentilationRune ventilationRune = VentilationRune.findNearestInRange(((Component)this).transform.position); owningRune = ventilationRune; hasOwner = (Object)(object)owningRune != (Object)null; } private void recalculateFireSize() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) fireSize = 0f; float num = 0f; foreach (ParticleSystem baseFireSystem in baseFireSystems) { if (!((Object)(object)baseFireSystem == (Object)null) && ((Component)((Component)baseFireSystem).transform.parent).gameObject.activeInHierarchy) { EmissionModule emission = baseFireSystem.emission; num += ((EmissionModule)(ref emission)).rateOverTime.GetAvgEmission(); } } float num2 = 0.58f; fireSize += (Mathf.Pow(num + 1f, 1f - num2) - 1f) / (10f * (1f - num2)); Smelter component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null && component.IsActive()) { fireSize += 1f; } SmokeSpawner componentInChildren = ((Component)this).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null && ((Component)componentInChildren).gameObject.activeInHierarchy) { fireSize = Math.Max(fireSize, 1f); } } private void findParticleVFX() { Transform val = ((Component)this).transform; while ((Object)(object)val.parent != (Object)null && (Object)(object)((Component)val).GetComponent() == (Object)null) { val = val.parent; } vfx = new SmokeVFX(((Component)val).gameObject); ParticleSystem[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); ParticleSystem[] array = componentsInChildren; foreach (ParticleSystem val2 in array) { if (((Component)val2).gameObject.activeSelf) { string text = ((Object)val2).name.ToLowerInvariant(); if (text.Contains("smoke") || text.Contains("smok_small")) { baseSmokeSystems.Add(val2); } else if (text.Contains("fire") || text.Contains("flame")) { baseFireSystems.Add(val2); } } } } } public class SolidLavaDecal : MonoBehaviour, SolidLavaArea { private const string RADIUS_KEY = "solidRadius"; private const string CRACKS_KEY = "cracksAnim"; private static readonly int radiusShaderID = Shader.PropertyToID("_Radius"); private static readonly int radiusEdgeShaderID = Shader.PropertyToID("_RadiusEdge"); private static readonly int cracksAnimationShaderID = Shader.PropertyToID("_CracksAnimation"); private MeshDecal meshDecal; private MeshRenderer renderer; private ZNetView nView; private float startSize; private float maxSize; private float currentRadius; private bool isCollapsing; private float currentCollapse; public Transform spawningTransform; public Player spawningPlayer; public static HashSet allInstances = new HashSet(); public static bool forceEffectActive = false; public void Awake() { meshDecal = ((Component)this).GetComponent(); renderer = ((Component)this).GetComponentInChildren(); nView = ((Component)this).GetComponent(); meshDecal.decalSideLength = ConfigLoader.getFloat("LavaDecal-sideLength"); meshDecal.perUnitResolution = ConfigLoader.getInt("LavaDecal-meshResolution"); meshDecal.meshOffset = 0f; GlobalLavaSolidifier.registerArea(this, meshDecal.decalSideLength / 2f); startSize = ConfigLoader.getFloat("LavaDecal-startSize"); maxSize = ConfigLoader.getFloat("LavaDecal-maxSize"); currentRadius = startSize; currentCollapse = 0f; setUpTerrainTextures(); updateSize(); allInstances.Add(this); } public void OnDestroy() { GlobalLavaSolidifier.unregisterArea(this); allInstances.Remove(this); } public void Update() { //IL_0079: 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) if (nView.IsValid() && nView.IsOwner()) { if (!isCollapsing) { if ((Object)(object)spawningPlayer != (Object)null && (Object)(object)spawningTransform != (Object)null) { bool flag = ((Character)spawningPlayer).GetSEMan().HaveStatusEffect(SE_WaterWalking.WaterWalkingStatusEffect) || forceEffectActive; float @float = ConfigLoader.getFloat("LavaDecal-expansionRadius"); bool flag2 = MathUtils.distanceXZSqr(spawningTransform.position, ((Component)this).transform.position) <= @float * @float; isCollapsing = !(flag && flag2); } else { isCollapsing = true; } } if (!isCollapsing) { float num = ConfigLoader.getFloat("LavaDecal-expansionRate") * (1f - currentRadius / maxSize); currentRadius = Mathf.MoveTowards(currentRadius, maxSize, num * Time.deltaTime); } else { currentCollapse = Mathf.MoveTowards(currentCollapse, 1f, ConfigLoader.getFloat("LavaDecal-shrinkRate") * Time.deltaTime); } updateSize(); nView.GetZDO().Set("solidRadius", currentRadius); nView.GetZDO().Set("cracksAnim", currentCollapse); if (currentCollapse == 1f) { ZNetScene.instance.Destroy(((Component)this).gameObject); } } else { currentRadius = nView.GetZDO().GetFloat("solidRadius", 0f); currentCollapse = nView.GetZDO().GetFloat("cracksAnim", 0f); updateSize(); } } public float getShaderRadius() { return currentRadius; } public float getCollisionRadius() { return currentRadius; } public float getFullySolidRadius() { return currentRadius; } public Transform getTransform() { return ((Component)this).transform; } public HashSet getAffectedCells(GridMap grid) where T : Component { //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) return grid.GetGridCellsOverlappingArea(((Component)this).transform.position.GetXZVector(), getCollisionRadius(), inclusive: true); } private void updateSize() { float num = Mathf.Max(0f, currentRadius); float num2 = (currentRadius + 0.16f) * ConfigLoader.getFloat("LavaDecal-radiusEdgeScale"); num2 = Mathf.Max(num2, 0.001f); MaterialPropertyBlock materialPropertyBlock = meshDecal.getMaterialPropertyBlock(); materialPropertyBlock.SetFloat(radiusShaderID, num); materialPropertyBlock.SetFloat(radiusEdgeShaderID, num2); materialPropertyBlock.SetFloat(cracksAnimationShaderID, currentCollapse * currentCollapse); ((Renderer)renderer).SetPropertyBlock(materialPropertyBlock); } public static bool anyInRange(Vector3 pos, bool onlyLocal) { //IL_003b: 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) foreach (SolidLavaDecal allInstance in allInstances) { if (!allInstance.isCollapsing && (!onlyLocal || (!((Object)(object)allInstance.nView == (Object)null) && allInstance.nView.IsOwner())) && MathUtils.distanceXZSqr(pos, ((Component)allInstance).transform.position) < allInstance.currentRadius * allInstance.currentRadius) { return true; } } return false; } public static float getCoverageAtPoint(Vector3 pos) { //IL_0024: 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) float num = 0f; foreach (SolidLavaDecal allInstance in allInstances) { if (!((Object)(object)allInstance == (Object)null) && !(MathUtils.distanceXZSqr(pos, ((Component)allInstance).transform.position) > allInstance.currentRadius * allInstance.currentRadius)) { num = Mathf.Max(num, 1f - allInstance.currentCollapse * allInstance.currentCollapse); if (num >= 1f) { break; } } } return num; } private void setUpTerrainTextures() { //IL_0011: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) using (new Profiler("SolidLavaDecal.setUpTerrainTextures")) { Heightmap heightmap = HeightmapPatch.getHeightmap(((Component)this).transform.position - new Vector3(32f, 0f, 32f)); Heightmap adjacent = HeightmapPatch.getAdjacent(heightmap, 1, 0); Heightmap adjacent2 = HeightmapPatch.getAdjacent(heightmap, 0, 1); Heightmap adjacent3 = HeightmapPatch.getAdjacent(heightmap, 1, 1); Texture2D val = new Texture2D(((Texture)heightmap.m_paintMask).width * 2, ((Texture)heightmap.m_paintMask).height * 2, heightmap.m_paintMask.format, false); ((Texture)val).wrapMode = (TextureWrapMode)1; copyTextureTile(heightmap.m_paintMask, val, 0, 0); copyTextureTile(adjacent.m_paintMask, val, 1, 0); copyTextureTile(adjacent2.m_paintMask, val, 0, 1); copyTextureTile(adjacent3.m_paintMask, val, 1, 1); MaterialPropertyBlock materialPropertyBlock = meshDecal.getMaterialPropertyBlock(); materialPropertyBlock.SetVector("_TerrainCorner", Vector4.op_Implicit(((Component)heightmap).transform.position - new Vector3(32f, 0f, 32f))); materialPropertyBlock.SetTexture("_TerrainPaintTex", (Texture)(object)val); materialPropertyBlock.SetFloat("_TerrainPaintTexSizeLength", 128f); } } private void copyTextureTile(Texture2D src, Texture2D dst, int x, int y) { Graphics.CopyTexture((Texture)(object)src, 0, 0, 0, 0, ((Texture)src).width, ((Texture)src).height, (Texture)(object)dst, 0, 0, ((Texture)src).width * x, ((Texture)src).height * y); } public void notifyHeightmapChanged(Heightmap hmap) { if (nView.IsValid() && nView.IsOwner()) { ZNetScene.instance.Destroy(((Component)this).gameObject); } } public long getIndex() { return -1L; } public float getCollapse() { return currentCollapse; } } internal class RestorationRune : MonoBehaviour, ZNetViewHook, ResizableRune { private const string BASE_RADIUS_KEY = "effectRadius"; private const string CURRENT_RADIUS_KEY = "currentRadius"; public float effectRadius; private float adjustmentSpeed; private float minAdjust; private float repaintSpeed; private TerrainHolder terrainHolder; private ZNetView nview; private GameObject glowVFX; private List glowVFXRenderers = new List(); private float currentRadius; private long framesSincePropagatingTerrain; private void Awake() { if (PlayerPatch.PlayerCreatingGhost) { Object.Destroy((Object)(object)this); return; } LogUtils.LogDebug($"Starting restoration with radius {effectRadius}"); RuneProjectorBlocker runeProjectorBlocker = ((Component)this).gameObject.AddComponent(); runeProjectorBlocker.radius = 128f; Object.Destroy((Object)(object)((Component)this).GetComponent()); nview = ((Component)this).GetComponent(); } public void PostZNetViewAwake(ZNetView view) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_006f: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) if (!PlayerPatch.PlayerCreatingGhost) { adjustmentSpeed = ConfigLoader.getFloat("RestorationRune_adjustmentSpeed"); minAdjust = ConfigLoader.getFloat("RestorationRune_minAdjust"); repaintSpeed = ConfigLoader.getFloat("RestorationRune_repaintSpeed"); float num = 2f; glowVFX = new GameObject(); glowVFX.transform.parent = ((Component)this).transform; glowVFX.transform.localPosition = default(Vector3); for (int i = -5; i < 5; i++) { GameObject val = Object.Instantiate(AssetLoader.GetPrefabFromAssetBundle("RuneProjector_RestorationRune"), glowVFX.transform); val.transform.localPosition = new Vector3(0f, (float)i * num, 0f); glowVFXRenderers.Add(val.GetComponentInChildren()); } float @float = ConfigLoader.getFloat("RestorationRune_vfxScaleAdjust"); if (view.IsOwner()) { view.GetZDO().Set("effectRadius", effectRadius); view.GetZDO().Set("currentRadius", 0); glowVFX.transform.localScale = new Vector3(@float, 1f, @float); setVFXInnerRadius(0f); List list = new List(); Heightmap.FindHeightmap(((Component)this).transform.position, effectRadius + 1f, list); terrainHolder = new TerrainHolder(list); terrainHolder.claimOwnership(); TerrainHolder.removeOldTerrainMods(); } else { effectRadius = view.GetZDO().GetFloat("effectRadius", 0f); glowVFX.transform.localScale = new Vector3(@float, 1f, @float); setVFXInnerRadius(0f); ((Component)this).transform.localScale = new Vector3(effectRadius, 1f, effectRadius); } } } private void OnDestroy() { } private void Update() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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) if (nview.IsOwner()) { Profiler.start("UpdateOwner"); UpdateOwner(); Profiler.stop("UpdateOwner"); } else { setVFXInnerRadius(nview.GetZDO().GetFloat("currentRadius", 0f)); } float y = default(float); Heightmap.GetHeight(((Component)this).transform.position, ref y); Vector3 position = ((Component)this).transform.position; position.y = y; ((Component)this).transform.position = position; TerrainHolder.resetGrass(((Component)this).transform.position, effectRadius); } private void UpdateOwner() { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) currentRadius += repaintSpeed * Time.deltaTime; currentRadius = Math.Min(currentRadius, effectRadius); nview.GetZDO().Set("currentRadius", currentRadius); setVFXInnerRadius(currentRadius); framesSincePropagatingTerrain++; bool flag = false; if (framesSincePropagatingTerrain >= ConfigLoader.getInt("RestorationRune_framesPerUpdate")) { flag = true; framesSincePropagatingTerrain = 0L; } bool flag2 = true; foreach (TerrainComp item in terrainHolder.affectedTerrain) { if (item.IsOwner()) { Profiler.start("adjustTerrain"); bool flag3 = adjustTerrain(item, Time.deltaTime, currentRadius + ConfigLoader.getFloat("RestorationRune_leadingEdgeFactor")); Profiler.stop("adjustTerrain"); Profiler.start("repaintTerrain"); terrainHolder.repaint(item, ((Component)this).transform.position, currentRadius, (PaintType)3); Profiler.stop("repaintTerrain"); Profiler.start("propagateChanges"); if (flag && flag3) { terrainHolder.propagateChanges(item); } Profiler.stop("propagateChanges"); if (flag3) { flag2 = false; } } } if (currentRadius == effectRadius && flag2) { LogUtils.LogDebug("Cleaning up RestorationRune"); ZNetScene.instance.Destroy(((Component)this).gameObject); } } private bool adjustTerrain(TerrainComp comp, float deltaTime, float radius) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_007e: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)this).transform.position; Heightmap val = terrainHolder.heightmaps[comp]; int num = default(int); int num2 = default(int); val.WorldToVertex(position, ref num, ref num2); float num3 = radius / val.m_scale; int num4 = Mathf.CeilToInt(num3); int num5 = val.m_width + 1; bool result = false; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor((float)num, (float)num2); for (int i = Mathf.Max(num2 - num4, 0); i < Mathf.Min(num2 + num4 + 1, num5); i++) { for (int j = Mathf.Max(num - num4, 0); j < Mathf.Min(num + num4 + 1, num5); j++) { if (Vector2.Distance(val2, new Vector2((float)j, (float)i)) <= num3) { int num6 = i * num5 + j; if (terrainHolder.smoothDeltas[comp][num6] == 0f && terrainHolder.levelDeltas[comp][num6] == 0f) { terrainHolder.modifiedHeights[comp][num6] = false; } else { result = true; } terrainHolder.smoothDeltas[comp][num6] = adjustToward(terrainHolder.smoothDeltas[comp][num6], 0f, deltaTime); terrainHolder.levelDeltas[comp][num6] = adjustToward(terrainHolder.levelDeltas[comp][num6], 0f, deltaTime); } } } return result; } private float adjustToward(float original, float target, float deltaTime) { float val = Math.Abs(target - original) * adjustmentSpeed * deltaTime; val = Math.Max(val, minAdjust); val = Math.Min(val, Math.Abs(target - original)); if (target > original) { return original + val; } return original - val; } private void setVFXInnerRadius(float radius) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown float @float = ConfigLoader.getFloat("RestorationRune_edgeWidth"); MaterialPropertyBlock val = new MaterialPropertyBlock(); float num = radius / effectRadius; float num2 = Mathf.Lerp(1f + @float * 1.5f, (0f - @float) / 2f, num); float num3 = Mathf.Max(num2 - @float, @float / 2f); val.SetFloat("_upperCutoff", num2); val.SetFloat("_lowerCutoff", num3); val.SetFloat("_edge", @float); foreach (MeshRenderer glowVFXRenderer in glowVFXRenderers) { ((Renderer)glowVFXRenderer).SetPropertyBlock(val); } } public void setSize(float size) { effectRadius = size; } public float getSize() { return effectRadius; } } internal class RuneProjectorBlocker : MonoBehaviour { public static HashSet allInstances = new HashSet(); public float radius; private void Awake() { allInstances.Add(this); } private void OnDestroy() { allInstances.Remove(this); } } public class RuneProjector : MonoBehaviour, PlacementGhostBehavior, ZNetViewHook { public enum RunePlacementBehavior { PieceOnly, StandingStoneOnly, BreakableStoneOnly, GroundOnly, Anywhere } public bool usingCommonRuneMaterial = true; [ColorUsage(true, true)] public Color runeColor = Color.white; public Texture runeTexture; public RunePlacementBehavior placementBehavior = RunePlacementBehavior.Anywhere; public bool normalToSurface = true; public float minDistance = 2f; private static HashSet allProjectors = new HashSet(); private Vector3 originalScale; private Material projectorMaterial; private void Awake() { //IL_00c4: 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_0104: Unknown result type (might be due to invalid IL or missing references) Piece component = ((Component)this).gameObject.GetComponent(); if ((Object)(object)component != (Object)null && !RunemagicPieceConfig.isEnabled(component)) { LogUtils.LogImportantMessage("Rune " + Utils.GetPrefabName(((Component)this).gameObject) + " is disabled, destroying."); if ((Object)(object)ZNetScene.instance != (Object)null) { ZNetScene.instance.Destroy(((Component)this).gameObject); } else { Object.Destroy((Object)(object)((Component)this).gameObject); } return; } MeshRenderer componentInChildren = ((Component)this).gameObject.GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { LogUtils.LogError("Gameobject " + ((Object)((Component)this).gameObject).name + " doesn't have a MeshRenderer!"); ZNetScene.instance.Destroy(((Component)this).gameObject); return; } projectorMaterial = ((Renderer)componentInChildren).material; projectorMaterial.SetColor("_Color", runeColor); if (usingCommonRuneMaterial) { projectorMaterial.SetTexture("_MainTex", runeTexture); } allProjectors.Add(this); originalScale = ((Component)this).transform.localScale; } private void OnDestroy() { allProjectors.Remove(this); if ((Object)(object)projectorMaterial != (Object)null) { Object.Destroy((Object)(object)projectorMaterial); projectorMaterial = null; } } public void PostZNetViewAwake(ZNetView view) { try { if ((ZNetScenePatch.ChangingLoadedObjects || PlayerPatch.PlayerPlacing) && (Object)(object)view != (Object)null) { ValheimMod.analytics.registerUniqueRune(Utils.GetPrefabName(((Component)this).gameObject), view.GetZDO()); } } catch (Exception ex) { ValheimMod.DevModeLog(ex); } } public static List getNearbyRunes(Vector3 pos, float distance) { //IL_001f: 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) List list = new List(); float num = distance * distance; foreach (RuneProjector allProjector in allProjectors) { if (Utils.DistanceSqr(pos, ((Component)allProjector).gameObject.transform.position) <= num) { list.Add(allProjector); } } return list; } private bool isTooNearOtherRunes() { //IL_0024: 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) foreach (RuneProjector allProjector in allProjectors) { if (!((Object)(object)allProjector == (Object)(object)this)) { float num = Vector3.Distance(((Component)allProjector).transform.position, ((Component)this).transform.position); if (num < minDistance || num < allProjector.minDistance) { return true; } } } return false; } private bool isTooNearBlockers() { //IL_001b: 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) foreach (RuneProjectorBlocker allInstance in RuneProjectorBlocker.allInstances) { float num = MathUtils.distanceXZSqr(((Component)allInstance).transform.position, ((Component)this).transform.position); if (num < allInstance.radius * allInstance.radius) { return true; } } return false; } public void setIntensity(float intensity) { //IL_001a: 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) if ((Object)(object)projectorMaterial != (Object)null) { projectorMaterial.SetColor("_Color", runeColor * intensity); } } public bool AdjustPlacementGhost(Player player, GameObject ghost, PlayerRaycast ray) { //IL_000e: 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_002e: 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_0041: 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_0069: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: 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_0145: 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_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0236: 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) if (normalToSurface) { Quaternion val = ((((RaycastHit)(ref ray.hitInfo)).normal.y == 1f) ? Quaternion.identity : Quaternion.Euler(-90f, 180f, 0f)); Quaternion val2 = ((((RaycastHit)(ref ray.hitInfo)).normal.y == 1f) ? Quaternion.identity : Quaternion.LookRotation(((RaycastHit)(ref ray.hitInfo)).normal, Vector3.up)); ghost.transform.rotation = val2 * val; } GameObject placementMarkerInstance = player.m_placementMarkerInstance; if ((Object)(object)placementMarkerInstance != (Object)null) { placementMarkerInstance.SetActive(false); } if (placementBehavior == RunePlacementBehavior.PieceOnly) { if ((Object)(object)((Component)((RaycastHit)(ref ray.hitInfo)).collider).GetComponentInParent() == (Object)null) { player.m_placementStatus = (PlacementStatus)1; return false; } } else if (placementBehavior == RunePlacementBehavior.StandingStoneOnly) { bool flag = ValheimMod.anyPrefixInTree(((Component)((RaycastHit)(ref ray.hitInfo)).collider).gameObject, ValheimMod.standingStoneNames); handleInvalidPlacementMessage(player, "$message_runemagic_onlyonstandingstone", !flag); if (!flag) { player.m_placementStatus = (PlacementStatus)1; return false; } Heightmap heightmap = HeightmapPatch.getHeightmap(((RaycastHit)(ref ray.hitInfo)).point); if ((Object)(object)heightmap != (Object)null) { float heightOffset = heightmap.GetHeightOffset(((RaycastHit)(ref ray.hitInfo)).point); float num = default(float); bool worldHeight = heightmap.GetWorldHeight(((RaycastHit)(ref ray.hitInfo)).point, ref num); if (heightOffset > 0f && worldHeight && ((RaycastHit)(ref ray.hitInfo)).point.y < num + heightOffset + 0.1f) { player.m_placementStatus = (PlacementStatus)1; return false; } } } else if (placementBehavior == RunePlacementBehavior.GroundOnly) { bool flag2 = (Object)(object)((Component)((RaycastHit)(ref ray.hitInfo)).collider).GetComponent() != (Object)null; handleInvalidPlacementMessage(player, "$message_runemagic_onlyonground", !flag2); if (!flag2) { ghost.SetActive(false); player.m_placementStatus = (PlacementStatus)1; return false; } } else if (placementBehavior == RunePlacementBehavior.BreakableStoneOnly && !RockDestroyer.isDestructibleStone(((RaycastHit)(ref ray.hitInfo)).collider)) { ghost.SetActive(false); player.m_placementStatus = (PlacementStatus)1; return false; } RuneProjector componentInChildren = ghost.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null && componentInChildren.isTooNearOtherRunes()) { player.m_placementStatus = (PlacementStatus)5; return false; } if ((Object)(object)componentInChildren != (Object)null && componentInChildren.isTooNearBlockers()) { ghost.SetActive(false); player.m_placementStatus = (PlacementStatus)1; return false; } return true; } private void handleInvalidPlacementMessage(Player player, string message, bool show) { if (show) { ((Character)player).Message((MessageType)1, message, 0, (Sprite)null); return; } string text = Localization.instance.Localize(message); if (MessageHud.instance.m_messageText.text == text) { ((Graphic)MessageHud.instance.m_messageText).CrossFadeAlpha(0f, 0.01f, true); } } public static void checkSupportDestroyedNearPosition(Vector3 pos) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) float num = 10f; foreach (RuneProjector nearbyRune in getNearbyRunes(pos, 5f)) { ((MonoBehaviour)nearbyRune).Invoke("checkSupportDestroyed", num / 1000f); num += 10f; } } public void checkSupportDestroyed() { //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_005c: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //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) if ((Object)(object)this == (Object)null) { return; } WearNTear component = ((Component)this).GetComponent(); if ((Object)(object)component == (Object)null || placementBehavior != RunePlacementBehavior.StandingStoneOnly) { return; } Collider[] colliders = component.m_colliders; if (colliders == null) { component.SetupColliders(); } List bounds = component.m_bounds; Collider[] s_tempColliders = WearNTear.s_tempColliders; int s_rayMask = WearNTear.s_rayMask; foreach (BoundData item in bounds) { int num = Physics.OverlapBoxNonAlloc(item.m_pos, item.m_size, s_tempColliders, item.m_rot, s_rayMask); for (int i = 0; i < num; i++) { Collider val = s_tempColliders[i]; if (!((Object)(object)val == (Object)null) && !colliders.Contains(val) && !val.isTrigger && ValheimMod.anyPrefixInTree(((Component)val).gameObject, ValheimMod.standingStoneNames)) { return; } } } LogUtils.LogImportantMessage("Destroying newly unsupported rune"); component.Remove(false); } } internal class SpriteFadeInOut : MonoBehaviour { private SpriteRenderer sprite; private TextMesh text; public float lifeTime = 6f; public float fadeInTime = 1f; public float fadeOutTime = 2f; private float secondsSinceSpawn; private Color32 originalColor; private float originalIntensity; private void Awake() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) sprite = ValheimMod.getComponentInChildrenAll(((Component)this).gameObject); text = ValheimMod.getComponentInChildrenAll(((Component)this).gameObject); if ((Object)(object)sprite != (Object)null) { ColorUtils.DecomposeHdrColor(((Renderer)sprite).material.GetColor("_EmissionColor"), out originalColor, out originalIntensity); } else if ((Object)(object)text != (Object)null) { ColorUtils.DecomposeHdrColor(text.color, out originalColor, out originalIntensity); } setOpacity(0f); } private void Update() { secondsSinceSpawn += Time.deltaTime; if (secondsSinceSpawn < fadeInTime) { setOpacity(secondsSinceSpawn / fadeInTime); } else if (secondsSinceSpawn > lifeTime - fadeOutTime) { float num = lifeTime - secondsSinceSpawn; setOpacity(num / fadeOutTime); } else { setOpacity(1f); } if (secondsSinceSpawn >= lifeTime) { Object.Destroy((Object)(object)((Component)this).gameObject); } } private void setOpacity(float alpha) { //IL_00bb: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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) if ((Object)(object)sprite != (Object)null) { if (StandardShaderUtils.GetRenderMode(((Renderer)sprite).material) == StandardShaderUtils.BlendMode.Fade) { ((Renderer)sprite).material.SetColor("_Color", new Color(0f, 0f, 0f, Mathf.Clamp01(Mathf.Pow(alpha, ConfigLoader.getFloat("SpriteFadeInOutMaxOpacity"))))); } else { ((Renderer)sprite).material.SetColor("_EmissionColor", ColorUtils.applyIntensity(Color32.op_Implicit(originalColor), Mathf.Lerp(ConfigLoader.getFloat("SpriteFadeInOutMinIntensity"), originalIntensity, alpha))); } } if ((Object)(object)text != (Object)null) { text.color = new Color(text.color.r, text.color.g, text.color.b, Mathf.Clamp(alpha, 0f, 1f)); } } } public class WaterSurfaceManager : MonoBehaviour { public const int OCEAN_WATERVOLUME_VERTICES = 1025; public static Dictionary managers = new Dictionary(); public WaterVolume waterVolume; public MeshFilter waterSurface; private HashSet knownDryLandRunes = new HashSet(); private HashSet knownCalmWatersRunes = new HashSet(); private bool animatingSurface; private bool animatingDepth; private Vector3[] meshFinalState; private float[] originalNormalizedDepths; private float[] cornerNormalizedDepthFinalState; private Vector3[] meshLatestState; private float calmWatersAnimationSpeed; private void Awake() { waterVolume = ((Component)this).gameObject.GetComponent(); waterSurface = ((Component)waterVolume.m_waterSurface).gameObject.GetComponent(); managers[waterVolume] = this; GlobalWaterSurfaceManager.registerWaterSurfaceManager(this); meshLatestState = waterSurface.sharedMesh.vertices; calmWatersAnimationSpeed = ConfigLoader.getFloat("calmWatersAnimationSpeed"); meshFinalState = waterSurface.sharedMesh.vertices; extendRenderBounds(); } private void Start() { waterVolume.DetectWaterDepth(); originalNormalizedDepths = new float[4]; cornerNormalizedDepthFinalState = new float[4]; float[] normalizedDepth = waterVolume.m_normalizedDepth; for (int i = 0; i < 4; i++) { originalNormalizedDepths[i] = normalizedDepth[i]; cornerNormalizedDepthFinalState[i] = normalizedDepth[i]; } findInitialNearbyRunes(); } private void extendRenderBounds() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0084: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) Renderer val = (Renderer)(object)waterVolume.m_waterSurface; if ((Object)(object)val == (Object)null || (Object)(object)ZoneSystem.instance == (Object)null) { LogUtils.LogInfo("Values null, can't extend render bounds"); return; } Bounds bounds = val.bounds; float num = ZoneSystem.instance.m_waterLevel - ConfigLoader.getFloat("dryLand_depth") * 2f; Vector3 extents = ((Bounds)(ref bounds)).extents; float num2 = ((Bounds)(ref bounds)).center.y - extents.y; if (num < num2) { float num3 = num2 - num; Bounds bounds2 = waterSurface.sharedMesh.bounds; Vector3 extents2 = ((Bounds)(ref bounds2)).extents; extents2.y -= num3; ((Bounds)(ref bounds2)).extents = extents2; waterSurface.sharedMesh.bounds = bounds2; } } private void drawRenderBounds() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) Renderer val = (Renderer)(object)waterVolume.m_waterSurface; if (!((Object)(object)val == (Object)null)) { Bounds bounds = val.bounds; ((Bounds)(ref bounds)).extents = ((Bounds)(ref bounds)).extents * 0.95f; DebugUtils.DrawBounds(bounds, Color.green, Color.green, Color.red, 1f); } } private void OnDestroy() { managers.Remove(waterVolume); GlobalWaterSurfaceManager.unregisterWaterSurfaceManager(this); } public void registerRune(DryLandRune rune, bool shouldAnimate) { if (knownDryLandRunes.Contains(rune)) { return; } knownDryLandRunes.Add(rune); if (!shouldAnimate && !animatingSurface) { Vector3[] vertices = waterSurface.mesh.vertices; resetVertices(vertices); foreach (DryLandRune knownDryLandRune in knownDryLandRunes) { calculateRuneEffect(knownDryLandRune, vertices); } waterSurface.mesh.vertices = vertices; waterSurface.mesh.RecalculateNormals(); meshLatestState = vertices; } else { recalculateMeshFinalState(); } } public void unregisterRune(DryLandRune rune) { if (knownDryLandRunes.Contains(rune)) { knownDryLandRunes.Remove(rune); recalculateMeshFinalState(); } } public void registerRune(CalmWatersRune rune, bool wasPlacedByPlayer) { if (!knownCalmWatersRunes.Contains(rune)) { knownCalmWatersRunes.Add(rune); if (!wasPlacedByPlayer && !animatingDepth) { recalculateNormalizedDepthsFinalState(); calmWatersAnimationSpeed = ConfigLoader.getFloat("calmWatersAnimationSpeedFast"); } else { recalculateNormalizedDepthsFinalState(); } } } public void unregisterRune(CalmWatersRune rune) { if (knownCalmWatersRunes.Contains(rune)) { knownCalmWatersRunes.Remove(rune); recalculateNormalizedDepthsFinalState(); } } private void findInitialNearbyRunes() { //IL_001b: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) foreach (DryLandRune allInstance in DryLandRune.allInstances) { if (Utils.DistanceXZ(((Component)allInstance).transform.position, ((Component)this).transform.position) <= allInstance.getMaxEffectRadius() + WaterVolumePatch.surfaceSideLength) { knownDryLandRunes.Add(allInstance); } } foreach (CalmWatersRune allInstance2 in CalmWatersRune.allInstances) { Vector3 val = ((Component)allInstance2).transform.position - ((Component)this).transform.position; if (Math.Abs(val.x) <= WaterVolumePatch.surfaceSideLength * 2f && Math.Abs(val.z) <= WaterVolumePatch.surfaceSideLength * 2f) { knownCalmWatersRunes.Add(allInstance2); } } if (knownDryLandRunes.Count > 0) { Vector3[] vertices = waterSurface.mesh.vertices; resetVertices(vertices); foreach (DryLandRune knownDryLandRune in knownDryLandRunes) { calculateRuneEffect(knownDryLandRune, vertices); } waterSurface.mesh.vertices = vertices; waterSurface.mesh.RecalculateNormals(); meshLatestState = vertices; } if (knownCalmWatersRunes.Count > 0) { recalculateNormalizedDepthsFinalState(); animateDepth(1000f); } } public void InternalUpdate() { if (animatingSurface) { animateSurface(Time.deltaTime); } if (animatingDepth) { animateDepth(Time.deltaTime); } } private void animateSurface(float dt) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0090: Unknown result type (might be due to invalid IL or missing references) Vector3[] vertices = waterSurface.mesh.vertices; animatingSurface = false; float num = ConfigLoader.getFloat("oceanAnimationSpeed") * dt; float @float = ConfigLoader.getFloat("oceanMinimumAdjust"); for (int i = 0; i < vertices.Length; i++) { Vector3 val = meshFinalState[i]; float val2 = Math.Abs(val.y - vertices[i].y) * num; val2 = Math.Max(val2, @float); val2 = Math.Min(val2, Math.Abs(val.y - vertices[i].y)); if (val.y > vertices[i].y) { vertices[i].y += val2; } else { vertices[i].y -= val2; } if ((double)val2 > 1E-05) { animatingSurface = true; } } meshLatestState = vertices; waterSurface.mesh.vertices = vertices; waterSurface.mesh.RecalculateNormals(); } private void recalculateMeshFinalState() { resetVertices(meshFinalState); foreach (DryLandRune knownDryLandRune in knownDryLandRunes) { calculateRuneEffect(knownDryLandRune, meshFinalState); } animatingSurface = true; } private void resetVertices(Vector3[] vertices) { for (int i = 0; i < vertices.Length; i++) { vertices[i].y = 0f; } } private void calculateRuneEffect(DryLandRune rune, Vector3[] vertices) { //IL_000f: 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_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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_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) if ((Object)(object)rune == (Object)null || Utils.DistanceXZ(((Component)rune).transform.position, ((Component)this).transform.position) > rune.getMaxEffectRadius() + WaterVolumePatch.surfaceSideLength) { return; } Vector3 position = ((Component)rune).transform.position; position = ((Component)waterSurface).gameObject.transform.InverseTransformPoint(position); for (int i = 0; i < vertices.Length; i++) { float num = Utils.DistanceXZ(position, vertices[i]) * WaterVolumePatch.localToWorldDistanceScaleFactor; if (num < rune.getMaxEffectRadius()) { vertices[i].y = Math.Min(vertices[i].y, rune.calculateVerticalOffset(num)); } } } private void recalculateNormalizedDepthsFinalState() { //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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0093: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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_0186: 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_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: 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_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < originalNormalizedDepths.Length; i++) { cornerNormalizedDepthFinalState[i] = originalNormalizedDepths[i]; } float @float = ConfigLoader.getFloat("calmWatersBaseNormalizedDepth"); BoxCollider component = ((Component)waterVolume).gameObject.GetComponent(); Vector3[] array = (Vector3[])(object)new Vector3[4]; Transform transform = ((Component)waterVolume).transform; Bounds bounds = ((Collider)component).bounds; float num = (0f - ((Bounds)(ref bounds)).size.x) / 2f; bounds = ((Collider)component).bounds; array[0] = transform.TransformPoint(num, 0f, ((Bounds)(ref bounds)).size.z / 2f); Transform transform2 = ((Component)waterVolume).transform; bounds = ((Collider)component).bounds; float num2 = ((Bounds)(ref bounds)).size.x / 2f; bounds = ((Collider)component).bounds; array[1] = transform2.TransformPoint(num2, 0f, ((Bounds)(ref bounds)).size.z / 2f); Transform transform3 = ((Component)waterVolume).transform; bounds = ((Collider)component).bounds; float num3 = ((Bounds)(ref bounds)).size.x / 2f; bounds = ((Collider)component).bounds; array[2] = transform3.TransformPoint(num3, 0f, (0f - ((Bounds)(ref bounds)).size.z) / 2f); Transform transform4 = ((Component)waterVolume).transform; bounds = ((Collider)component).bounds; float num4 = (0f - ((Bounds)(ref bounds)).size.x) / 2f; bounds = ((Collider)component).bounds; array[3] = transform4.TransformPoint(num4, 0f, (0f - ((Bounds)(ref bounds)).size.z) / 2f); foreach (CalmWatersRune knownCalmWatersRune in knownCalmWatersRunes) { Vector3 position = ((Component)knownCalmWatersRune).transform.position; for (int j = 0; j < array.Length; j++) { Vector3 val = array[j]; if (Math.Abs(val.x - position.x) <= WaterVolumePatch.surfaceSideLength && Math.Abs(val.z - position.z) <= WaterVolumePatch.surfaceSideLength) { cornerNormalizedDepthFinalState[j] = Math.Min(@float, cornerNormalizedDepthFinalState[j]); } } } calmWatersAnimationSpeed = ConfigLoader.getFloat("calmWatersAnimationSpeed"); animatingDepth = true; } private void animateDepth(float dt) { animatingDepth = false; float num = calmWatersAnimationSpeed * dt; float @float = ConfigLoader.getFloat("calmWatersMinimumAdjust"); float[] array = Traverse.Create((object)waterVolume).Field("m_normalizedDepth").GetValue() as float[]; for (int i = 0; i < cornerNormalizedDepthFinalState.Length; i++) { float num2 = cornerNormalizedDepthFinalState[i]; float val = Math.Abs(num2 - array[i]) * num; val = Math.Max(val, @float); val = Math.Min(val, Math.Abs(num2 - array[i])); if (num2 > array[i]) { array[i] += val; } else { array[i] -= val; } if ((double)val > 1E-05) { animatingDepth = true; } } waterVolume.SetupMaterial(); } public Vector3[] getLatestWaterSurface() { return meshLatestState; } public bool isSurfaceAltered() { if (animatingSurface) { return true; } return knownDryLandRunes.Count > 0; } public static HashSet getManagers(Vector3 point, float radius) { //IL_0006: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_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) HashSet hashSet = new HashSet(); WaterSurfaceManager managerAtPoint = getManagerAtPoint(point); if ((Object)(object)managerAtPoint == (Object)null) { return hashSet; } float surfaceSideLength = WaterVolumePatch.surfaceSideLength; int num = (int)Math.Ceiling(radius / surfaceSideLength); for (int i = -num; i <= num; i++) { for (int j = -num; j <= num; j++) { Vector3 point2 = ((Component)managerAtPoint).transform.position + new Vector3((float)i * surfaceSideLength, 0f, (float)j * surfaceSideLength); WaterSurfaceManager managerAtPoint2 = getManagerAtPoint(point2); if ((Object)(object)managerAtPoint2 != (Object)null) { hashSet.Add(managerAtPoint2); } } } return hashSet; } public static WaterSurfaceManager getManagerAtPoint(Vector3 point) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Heightmap heightmap = HeightmapPatch.getHeightmap(point); if ((Object)(object)heightmap == (Object)null) { return null; } GameObject gameObject = ((Component)((Component)heightmap).transform.root).gameObject; return gameObject.GetComponentInChildren(); } public static void addToWaterVolumes() { WaterVolume[] array = Resources.FindObjectsOfTypeAll(); WaterVolume[] array2 = array; foreach (WaterVolume val in array2) { if ((Object)(object)val != (Object)null && (Object)(object)val.m_waterSurface != (Object)null && (Object)(object)((Component)val).GetComponentInParent(true) == (Object)null) { MeshFilter component = ((Component)val.m_waterSurface).gameObject.GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null && component.sharedMesh.vertexCount == 1025) { WaterVolumePatch.precalculateVertices(component); ((Component)val).gameObject.AddComponent(); } } } } } } namespace ValheimMod.Monobehaviours.Runes { [DefaultExecutionOrder(500)] public class ExtinguishingRune : MonoBehaviour { [CompilerGenerated] private sealed class d__23 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private int 5__2; private int 5__3; private int 5__4; private List 5__5; private int 5__6; private int 5__7; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__23(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = 10; 5__3 = Fire.s_fires.Count - 1; goto IL_00f5; case 1: <>1__state = -1; goto IL_00f5; case 2: <>1__state = -1; goto IL_01b5; case 3: <>1__state = -1; goto IL_01ed; case 4: <>1__state = -1; goto IL_0340; case 5: { <>1__state = -1; goto IL_0378; } IL_00f5: if (5__3 >= 0) { for (int i = 0; i < 5__2; i++) { while (5__3 >= Fire.s_fires.Count) { 5__3--; } if (5__3 < 0) { break; } Fire val = Fire.s_fires[5__3]; 5__3--; if (!((Object)(object)val == (Object)null) && (Object)(object)((Component)val).gameObject.GetComponent() == (Object)null) { PieceExtinguisher pieceExtinguisher = ((Component)val).gameObject.AddComponent(); pieceExtinguisher.killOnExtinguish = true; } } <>2__current = null; <>1__state = 1; return true; } 5__4 = Character.s_characters.Count - 1; goto IL_01ed; IL_01ed: if (5__4 >= 0) { 5__7 = 0; goto IL_01c5; } 5__5 = WearNTear.GetAllInstances(); 5__6 = 5__5.Count - 1; goto IL_0378; IL_0340: 5__7++; goto IL_0350; IL_0378: if (5__6 >= 0) { 5__7 = 0; goto IL_0350; } return false; IL_01b5: 5__7++; goto IL_01c5; IL_01c5: if (5__7 < 5__2) { while (5__4 >= Character.s_characters.Count) { 5__4--; } if (5__4 >= 0) { Character val2 = Character.s_characters[5__4]; 5__4--; if ((Object)(object)val2 != (Object)null && val2 is Humanoid) { Humanoid val3 = (Humanoid)val2; VisEquipmentPatch.setupItemExtinguishers(val3.m_visEquipment, val3); <>2__current = null; <>1__state = 2; return true; } goto IL_01b5; } } <>2__current = null; <>1__state = 3; return true; IL_0350: if (5__7 < 5__2) { while (5__6 >= 5__5.Count) { 5__6--; } if (5__6 >= 0) { WearNTear val4 = 5__5[5__6]; 5__6--; if (!((Object)(object)val4 == (Object)null)) { Fireplace component = ((Component)val4).gameObject.GetComponent(); CookingStation component2 = ((Component)val4).gameObject.GetComponent(); Smelter componentInChildren = ((Component)val4).gameObject.GetComponentInChildren(); if (!((Object)(object)component == (Object)null) || (!((Object)(object)component2 == (Object)null) && !((Object)(object)component2.m_haveFireObject == (Object)null)) || !((Object)(object)componentInChildren == (Object)null)) { GameObject val5 = ((component != null) ? ((Component)component).gameObject : null) ?? ((component2 != null) ? ((Component)component2).gameObject : null) ?? ((componentInChildren != null) ? ((Component)componentInChildren).gameObject : null); if ((Object)(object)val5.GetComponent() == (Object)null) { val5.AddComponent(); } <>2__current = null; <>1__state = 4; return true; } } goto IL_0340; } } <>2__current = null; <>1__state = 5; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly HashSet FIRE_ENEMIES = new HashSet { "BlobLava(Clone)", "Skeleton_Hildir(Clone)", "Skeleton_Hildir_nochest(Clone)", "Surtling(Clone)", "Troll_Summoned(Clone)" }; private float radius; private float runeEngravingAnimSpeed; private float runeEngravingMinGlow; private StaticTarget enemyTarget; private Coroutine pieceLoop; private PeriodicTrigger activityCheck; private PeriodicTrigger substrateCheck; private RangefindingChasmController chasmController; private float targetChasmAnim = 1f; private float currentChasmAnim = 1f; private Material projectorMaterial; private RuneProjector runeProjector; private LocalKeyword tracingDisableOverrideKeyword; private bool highQualityVisual = true; private SolidLavaRune solidLavaRune; private static HashSet allInstances = new HashSet(); public void Awake() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) if (PlayerPatch.PlayerCreatingGhost) { Object.Destroy((Object)(object)this); return; } radius = ConfigLoader.getBoundedFloat("ExtinguishingRune_EffectRadius", 0.5f, 31f); runeEngravingAnimSpeed = ConfigLoader.getFloat("ExtinguishingRune-animSpeed"); runeEngravingMinGlow = ConfigLoader.getFloat("ExtinguishingRune-minGlow"); runeProjector = ((Component)this).GetComponent(); if (allInstances.Count == 0) { setupNearbyCreatures(); } GameObject val = new GameObject("ExtinguishingRuneTarget"); val.transform.SetParent(((Component)this).transform, false); val.transform.localPosition = new Vector3(0f, 0.3f, 0f); enemyTarget = val.AddComponent(); enemyTarget.m_haveCenter = true; enemyTarget.m_localCenter = default(Vector3); enemyTarget.m_colliders = new List(); if (ConfigLoader.getInt("extinguishingRune_visualQuality") == 0) { highQualityVisual = false; } chasmController = ((Component)this).GetComponent(); projectorMaterial = ((Renderer)chasmController.chasmRenderer).material; tracingDisableOverrideKeyword = new LocalKeyword(projectorMaterial.shader, "_PLAINDECALOVERRIDE_ON"); if (highQualityVisual) { projectorMaterial.SetKeyword(ref tracingDisableOverrideKeyword, false); } activityCheck = new PeriodicTrigger(2f); substrateCheck = new PeriodicTrigger(10f); setMaterialProperties(); solidLavaRune = ((Component)this).GetComponent(); if (allInstances.Count == 0) { pieceLoop = ((MonoBehaviour)ZNetScene.instance).StartCoroutine(SetupNearbyExtinguishables()); } allInstances.Add(this); } private void Start() { if (highQualityVisual) { recalculateSubstrates(); } } private void OnDestroy() { if ((Object)(object)projectorMaterial != (Object)null) { Object.Destroy((Object)(object)projectorMaterial); projectorMaterial = null; } allInstances.Remove(this); } private void Update() { //IL_000b: 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_007e: 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_0105: Unknown result type (might be due to invalid IL or missing references) if (ZNetScene.instance.OutsideActiveArea(((Component)this).transform.position)) { return; } activityCheck.update(Time.deltaTime); if (activityCheck.shouldTrigger()) { bool flag = false; if ((Object)(object)solidLavaRune != (Object)null && solidLavaRune.getHasNearbyLava()) { flag = true; } else { bool flag2 = PieceExtinguisher.getActiveInRange(((Component)this).transform.position, radius).Count > 0; bool flag3 = ItemExtinguisher.anyInRange(((Component)this).transform.position, radius); bool flag4 = DamageFireEnemies.anyInRange(((Component)this).transform.position, radius); flag = flag2 || flag3 || flag4; } targetChasmAnim = ((!flag) ? 1 : 0); } if (highQualityVisual) { substrateCheck.update(Time.deltaTime); if (substrateCheck.shouldTrigger()) { GameCamera instance = GameCamera.instance; if (instance != null && (instance.m_camera?.IsInView(((Component)this).transform.position)).GetValueOrDefault()) { recalculateSubstrates(); } } } float num = Mathf.MoveTowards(currentChasmAnim, targetChasmAnim, runeEngravingAnimSpeed * Time.deltaTime); if (num != currentChasmAnim) { currentChasmAnim = num; setMaterialProperties(); } } private void setupNearbyCreatures() { ValheimMod.DevModeLog("ExtinguishingRune.setupNearbyCreatures() called"); foreach (Character s_character in Character.s_characters) { if (isFireEnemy(((Component)s_character).gameObject) && (Object)(object)((Component)s_character).gameObject.GetComponent() == (Object)null) { ((Component)s_character).gameObject.AddComponent(); } } } public StaticTarget getStaticTarget() { return enemyTarget; } [IteratorStateMachine(typeof(d__23))] private IEnumerator SetupNearbyExtinguishables() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__23(0); } private void recalculateSubstrates() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) chasmController.substrates.Clear(); Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, 1f, LayerMask.GetMask(new string[2] { "static_solid", "piece" }), (QueryTriggerInteraction)1); Collider[] array2 = array; foreach (Collider val in array2) { GameObject val2 = ValheimMod.findPrefixInTree(((Component)val).gameObject, ValheimMod.standingStoneNames); MeshFilter val3 = ((val2 != null) ? val2.GetComponentInChildren() : null); if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val3 == (Object)null)) { chasmController.substrates.Add(val3); } } chasmController.generateRangeTexture(substrateChanged: true); chasmController.setTexturesOnRenderer(); } private void setMaterialProperties() { //IL_0058: 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_006e: 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_008a: Unknown result type (might be due to invalid IL or missing references) if (highQualityVisual) { float num = Mathf.Lerp(0f, 1.57f, currentChasmAnim * currentChasmAnim); projectorMaterial.SetFloat("_ChasmSlope", num); runeProjector.setIntensity(Mathf.Lerp(1f, runeEngravingMinGlow, currentChasmAnim)); } else { Color val = Color.Lerp(Color.black, runeProjector.runeColor * runeEngravingMinGlow, currentChasmAnim); projectorMaterial.SetColor("_Color", val); } } public static bool isFireEnemy(GameObject target) { return FIRE_ENEMIES.Contains(((Object)target).name); } public static bool anyInRange(Vector3 pos) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) foreach (ExtinguishingRune allInstance in allInstances) { if (MathUtils.distanceXZSqr(((Component)allInstance).transform.position, pos) <= allInstance.radius * allInstance.radius) { return true; } } return false; } public static ExtinguishingRune closestInRange(Vector3 pos) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) float num = float.MaxValue; ExtinguishingRune result = null; foreach (ExtinguishingRune allInstance in allInstances) { float num2 = MathUtils.distanceXZSqr(((Component)allInstance).transform.position, pos); if (num2 <= allInstance.radius * allInstance.radius && num2 < num) { num = num2; result = allInstance; } } return result; } public static bool anyActive() { return allInstances.Count != 0; } } [DefaultExecutionOrder(500)] public class SolidLavaRune : MonoBehaviour { private struct SetupInfo { public float areaStartRadius; public float areaStartCollapse; } [CompilerGenerated] private sealed class d__18 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public SolidLavaRune <>4__this; private Vector2 5__2; private int[] 5__3; private float 5__4; private int 5__5; private int 5__6; private HashSet.Enumerator <>7__wrap6; private Heightmap 5__8; private int 5__9; private int 5__10; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__18(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } 5__3 = null; <>7__wrap6 = default(HashSet.Enumerator); 5__8 = null; <>1__state = -2; } private bool MoveNext() { //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_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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_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_014c: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: 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) bool result; try { int num = <>1__state; SolidLavaRune solidLavaRune = <>4__this; if (num == 0) { <>1__state = -1; float maxVisualRadius = solidLavaRune.area.getMaxVisualRadius(); 5__2 = ((Component)solidLavaRune).transform.position.GetXZVector(); HashSet affectedHeightmapCoords = HeightmapPatch.getAffectedHeightmapCoords(5__2, maxVisualRadius, inclusive: true); 5__3 = new int[Mathf.CeilToInt(maxVisualRadius)]; 5__4 = ConfigLoader.getFloat("pathOfIce-lavaTransitionPoint"); 5__5 = 10; 5__6 = 0; <>7__wrap6 = affectedHeightmapCoords.GetEnumerator(); <>1__state = -3; goto IL_0247; } if (num == 1) { <>1__state = -3; goto IL_01ec; } result = false; goto end_IL_0000; IL_01ec: 5__10++; goto IL_01fe; IL_0228: if (5__9 < 5__8.m_width + 1) { 5__10 = 0; goto IL_01fe; } 5__8 = null; goto IL_0247; IL_01fe: if (5__10 >= 5__8.m_width + 1) { 5__9++; goto IL_0228; } float lavaFactor = LavaSolidifier.getLavaFactor(5__8, 5__10, 5__9); if (lavaFactor >= 5__4) { Vector3 vec = 5__8.CalcVertex(5__10, 5__9) + ((Component)5__8).transform.position; Vector2 val = 5__2 - vec.GetXZVector(); float magnitude = ((Vector2)(ref val)).magnitude; int num2 = Mathf.Max(0, Mathf.CeilToInt(magnitude) - 1); if (num2 < 5__3.Length) { 5__3[num2]++; solidLavaRune.hasNearbyLava = true; result = false; goto IL_025f; } } 5__6++; if (5__6 < 5__5) { goto IL_01ec; } 5__6 = 0; <>2__current = null; <>1__state = 1; result = true; goto end_IL_0000; IL_025f: <>m__Finally1(); goto end_IL_0000; IL_0247: if (<>7__wrap6.MoveNext()) { Vector2i current = <>7__wrap6.Current; 5__8 = HeightmapPatch.getHeightmap(current); if ((Object)(object)5__8 == (Object)null) { ValheimMod.DevModeWarn("SolidLavaRune found null heightmap when looking for lava"); solidLavaRune.hasNearbyLava = true; result = false; goto IL_025f; } 5__9 = 0; goto IL_0228; } <>m__Finally1(); <>7__wrap6 = default(HashSet.Enumerator); if (!solidLavaRune.hasNearbyLava) { LogUtils.LogInfo("No nearby lava found, destroying. " + string.Join(", ", 5__3)); Object.Destroy((Object)(object)solidLavaRune); } result = false; end_IL_0000:; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap6).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private const string UUID_KEY = "uuid"; private const string CREATION_TIME_KEY = "createdAt"; public const float MAX_CONFIG_RADIUS = 31f; private ZNetView nView; private ManagedSolidLavaArea area; private string uuid; private float creationTime; public float maxRadius; public float baseExpansionRate; private bool hasNearbyLava; private static Dictionary uuidMap = new Dictionary(); public void Awake() { //IL_0014: 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_011b: 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_0145: Unknown result type (might be due to invalid IL or missing references) if (PlayerPatch.PlayerCreatingGhost) { Object.Destroy((Object)(object)this); return; } if (!WorldGenerator.IsAshlands(((Component)this).transform.position.x, ((Component)this).transform.position.z)) { Object.Destroy((Object)(object)this); return; } baseExpansionRate = ConfigLoader.getFloat("SolidLavaRune-expansionRate"); maxRadius = ConfigLoader.getBoundedFloat("ExtinguishingRune_EffectRadius", 0.5f, 31f); nView = ((Component)this).GetComponent(); if (nView.IsValid()) { uuid = nView.GetZDO().GetString("uuid", ""); if (uuid == "") { if (nView.IsOwner()) { uuid = Guid.NewGuid().ToString(); nView.GetZDO().Set("uuid", uuid); ManagedSolidLavaArea.initUUID = uuid; GameObject prefabFromAssetBundle = AssetLoader.GetPrefabFromAssetBundle("Lava/ManagedSolidArea"); area = Object.Instantiate(prefabFromAssetBundle, ((Component)this).transform.position, Quaternion.identity).GetComponent(); ManagedSolidLavaArea.initUUID = null; SetupInfo setupInfo = findLargestStartingRadius(((Component)area).transform.position); area.radius = setupInfo.areaStartRadius; area.initialCollapse = setupInfo.areaStartCollapse; float num = (0f - maxRadius / baseExpansionRate) * Mathf.Log((maxRadius - setupInfo.areaStartRadius) / maxRadius); nView.GetZDO().Set("createdAt", (float)ZNet.instance.GetTimeSeconds() - num); } else { LogUtils.LogWarning("Not owner but no UUID set during Awake on SolidLavaRune"); } } uuidMap.Add(uuid, this); } else { LogUtils.LogWarning("ZNetView not valid during Awake on SolidLavaRune"); } } public void Start() { //IL_007e: 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) area = ManagedSolidLavaArea.getById(uuid); if ((Object)(object)area == (Object)null) { LogUtils.LogError("No corresponding CenteredSolidLavaArea found for rune, destroying"); ZNetScene.instance.Destroy(((Component)this).gameObject); return; } if (nView.IsValid()) { creationTime = nView.GetZDO().GetFloat("createdAt", -1f); area.radius = getCalculatedRadius(); GlobalLavaSolidifier.recalculateColliders(((Component)this).transform.position, area.getCollisionRadius()); GlobalLavaVisualsHandler.recalculateVisuals(((Component)this).transform.position, area.getMaxVisualRadius()); } else { LogUtils.LogWarning("ZNetView not valid during start on SolidLavaRune"); } ((MonoBehaviour)this).StartCoroutine(FindNearbyLava()); } private void OnDestroy() { if (uuid != null) { uuidMap.Remove(uuid); } } private void Update() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (nView.IsValid() && !ZNetScene.instance.OutsideActiveArea(((Component)this).transform.position) && maxRadius - area.radius > 0.01f) { area.updateRadius(getCalculatedRadius()); } } private float getCalculatedRadius() { float num = (float)ZNet.instance.GetTimeSeconds() - creationTime; float num2 = Mathf.Exp((0f - baseExpansionRate) * num / maxRadius); return maxRadius * (1f - num2); } private static SetupInfo findLargestStartingRadius(Vector3 areaPos) { //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_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00c7: Unknown result type (might be due to invalid IL or missing references) Vector2i terrainCoord = HeightmapPatch.getTerrainCoord(areaPos); SetupInfo result = default(SetupInfo); result.areaStartRadius = 0f; result.areaStartCollapse = 0f; Vector3 val; foreach (SolidLavaArea item in GlobalLavaSolidifier.getSolidAreasInSector(terrainCoord)) { val = areaPos - item.getTransform().position; float magnitude = ((Vector3)(ref val)).magnitude; float num = item.getShaderRadius() - magnitude; if (num > result.areaStartRadius) { result.areaStartRadius = num; result.areaStartCollapse = item.getCollapse(); } } foreach (SolidLavaHole item2 in GlobalLavaSolidifier.getHolesInSector(terrainCoord)) { val = areaPos - ((Component)item2).transform.position; float magnitude2 = ((Vector3)(ref val)).magnitude; result.areaStartRadius = Mathf.Min(result.areaStartRadius, magnitude2 - item2.getSolidRadius()); } return result; } [IteratorStateMachine(typeof(d__18))] private IEnumerator FindNearbyLava() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__18(0) { <>4__this = this }; } public bool getHasNearbyLava() { return hasNearbyLava; } public static SolidLavaRune getById(string uuid) { if (uuidMap.ContainsKey(uuid)) { return uuidMap[uuid]; } return null; } public static int getInstanceCount() { return uuidMap.Count; } } public class VentilationRune : MonoBehaviour { [CompilerGenerated] private sealed class d__44 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private int 5__2; private int 5__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__44(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = 2; LogUtils.LogDebug("ChimneyRune smoke tracking setup start"); 5__3 = SmokeSpawner.Instances.Count - 1; break; case 1: <>1__state = -1; break; } if (5__3 >= 0) { for (int i = 0; i < 5__2; i++) { int count = SmokeSpawner.Instances.Count; if (5__3 >= count) { 5__3 = count - 1; } if (5__3 < 0) { break; } SmokeSpawner val = (SmokeSpawner)SmokeSpawner.Instances[5__3]; 5__3--; if (!((Object)(object)val == (Object)null)) { SmokeSpawnerPatch.setupSmokeTracker(val); } } <>2__current = null; <>1__state = 1; return true; } LogUtils.LogDebug("ChimneyRune smoke tracking setup complete"); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static float MIN_SMOKE_SPAWN_RADIUS = 0.2f; private static Particle[] particles = (Particle[])(object)new Particle[256]; private Material projectorMaterial; private Light pointLight; private float prevLightTemp; private static HashSet allInstances = new HashSet(); public static bool isVentilationRuneSpawning = false; public List directSmokeSystems = new List(); public List areaSmokeSystems = new List(); public SmokeSpawner spawner; public GameObject activeEffects; private float timeSinceGlowCheck; private float glowCheckDelay = 1f; private float nearbyFireSize; private float lastBlockedChangeTime; private bool particlesCollisionFound; private float effectRadius; private float lastSpawnCheck; private float spawnDelay = 0.5f; private float targetTemperature; private float targetDesaturation; private float currentTemperature; private float currentDesaturation; private Aoe burnArea; private SphereCollider smokedArea; private Coroutine setupCoroutine; private int smokeLayer; private float particleSmokeSpawnChance; private float particleFadeOutDistance; private float smokeMinRadius; private float smokeMaxRadius; private float smokeExpansionThreshold; private float fireSizeAtMaxSmoke; private float fireSizeAtMaxTemperature; private float baseSmokeballSpawnDelay; private float runeGlowChangeSpeed; private float minTemperatureForBurn; public bool isBlocked { get; private set; } private void Awake() { //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) if (PlayerPatch.PlayerCreatingGhost || Application.isEditor) { Object.Destroy((Object)(object)spawner); Object.Destroy((Object)(object)this); return; } smokeLayer = LayerMaskUtils.NameToLayer("smoke"); effectRadius = ConfigLoader.getFloat("Ventilation_EffectRadius"); particleSmokeSpawnChance = ConfigLoader.getFloat("Ventilation_particlesRoofSpawnChance"); particleFadeOutDistance = ConfigLoader.getFloat("Ventilation_particlesRoofDistance"); smokeMinRadius = ConfigLoader.getFloat("Ventilation_areaSmokeRadius_min"); smokeMaxRadius = ConfigLoader.getFloat("Ventilation_areaSmokeRadius_max"); smokeExpansionThreshold = ConfigLoader.getFloat("Ventilation_areaSmokeRadius_expansionThreshold"); fireSizeAtMaxSmoke = ConfigLoader.getFloat("Ventilation-fireSizeAtMaxSmoke"); fireSizeAtMaxTemperature = ConfigLoader.getFloat("Ventilation-fireSizeAtMaxTemp"); baseSmokeballSpawnDelay = ConfigLoader.getFloat("Ventilation_smokeSpawnDelay"); runeGlowChangeSpeed = ConfigLoader.getFloat("Ventilation_glowFadeSpeed"); minTemperatureForBurn = ConfigLoader.getFloat("Ventilation_burnTemperatureThresholdMin"); spawner.m_smokePrefab = SoftReferenceUtils.smokeBall.getAsset(); spawner.m_interval = 3.1536E+13f; MeshRenderer componentInChildren = ((Component)this).gameObject.GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { LogUtils.LogError("Gameobject " + ((Object)((Component)this).gameObject).name + " doesn't have a MeshRenderer!"); ZNetScene.instance.Destroy(((Component)this).gameObject); return; } projectorMaterial = ((Renderer)componentInChildren).material; currentTemperature = 0f; currentDesaturation = 0f; projectorMaterial.SetFloat("_temperature", currentTemperature); projectorMaterial.SetFloat("_desaturate", currentDesaturation); burnArea = ((Component)activeEffects.transform.Find("BurnArea")).gameObject.GetComponent(); smokedArea = ((Component)activeEffects.transform.Find("SmokedArea")).GetComponent(); activeEffects.SetActive(false); pointLight = ((Component)this).gameObject.GetComponentInChildren(); if (allInstances.Count == 0) { setupCoroutine = ((MonoBehaviour)ZNetScene.instance).StartCoroutine(SetupSmokeTrackers()); } allInstances.Add(this); foreach (ParticleSystem directSmokeSystem in directSmokeSystems) { EmissionModule emission = directSmokeSystem.emission; ((EmissionModule)(ref emission)).enabled = false; } recalculateVFX(); } private void OnDisable() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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) foreach (ParticleSystem directSmokeSystem in directSmokeSystems) { ((Component)directSmokeSystem).gameObject.transform.parent = null; MainModule main = directSmokeSystem.main; directSmokeSystem.Stop(true, (ParticleSystemStopBehavior)1); Object.Destroy((Object)(object)((Component)directSmokeSystem).gameObject, 15f); } foreach (ParticleSystem areaSmokeSystem in areaSmokeSystems) { ((Component)areaSmokeSystem).gameObject.transform.parent = null; MainModule main2 = areaSmokeSystem.main; areaSmokeSystem.Stop(true, (ParticleSystemStopBehavior)1); Object.Destroy((Object)(object)((Component)areaSmokeSystem).gameObject, 15f); } } private void OnDestroy() { if ((Object)(object)projectorMaterial != (Object)null) { Object.Destroy((Object)(object)projectorMaterial); } allInstances.Remove(this); } [IteratorStateMachine(typeof(d__44))] private IEnumerator SetupSmokeTrackers() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__44(0); } private void Update() { //IL_0017: 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) if ((Object)(object)Player.m_localPlayer == (Object)null || Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)this).transform.position) > 64f + effectRadius) { return; } timeSinceGlowCheck += Time.deltaTime; if (timeSinceGlowCheck > glowCheckDelay) { timeSinceGlowCheck = 0f; checkBlocked(); recalculateVFX(); particlesRoofCheck(); } if (nearbyFireSize > 0f) { lastSpawnCheck += Time.deltaTime; spawnDelay = baseSmokeballSpawnDelay * Mathf.Lerp(1f, 0.5f, Mathf.Clamp01(nearbyFireSize / fireSizeAtMaxSmoke)); if (lastSpawnCheck >= spawnDelay) { lastSpawnCheck = 0f; SpawnSmoke(); } } currentTemperature = Mathf.MoveTowards(currentTemperature, targetTemperature, runeGlowChangeSpeed * Time.deltaTime); currentDesaturation = Mathf.MoveTowards(currentDesaturation, targetDesaturation, 0.5f * Time.deltaTime); float num = Mathf.Lerp(currentTemperature, 0.35f, currentDesaturation); projectorMaterial.SetFloat("_temperature", num); projectorMaterial.SetFloat("_desaturate", currentDesaturation); if ((Object)(object)pointLight != (Object)null && prevLightTemp != num) { prevLightTemp = num; updateLight(num); } ((Component)burnArea).gameObject.SetActive(num > minTemperatureForBurn); burnArea.m_damage.m_fire = Mathf.InverseLerp(minTemperatureForBurn, 1f, num) * 10f; spawner.m_time = 0f; if (particlesCollisionFound) { particlesRoofDecay(); } } private void checkBlocked() { //IL_001c: 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_008f: Unknown result type (might be due to invalid IL or missing references) if (Time.time - lastBlockedChangeTime > 4f) { Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, ConfigLoader.getFloat("Ventilation_nearbySmokeRadius"), LayerMaskUtils.GetMask("smoke"), (QueryTriggerInteraction)1); bool flag = ((!isBlocked) ? ((float)array.Length > ConfigLoader.getFloat("Ventilation_nearbySmokeMax")) : ((float)array.Length > ConfigLoader.getFloat("Ventilation_nearbySmokeMin"))); float num = default(float); if (Heightmap.GetHeight(((Component)this).transform.position, ref num) && num > ((Component)this).transform.position.y + 0.5f) { ZNetScene.instance.Destroy(((Component)this).gameObject); } if (flag != isBlocked) { lastBlockedChangeTime = Time.time; } isBlocked = flag; } } public void recalculateVFX() { //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_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: 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_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: 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) nearbyFireSize = 0f; foreach (VentilationSmokeTracker allInstance in VentilationSmokeTracker.allInstances) { if ((Object)(object)allInstance.getOwningRune() == (Object)(object)this && !isBlocked) { nearbyFireSize += allInstance.fireSize; } } activeEffects.SetActive(nearbyFireSize > 0f); if (isBlocked) { targetDesaturation = 1f; foreach (ParticleSystem directSmokeSystem in directSmokeSystems) { EmissionModule emission = directSmokeSystem.emission; ((EmissionModule)(ref emission)).enabled = false; } { foreach (ParticleSystem areaSmokeSystem in areaSmokeSystems) { EmissionModule emission2 = areaSmokeSystem.emission; ((EmissionModule)(ref emission2)).rateOverTime = MinMaxCurve.op_Implicit(0f); } return; } } if (nearbyFireSize == 0f) { targetTemperature = 0f; targetDesaturation = 0f; foreach (ParticleSystem directSmokeSystem2 in directSmokeSystems) { EmissionModule emission3 = directSmokeSystem2.emission; ((EmissionModule)(ref emission3)).enabled = false; } { foreach (ParticleSystem areaSmokeSystem2 in areaSmokeSystems) { EmissionModule emission4 = areaSmokeSystem2.emission; ((EmissionModule)(ref emission4)).rateOverTime = MinMaxCurve.op_Implicit(0f); } return; } } float num = Mathf.InverseLerp(0f, fireSizeAtMaxTemperature, nearbyFireSize); float num2 = Mathf.InverseLerp(1f, fireSizeAtMaxSmoke, nearbyFireSize); targetTemperature = num; targetDesaturation = 0f; targetTemperature = Mathf.Max(targetTemperature, ConfigLoader.getFloat("Ventilation_minTargetTemp")); float num3 = Mathf.Lerp(ConfigLoader.getFloat("Ventilation_constantAreaSmoke_minRate"), ConfigLoader.getFloat("Ventilation_constantAreaSmoke_maxRate"), num2); float @float = ConfigLoader.getFloat("Ventilation_areaSmokeRadiusThickness"); float float2 = ConfigLoader.getFloat("Ventilation_SmokedOutArea_rateThreshold"); foreach (ParticleSystem areaSmokeSystem3 in areaSmokeSystems) { EmissionModule emission5 = areaSmokeSystem3.emission; float num4 = smokeMinRadius; float smokeRadius = getSmokeRadius(); float densityPerSec = num3 / ((float)Math.PI * num4 * num4); float rateByDensity = getRateByDensity(densityPerSec, smokeRadius); ((EmissionModule)(ref emission5)).rateOverTime = MinMaxCurve.op_Implicit(rateByDensity); ShapeModule shape = areaSmokeSystem3.shape; ((ShapeModule)(ref shape)).radius = smokeRadius; ((ShapeModule)(ref shape)).radiusThickness = @float; ((Component)smokedArea).gameObject.SetActive(rateByDensity >= float2); smokedArea.radius = smokeRadius; ((Component)areaSmokeSystem3).transform.rotation = Quaternion.LookRotation(Vector3.forward, Vector3.up); } } private void particlesRoofCheck() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) int mask = LayerMaskUtils.GetMask("Piece"); particlesCollisionFound = false; RaycastHit val = default(RaycastHit); foreach (ParticleSystem areaSmokeSystem in areaSmokeSystems) { int num = areaSmokeSystem.GetParticles(particles); for (int i = 0; i < num; i++) { if (((Particle)(ref particles[i])).rotation != 0f) { particlesCollisionFound = true; continue; } Vector3 position = ((Particle)(ref particles[i])).position; if (Physics.Raycast(new Ray(position, Vector3.up), ref val, 3f, mask, (QueryTriggerInteraction)1)) { ((Particle)(ref particles[i])).rotation = 0.001f; ((Particle)(ref particles[i])).axisOfRotation = ((RaycastHit)(ref val)).point; particlesCollisionFound = true; } } areaSmokeSystem.SetParticles(particles, num); } } private void particlesRoofDecay() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00ab: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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) float num = Time.deltaTime / particleFadeOutDistance; foreach (ParticleSystem areaSmokeSystem in areaSmokeSystems) { int num2 = areaSmokeSystem.GetParticles(particles); for (int i = 0; i < num2; i++) { if (((Particle)(ref particles[i])).rotation == 0f) { continue; } Vector3 axisOfRotation = ((Particle)(ref particles[i])).axisOfRotation; float num3 = axisOfRotation.y - ((Particle)(ref particles[i])).position.y; if (!(num3 < particleFadeOutDistance)) { continue; } Color val = Color32.op_Implicit(((Particle)(ref particles[i])).startColor); val.a -= num; ((Particle)(ref particles[i])).startColor = Color32.op_Implicit(val); if (val.a <= 0f) { ((Particle)(ref particles[i])).remainingLifetime = 0f; if (Random.Range(0f, 1f) < particleSmokeSpawnChance) { isVentilationRuneSpawning = true; GameObject val2 = Object.Instantiate(spawner.m_smokePrefab, ((Particle)(ref particles[i])).position, Quaternion.identity); isVentilationRuneSpawning = false; } } } areaSmokeSystem.SetParticles(particles, num2); } } private float getRateByDensity(float densityPerSec, float radius) { float num = (float)Math.PI * radius * radius; return densityPerSec * num; } public void SpawnSmoke() { //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) Vector3 spawnPos = getSpawnPos(); ((Component)spawner).transform.position = spawnPos; isVentilationRuneSpawning = true; ((Component)smokedArea).gameObject.layer = 0; spawner.Spawn(Time.time); ((Component)smokedArea).gameObject.layer = smokeLayer; isVentilationRuneSpawning = false; } private float getSmokeRadius() { float num = Mathf.InverseLerp(smokeExpansionThreshold, fireSizeAtMaxSmoke, nearbyFireSize); return Mathf.Lerp(smokeMinRadius, smokeMaxRadius, num); } private float getSmokeballSpawnRadius() { float num = 2f; return Math.Max(MIN_SMOKE_SPAWN_RADIUS, getSmokeRadius() - num / 2f); } private Vector3 getSpawnPos() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_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) float smokeballSpawnRadius = getSmokeballSpawnRadius(); Quaternion val = Quaternion.AngleAxis((float)Random.Range(0, 360), Vector3.up); Vector3 val2 = val * Vector3.forward; float num = smokeballSpawnRadius; return ((Component)this).transform.position + val2 * Random.Range(MIN_SMOKE_SPAWN_RADIUS, num); } private void updateLight(float temperature) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Lerp(0.6f, 0.9f, temperature); float num2 = Mathf.InverseLerp(0f, 0.433f, num); float num3 = Mathf.InverseLerp(0.333f, 1f, num); float num4 = Mathf.InverseLerp(0.666f, 1f, num); float num5 = (num2 + num3 + num4) / 3f; num2 = Mathf.Lerp(num2, num5, currentDesaturation); num3 = Mathf.Lerp(num3, num5, currentDesaturation); num4 = Mathf.Lerp(num4, num5, currentDesaturation); pointLight.color = new Color(num2, num3, num4); pointLight.intensity = Mathf.InverseLerp(0.3f, 0.4f, temperature) + Mathf.InverseLerp(0.4f, 1f, temperature) * 0.2f; } public static bool anyActive() { return allInstances.Count > 0; } public static VentilationRune findNearestInRange(Vector3 pos) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) VentilationRune ventilationRune = null; float num = float.MaxValue; VentilationRune ventilationRune2 = null; float num2 = float.MaxValue; foreach (VentilationRune allInstance in allInstances) { if (!((Object)(object)allInstance == (Object)null)) { float num3 = Utils.DistanceXZ(((Component)allInstance).transform.position, pos); if (num3 <= allInstance.effectRadius && num3 < num && !allInstance.isBlocked) { ventilationRune = allInstance; num = num3; } if (num3 <= allInstance.effectRadius && num3 < num2) { ventilationRune2 = allInstance; num2 = num3; } } } return ventilationRune ?? ventilationRune2; } } } namespace ValheimMod.Monobehaviours.InProgress { public class FastRestorationRune : MonoBehaviour, ZNetViewHook, ResizableRune { private const string BASE_RADIUS_KEY = "effectRadius"; private const string CURRENT_RADIUS_KEY = "currentRadius"; public float effectRadius; private float adjustmentSpeed; private float minAdjust; private float repaintSpeed; private TerrainHolder terrainHolder; private ZNetView nview; private GameObject glowVFX; private List glowVFXRenderers = new List(); private float currentRadius; private long framesSincePropagatingTerrain; private float ringWidth; private float edgeSize; private float vfxRadius; public void PostZNetViewAwake(ZNetView view) { } public void setSize(float size) { effectRadius = size; } public float getSize() { return effectRadius; } } internal class RadiusIndicatorGhostVFX : MonoBehaviour { public string radiusConfigKey = ""; private List pSystems = new List(); private Dictionary originalRadii = new Dictionary(); private Dictionary originalEmission = new Dictionary(); private void Awake() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) ParticleSystem[] componentsInChildren = ((Component)this).GetComponentsInChildren(); foreach (ParticleSystem val in componentsInChildren) { pSystems.Add(val); ShapeModule shape = val.shape; originalRadii[val] = ((ShapeModule)(ref shape)).radius; EmissionModule emission = val.emission; Dictionary dictionary = originalEmission; MinMaxCurve rateOverTime = ((EmissionModule)(ref emission)).rateOverTime; dictionary[val] = ((MinMaxCurve)(ref rateOverTime)).constant; } } private void Update() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Invalid comparison between Unknown and I4 //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) float @float = ConfigLoader.getFloat(radiusConfigKey); ((Component)this).transform.rotation = Quaternion.LookRotation(Vector3.forward, Vector3.up); foreach (ParticleSystem pSystem in pSystems) { ShapeModule shape = pSystem.shape; ((ShapeModule)(ref shape)).radius = @float; EmissionModule emission = pSystem.emission; if ((int)((ShapeModule)(ref shape)).shapeType == 4) { float num = (float)Math.PI * 2f * originalRadii[pSystem] * ((ShapeModule)(ref shape)).length; float num2 = (float)Math.PI * 2f * @float * ((ShapeModule)(ref shape)).length; MinMaxCurve rateOverTime = ((EmissionModule)(ref emission)).rateOverTime; ((MinMaxCurve)(ref rateOverTime)).constant = num2 / num * originalEmission[pSystem]; ((EmissionModule)(ref emission)).rateOverTime = rateOverTime; } else if ((int)((ShapeModule)(ref shape)).shapeType == 0) { float num3 = (float)Math.PI * 4f * originalRadii[pSystem] * originalRadii[pSystem]; float num4 = (float)Math.PI * 4f * @float * @float; MinMaxCurve rateOverTime2 = ((EmissionModule)(ref emission)).rateOverTime; ((MinMaxCurve)(ref rateOverTime2)).constant = num4 / num3 * originalEmission[pSystem]; ((EmissionModule)(ref emission)).rateOverTime = rateOverTime2; } } } } } namespace ValheimMod.Monobehaviours.Lava { [DefaultExecutionOrder(600)] public class ManagedSolidLavaArea : MonoBehaviour, SolidLavaArea { private const string INDEX_KEY = "creationIndex"; private const string CRACKS_KEY = "cracksAnimTarget"; private const string UUID_KEY = "uuid"; public float radius; public float initialCollapse; private NetSyncFloat collapse; private bool isCollapsing; public float collapseRate; public float maxRadius; private ZNetView nView; private long creationIndex = -1L; private bool isAreaLoaded; private PeriodicTrigger loadingCheck = new PeriodicTrigger(2f); public static string initUUID; private string uuid; private static HashSet allAreas = new HashSet(); private static Dictionary uuidMap = new Dictionary(); private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0050: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)this).transform.position; position.x = (float)Mathf.RoundToInt(position.x * 2f) / 2f; position.z = (float)Mathf.RoundToInt(position.z * 2f) / 2f; ((Component)this).transform.position = position; maxRadius = ConfigLoader.getBoundedFloat("ExtinguishingRune_EffectRadius", 0.5f, 31f); collapseRate = ConfigLoader.getFloat("SolidLavaRune-shrinkRate"); allAreas.Add(this); nView = ((Component)this).GetComponent(); if (initUUID != null) { uuid = initUUID; } if (nView.IsValid()) { string @string = nView.GetZDO().GetString("uuid", ""); if (@string != "" && uuid != null) { LogUtils.LogWarning("CenteredSolidLavaArea had a stored uuid while a new one was also assigned!"); } else if (@string == "" && uuid == null) { LogUtils.LogError("CenteredSolidLavaArea had no stored or assigned uuid, destroying!"); ZNetScene.instance.Destroy(((Component)this).gameObject); return; } if (uuid == null) { uuid = @string; } uuidMap.Add(uuid, this); if (nView.IsOwner()) { nView.GetZDO().Set("uuid", uuid); creationIndex = (long)(ZNet.instance.GetTimeSeconds() * 10.0); nView.GetZDO().Set("creationIndex", creationIndex); LogUtils.LogDebug("CenteredLavaArea znetview set up, visIndex " + creationIndex); } } else { LogUtils.LogError("ZNetView not valid during Awake on CenteredSolidLavaArea"); } } private void Start() { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) if (nView.IsValid()) { if (!nView.IsOwner()) { creationIndex = nView.GetZDO().GetLong("creationIndex", -1L); LogUtils.LogDebug("CenteredLavaArea start, visIndex " + creationIndex); } collapse = new NetSyncFloat(nView, "cracksAnimTarget", 2f, (float v) => Mathf.MoveTowards(v, (float)(isCollapsing ? 1 : 0), collapseRate * Time.deltaTime) - v, initialCollapse, useStoredValue: true); } else { LogUtils.LogError("ZNetView not valid during start on CenteredSolidLavaArea"); } GlobalLavaSolidifier.registerArea(this, getMaxVisualRadius()); GlobalLavaVisualsHandler.registerArea(this, getMaxVisualRadius()); if (radius > 0f) { GlobalLavaSolidifier.recalculateColliders(((Component)this).transform.position, getCollisionRadius()); GlobalLavaVisualsHandler.recalculateVisuals(((Component)this).transform.position, getMaxVisualRadius()); } } private void OnDestroy() { GlobalLavaSolidifier.unregisterArea(this); GlobalLavaVisualsHandler.unregisterArea(this); allAreas.Remove(this); if (uuid != null) { uuidMap.Remove(uuid); } } private void Update() { //IL_0023: 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_011c: Unknown result type (might be due to invalid IL or missing references) if (!nView.IsValid()) { LogUtils.LogWarning("ManagedSolidLavaArea invalid netview!"); } else { if (ZNetScene.instance.OutsideActiveArea(((Component)this).transform.position)) { return; } isCollapsing = (Object)(object)SolidLavaRune.getById(uuid) == (Object)null; if ((isCollapsing && collapse.get() != 1f) || (!isCollapsing && collapse.get() != 0f)) { collapse.updateValue(Time.deltaTime); GlobalLavaVisualsHandler.recalculateVisuals(((Component)this).transform.position, getMaxVisualRadius()); } if (!nView.IsOwner()) { return; } if (isAreaLoaded && collapse.get() == 1f) { ZNetScene.instance.Destroy(((Component)this).gameObject); } else if (!isAreaLoaded) { loadingCheck.update(Time.deltaTime); if (collapse.get() == 1f && loadingCheck.shouldTrigger()) { isAreaLoaded = ZNetScene.instance.IsAreaReady(((Component)this).transform.position); } } } } public void updateRadius(float newRadius) { float oldRadius = radius; radius = newRadius; checkVertexExpansion(oldRadius, radius); } private void checkVertexExpansion(float oldRadius, float newRadius) { //IL_000b: 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) if (oldRadius != newRadius) { GlobalLavaVisualsHandler.recalculateVisuals(((Component)this).transform.position, getMaxVisualRadius()); if (Mathf.Floor(oldRadius * 5f) != Mathf.Floor(newRadius * 5f)) { GlobalLavaSolidifier.recalculateColliders(((Component)this).transform.position, getCollisionRadius()); } } } public static bool anyAreaOverlaps(Vector3 pos, float radius) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) foreach (ManagedSolidLavaArea allArea in allAreas) { Vector2 val = pos.GetXZVector() - ((Component)allArea).transform.position.GetXZVector(); float sqrMagnitude = ((Vector2)(ref val)).sqrMagnitude; float num = allArea.getMaxVisualRadius() + radius; float num2 = num * num; if (sqrMagnitude < num2) { return true; } } return false; } public HashSet getAffectedCells(GridMap grid) where T : Component { //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) return grid.GetGridCellsOverlappingArea(((Component)this).transform.position.GetXZVector(), radius, inclusive: true); } public float getShaderRadius() { return radius; } public float getMaxVisualRadius() { float num = (maxRadius + 0.16f) * 0.5f; return maxRadius + num * 0.5f; } public float getCollisionRadius() { float num = (radius + 0.16f) * 0.5f; return radius + num * 0.5f; } public float getFullySolidRadius() { float num = (radius + 0.16f) * 0.5f; return radius - num * 0.5f; } public Transform getTransform() { return ((Component)this).transform; } public void notifyHeightmapChanged(Heightmap hmap) { } public long getIndex() { return creationIndex; } public float getCollapse() { return collapse.get(); } public static ManagedSolidLavaArea getById(string uuid) { if (uuidMap.ContainsKey(uuid)) { return uuidMap[uuid]; } return null; } public static bool anyActive() { return allAreas.Count > 0; } } public class DestructibleSolidLava : MonoBehaviour, IDestructible { public void Damage(HitData hit) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (hit.m_damage.m_pickaxe > 1f) { SolidLavaHole.spawnHole(hit.m_point, 2f); } } public DestructibleType GetDestructibleType() { return (DestructibleType)1; } } public class GlobalLavaVisualsHandler : MonoBehaviour { private static GlobalLavaVisualsHandler SINGLETON; private static GameObject visMeshPrefab; private static MaterialPropertyBlock propBlock; private static Vector4[] holeData = (Vector4[])(object)new Vector4[64]; private static Vector4[] areaData = (Vector4[])(object)new Vector4[64]; private BiDictionary solidAreas = new BiDictionary(); private BiDictionary lavaHoles = new BiDictionary(); private Dictionary activeAreas = new Dictionary(); private Dictionary> meshObjs = new Dictionary>(); private Dictionary rendererMap = new Dictionary(); private Dictionary dirtyAreas = new Dictionary(); public void Awake() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown if ((Object)(object)SINGLETON != (Object)null && (Object)(object)SINGLETON != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } if ((Object)(object)visMeshPrefab == (Object)null) { visMeshPrefab = AssetLoader.GetPrefabFromAssetBundle("Lava/HeightmapLavaVisual"); } propBlock = new MaterialPropertyBlock(); } private static GlobalLavaVisualsHandler getSingleton() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown if ((Object)(object)SINGLETON == (Object)null) { LogUtils.LogDebug("GlobalLavaVisualsHandler created"); GameObject val = new GameObject("GlobalLavaVisualsHandler"); SINGLETON = val.AddComponent(); } return SINGLETON; } public static void destroySingleton() { if ((Object)(object)SINGLETON != (Object)null) { LogUtils.LogDebug("GlobalLavaVisualsHandler destroyed"); Object.Destroy((Object)(object)((Component)SINGLETON).gameObject); SINGLETON = null; } } public static void registerArea(SolidLavaArea area, float maxVisualRadius) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_007d: Unknown result type (might be due to invalid IL or missing references) GlobalLavaVisualsHandler singleton = getSingleton(); HashSet affectedHeightmapCoords = HeightmapPatch.getAffectedHeightmapCoords(area.getTransform().position.GetXZVector(), maxVisualRadius, inclusive: true); bool flag = area.getIndex() == -1; singleton.solidAreas.AddAll(area, affectedHeightmapCoords); foreach (Vector2i item in affectedHeightmapCoords) { singleton.activeAreas[item] = singleton.activeAreas.GetValueOrDefault(item, 0) + 1; if (flag) { LogUtils.LogError("Ephemeral area registered with visual handler, not supported yet"); continue; } List list = singleton.solidAreas.Get(item); if (list.Count < 2) { continue; } long index = list[list.Count - 2].getIndex(); if (index > area.getIndex()) { ValheimMod.DevModeWarn("Invalid index order when registering visual area, resorting"); list.Sort((SolidLavaArea a, SolidLavaArea b) => (int)(b.getIndex() - a.getIndex())); } } } public static void registerHole(SolidLavaHole hole, float maxVisualRadius) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_005a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)SINGLETON == (Object)null) { ValheimMod.DevModeWarn("Attempted to register hole with no visual handler active!"); return; } GlobalLavaVisualsHandler singleton = getSingleton(); HashSet affectedHeightmapCoords = HeightmapPatch.getAffectedHeightmapCoords(((Component)hole).transform.position.GetXZVector(), maxVisualRadius, inclusive: true); singleton.lavaHoles.AddAll(hole, affectedHeightmapCoords); foreach (Vector2i item in affectedHeightmapCoords) { List list = singleton.lavaHoles.Get(item); if (list.Count < 2) { continue; } long index = list[list.Count - 2].getIndex(); if (index > hole.getIndex()) { ValheimMod.DevModeWarn("Invalid index order when registering visual hole, resorting"); list.Sort((SolidLavaHole a, SolidLavaHole b) => (int)(b.getIndex() - a.getIndex())); } } } public static void unregisterArea(SolidLavaArea area) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_0072: 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_0170: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)SINGLETON == (Object)null) { return; } GlobalLavaVisualsHandler singleton = getSingleton(); HashSet hashSet = new HashSet(singleton.solidAreas.Get(area)); if (hashSet.Count == 0) { ValheimMod.DevModeWarn("areaToHmapCoord doesn't contain expected area!"); } bool flag = area.getIndex() == -1; foreach (Vector2i item in hashSet) { if (singleton.solidAreas.Remove(item, area)) { singleton.activeAreas[item] = singleton.activeAreas[item] - 1; } if (singleton.activeAreas[item] <= 0) { singleton.activeAreas.Remove(item); if (singleton.meshObjs.ContainsKey(item)) { foreach (GameObject item2 in singleton.meshObjs[item]) { if ((Object)(object)singleton.rendererMap[item2] != (Object)null) { Material[] materials = ((Renderer)singleton.rendererMap[item2]).materials; foreach (Material val in materials) { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } } singleton.rendererMap.Remove(item2); Object.Destroy((Object)(object)item2); } singleton.meshObjs.Remove(item); } } singleton.dirtyAreas[item] = 0; } } public static void unregisterHole(SolidLavaHole hole) { //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_004f: 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 ((Object)(object)SINGLETON == (Object)null) { return; } GlobalLavaVisualsHandler singleton = getSingleton(); HashSet hashSet = new HashSet(singleton.lavaHoles.Get(hole)); if (hashSet.Count == 0) { ValheimMod.DevModeWarn("holeToHmapCoord doesn't contain expected hole!"); } foreach (Vector2i item in hashSet) { if (!singleton.lavaHoles.Remove(item, hole)) { ValheimMod.DevModeWarn("Coord doesn't contain expected area!"); } singleton.dirtyAreas[item] = 0; } } public static void recalculateVisuals(Vector3 pos, float radius) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_005c: 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_0062: 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_0070: 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) if ((Object)(object)SINGLETON == (Object)null) { return; } GlobalLavaVisualsHandler singleton = getSingleton(); Vector2i terrainCoord = HeightmapPatch.getTerrainCoord(ZNet.instance.GetReferencePosition()); int frameCount = Time.frameCount; HashSet affectedHeightmapCoords = HeightmapPatch.getAffectedHeightmapCoords(pos.GetXZVector(), radius, inclusive: true); foreach (Vector2i item in affectedHeightmapCoords) { if (!singleton.dirtyAreas.ContainsKey(item)) { Vector2i val = item - terrainCoord; int num = Math.Min(Mathf.Abs(val.x), Mathf.Abs(val.y)); num = Math.Max(0, num - 1); singleton.dirtyAreas[item] = frameCount + num * 20 + 1; } } } private void Update() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_008a: Unknown result type (might be due to invalid IL or missing references) List list = new List(); int frameCount = Time.frameCount; foreach (Vector2i key in dirtyAreas.Keys) { if (dirtyAreas[key] <= frameCount) { Heightmap heightmap = HeightmapPatch.getHeightmap(key); if ((Object)(object)heightmap != (Object)null) { handleVisuals(key, heightmap); list.Add(key); } } } foreach (Vector2i item in list) { dirtyAreas.Remove(item); } if (activeAreas.Count == 0) { destroySingleton(); } } private void handleVisuals(Vector2i coord, Heightmap hmap) { //IL_0006: 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_025c: 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_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: 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_0096: 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_0118: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) List list = solidAreas.Get(coord); List list2 = lavaHoles.Get(coord); long num = ((list2.Count > 0) ? list2[0].getIndex() : long.MaxValue); int i = 0; int num2 = 0; int num3 = 0; while (num2 < list.Count) { int num4 = 0; for (int j = 0; j < areaData.Length; j++) { if (num2 >= list.Count) { break; } SolidLavaArea solidLavaArea = list[num2]; if (solidLavaArea == null) { num2++; continue; } if (solidLavaArea.getIndex() >= num) { break; } areaData[num4] = new Vector4(solidLavaArea.getTransform().position.x, solidLavaArea.getShaderRadius(), solidLavaArea.getTransform().position.z, solidLavaArea.getCollapse()); num4++; num2++; } int num5 = 0; holeData[0] = default(Vector4); for (int k = 0; k < holeData.Length && i + k < list2.Count; k++) { SolidLavaHole solidLavaHole = list2[i + k]; if (!((Object)(object)solidLavaHole == (Object)null)) { holeData[num5] = new Vector4(((Component)solidLavaHole).transform.position.x, solidLavaHole.solidRadius, ((Component)solidLavaHole).transform.position.z, solidLavaHole.cracksRadius); num5++; } } propBlock.SetVectorArray("_nearbyRunes", areaData); propBlock.SetInteger("numNearbyRunes", num4); propBlock.SetVectorArray("_holes", holeData); propBlock.SetInteger("numHoles", num5); GameObject meshObj = getMeshObj(coord, hmap, num3); ((Renderer)rendererMap[meshObj]).SetPropertyBlock(propBlock); num3++; if (num2 >= list.Count) { break; } for (long index = list[num2].getIndex(); i < list2.Count && ((Object)(object)list2[i] == (Object)null || list2[i].getIndex() <= index); i++) { } num = ((i < list2.Count) ? list2[i].getIndex() : long.MaxValue); } if (meshObjs.ContainsKey(coord)) { for (int l = num3; l < meshObjs[coord].Count; l++) { meshObjs[coord][l].SetActive(false); } } } private GameObject getMeshObj(Vector2i coord, Heightmap hmap, int index) { //IL_0006: 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_0014: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (!meshObjs.ContainsKey(coord)) { meshObjs[coord] = new List(); } if (meshObjs[coord].Count <= index) { GameObject val = Object.Instantiate(visMeshPrefab, ((Component)hmap).transform.position, Quaternion.identity); meshObjs[coord].Add(val); MeshFilter component = val.GetComponent(); component.mesh = hmap.m_renderMesh; bool flag = ((Object)((Renderer)hmap.m_meshRenderer).sharedMaterial.shader).name == "Custom/HDTerrainHeightMap"; rendererMap[val] = val.GetComponent(); Material[] materials = ((Renderer)rendererMap[val]).materials; foreach (Material val2 in materials) { val2.SetTexture("_ClearedMaskTex", (Texture)(object)hmap.m_paintMask); val2.SetInteger("_BadgerHDTerrain", flag ? 1 : 0); } return val; } GameObject val3 = meshObjs[coord][index]; val3.SetActive(true); return val3; } private void notifyHeightmapChangedInternal(Heightmap hmap) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) Vector2i terrainCoord = HeightmapPatch.getTerrainCoord(((Component)hmap).transform.position); if (!meshObjs.ContainsKey(terrainCoord)) { return; } foreach (GameObject item in meshObjs[terrainCoord]) { MeshFilter component = item.GetComponent(); component.mesh = hmap.m_renderMesh; Material[] materials = ((Renderer)rendererMap[item]).materials; foreach (Material val in materials) { val.SetTexture("_ClearedMaskTex", (Texture)(object)hmap.m_paintMask); } } } public static void notifyHeightmapChanged(Heightmap hmap) { if (!((Object)(object)SINGLETON == (Object)null)) { SINGLETON.notifyHeightmapChangedInternal(hmap); } } } public class HeightmapLavaColliderGenerator { public struct AreaData { public Vector2 xzPos; public float solidRadius; public float cracksRadius; public long index; public bool solid; public AreaData(Vector2 xzPos, float solidRadius, float cracksRadius, long index, bool solid) { //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) this.xzPos = xzPos; this.solidRadius = solidRadius; this.cracksRadius = cracksRadius; this.index = index; this.solid = solid; } } public class FutureColliderMesh : ParallelMeshUtils.FutureMesh { private JobHandle constructingJob; private JobHandle bakingJob; private MeshDataArray hmapData; private MeshDataArray mda; private NativeArray protectionFactorArr; private Mesh mesh; private float[] protectionFactors; private bool ready; public FutureColliderMesh(JobHandle constructingJob, MeshDataArray hmapData, MeshDataArray mda, NativeArray protectionFactorArr) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0016: 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_001e: Unknown result type (might be due to invalid IL or missing references) this.constructingJob = constructingJob; this.hmapData = hmapData; this.mda = mda; this.protectionFactorArr = protectionFactorArr; ready = false; } public Mesh getMesh() { if (!ready) { return null; } return mesh; } public float[] getProtectionFactors() { return protectionFactors; } public bool isMeshReady() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_006d: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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) if (ready) { return true; } if (!((JobHandle)(ref constructingJob)).IsCompleted) { return false; } if (((JobHandle)(ref constructingJob)).IsCompleted && (Object)(object)mesh == (Object)null) { ((MeshDataArray)(ref hmapData)).Dispose(); protectionFactors = protectionFactorArr.ToArray(); protectionFactorArr.Dispose(); mesh = new Mesh(); Mesh.ApplyAndDisposeWritableMeshData(mda, mesh, (MeshUpdateFlags)0); mesh.RecalculateBounds(); BakeMeshJob bakeMeshJob = default(BakeMeshJob); bakeMeshJob.meshId = ((Object)mesh).GetInstanceID(); BakeMeshJob bakeMeshJob2 = bakeMeshJob; bakingJob = IJobForExtensions.ScheduleByRef(ref bakeMeshJob2, 1, default(JobHandle)); return false; } if (((JobHandle)(ref bakingJob)).IsCompleted) { ready = true; } return ready; } public void waitForCompletion() { while (!isMeshReady()) { Thread.Sleep(1); } } } private struct RGBA32_Color { public byte r; public byte g; public byte b; public byte a; } private struct CalcMeshVerticesJob : IJobFor { [ReadOnly] public NativeArray terrainPaintmask; [ReadOnly] public int paintmaskSize; [ReadOnly] public int heightmapWidth; [ReadOnly] public Vector3 hmapPos; [ReadOnly] public NativeArray hmapVerts; [ReadOnly] public NativeArray hmapIndices; [ReadOnly] public NativeArray areaList; public NativeArray vertices; public NativeArray indices; public NativeArray protectionFactors; public void Execute(int jobIndex) { //IL_0025: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_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_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: 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_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) float num = 2f; float num2 = 0.8f; float num3 = num / num2; for (int i = 0; i < hmapVerts.Length; i++) { vertices[i] = hmapVerts[i] + Vector3.down * num; } for (int j = 0; j < hmapIndices.Length; j++) { indices[j] = hmapIndices[j]; } int num4 = heightmapWidth + 1; for (int k = 0; k < hmapVerts.Length; k++) { int x = k % num4; int z = k / num4; float num5 = 0f; float num6 = 0f; Vector2 xZVector = (hmapVerts[k] + hmapPos).GetXZVector(); for (int l = 0; l < areaList.Length; l++) { AreaData areaData = areaList[l]; Vector2 val = xZVector - areaData.xzPos; float magnitude = ((Vector2)(ref val)).magnitude; if (areaData.solid) { num5 = Mathf.Max(num5, Mathf.InverseLerp(areaData.cracksRadius + num3, areaData.cracksRadius, magnitude)); num6 = Mathf.Max(num6, Mathf.InverseLerp(areaData.cracksRadius, areaData.solidRadius, magnitude)); } else { num5 = Mathf.Min(num5, Mathf.InverseLerp(areaData.cracksRadius - num3, areaData.cracksRadius, magnitude)); num6 = Mathf.Min(num6, Mathf.InverseLerp(areaData.cracksRadius, areaData.solidRadius, magnitude)); } } ref NativeArray reference = ref vertices; int num7 = k; reference[num7] += Vector3.up * (CalcVertexWithLavaOffset(x, z) + num) * num5; if (num5 == 0f) { reference = ref vertices; num7 = k; reference[num7] += Vector3.down * 10000f; } protectionFactors[k] = num6 * num6; } } private float CalcVertexWithLavaOffset(int x, int z) { float num = 0.2f; float lavaFactor = getLavaFactor(x, z); float num2 = Heightmap.GetGroundMaterialOffset((GroundMaterial)2048) * 0.3f; if (lavaFactor < num) { return Mathf.Lerp(-1f, num2, Mathf.InverseLerp(0f, num, lavaFactor)); } return Mathf.Lerp(num2, Heightmap.GetGroundMaterialOffset((GroundMaterial)2048) * 1.3f, Mathf.InverseLerp(num, 1f, lavaFactor)); } private float getLavaFactor(int x, int z) { if (x < 0 || z >= paintmaskSize || x < 0 || z >= paintmaskSize) { return 0f; } int num = z * paintmaskSize + x; return (float)(int)terrainPaintmask[num].a / 255f; } } private struct BakeMeshJob : IJobFor { [ReadOnly] public int meshId; public void Execute(int index) { Physics.BakeMesh(meshId, false, (MeshColliderCookingOptions)16); } } public static FutureColliderMesh createHeightmapColliderAsync(Vector2i coord, AreaData[] areas) { //IL_0000: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_008e: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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_012d: 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_015e: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0182: 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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0194: 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_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //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_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01be: 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_01c1: Unknown result type (might be due to invalid IL or missing references) Heightmap heightmap = HeightmapPatch.getHeightmap(coord); if ((Object)(object)heightmap == (Object)null) { LogUtils.LogError("Heightmap for lava was null"); return null; } Array.Sort(areas, (AreaData a, AreaData b) => a.index.CompareTo(b.index)); MeshDataArray hmapData = Mesh.AcquireReadOnlyMeshData(heightmap.m_collisionMesh); MeshData val = ((MeshDataArray)(ref hmapData))[0]; NativeArray rawTextureData = heightmap.m_paintMask.GetRawTextureData(); MeshDataArray mda = Mesh.AllocateWritableMeshData(1); MeshData val2 = ((MeshDataArray)(ref mda))[0]; ((MeshData)(ref val2)).SetVertexBufferParams(((MeshData)(ref val)).vertexCount, (VertexAttributeDescriptor[])(object)new VertexAttributeDescriptor[1] { new VertexAttributeDescriptor((VertexAttribute)0, (VertexAttributeFormat)0, 3, 0) }); int indexCount = (int)heightmap.m_collisionMesh.GetIndexCount(0); ((MeshData)(ref val2)).SetIndexBufferParams(indexCount, ((MeshData)(ref val)).indexFormat); ((MeshData)(ref val2)).subMeshCount = 1; SubMeshDescriptor val3 = default(SubMeshDescriptor); ((SubMeshDescriptor)(ref val3))..ctor(0, indexCount, (MeshTopology)0); ((SubMeshDescriptor)(ref val3)).vertexCount = ((MeshData)(ref val)).vertexCount; ((MeshData)(ref val2)).SetSubMesh(0, val3, (MeshUpdateFlags)9); NativeArray vertexData = ((MeshData)(ref val2)).GetVertexData(0); NativeArray indexData = ((MeshData)(ref val2)).GetIndexData(); NativeArray vertexData2 = ((MeshData)(ref val)).GetVertexData(0); NativeArray indexData2 = ((MeshData)(ref val)).GetIndexData(); NativeArray areaList = default(NativeArray); areaList..ctor(areas, (Allocator)4); NativeArray val4 = default(NativeArray); val4..ctor(vertexData.Length, (Allocator)4, (NativeArrayOptions)1); CalcMeshVerticesJob calcMeshVerticesJob = default(CalcMeshVerticesJob); calcMeshVerticesJob.terrainPaintmask = rawTextureData; calcMeshVerticesJob.paintmaskSize = ((Texture)heightmap.m_paintMask).width; calcMeshVerticesJob.heightmapWidth = heightmap.m_width; calcMeshVerticesJob.hmapPos = ((Component)heightmap).transform.position; calcMeshVerticesJob.hmapVerts = vertexData2; calcMeshVerticesJob.hmapIndices = indexData2; calcMeshVerticesJob.areaList = areaList; calcMeshVerticesJob.vertices = vertexData; calcMeshVerticesJob.indices = indexData; calcMeshVerticesJob.protectionFactors = val4; CalcMeshVerticesJob calcMeshVerticesJob2 = calcMeshVerticesJob; JobHandle val5 = IJobForExtensions.Schedule(calcMeshVerticesJob2, 1, default(JobHandle)); JobHandle constructingJob = areaList.Dispose(val5); return new FutureColliderMesh(constructingJob, hmapData, mda, val4); } public static Mesh createHeightmapCollider(Vector2i coord, List areaList) { //IL_0000: 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_0020: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00ab: 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_014f: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) Heightmap heightmap = HeightmapPatch.getHeightmap(coord); if ((Object)(object)heightmap == (Object)null) { LogUtils.LogError("Heightmap for lava was null"); return new Mesh(); } areaList.Sort((AreaData a, AreaData b) => b.index.CompareTo(a.index)); Profiler.start("HeightmapLavaColliderGenerator.createHeightmapCollider-adjustVerts"); Vector3[] vertices = heightmap.m_collisionMesh.vertices; int num = heightmap.m_width + 1; for (int i = 0; i < vertices.Length; i++) { int x = i % num; int z = i / num; vertices[i].y -= 20f; Vector2 xZVector = (vertices[i] + ((Component)heightmap).transform.position).GetXZVector(); for (int j = 0; j < areaList.Count; j++) { AreaData areaData = areaList[j]; Vector2 val = xZVector - areaData.xzPos; if (!(((Vector2)(ref val)).sqrMagnitude > areaData.cracksRadius * areaData.cracksRadius)) { if (areaData.solid) { vertices[i] = LavaSolidifier.CalcVertexWithLava(heightmap, x, z) + Vector3.up * 0.1f; } break; } } } Profiler.stop("HeightmapLavaColliderGenerator.createHeightmapCollider-adjustVerts"); Profiler.start("HeightmapLavaColliderGenerator.createHeightmapCollider-createMesh"); Mesh val2 = new Mesh(); val2.SetVertices(vertices); val2.SetTriangles(heightmap.m_collisionMesh.triangles, 0); Profiler.stop("HeightmapLavaColliderGenerator.createHeightmapCollider-createMesh"); Profiler.start("HeightmapLavaColliderGenerator.createHeightmapCollider-bakeMesh"); Physics.BakeMesh(((Object)val2).GetInstanceID(), false, (MeshColliderCookingOptions)16); Profiler.stop("HeightmapLavaColliderGenerator.createHeightmapCollider-bakeMesh"); return val2; } } [DefaultExecutionOrder(500)] public class SolidLavaHole : MonoBehaviour { private const string INDEX_KEY = "creationIndex"; private const string RADIUS_KEY = "radius"; private const string CRACKS_KEY = "cracks"; private const string ACTIVE_KEY = "active"; public float solidRadius; public float cracksRadius; public float changeRate; private ZNetView nView; private long creationIndex = -1L; private float maxCracksRadius; private float minCracksRadius; public bool shrinking = true; public bool active = true; private PeriodicTrigger intersectingSolidArea = new PeriodicTrigger(4f); public static SolidLavaHole spawnHole(Vector3 pos, float startingRadius) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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_0099: 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_00a8: Unknown result type (might be due to invalid IL or missing references) if (!ManagedSolidLavaArea.anyAreaOverlaps(pos, startingRadius)) { LogUtils.LogDebug("No overlapping areas, skipping hole spawn"); return null; } LogUtils.LogDebug("Spawning lava hole"); Vector2i terrainCoord = HeightmapPatch.getTerrainCoord(pos); float num = startingRadius * startingRadius; float num2 = 0.1f; long num3 = GlobalLavaSolidifier.getSolidAreasInSector(terrainCoord).Max((SolidLavaArea area) => area.getIndex()); foreach (SolidLavaHole item in GlobalLavaSolidifier.getHolesInSector(terrainCoord)) { if (item.getIndex() >= num3 && item.nView.IsOwner()) { Vector2 xZVector = (pos - ((Component)item).transform.position).GetXZVector(); float sqrMagnitude = ((Vector2)(ref xZVector)).sqrMagnitude; float num4 = item.solidRadius * item.solidRadius; float num5 = item.getCollisionRadius() * item.getCollisionRadius(); if (sqrMagnitude + num + num2 < num5) { LogUtils.LogInfo("Other hole encloses this one, no-op"); return null; } if (sqrMagnitude + num4 + num2 < num) { LogUtils.LogInfo("Destroying old hole"); Object.Destroy((Object)(object)item); } } } GameObject prefabFromAssetBundle = AssetLoader.GetPrefabFromAssetBundle("Lava/SolidAreaHole"); SolidLavaHole component = Object.Instantiate(prefabFromAssetBundle, pos, Quaternion.identity).GetComponent(); component.solidRadius = startingRadius; return component; } private void Awake() { LogUtils.LogDebug("SolidLavaHole awake"); changeRate = ConfigLoader.getFloat("SolidLavaHole-changeRate"); minCracksRadius = ConfigLoader.getFloat("SolidLavaHole-minCracksRadius"); maxCracksRadius = ConfigLoader.getFloat("SolidLavaHole-maxCracksRadius"); cracksRadius = minCracksRadius; nView = ((Component)this).GetComponent(); if (nView.IsValid()) { if (nView.IsOwner()) { creationIndex = (long)(ZNet.instance.GetTimeSeconds() * 10.0); nView.GetZDO().Set("creationIndex", creationIndex); ValheimMod.DevModeLog("SolidLavaHole znetview set up, visIndex " + creationIndex); } } else { ValheimMod.DevModeWarn("ZNetView not valid during Awake on SolidLavaHole"); } } private void Start() { //IL_0130: 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) if (nView.IsValid()) { if (nView.IsOwner()) { nView.GetZDO().Set("radius", solidRadius); nView.GetZDO().Set("cracks", cracksRadius); nView.GetZDO().Set("active", active); } else { creationIndex = nView.GetZDO().GetLong("creationIndex", -1L); solidRadius = nView.GetZDO().GetFloat("radius", 0f); cracksRadius = nView.GetZDO().GetFloat("cracks", 0f); active = nView.GetZDO().GetBool("active", false); ValheimMod.DevModeLog("SolidLavaHole start, visIndex " + creationIndex); } } else { ValheimMod.DevModeWarn("ZNetView not valid during start on SolidLavaHole"); } GlobalLavaVisualsHandler.registerHole(this, getSolidRadius()); GlobalLavaSolidifier.registerHole(this, getSolidRadius()); GlobalLavaSolidifier.recalculateColliders(((Component)this).transform.position, getCollisionRadius()); GlobalLavaVisualsHandler.recalculateVisuals(((Component)this).transform.position, getSolidRadius()); } private void OnDestroy() { GlobalLavaVisualsHandler.unregisterHole(this); GlobalLavaSolidifier.unregisterHole(this); } private void Update() { //IL_0114: Unknown result type (might be due to invalid IL or missing references) float num = 0f; float num2 = 0f; if (active && nView.IsOwner()) { float num3 = 1f - cracksRadius / maxCracksRadius; if (shrinking) { num = (0f - changeRate) * (1f - num3) * Time.deltaTime; num2 = changeRate * num3 * Time.deltaTime; } else { num2 = changeRate * num3 * Time.deltaTime; num = num2; } float collisionRadius = getCollisionRadius(); solidRadius += num; cracksRadius += num2; checkVertexExpansion(collisionRadius, getCollisionRadius()); if (num != 0f) { nView.GetZDO().Set("radius", solidRadius); } if (num2 != 0f) { nView.GetZDO().Set("cracks", cracksRadius); } intersectingSolidArea.update(Time.deltaTime); if (intersectingSolidArea.shouldTrigger() && !ManagedSolidLavaArea.anyAreaOverlaps(((Component)this).transform.position, solidRadius)) { LogUtils.LogDebug("Hole no longer overlapping any solid areas, destroying"); ZNetScene.instance.Destroy(((Component)this).gameObject); return; } if (solidRadius <= -0.5f) { ZNetScene.instance.Destroy(((Component)this).gameObject); return; } } if ((Object)(object)nView != (Object)null && nView.IsValid() && !nView.IsOwner()) { solidRadius = nView.GetZDO().GetFloat("radius", 0f); cracksRadius = nView.GetZDO().GetFloat("cracks", 0f); active = nView.GetZDO().GetBool("active", false); } } public float getCollisionRadius() { return solidRadius - cracksRadius / 2f; } public float getSolidRadius() { return solidRadius + cracksRadius / 2f; } public long getIndex() { return creationIndex; } private void checkVertexExpansion(float oldRadius, float newRadius) { //IL_000b: 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) if (oldRadius != newRadius) { GlobalLavaVisualsHandler.recalculateVisuals(((Component)this).transform.position, getSolidRadius()); if (Mathf.Floor(oldRadius * 5f) != Mathf.Floor(newRadius * 5f)) { GlobalLavaSolidifier.recalculateColliders(((Component)this).transform.position, getCollisionRadius()); } } } } } namespace ValheimMod.Monobehaviours.FireBehaviors { [DefaultExecutionOrder(500)] public class DamageFireEnemies : MonoBehaviour { private PeriodicTrigger dmgTrigger; private ZNetView nView; private Character character; private static HashSet allInstances = new HashSet(); private void Awake() { dmgTrigger = new PeriodicTrigger(0.5f); nView = ((Component)this).GetComponent(); character = ((Component)this).GetComponent(); allInstances.Add(this); } private void OnDestroy() { allInstances.Remove(this); } private void Update() { //IL_004c: 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_005e: Expected O, but got Unknown //IL_0070: 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_0081: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)nView == (Object)null) && nView.IsValid() && nView.IsOwner()) { dmgTrigger.update(Time.deltaTime); if (dmgTrigger.shouldTrigger() && ExtinguishingRune.anyInRange(((Component)this).transform.position)) { HitData val = new HitData(); val.m_damage.m_damage = 0.2f; val.m_hitType = (HitType)6; val.m_point = ((Component)this).transform.position; character.Damage(val); } } } public static bool anyInRange(Vector3 pos, float range) { //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) float num = range * range; foreach (DamageFireEnemies allInstance in allInstances) { if (MathUtils.distanceXZSqr(((Component)allInstance).transform.position, pos) <= num) { return true; } } return false; } } public class FireVFX { public enum State { INACTIVE, DWINDLING, EXTINGUISHED } private static readonly string[] FIRE_TRANSFORMS = new string[7] { "flame", "fire", "spark", "flare", "sparc", "fx_torch", "vfx" }; private Dictionary originalPSData = new Dictionary(); private Dictionary originalLights = new Dictionary(); private Dictionary originalFlickers = new Dictionary(); private float prevVFXLevel; public FireVFX(GameObject target) { ParticleSystem[] componentsInChildren = target.GetComponentsInChildren(true); Light[] componentsInChildren2 = target.GetComponentsInChildren(true); ParticleSystem[] array = componentsInChildren; foreach (ParticleSystem val in array) { bool flag = false; string[] fIRE_TRANSFORMS = FIRE_TRANSFORMS; foreach (string value in fIRE_TRANSFORMS) { if (((Object)((Component)val).gameObject).name.ToLower().Contains(value)) { originalPSData.Add(val, new PSData(val)); flag = true; break; } } } Light[] array2 = componentsInChildren2; foreach (Light val2 in array2) { LightFlicker component = ((Component)val2).gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { originalFlickers.Add(component, component.m_baseIntensity); } else { originalLights.Add(val2, val2.intensity); } } prevVFXLevel = 1f; } public bool isValid() { return originalPSData.Count > 0; } public void setVisuals(float frac) { if (frac == prevVFXLevel) { return; } prevVFXLevel = frac; foreach (ParticleSystem key in originalPSData.Keys) { if ((Object)(object)key != (Object)null) { originalPSData[key].applyScale(key, frac); } } foreach (Light key2 in originalLights.Keys) { if ((Object)(object)key2 != (Object)null) { key2.intensity = originalLights[key2] * (frac / 2f + 0.5f); } } foreach (LightFlicker key3 in originalFlickers.Keys) { if ((Object)(object)key3 != (Object)null) { key3.m_baseIntensity = originalFlickers[key3] * (frac / 2f + 0.5f); } } } } [DefaultExecutionOrder(500)] public class ItemExtinguisher : MonoBehaviour { private const string STATE_KEY = "RunemagicItemExtinguisherState"; private FireVFX fireVFX; private FireVFX.State state; private PeriodicTrigger runeCheck = new PeriodicTrigger(1f); private float elapsedTime; private float extinguishTime; public VisEquipment equipment; public Humanoid holder; public int heldItemHash; private ZNetView nView; private static HashSet allInstances = new HashSet(); private void Awake() { fireVFX = new FireVFX(((Component)this).gameObject); if (!fireVFX.isValid()) { ValheimMod.DevModeLog("ItemExtinguisher attached to item with no fire VFX, destroying"); Object.Destroy((Object)(object)this); } extinguishTime = ConfigLoader.getFloat("PieceExtinguisher-delay"); elapsedTime = 0f; state = FireVFX.State.INACTIVE; allInstances.Add(this); ValheimMod.DevModeLog("ItemExtinguisher Awake"); } private void Start() { nView = equipment.m_nview; updateState(); } private void OnDestroy() { allInstances.Remove(this); } private void Update() { //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Expected O, but got Unknown runeCheck.update(Time.deltaTime); if (runeCheck.shouldTrigger()) { updateState(); } if (state == FireVFX.State.DWINDLING) { elapsedTime += Time.deltaTime; float num = 1f - getExtinguishFactor(); fireVFX.setVisuals(num); if (num == 0f && elapsedTime > extinguishTime + 1f && ((Object)(object)nView == (Object)null || nView.IsOwner())) { ValheimMod.DevModeLog("ItemExtinguisher state set to EXTINGUISHED"); state = FireVFX.State.EXTINGUISHED; } } else { if (state != FireVFX.State.EXTINGUISHED || !((Object)(object)holder != (Object)null)) { return; } ItemData val = null; if (holder.m_leftItem != null && StringExtensionMethods.GetStableHashCode(((Object)holder.m_leftItem.m_dropPrefab).name) == heldItemHash) { val = holder.m_leftItem; } else if (holder.m_rightItem != null && StringExtensionMethods.GetStableHashCode(((Object)holder.m_rightItem.m_dropPrefab).name) == heldItemHash) { val = holder.m_rightItem; } if (val == null) { return; } if (holder is Player) { Player val2 = (Player)holder; if (val2.GetActionQueueCount() == 0) { val2.QueueUnequipAction(val); } return; } val.m_shared.m_damages.m_fire = 0f; for (int i = 0; i < val.m_shared.m_hitEffect.m_effectPrefabs.Length; i++) { if (((Object)val.m_shared.m_hitEffect.m_effectPrefabs[i].m_prefab).name == "vfx_torch_hit") { val.m_shared.m_hitEffect.m_effectPrefabs[i].m_enabled = false; } } Transform obj = ((Component)this).transform.Find("equiped"); if (obj != null) { GameObject gameObject = ((Component)obj).gameObject; if (gameObject != null) { gameObject.SetActive(false); } } } } private void updateState() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) FireVFX.State state = this.state; if ((Object)(object)nView == (Object)null || nView.IsOwner()) { bool flag = ExtinguishingRune.anyInRange(((Component)this).transform.position); if (!flag && this.state == FireVFX.State.DWINDLING) { this.state = FireVFX.State.INACTIVE; } else if (flag && this.state == FireVFX.State.INACTIVE) { this.state = FireVFX.State.DWINDLING; } if ((Object)(object)nView != (Object)null && nView.IsValid()) { nView.GetZDO().Set("RunemagicItemExtinguisherState", (int)this.state); } } else if (nView.IsValid()) { this.state = (FireVFX.State)nView.GetZDO().GetInt("RunemagicItemExtinguisherState", 0); } if (state != this.state) { ValheimMod.DevModeLog("ItemExtinguisher state set to " + this.state); if (this.state == FireVFX.State.DWINDLING) { elapsedTime = 0f; } else if (this.state == FireVFX.State.INACTIVE) { fireVFX.setVisuals(1f); } } } private float getExtinguishFactor() { return Mathf.Clamp01(elapsedTime / extinguishTime); } public static bool anyInRange(Vector3 pos, float range) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) float num = range * range; foreach (ItemExtinguisher allInstance in allInstances) { if (allInstance.state != FireVFX.State.EXTINGUISHED && MathUtils.distanceXZSqr(((Component)allInstance).transform.position, pos) <= num) { return true; } } return false; } } [DefaultExecutionOrder(500)] public class PieceExtinguisher : MonoBehaviour { private const string STATE_KEY = "RunemagicPieceExtinguisherState"; private FireVFX fireVFX; private string targetName; private float elapsedTime; private FireVFX.State state; private PeriodicTrigger runeCheck = new PeriodicTrigger(1f); private ZNetView nView; private float extinguishTime; private bool autoignite; public bool killOnExtinguish; private Fireplace fireplace; private CookingStation cookingStation; private Smelter smelter; private OfferingBowl offeringBowl; public static Dictionary allInstances = new Dictionary(); private void Awake() { if (PlayerPatch.PlayerCreatingGhost) { Object.Destroy((Object)(object)this); return; } fireVFX = new FireVFX(((Component)this).gameObject); if (!fireVFX.isValid()) { LogUtils.LogInfo("PieceExtinguisher attached to unextinguishable: " + ((Object)((Component)this).gameObject).name); Object.Destroy((Object)(object)this); return; } fireplace = ((Component)this).GetComponent(); cookingStation = ((Component)this).GetComponent(); smelter = ((Component)this).GetComponent(); offeringBowl = ((Component)this).GetComponentInChildren(); targetName = fireplace?.m_name ?? cookingStation?.m_name ?? smelter?.m_name ?? offeringBowl?.m_name; autoignite = (Object)(object)smelter != (Object)null || (Object)(object)offeringBowl != (Object)null; extinguishTime = ConfigLoader.getFloat("PieceExtinguisher-delay"); elapsedTime = 0f; state = FireVFX.State.INACTIVE; allInstances.Add(((Component)this).gameObject, this); } private void Start() { nView = ((Component)this).GetComponentInParent(); if ((Object)(object)nView == (Object)null) { LogUtils.LogWarning("PieceExtinguisher added to GameObject " + targetName + " without active ZNetView"); } else { nView.Register("RPC_resetEffect", (Action)RPC_resetEffect); } updateState(); } private void OnDestroy() { if ((Object)(object)((Component)this).gameObject != (Object)null) { allInstances.Remove(((Component)this).gameObject); } } private void Update() { runeCheck.update(Time.deltaTime); if (runeCheck.shouldTrigger()) { updateState(); } if (state != FireVFX.State.DWINDLING) { return; } elapsedTime += Time.deltaTime; float num = 1f - getExtinguishFactor(); fireVFX.setVisuals(num); if (num == 0f && elapsedTime > extinguishTime + 1f && ((Object)(object)nView == (Object)null || nView.IsOwner())) { LogUtils.LogDebug("State for " + targetName + " set to EXTINGUISHED"); state = FireVFX.State.EXTINGUISHED; updateRelatedPieceState(); if (killOnExtinguish) { ZNetScene.instance.Destroy(((Component)this).gameObject); } } } private void updateState() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) FireVFX.State state = this.state; if ((Object)(object)nView == (Object)null || nView.IsOwner()) { bool flag = ExtinguishingRune.anyInRange(((Component)this).transform.position); if (!flag && (this.state == FireVFX.State.DWINDLING || (this.state == FireVFX.State.EXTINGUISHED && autoignite))) { this.state = FireVFX.State.INACTIVE; } else if (flag && this.state == FireVFX.State.INACTIVE) { this.state = FireVFX.State.DWINDLING; } if ((Object)(object)nView != (Object)null && nView.IsValid()) { nView.GetZDO().Set("RunemagicPieceExtinguisherState", (int)this.state); } } else if (nView.IsValid()) { this.state = (FireVFX.State)nView.GetZDO().GetInt("RunemagicPieceExtinguisherState", 0); } if (state != this.state) { LogUtils.LogDebug($"State for {targetName} set to {this.state}"); if (this.state == FireVFX.State.DWINDLING) { elapsedTime = 0f; } else if (this.state == FireVFX.State.INACTIVE) { fireVFX.setVisuals(1f); } updateRelatedPieceState(); } } public static HashSet getActiveInRange(Vector3 pos, float range) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(); float num = range * range; foreach (PieceExtinguisher value in allInstances.Values) { if (value.state != FireVFX.State.EXTINGUISHED && MathUtils.distanceXZSqr(((Component)value).transform.position, pos) <= num) { hashSet.Add(value); } } return hashSet; } private float getExtinguishFactor() { return Mathf.Clamp01(elapsedTime / extinguishTime); } public bool isFullyExtinguished() { return state == FireVFX.State.EXTINGUISHED; } public void resetEffect() { if (state != 0) { if ((Object)(object)nView != (Object)null) { nView.InvokeRPC(0L, "RPC_resetEffect", Array.Empty()); } else { RPC_resetEffect(0L); } } } private void RPC_resetEffect(long sender) { if ((Object)(object)nView == (Object)null || nView.IsOwner()) { elapsedTime = 0f; LogUtils.LogDebug("State for " + targetName + " set to DWINDLING"); state = FireVFX.State.DWINDLING; fireVFX.setVisuals(1f); updateState(); updateRelatedPieceState(); } else { elapsedTime = 0f; fireVFX.setVisuals(1f); } } private void updateRelatedPieceState() { if ((Object)(object)fireplace != (Object)null) { SmokeSpawner smokeSpawner = fireplace.m_smokeSpawner; fireplace.m_smokeSpawner = null; fireplace.CheckUnderTerrain(); fireplace.m_smokeSpawner = smokeSpawner; if ((Object)(object)smokeSpawner != (Object)null) { smokeSpawner.m_lastSpawnTime = Time.time; } fireplace.UpdateState(); } else if ((Object)(object)cookingStation != (Object)null) { cookingStation.UpdateCooking(); } else if ((Object)(object)smelter != (Object)null) { smelter.UpdateState(); } else if ((Object)(object)offeringBowl != (Object)null) { Transform val = ((Component)this).transform.Find("Fire"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(state != FireVFX.State.EXTINGUISHED); } } } } public class SmokeVFX { private static readonly string[] SMOKE_NAMES = new string[2] { "smoke", "smok_small" }; private Dictionary originalPSData = new Dictionary(); private float prevVFXLevel; public SmokeVFX(GameObject target) { ParticleSystem[] componentsInChildren = target.GetComponentsInChildren(true); ParticleSystem[] array = componentsInChildren; foreach (ParticleSystem val in array) { string[] sMOKE_NAMES = SMOKE_NAMES; foreach (string value in sMOKE_NAMES) { if (((Object)val).name.ToLowerInvariant().Contains(value)) { originalPSData.Add(val, new PSData(val)); break; } } } LogUtils.LogDebug($"Found {originalPSData.Count} smoke particlesystems on {((Object)target).name}"); prevVFXLevel = 1f; } public bool isValid() { return originalPSData.Count > 0; } public void setVisuals(float frac) { if (frac == prevVFXLevel) { return; } LogUtils.LogDebug("Set smoke vfx to " + frac); prevVFXLevel = frac; foreach (ParticleSystem key in originalPSData.Keys) { if ((Object)(object)key != (Object)null) { originalPSData[key].applyScale(key, frac); } } } } }