Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of FreshCommands v2.6.50
FreshCommands.dll
Decompiled 4 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using Splatform; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("FreshCommands")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("2.6.50.0")] [assembly: AssemblyInformationalVersion("2.6.50+6e8692993fb4a7961a26992cf8b4f4d4400f1a09")] [assembly: AssemblyProduct("FreshCommands")] [assembly: AssemblyTitle("FreshCommands")] [assembly: AssemblyVersion("2.6.50.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace JuStIIFrEsH.Valheim.FreshCommands { public sealed class WayfarersReachVfx : MonoBehaviour { [SerializeField] private Transform portalCore; [SerializeField] private Transform portalEnergy; [SerializeField] private Transform portalAura; [SerializeField] private Renderer portalAuraRenderer; [SerializeField] private Renderer runeRenderer; [SerializeField] private float coreDegreesPerSecond = 5.5f; [SerializeField] private float energyDegreesPerSecond = 12f; [SerializeField] private float auraDegreesPerSecond = 1.5f; [SerializeField] private float auraPulseSeconds = 3.4f; [SerializeField] private float runePulseSeconds = 2.6f; [SerializeField] private Color auraEmission = new Color(0f, 0.35f, 0.5f, 1f); [SerializeField] private Color runeEmission = new Color(0f, 1.8f, 2.4f, 1f); private Material auraMaterial; private Material runeMaterial; private Renderer crackleRenderer; private MaterialPropertyBlock crackleProperties; private Renderer flameRenderer; private MaterialPropertyBlock flameProperties; private Texture2D[] flameFrames; private int lastFlameFrame = -1; private Vector3 auraBaseScale; public void Initialize(Transform core, Transform energy, Transform aura, Renderer auraRenderer, Renderer runes) { //IL_0040: 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) portalCore = core; portalEnergy = energy; portalAura = aura; portalAuraRenderer = auraRenderer; runeRenderer = runes; auraBaseScale = (Object.op_Implicit((Object)(object)portalAura) ? portalAura.localScale : Vector3.one); InitializeMaterials(); } private void Awake() { //IL_001b: 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_0020: Unknown result type (might be due to invalid IL or missing references) auraBaseScale = (Object.op_Implicit((Object)(object)portalAura) ? portalAura.localScale : Vector3.one); InitializeMaterials(); } private void InitializeMaterials() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)portalCore) && !Object.op_Implicit((Object)(object)flameRenderer)) { flameRenderer = ((Component)portalCore).GetComponent<Renderer>(); flameProperties = new MaterialPropertyBlock(); flameFrames = WayfarersReachAsset.GetFlameFrames(); } if (Object.op_Implicit((Object)(object)portalEnergy) && !Object.op_Implicit((Object)(object)crackleRenderer)) { crackleRenderer = ((Component)portalEnergy).GetComponent<Renderer>(); crackleProperties = new MaterialPropertyBlock(); } if (Object.op_Implicit((Object)(object)portalAuraRenderer) && !Object.op_Implicit((Object)(object)auraMaterial)) { auraMaterial = portalAuraRenderer.material; auraMaterial.EnableKeyword("_EMISSION"); } if (Object.op_Implicit((Object)(object)runeRenderer) && !Object.op_Implicit((Object)(object)runeMaterial)) { runeMaterial = runeRenderer.material; runeMaterial.EnableKeyword("_EMISSION"); } } private void Update() { //IL_0208: 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_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) float time = Time.time; if (Object.op_Implicit((Object)(object)flameRenderer) && flameFrames != null) { int num = Mathf.FloorToInt(time * 16f) % flameFrames.Length; if (num != lastFlameFrame) { lastFlameFrame = num; flameRenderer.GetPropertyBlock(flameProperties); flameProperties.SetTexture("_MainTex", (Texture)(object)flameFrames[num]); flameProperties.SetTexture("_EmissionMap", (Texture)(object)flameFrames[num]); flameRenderer.SetPropertyBlock(flameProperties); } } if (Object.op_Implicit((Object)(object)portalCore)) { portalCore.Rotate(coreDegreesPerSecond * (0.35f + 0.12f * Mathf.Sin(time * 0.31f)) * Time.deltaTime, (0f - coreDegreesPerSecond) * Time.deltaTime, coreDegreesPerSecond * 0.55f * Time.deltaTime, (Space)1); } if (Object.op_Implicit((Object)(object)portalEnergy)) { portalEnergy.Rotate((0f - energyDegreesPerSecond) * 0.65f * Time.deltaTime, energyDegreesPerSecond * (0.85f + 0.18f * Mathf.Sin(time * 0.71f)) * Time.deltaTime, (0f - energyDegreesPerSecond) * 0.4f * Time.deltaTime, (Space)1); } if (Object.op_Implicit((Object)(object)portalAura)) { portalAura.Rotate(auraDegreesPerSecond * 0.55f * Time.deltaTime, auraDegreesPerSecond * Time.deltaTime, (0f - auraDegreesPerSecond) * 0.35f * Time.deltaTime, (Space)1); } if (Object.op_Implicit((Object)(object)auraMaterial)) { float num2 = Mathf.Max(0.2f, auraPulseSeconds); float num3 = Mathf.Sin(Time.time * MathF.PI * 2f / num2); float num4 = 0.72f + 0.12f * num3; if (auraMaterial.HasProperty("_EmissionColor")) { auraMaterial.SetColor("_EmissionColor", auraEmission * num4); } if (Object.op_Implicit((Object)(object)portalAura)) { portalAura.localScale = auraBaseScale * (1f + 0.006f * num3); } } if (Object.op_Implicit((Object)(object)crackleRenderer) && crackleProperties != null) { float num5 = 0.68f + 0.22f * Mathf.Sin(time * 9.7f) + 0.1f * Mathf.Sin(time * 23.3f); crackleRenderer.GetPropertyBlock(crackleProperties); crackleProperties.SetColor("_EmissionColor", new Color(0f, 1f, 1.25f, 1f) * num5); crackleRenderer.SetPropertyBlock(crackleProperties); } if (Object.op_Implicit((Object)(object)runeMaterial)) { float num6 = Mathf.Max(0.2f, runePulseSeconds); float num7 = 0.72f + 0.28f * Mathf.Sin(Time.time * MathF.PI * 2f / num6); if (runeMaterial.HasProperty("_EmissionColor")) { runeMaterial.SetColor("_EmissionColor", runeEmission * num7); } } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)auraMaterial)) { Object.Destroy((Object)(object)auraMaterial); } if (Object.op_Implicit((Object)(object)runeMaterial)) { Object.Destroy((Object)(object)runeMaterial); } } } public sealed class CorpsecallerEffigy : MonoBehaviour, Hoverable, Interactable { public string GetHoverName() { return "Corpsecaller's Effigy"; } public float GetHoverOffset() { return 0.35f; } public string GetHoverText() { return Localization.instance.Localize("Corpsecaller's Effigy\n[<color=yellow>$KEY_Use</color>] Recover most recent corpse\n[<color=yellow>Shift + $KEY_Use</color>] Teleport to most recent corpse"); } public bool UseItem(Humanoid user, ItemData item) { return false; } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold || (Object)(object)user != (Object)(object)Player.m_localPlayer) { return false; } Plugin.UseCorpsecallerEffigy(Player.m_localPlayer, alt); return true; } } internal static class OathstoneShards { private static readonly float[] Heights = new float[7] { 0.28f, 0.68f, 1.15f, 1.52f, 1.86f, 2.22f, 2.46f }; private static readonly float[] LeftWidths = new float[7] { 0.3f, 0.34f, 0.26f, 0.32f, 0.19f, 0.22f, 0.025f }; private static readonly float[] RightWidths = new float[7] { 0.32f, 0.27f, 0.34f, 0.23f, 0.27f, 0.12f, 0.018f }; internal static void Create(Transform parent, Material stone, Material glow) { //IL_00aa: 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_01b0: 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_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0235: 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_024d: 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_00da: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0320: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: 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_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 2; i++) { float num = ((i == 0) ? (-1f) : 1f); float[] array = ((i == 0) ? LeftWidths : RightWidths); Vector3[,] array2 = new Vector3[Heights.Length, 6]; for (int j = 0; j < Heights.Length; j++) { float num2 = Heights[j] * ((i == 0) ? 1f : 0.95f); float num3 = num * (0.31f + 0.17f * num2 + ((j % 3 == 1) ? 0.045f : (-0.025f))); float num4 = array[j]; float num5 = 0.18f + (float)(j % 2) * 0.045f; array2[j, 0] = new Vector3(num3 - num4 * 0.7f, num2, 0f - num5); array2[j, 1] = new Vector3(num3 + num4 * 0.62f, num2 + ((j == 6) ? (-0.14f) : 0f), 0f - num5); array2[j, 2] = new Vector3(num3 + num4, num2 + ((j == 6) ? (-0.26f) : 0.018f), -0.025f); array2[j, 3] = new Vector3(num3 + num4 * 0.5f, num2, num5 * 0.8f); array2[j, 4] = new Vector3(num3 - num4 * 0.8f, num2 + ((j == 6) ? (-0.2f) : 0f), num5); array2[j, 5] = new Vector3(num3 - num4, num2, 0.02f); } List<Vector3> v = new List<Vector3>(); for (int k = 0; k < Heights.Length - 1; k++) { for (int l = 0; l < 6; l++) { int num6 = (l + 1) % 6; Triangle(v, array2[k, l], array2[k + 1, l], array2[k + 1, num6]); Triangle(v, array2[k, l], array2[k + 1, num6], array2[k, num6]); } } for (int m = 1; m < 5; m++) { Triangle(v, array2[0, 0], array2[0, m + 1], array2[0, m]); Triangle(v, array2[6, 0], array2[6, m], array2[6, m + 1]); } AddMesh(parent, (i == 0) ? "Fractured left shard" : "Fractured right shard", v, stone); List<Vector3> v2 = new List<Vector3>(); for (int n = 0; n < 4; n++) { float num7 = 0.62f + (float)n * 0.34f + ((i == 1) ? 0.08f : 0f); float num8 = num * (0.31f + 0.17f * num7); int num9 = n + i * 4; Vector2[][] array3 = Glyph(num9); float num10 = 0.1f + 0.018f * (float)(num9 * 3 % 4); float num11 = (float)(num9 % 3 - 1) * 12f; Vector2[][] array4 = array3; foreach (Vector2[] array5 in array4) { for (int num13 = 1; num13 < array5.Length; num13++) { Vector3 val = Quaternion.Euler(0f, 0f, num11) * Vector2.op_Implicit(array5[num13 - 1] * num10) + new Vector3(num8, num7, 0f); Vector3 val2 = Quaternion.Euler(0f, 0f, num11) * Vector2.op_Implicit(array5[num13] * num10) + new Vector3(num8, num7, 0f); val.z = FrontDepth(val.y, i); val2.z = FrontDepth(val2.y, i); Vector3 val3 = new Vector3(0f - (val2 - val).y, (val2 - val).x, 0f); Vector3 val4 = ((Vector3)(ref val3)).normalized * 0.008f; Triangle(v2, val - val4, val + val4, val2 + val4); Triangle(v2, val - val4, val2 + val4, val2 - val4); } } } AddMesh(parent, "Individual carved runes " + i, v2, glow); } } private static float FrontDepth(float y, int side) { y /= ((side == 0) ? 1f : 0.95f); for (int i = 0; i < Heights.Length - 1; i++) { if (y <= Heights[i + 1]) { return 0f - Mathf.Lerp(0.18f + (float)(i % 2) * 0.045f, 0.18f + (float)((i + 1) % 2) * 0.045f, Mathf.InverseLerp(Heights[i], Heights[i + 1], y)) - 0.006f; } } return -0.186f; } private static Vector2[][] Glyph(int i) { //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_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_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_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_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_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_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_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_010c: 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_0136: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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_0188: 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_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_01b4: 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_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: 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_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) Vector2[] array = (Vector2[])(object)new Vector2[2] { new Vector2(0f, -1f), new Vector2(0f, 1f) }; return i switch { 0 => new Vector2[2][] { array, (Vector2[])(object)new Vector2[3] { new Vector2(0f, 1f), new Vector2(0.65f, 0.35f), new Vector2(0f, 0f) } }, 1 => new Vector2[1][] { (Vector2[])(object)new Vector2[4] { new Vector2(-0.5f, -1f), new Vector2(0.3f, 0f), new Vector2(-0.4f, 0.45f), new Vector2(0.4f, 1f) } }, 2 => new Vector2[2][] { array, (Vector2[])(object)new Vector2[3] { new Vector2(-0.6f, 0.3f), new Vector2(0f, 0.75f), new Vector2(0.5f, 0.2f) } }, 3 => new Vector2[1][] { (Vector2[])(object)new Vector2[5] { new Vector2(-0.55f, 0f), new Vector2(0f, 1f), new Vector2(0.55f, 0f), new Vector2(0f, -1f), new Vector2(-0.55f, 0f) } }, 4 => new Vector2[2][] { array, (Vector2[])(object)new Vector2[3] { new Vector2(-0.6f, -0.3f), new Vector2(0f, 0.2f), new Vector2(0.5f, -0.1f) } }, 5 => new Vector2[1][] { (Vector2[])(object)new Vector2[5] { new Vector2(-0.5f, -1f), new Vector2(-0.5f, 1f), new Vector2(0.5f, 0.4f), new Vector2(-0.5f, 0f), new Vector2(0.5f, -0.7f) } }, 6 => new Vector2[1][] { (Vector2[])(object)new Vector2[4] { new Vector2(-0.5f, 0.8f), new Vector2(0.5f, 0.2f), new Vector2(-0.3f, -0.25f), new Vector2(0.3f, -1f) } }, _ => new Vector2[2][] { array, (Vector2[])(object)new Vector2[2] { new Vector2(-0.5f, 0.9f), new Vector2(0.5f, -0.4f) } }, }; } private static void Triangle(List<Vector3> v, Vector3 a, Vector3 b, Vector3 c) { //IL_0001: 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_000f: Unknown result type (might be due to invalid IL or missing references) v.Add(a); v.Add(b); v.Add(c); } private static void AddMesh(Transform parent, string name, List<Vector3> v, Material material) { //IL_0010: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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) int count = v.Count; for (int i = 0; i < count; i += 3) { v.Add(v[i]); v.Add(v[i + 2]); v.Add(v[i + 1]); } int[] array = new int[v.Count]; Vector2[] array2 = (Vector2[])(object)new Vector2[v.Count]; for (int j = 0; j < v.Count; j++) { array[j] = j; array2[j] = new Vector2(v[j].x, v[j].y); } Mesh val = new Mesh { name = name }; val.SetVertices(v); val.uv = array2; val.triangles = array; val.RecalculateNormals(); val.RecalculateBounds(); GameObject val2 = new GameObject(name) { layer = ((Component)parent).gameObject.layer }; val2.transform.SetParent(parent, false); val2.AddComponent<MeshFilter>().sharedMesh = val; ((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = material; } } internal static class OathstoneVisual { private readonly struct ObjIndex { internal readonly int Vertex; internal readonly int Uv; internal ObjIndex(int vertex, int uv) { Vertex = vertex; Uv = uv; } } private sealed class MeshBuilder { private readonly string name; private readonly List<Vector3> vertices = new List<Vector3>(); private readonly List<Vector2> textureCoordinates = new List<Vector2>(); private readonly List<int> triangles = new List<int>(); internal MeshBuilder(string name) { this.name = name; } internal void Add(ObjIndex index, List<Vector3> positions, List<Vector2> uvs) { //IL_000d: 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_0042: Unknown result type (might be due to invalid IL or missing references) vertices.Add(positions[index.Vertex]); textureCoordinates.Add((index.Uv >= 0 && index.Uv < uvs.Count) ? uvs[index.Uv] : Vector2.zero); triangles.Add(vertices.Count - 1); } internal Mesh Build() { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00f4: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown int count = vertices.Count; List<Vector3> list = new List<Vector3>(count * 2); List<Vector2> list2 = new List<Vector2>(textureCoordinates.Count * 2); List<int> list3 = new List<int>(triangles.Count * 2); list.AddRange(vertices); list2.AddRange(textureCoordinates); list3.AddRange(triangles); list.AddRange(vertices); list2.AddRange(textureCoordinates); for (int i = 0; i < triangles.Count; i += 3) { list3.Add(triangles[i] + count); list3.Add(triangles[i + 2] + count); list3.Add(triangles[i + 1] + count); } Mesh val = new Mesh { name = name }; val.SetVertices(list); val.SetUVs(0, list2); val.SetTriangles(list3, 0); val.RecalculateNormals(); val.RecalculateBounds(); return val; } } private const string ObjResource = "FreshCommands.Assets.WayfarersOathstone.obj"; private static readonly Vector3 EyeAnchor = new Vector3(0f, 1.97f, 0.05f); internal static GameObject Create(Transform parent, Material stone, GameObject eyePrefab) { //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_003e: Expected O, but got Unknown //IL_0072: 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_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) //IL_00cd: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: 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_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: 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_023e: Unknown result type (might be due to invalid IL or missing references) string text = AssetUtils.LoadTextFromResources("FreshCommands.Assets.WayfarersOathstone.obj", Assembly.GetExecutingAssembly()); if (string.IsNullOrEmpty(text)) { throw new InvalidOperationException("Embedded Wayfarer's Oathstone mesh was not found."); } GameObject val = new GameObject("Oathstone shrine visual") { layer = ((Component)parent).gameObject.layer }; val.transform.SetParent(parent, false); Dictionary<string, Mesh> dictionary = ParseObj(text); Material val2 = CreateEyeShellMaterial(stone); Material val3 = CreateGlowMaterial(eyePrefab, stone, "Oathstone eye glow", new Color(0.02f, 0.52f, 0.95f, 1f), 2.15f); Material val4 = CreateGlowMaterial(eyePrefab, stone, "Oathstone rune glow", new Color(0.02f, 0.55f, 1f, 1f), 2.5f); Material val5 = CreatePupilMaterial(stone); GameObject val6 = new GameObject("Suspended Greydwarf Eye") { layer = val.layer }; val6.transform.SetParent(val.transform, false); val6.transform.localPosition = EyeAnchor; Renderer eyeGlowRenderer = null; Renderer runeRenderer = null; foreach (KeyValuePair<string, Mesh> item in dictionary) { bool flag = item.Key == "WO_EyeShell" || item.Key == "WO_EyeIris" || item.Key == "WO_EyePupil"; if (!flag && !(item.Key == "WO_LeftSpire") && !(item.Key == "WO_RightSpire") && !(item.Key == "WO_RuneGlow")) { Mesh value = item.Value; ApplyV2GeometryTransform(item.Key, value); Transform transform = val.transform; Material sharedMaterial = stone; if (flag) { MoveMeshOrigin(value, EyeAnchor); transform = val6.transform; sharedMaterial = ((item.Key == "WO_EyeShell") ? val2 : ((!(item.Key == "WO_EyeIris")) ? val5 : val3)); } else if (item.Key == "WO_RuneGlow") { sharedMaterial = val4; } GameObject val7 = new GameObject(item.Key) { layer = val.layer }; val7.transform.SetParent(transform, false); val7.AddComponent<MeshFilter>().sharedMesh = value; MeshRenderer val8 = val7.AddComponent<MeshRenderer>(); ((Renderer)val8).sharedMaterial = sharedMaterial; if (item.Key == "WO_EyeIris") { eyeGlowRenderer = (Renderer)(object)val8; } if (item.Key == "WO_RuneGlow") { runeRenderer = (Renderer)(object)val8; } } } OathstoneShards.Create(val.transform, stone, val4); CreateVanillaEye(val6.transform, eyePrefab); Light obj = val6.AddComponent<Light>(); obj.color = new Color(0.08f, 0.56f, 1f); obj.range = 1.35f; obj.intensity = 0.12f; obj.shadows = (LightShadows)0; val6.AddComponent<OathstoneEyeMotion>().Initialize(eyeGlowRenderer, runeRenderer); return val; } private static void CreateVanillaEye(Transform parent, GameObject prefab) { //IL_0005: 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_001c: Expected O, but got Unknown //IL_002b: 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_026b: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: 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_0090: Expected O, but got Unknown //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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00e9: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_019b: 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_0169: 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_01a9: 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_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0219: 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) GameObject val = new GameObject("Vanilla Greydwarf Eye visual") { layer = ((Component)parent).gameObject.layer }; val.transform.SetParent(parent, false); Bounds val2 = default(Bounds); bool flag = false; MeshFilter[] componentsInChildren = prefab.GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val3 in componentsInChildren) { MeshRenderer component = ((Component)val3).GetComponent<MeshRenderer>(); if (!Object.op_Implicit((Object)(object)val3.sharedMesh) || !Object.op_Implicit((Object)(object)component)) { continue; } GameObject val4 = new GameObject(((Object)val3).name) { layer = ((Component)parent).gameObject.layer }; val4.transform.SetParent(val.transform, false); val4.transform.localPosition = prefab.transform.InverseTransformPoint(((Component)val3).transform.position); val4.transform.localRotation = Quaternion.Inverse(prefab.transform.rotation) * ((Component)val3).transform.rotation; val4.transform.localScale = ((Component)val3).transform.lossyScale; val4.AddComponent<MeshFilter>().sharedMesh = val3.sharedMesh; MeshRenderer val5 = val4.AddComponent<MeshRenderer>(); Material[] sharedMaterials = ((Renderer)component).sharedMaterials; for (int j = 0; j < sharedMaterials.Length; j++) { sharedMaterials[j] = new Material(sharedMaterials[j]); if (sharedMaterials[j].HasProperty("_EmissionColor")) { sharedMaterials[j].SetColor("_EmissionColor", sharedMaterials[j].GetColor("_EmissionColor") * 1.15f); } } ((Renderer)val5).sharedMaterials = sharedMaterials; Bounds bounds = val3.sharedMesh.bounds; for (int k = 0; k < 8; k++) { Vector3 val6 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((k & 1) != 0) ? 1 : (-1)), (float)(((k & 2) != 0) ? 1 : (-1)), (float)(((k & 4) != 0) ? 1 : (-1)))); val6 = val.transform.InverseTransformPoint(val4.transform.TransformPoint(val6)); if (!flag) { ((Bounds)(ref val2))..ctor(val6, Vector3.zero); flag = true; } else { ((Bounds)(ref val2)).Encapsulate(val6); } } } if (!flag) { throw new InvalidOperationException("Greydwarf Eye visual meshes unavailable."); } float num = 0.34f / Mathf.Max(new float[3] { ((Bounds)(ref val2)).size.x, ((Bounds)(ref val2)).size.y, ((Bounds)(ref val2)).size.z }); val.transform.localScale = Vector3.one * num; val.transform.localPosition = -((Bounds)(ref val2)).center * num; } private static Material CreateEyeShellMaterial(Material stone) { //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: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(stone) { name = "Oathstone eye shell" }; if (val.HasProperty("_Color")) { val.SetColor("_Color", new Color(0.48f, 0.67f, 0.7f, 1f)); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0f); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0.12f); } return val; } private static Material CreateGlowMaterial(GameObject eyePrefab, Material fallback, string name, Color color, float emission) { //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_0018: Expected O, but got Unknown //IL_0018: 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_007a: 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_00ba: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(FindEmissiveEyeMaterial(eyePrefab) ?? fallback) { name = name }; Texture2D val2 = (Texture2D)(object)(val.mainTexture = (Texture)(object)SolidTexture(Color.white, name + " texture")); if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", (Texture)(object)val2); } if (val.HasProperty("_Color")) { val.SetColor("_Color", color); } if (val.HasProperty("_TintColor")) { val.SetColor("_TintColor", color); } if (val.HasProperty("_EmissionMap")) { val.SetTexture("_EmissionMap", (Texture)(object)val2); } if (val.HasProperty("_EmissionColor")) { val.EnableKeyword("_EMISSION"); val.SetColor("_EmissionColor", color * emission); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0f); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0.08f); } return val; } private static Material CreatePupilMaterial(Material stone) { //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: Expected O, but got Unknown //IL_0026: 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_009f: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(stone) { name = "Oathstone eye pupil" }; Texture2D val2 = (Texture2D)(object)(val.mainTexture = (Texture)(object)SolidTexture(new Color(0.002f, 0.006f, 0.012f, 1f), "Oathstone pupil texture")); if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", (Texture)(object)val2); } if (val.HasProperty("_Color")) { val.SetColor("_Color", Color.white); } if (val.HasProperty("_EmissionMap")) { val.SetTexture("_EmissionMap", (Texture)null); } if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", Color.black); } val.DisableKeyword("_EMISSION"); return val; } private static Material FindEmissiveEyeMaterial(GameObject eyePrefab) { if (!Object.op_Implicit((Object)(object)eyePrefab)) { return null; } Renderer[] componentsInChildren = eyePrefab.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Material[] sharedMaterials = componentsInChildren[i].sharedMaterials; foreach (Material val in sharedMaterials) { if (Object.op_Implicit((Object)(object)val) && val.HasProperty("_EmissionColor")) { return val; } } } return null; } private static Texture2D SolidTexture(Color color, string name) { //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_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_001f: Expected O, but got Unknown //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_0030: 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_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_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) Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false) { name = name, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; val.SetPixels((Color[])(object)new Color[4] { color, color, color, color }); val.Apply(false, true); return val; } private static void ApplyV2GeometryTransform(string objectName, Mesh mesh) { //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_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_0216: 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_01b7: 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_0064: 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_0184: Unknown result type (might be due to invalid IL or missing references) Vector3[] vertices = mesh.vertices; bool flag = objectName == "WO_LeftSpire"; bool flag2 = objectName == "WO_RightSpire"; bool flag3 = objectName == "WO_RuneGlow"; for (int i = 0; i < vertices.Length; i++) { Vector3 val = vertices[i]; Vector3 val2 = val * 2f; if (flag || flag2) { float num = (flag ? (-1f) : 1f); float num2 = Mathf.Clamp01((val.y - 0.17f) / 1.02f); float num3 = Mathf.Lerp(0.205f, 0.135f, num2); float num4 = num * num3; float num5 = val.x - num4; float num6 = 1f - 0.42f * Mathf.SmoothStep(0.78f, 1f, num2); float num7 = Mathf.Lerp(1.75f, 1.48f, num2) * num6; float num8 = Mathf.Lerp(1.38f, 1.18f, num2) * num6; float num9 = ((num2 < 0.38f) ? Mathf.Lerp(0f, -0.028f, num2 / 0.38f) : ((num2 < 0.68f) ? Mathf.Lerp(-0.028f, 0.036f, (num2 - 0.38f) / 0.3f) : Mathf.Lerp(0.036f, -0.012f, (num2 - 0.68f) / 0.32f))); val2.x = num4 * 2f + num5 * 2f * num7 + num * (0.36f * num2 + num9); val2.z = val.z * 2f * num8; val2.z += num5 * num * 0.16f * num2; } else if (flag3) { float num10 = Mathf.Sign(val.x); if (Mathf.Abs(num10) > 0.01f) { float num11 = Mathf.Clamp01((val.y - 0.2f) / 1f); val2.x += num10 * (0.36f * num11); val2.z *= 1.3f; } } vertices[i] = val2; } mesh.vertices = vertices; mesh.RecalculateBounds(); mesh.RecalculateNormals(); } private static void MoveMeshOrigin(Mesh mesh, Vector3 origin) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) Vector3[] vertices = mesh.vertices; for (int i = 0; i < vertices.Length; i++) { ref Vector3 reference = ref vertices[i]; reference -= origin; } mesh.vertices = vertices; mesh.RecalculateBounds(); } private static Dictionary<string, Mesh> ParseObj(string source) { //IL_00f0: 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) List<Vector3> list = new List<Vector3>(); List<Vector2> list2 = new List<Vector2>(); Dictionary<string, MeshBuilder> dictionary = new Dictionary<string, MeshBuilder>(StringComparer.Ordinal); MeshBuilder meshBuilder = null; using StringReader stringReader = new StringReader(source); string text; while ((text = stringReader.ReadLine()) != null) { text = text.Trim(); if (text.Length == 0 || text[0] == '#') { continue; } string[] array = text.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 0) { continue; } switch (array[0]) { case "o": { string text2 = ((array.Length > 1) ? array[1] : "OathstonePart"); meshBuilder = (dictionary[text2] = new MeshBuilder(text2)); break; } case "v": list.Add(new Vector3(Parse(array[1]), Parse(array[2]), Parse(array[3]))); break; case "vt": list2.Add(new Vector2(Parse(array[1]), Parse(array[2]))); break; case "f": if (meshBuilder != null && array.Length >= 4) { List<ObjIndex> list3 = new List<ObjIndex>(); for (int i = 1; i < array.Length; i++) { list3.Add(ParseIndex(array[i])); } for (int j = 1; j < list3.Count - 1; j++) { meshBuilder.Add(list3[0], list, list2); meshBuilder.Add(list3[j], list, list2); meshBuilder.Add(list3[j + 1], list, list2); } } break; } } Dictionary<string, Mesh> dictionary2 = new Dictionary<string, Mesh>(StringComparer.Ordinal); foreach (KeyValuePair<string, MeshBuilder> item in dictionary) { dictionary2[item.Key] = item.Value.Build(); } return dictionary2; } private static ObjIndex ParseIndex(string token) { string[] array = token.Split('/'); int vertex = int.Parse(array[0], CultureInfo.InvariantCulture) - 1; int uv = ((array.Length > 1 && array[1].Length > 0) ? (int.Parse(array[1], CultureInfo.InvariantCulture) - 1) : (-1)); return new ObjIndex(vertex, uv); } private static float Parse(string value) { return float.Parse(value, NumberStyles.Float, CultureInfo.InvariantCulture); } } public sealed class OathstoneEyeMotion : MonoBehaviour { private Vector3 anchor; private Light glow; private Material eyeGlowMaterial; private Material runeGlowMaterial; private static readonly Color EyeEmission = new Color(0.02f, 0.52f, 0.95f, 1f); private static readonly Color RuneEmission = new Color(0f, 0.78f, 1f, 1f); private float rotationSeed; internal void Initialize(Renderer eyeGlowRenderer, Renderer runeRenderer) { eyeGlowMaterial = (Object.op_Implicit((Object)(object)eyeGlowRenderer) ? eyeGlowRenderer.sharedMaterial : null); runeGlowMaterial = (Object.op_Implicit((Object)(object)runeRenderer) ? runeRenderer.sharedMaterial : null); } private void Start() { //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) anchor = ((Component)this).transform.localPosition; glow = ((Component)this).GetComponent<Light>(); rotationSeed = (float)(((Object)this).GetInstanceID() & 0x3FF) * 0.137f; } 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_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_00a5: 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_0118: 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_015e: 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) float num = Time.time * 1.15f; ((Component)this).transform.localPosition = anchor + Vector3.up * (0.024f * Mathf.Sin(num)); float num2 = Time.time * 0.12f; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor((Mathf.PerlinNoise(rotationSeed, num2) - 0.5f) * 26f, 15f + 12f * Mathf.PerlinNoise(rotationSeed + 31f, num2), (Mathf.PerlinNoise(rotationSeed + 67f, num2) - 0.5f) * 22f); ((Component)this).transform.Rotate(val * Time.deltaTime, (Space)1); float num3 = 0.9f + 0.1f * Mathf.Sin(num); if (Object.op_Implicit((Object)(object)glow)) { glow.intensity = 0.24f + 0.06f * num3; } if (Object.op_Implicit((Object)(object)eyeGlowMaterial) && eyeGlowMaterial.HasProperty("_EmissionColor")) { eyeGlowMaterial.SetColor("_EmissionColor", EyeEmission * (1.9f + 0.35f * num3)); } if (Object.op_Implicit((Object)(object)runeGlowMaterial) && runeGlowMaterial.HasProperty("_EmissionColor")) { runeGlowMaterial.SetColor("_EmissionColor", RuneEmission * (1.3f + 0.2f * num3)); } } } public sealed class PlacementGhostVisual : MonoBehaviour { public GameObject VisualRoot; private ZNetView networkView; private void Awake() { networkView = ((Component)this).GetComponent<ZNetView>(); } private void LateUpdate() { if (!Object.op_Implicit((Object)(object)VisualRoot) || !Object.op_Implicit((Object)(object)networkView)) { return; } bool flag = !networkView.IsValid(); ReachPortalFire[] componentsInChildren = VisualRoot.GetComponentsInChildren<ReachPortalFire>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].SetPlacementPreview(flag); } if (flag) { if (!VisualRoot.activeSelf) { VisualRoot.SetActive(true); } Renderer[] componentsInChildren2 = VisualRoot.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].enabled = true; } } } } [BepInPlugin("justiifresh.valheim.freshcommands", "FreshCommands", "2.6.50")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(Minimap), "Update")] private static class MapCoordinatePatch { [HarmonyPostfix] private static void Postfix(Minimap __instance) { UpdateMapCoordinates(__instance); } } [HarmonyPatch(typeof(Minimap), "OnMapLeftClick")] private static class MapTeleportPatch { [HarmonyPrefix] private static bool Prefix(Minimap __instance) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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) if ((!ZInput.GetKey((KeyCode)306, true) && !ZInput.GetKey((KeyCode)305, true)) || (!ZInput.GetKey((KeyCode)304, true) && !ZInput.GetKey((KeyCode)303, true)) || !Minimap.IsOpen()) { return true; } Vector3 val = (Vector3)MapScreenToWorldPoint.Invoke(__instance, new object[1] { ZInput.pointerPosition }); object? obj = MapClosestPin.Invoke(__instance, new object[3] { val, 25f, true }); if (!TryGetSavedLocationForPin((PinData)((obj is PinData) ? obj : null), out var locationName)) { return true; } ConfirmMapTeleport(locationName); return false; } } [HarmonyPatch] private static class LocationStoreMigration { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(ZNetScene), "IsPrefabZDOValid", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(ZNetScene), "CreateObject", (Type[])null, (Type[])null); } [HarmonyPrefix] private static void Migrate(ZDO zdo) { if (zdo != null && zdo.GetPrefab() == 0 && (zdo.GetString("freshcommands.locations.v1", "").StartsWith("v1", StringComparison.Ordinal) || zdo.GetString("freshcommands.locations.backup.v1", "").StartsWith("v1", StringComparison.Ordinal))) { zdo.SetPrefab(StringExtensionMethods.GetStableHashCode("FreshCommands_LocationStore")); } } } [CompilerGenerated] private static class <>O { public static Action <0>__RegisterLocationStore; public static ConsoleEvent <1>__CorpseSubcommand; public static ConsoleEvent <2>__SetLocationCommand; public static ConsoleEvent <3>__DeleteLocationCommand; public static ConsoleEvent <4>__TpCommand; public static ConsoleEvent <5>__ListFreshCommands; public static PopupButtonCallback <6>__Pop; } public const string PluginGuid = "justiifresh.valheim.freshcommands"; public const string PluginName = "FreshCommands"; public const string PluginVersion = "2.6.50"; private static Plugin Instance; private const string LocationStoreKey = "freshcommands.locations.v1"; private const string LocationBackupStoreKey = "freshcommands.locations.backup.v1"; private const string LocationStoreHeader = "v1"; private const string LocationStorePrefab = "FreshCommands_LocationStore"; private bool recoveryChecked; private static readonly Dictionary<string, Vector3> SavedLocations = new Dictionary<string, Vector3>(StringComparer.OrdinalIgnoreCase); private static readonly SortedDictionary<string, string> AvailableCommands = new SortedDictionary<string, string>(StringComparer.OrdinalIgnoreCase); private static readonly FieldInfo ChatBufferField = typeof(Chat).GetField("m_chatBuffer", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo ChatHideTimerField = typeof(Chat).GetField("m_hideTimer", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly MethodInfo MapScreenToWorldPoint = AccessTools.Method(typeof(Minimap), "ScreenToWorldPoint", (Type[])null, (Type[])null); private static readonly MethodInfo MapClosestPin = AccessTools.Method(typeof(Minimap), "GetClosestPin", (Type[])null, (Type[])null); private static TMP_Text mapCoordinateLabel; private static TMP_Text mapControlsLabel; private ZoneSystem loadedZoneSystem; private bool welcomeTipShown; private float playerJoinTime = -1f; private void Awake() { //IL_000b: 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_005f: Expected O, but got Unknown //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_008b: Expected O, but got Unknown //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_00b7: 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_00e3: Expected O, but got Unknown //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_010f: Expected O, but got Unknown Instance = this; new Harmony("justiifresh.valheim.freshcommands.features").PatchAll(Assembly.GetExecutingAssembly()); PrefabManager.OnVanillaPrefabsAvailable += RegisterLocationStore; object obj = <>O.<1>__CorpseSubcommand; if (obj == null) { ConsoleEvent val = CorpseSubcommand; <>O.<1>__CorpseSubcommand = val; obj = (object)val; } RegisterCommand("corpse", "Corpse commands: corpse <recover|tp>", (ConsoleEvent)obj, isCheat: false, isNetwork: true); object obj2 = <>O.<2>__SetLocationCommand; if (obj2 == null) { ConsoleEvent val2 = SetLocationCommand; <>O.<2>__SetLocationCommand = val2; obj2 = (object)val2; } RegisterCommand("set", "Saves current position or X/Z: set <name> | set <name> <x> <z>", (ConsoleEvent)obj2, isCheat: false, isNetwork: true); object obj3 = <>O.<3>__DeleteLocationCommand; if (obj3 == null) { ConsoleEvent val3 = DeleteLocationCommand; <>O.<3>__DeleteLocationCommand = val3; obj3 = (object)val3; } RegisterCommand("delete", "Deletes a saved location: delete <name>", (ConsoleEvent)obj3, isCheat: false, isNetwork: true); object obj4 = <>O.<4>__TpCommand; if (obj4 == null) { ConsoleEvent val4 = TpCommand; <>O.<4>__TpCommand = val4; obj4 = (object)val4; } RegisterCommand("tp", "Lists locations or teleports: tp [home|corpse|name]", (ConsoleEvent)obj4, isCheat: false, isNetwork: true); object obj5 = <>O.<5>__ListFreshCommands; if (obj5 == null) { ConsoleEvent val5 = ListFreshCommands; <>O.<5>__ListFreshCommands = val5; obj5 = (object)val5; } RegisterCommand("freshcommands", "Lists all FreshCommands commands", (ConsoleEvent)obj5, isCheat: false, isNetwork: true); PrefabManager.OnVanillaPrefabsAvailable += RegisterCorpsecallerEffigy; PrefabManager.OnVanillaPrefabsAvailable += RegisterWayfarersCairn; PrefabManager.OnVanillaPrefabsAvailable += RegisterWayfarersReach; ((BaseUnityPlugin)this).Logger.LogInfo((object)"FreshCommands 2.6.50 loaded. Registered commands and placeable structures."); } private void OnDestroy() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) PrefabManager.OnVanillaPrefabsAvailable -= RegisterLocationStore; new Harmony("justiifresh.valheim.freshcommands.features").UnpatchSelf(); PrefabManager.OnVanillaPrefabsAvailable -= RegisterCorpsecallerEffigy; PrefabManager.OnVanillaPrefabsAvailable -= RegisterWayfarersCairn; PrefabManager.OnVanillaPrefabsAvailable -= RegisterWayfarersReach; } private void Update() { if (Object.op_Implicit((Object)(object)ZoneSystem.instance) && (Object)(object)ZoneSystem.instance != (Object)(object)loadedZoneSystem) { loadedZoneSystem = ZoneSystem.instance; recoveryChecked = false; LoadSavedLocations(); } if (!Object.op_Implicit((Object)(object)Player.m_localPlayer)) { welcomeTipShown = false; playerJoinTime = -1f; return; } if (playerJoinTime < 0f) { playerJoinTime = Time.unscaledTime; } if (!welcomeTipShown && Object.op_Implicit((Object)(object)Chat.instance) && Time.unscaledTime - playerJoinTime >= 3f) { if (!recoveryChecked && ZNet.instance.IsServer()) { recoveryChecked = true; RecoverMissingLocations(); } AddLocalChatTip(); } } private void AddLocalChatTip() { if (ChatBufferField?.GetValue(Chat.instance) is List<string> list && Object.op_Implicit((Object)(object)((Terminal)Chat.instance).m_output)) { list.Add("<color=orange>FreshCommands:</color> Type /freshcommands for help."); ((Component)((Terminal)Chat.instance).m_chatWindow).gameObject.SetActive(true); ChatHideTimerField?.SetValue(Chat.instance, 3f); ((TMP_Text)((Terminal)Chat.instance).m_output).text = string.Join("\n", list); welcomeTipShown = true; } } private static void RegisterCommand(string command, string description, ConsoleEvent action, bool isCheat, bool isNetwork) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) new ConsoleCommand(command, description, action, isCheat, isNetwork, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); AvailableCommands[command] = description; } private void RegisterCorpsecallerEffigy() { //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_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_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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00f4: 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_0116: Expected O, but got Unknown //IL_0130: 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_01a0: 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_024f: Unknown result type (might be due to invalid IL or missing references) PrefabManager.OnVanillaPrefabsAvailable -= RegisterCorpsecallerEffigy; try { PieceConfig val = new PieceConfig { Name = "Corpsecaller's Effigy", Description = "A wall-mounted skull reliquary. E recovers your corpse; Shift+E teleports to it.", Enabled = true, PieceTable = "Hammer", Category = "Furniture", CraftingStation = "piece_workbench" }; val.AddRequirement("BoneFragments", 8, true); val.AddRequirement("Wood", 4, true); val.AddRequirement("Resin", 5, true); CustomPiece val2 = new CustomPiece("FreshCommands_CorpsecallerEffigy", "itemstand", val); GameObject piecePrefab = val2.PiecePrefab; if (!Object.op_Implicit((Object)(object)piecePrefab)) { throw new InvalidOperationException("Could not clone itemstand."); } ItemStand component = piecePrefab.GetComponent<ItemStand>(); if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.m_attachOther)) { throw new InvalidOperationException("Could not find item stand attachment transform."); } Vector3 localPosition = component.m_attachOther.localPosition; Quaternion localRotation = component.m_attachOther.localRotation; ClearVisual(piecePrefab); piecePrefab.transform.localScale = Vector3.one; GameObject val3 = new GameObject("Corpsecaller's Effigy visual") { layer = piecePrefab.layer }; val3.transform.SetParent(piecePrefab.transform, false); val3.transform.localPosition = localPosition; val3.transform.localRotation = localRotation; GameObject prefab = PrefabManager.Instance.GetPrefab("TrophySkeleton"); if (!Object.op_Implicit((Object)(object)prefab)) { throw new InvalidOperationException("Could not find TrophySkeleton."); } GameObject val4 = Object.Instantiate<GameObject>(prefab, val3.transform, false); ((Object)val4).name = "Corpsecaller skull effigy"; ConfigureTrophyForWallStand(prefab, val4); val4.transform.localPosition = new Vector3(0f, 0f, -0.05f); StripVisualComponents(val4); BoxCollider collider = piecePrefab.AddComponent<BoxCollider>(); FitColliderToVisualBounds(piecePrefab.transform, val3, collider, new Vector3(0.08f, 0.08f, 0.12f)); val2.Piece.m_groundOnly = false; val2.Piece.m_groundPiece = false; val2.Piece.m_notOnWood = false; val2.Piece.m_noClipping = true; val2.Piece.m_removePiece = false; val2.Piece.m_canBeRemoved = true; ConfigureWearNTear(piecePrefab, val3, (Collider)(object)collider); piecePrefab.AddComponent<PlacementGhostVisual>().VisualRoot = val3; piecePrefab.AddComponent<CorpsecallerEffigy>(); val2.Piece.m_icon = RenderManager.Instance.Render(piecePrefab, RenderManager.IsometricRotation); if (!PieceManager.Instance.AddPiece(val2)) { throw new InvalidOperationException("Effigy registration rejected."); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered Corpsecaller's Effigy."); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Corpsecaller's Effigy registration failed: {arg}"); } } private void RegisterWayfarersCairn() { //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_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_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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_0171: 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_0196: 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) PrefabManager.OnVanillaPrefabsAvailable -= RegisterWayfarersCairn; try { PieceConfig val = new PieceConfig { Name = "Wayfarer's Oathstone", Description = "A rune-bound wilderness stone. Press E to return to your current spawn point.", Enabled = true, PieceTable = "Hammer", Category = "Furniture", CraftingStation = CraftingStations.None }; val.AddRequirement("Stone", 10, true); val.AddRequirement("GreydwarfEye", 1, true); CustomPiece val2 = new CustomPiece("FreshCommands_WayfarersCairn", "piece_table", val); GameObject piecePrefab = val2.PiecePrefab; if (!Object.op_Implicit((Object)(object)piecePrefab)) { throw new InvalidOperationException("Could not clone piece_table."); } piecePrefab.GetComponent<Piece>().m_craftingStation = null; GameObject prefab = PrefabManager.Instance.GetPrefab("Stone"); if (!Object.op_Implicit((Object)(object)prefab)) { throw new InvalidOperationException("Could not find Stone."); } GameObject prefab2 = PrefabManager.Instance.GetPrefab("GreydwarfEye"); if (!Object.op_Implicit((Object)(object)prefab2)) { throw new InvalidOperationException("Could not find GreydwarfEye."); } MeshRenderer componentInChildren = prefab.GetComponentInChildren<MeshRenderer>(true); if (!Object.op_Implicit((Object)(object)componentInChildren)) { throw new InvalidOperationException("Could not find Stone material."); } ClearVisual(piecePrefab); piecePrefab.transform.localScale = Vector3.one; GameObject val3 = OathstoneVisual.Create(piecePrefab.transform, ((Renderer)componentInChildren).sharedMaterial, prefab2); val3.transform.localScale = Vector3.one * 0.75f; BoxCollider val4 = piecePrefab.AddComponent<BoxCollider>(); val4.center = new Vector3(0f, 1.24f, 0f) * 0.75f; val4.size = new Vector3(1.7f, 2.52f, 0.9f) * 0.75f; val2.Piece.m_groundOnly = true; val2.Piece.m_groundPiece = true; val2.Piece.m_notOnWood = false; val2.Piece.m_noClipping = true; val2.Piece.m_removePiece = false; val2.Piece.m_canBeRemoved = true; ConfigureWearNTear(piecePrefab, val3, (Collider)(object)val4); piecePrefab.AddComponent<PlacementGhostVisual>().VisualRoot = val3; piecePrefab.AddComponent<WayfarersCairn>(); val2.Piece.m_icon = RenderManager.Instance.Render(piecePrefab, RenderManager.IsometricRotation); if (!PieceManager.Instance.AddPiece(val2)) { throw new InvalidOperationException("Cairn registration rejected."); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered Wayfarer's Oathstone."); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Wayfarer's Oathstone registration failed: {arg}"); } } private void RegisterWayfarersReach() { //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_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_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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_00ec: 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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) PrefabManager.OnVanillaPrefabsAvailable -= RegisterWayfarersReach; try { PieceConfig val = new PieceConfig { Name = "Wayfarer's Reach", Description = "An ancient waystone for distant travel. Press E to choose a saved location.", Enabled = true, PieceTable = "Hammer", Category = "Furniture", CraftingStation = "piece_workbench" }; val.AddRequirement("Stone", 10, true); val.AddRequirement("SurtlingCore", 1, true); val.AddRequirement("GreydwarfEye", 1, true); CustomPiece val2 = new CustomPiece("FreshCommands_WayfarersReach", "piece_table", val); GameObject piecePrefab = val2.PiecePrefab; if (!Object.op_Implicit((Object)(object)piecePrefab)) { throw new InvalidOperationException("Could not clone piece_table for Wayfarer's Reach."); } GameObject prefab = PrefabManager.Instance.GetPrefab("Stone"); MeshRenderer val3 = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponentInChildren<MeshRenderer>(true) : null); if (!Object.op_Implicit((Object)(object)val3)) { throw new InvalidOperationException("Could not find the vanilla Stone material."); } ClearVisual(piecePrefab); piecePrefab.transform.localScale = Vector3.one; GameObject visualRoot = WayfarersReachAsset.CreateVisual(piecePrefab.transform, piecePrefab.layer, ((Renderer)val3).sharedMaterial); BoxCollider val4 = piecePrefab.AddComponent<BoxCollider>(); val4.center = new Vector3(0f, 0.78f, 0f); val4.size = new Vector3(0.9f, 1.6f, 0.65f); val2.Piece.m_groundOnly = false; val2.Piece.m_groundPiece = false; val2.Piece.m_notOnWood = false; val2.Piece.m_noClipping = true; val2.Piece.m_removePiece = false; val2.Piece.m_canBeRemoved = true; ConfigureWearNTear(piecePrefab, visualRoot, (Collider)(object)val4); piecePrefab.AddComponent<PlacementGhostVisual>().VisualRoot = visualRoot; piecePrefab.AddComponent<WayfarersReach>(); ReachPortalFire.SetBuildIconMode(piecePrefab, enabled: true); val2.Piece.m_icon = RenderManager.Instance.Render(piecePrefab, RenderManager.IsometricRotation); ReachPortalFire.SetBuildIconMode(piecePrefab, enabled: false); if (!PieceManager.Instance.AddPiece(val2)) { throw new InvalidOperationException("Wayfarer's Reach registration rejected."); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered Wayfarer's Reach."); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Wayfarer's Reach registration failed: {arg}"); } } private static void ClearVisual(GameObject root) { for (int num = root.transform.childCount - 1; num >= 0; num--) { Object.DestroyImmediate((Object)(object)((Component)root.transform.GetChild(num)).gameObject); } Component[] components = root.GetComponents<Component>(); foreach (Component val in components) { if (!(val is Transform) && !(val is Piece) && !(val is ZNetView) && !(val is ZSyncTransform) && !(val is WearNTear)) { Object.DestroyImmediate((Object)(object)val); } } } private static void StripVisualComponents(GameObject visual, bool keepParticles = false) { Component[] componentsInChildren = visual.GetComponentsInChildren<Component>(true); foreach (Component val in componentsInChildren) { if (val is MonoBehaviour || val is Animator || val is Rigidbody || val is Collider || (!keepParticles && val is ParticleSystem) || val is Light || val is AudioSource) { Object.DestroyImmediate((Object)(object)val); } } } private static void ConfigureTrophyForWallStand(GameObject trophyPrefab, GameObject trophyVisual) { //IL_00af: 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_00cf: 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_0034: 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_0044: 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_006b: 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) ItemDrop component = trophyPrefab.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null) { foreach (OrientationSettings itemStandOffset in component.m_itemData.m_shared.m_itemStandOffsets) { if ((itemStandOffset.m_orientations & 1) != 0) { trophyVisual.transform.localPosition = itemStandOffset.m_position; trophyVisual.transform.localRotation = Quaternion.Euler(itemStandOffset.m_rotation); trophyVisual.transform.localScale = itemStandOffset.m_scale * 1.4f; return; } } } trophyVisual.transform.localPosition = new Vector3(0f, 0.35f, 0.08f); trophyVisual.transform.localRotation = Quaternion.identity; trophyVisual.transform.localScale = Vector3.one * 1.4f; } private static void FitColliderToVisualBounds(Transform root, GameObject visualRoot, BoxCollider collider, Vector3 padding) { //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_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_0045: 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_0018: 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_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_00d4: 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_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_0075: 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_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) Renderer[] componentsInChildren = visualRoot.GetComponentsInChildren<Renderer>(true); if (componentsInChildren.Length == 0) { collider.center = Vector3.zero; collider.size = Vector3.one * 0.5f; return; } Bounds bounds = componentsInChildren[0].bounds; Bounds val = default(Bounds); ((Bounds)(ref val))..ctor(root.InverseTransformPoint(((Bounds)(ref bounds)).center), Vector3.zero); Renderer[] array = componentsInChildren; for (int i = 0; i < array.Length; i++) { Bounds bounds2 = array[i].bounds; for (int j = -1; j <= 1; j += 2) { for (int k = -1; k <= 1; k += 2) { for (int l = -1; l <= 1; l += 2) { ((Bounds)(ref val)).Encapsulate(root.InverseTransformPoint(((Bounds)(ref bounds2)).center + Vector3.Scale(((Bounds)(ref bounds2)).extents, new Vector3((float)j, (float)k, (float)l)))); } } } } collider.center = ((Bounds)(ref val)).center; collider.size = ((Bounds)(ref val)).size + padding; } private static void ConfigureWearNTear(GameObject root, GameObject visualRoot, Collider collider) { //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_0074: 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_0089: Unknown result type (might be due to invalid IL or missing references) WearNTear component = root.GetComponent<WearNTear>(); if (Object.op_Implicit((Object)(object)component)) { component.m_new = visualRoot; component.m_worn = visualRoot; component.m_broken = visualRoot; component.m_wet = null; component.m_snow = null; component.m_snowWorn = null; component.m_snowBroken = null; component.m_fragmentRoots = (GameObject[])(object)new GameObject[1] { visualRoot }; component.m_autoCreateFragments = false; component.m_nonSolidRenderers.Clear(); component.m_supports = true; Bounds bounds = collider.bounds; component.m_comOffset = ((Bounds)(ref bounds)).center - root.transform.position; } } private static void ListFreshCommands(ConsoleEventArgs args) { Reply(args, "FreshCommands:"); Reply(args, " /freshcommands — Lists all FreshCommands commands"); Reply(args, " /corpse recover — recovers items from your most recent corpse."); Reply(args, " /corpse tp — teleports you to your most recent corpse."); Reply(args, " /set <name> — adds current location to saved locations."); Reply(args, " /set <name> <x> <z> — adds the supplied X/Z coordinates to saved locations."); Reply(args, " /delete <name> — Deletes a saved location."); Reply(args, " /tp home — teleports you to your current spawn point."); Reply(args, " /tp corpse — teleports you to your most recent corpse."); Reply(args, " /tp <name> — teleports you to a saved location."); Reply(args, " /tp — lists saved locations."); Reply(args, " Feedback, bugs, or mod integration suggestions: https://justiifresh.com/valheim/"); } private static void CorpseSubcommand(ConsoleEventArgs args) { if (args.Length != 2) { Reply(args, "Usage: corpse <recover|tp>."); return; } string text = args[1].ToLowerInvariant(); if (!(text == "tp")) { if (text == "recover") { CorpseRecoverCommand(args); } else { Reply(args, "Usage: corpse <recover|tp>."); } } else { CorpseTeleportCommand(args); } } private static void TpCommand(ConsoleEventArgs args) { if (args.Length == 1) { ListSavedLocationsCommand(args); return; } if (args.Length != 2) { Reply(args, "Usage: tp [home|corpse|name]."); return; } string text = args[1].ToLowerInvariant(); if (!(text == "home")) { if (text == "corpse") { CorpseTeleportCommand(args); } else { TeleportToSavedLocation(args, args[1]); } } else { HomeCommand(args); } } private static void CorpseTeleportCommand(ConsoleEventArgs args) { //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_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) //IL_00c7: 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.op_Implicit((Object)(object)Player.m_localPlayer) || !Object.op_Implicit((Object)(object)Game.instance) || ZDOMan.instance == null || !Object.op_Implicit((Object)(object)ZNet.instance)) { Reply(args, "Join a world before using corpse tp."); return; } if (!ZNet.instance.IsServer()) { Reply(args, "corpse tp currently requires a single-player world or the hosting player."); return; } LoadSavedLocations(); PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); long newestDeath; ZDO val = FindNewestCorpse(playerProfile.GetPlayerID(), playerProfile.GetName(), out newestDeath); if (val == null) { if (!playerProfile.HaveDeathPoint()) { Reply(args, "No corpse or saved death point belonging to this character was found."); return; } TeleportPlayer(Player.m_localPlayer, playerProfile.GetDeathPoint() + Vector3.up); Reply(args, "No tombstone was found, so you were teleported to your saved death point."); } else { Vector3 destination = val.GetPosition() + Vector3.up; TeleportPlayer(Player.m_localPlayer, destination); Reply(args, (newestDeath > 0) ? "Teleported to your most recent corpse." : "Teleported to your corpse."); } } private static void CorpseRecoverCommand(ConsoleEventArgs args) { if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || !Object.op_Implicit((Object)(object)Game.instance) || ZDOMan.instance == null || !Object.op_Implicit((Object)(object)ZNet.instance) || !Object.op_Implicit((Object)(object)ZNetScene.instance)) { Reply(args, "Join a world before using corpse recover."); return; } if (!ZNet.instance.IsServer()) { Reply(args, "corpse recover currently requires a single-player world or the hosting player."); return; } PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); long newestDeath; ZDO val = FindNewestCorpse(playerProfile.GetPlayerID(), playerProfile.GetName(), out newestDeath); if (val == null) { Reply(args, "No corpse belonging to this character was found."); } else { RecoverCorpse(val, args); } } internal static void UseCorpsecallerEffigy(Player player, bool teleport) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_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) if (!Object.op_Implicit((Object)(object)player) || !Object.op_Implicit((Object)(object)Game.instance) || ZDOMan.instance == null || !Object.op_Implicit((Object)(object)ZNet.instance)) { ((Character)player).Message((MessageType)2, "Join a world before using the Corpsecaller's Effigy.", 0, (Sprite)null, false); return; } if (!ZNet.instance.IsServer()) { ((Character)player).Message((MessageType)2, "The Corpsecaller's Effigy requires a single-player world or the hosting player.", 0, (Sprite)null, false); return; } PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); long newestDeath; ZDO val = FindNewestCorpse(playerProfile.GetPlayerID(), playerProfile.GetName(), out newestDeath); if (teleport) { if (val == null) { if (!playerProfile.HaveDeathPoint()) { ((Character)player).Message((MessageType)2, "No corpse or saved death point belonging to this character was found.", 0, (Sprite)null, false); return; } TeleportPlayer(player, playerProfile.GetDeathPoint() + Vector3.up, structureTransition: true); ((Character)player).Message((MessageType)2, "Your soul calls you to it's resting place.", 0, (Sprite)null, false); } else { TeleportPlayer(player, val.GetPosition() + Vector3.up, structureTransition: true); ((Character)player).Message((MessageType)2, (newestDeath > 0) ? "Teleported to your most recent corpse." : "Teleported to your corpse.", 0, (Sprite)null, false); } } else if (val == null) { ((Character)player).Message((MessageType)2, "No corpse belonging to this character was found.", 0, (Sprite)null, false); } else { RecoverCorpseFromEffigy(player, val); } } internal static void UseWayfarersCairn(Player player) { //IL_0068: 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_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_0070: 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) if (!Object.op_Implicit((Object)(object)player) || !Object.op_Implicit((Object)(object)Game.instance) || !Object.op_Implicit((Object)(object)ZNet.instance)) { ((Character)player).Message((MessageType)2, "Join a world before using the Wayfarer's Oathstone.", 0, (Sprite)null, false); return; } if (!ZNet.instance.IsServer()) { ((Character)player).Message((MessageType)2, "The Wayfarer's Oathstone requires a single-player world or the hosting player.", 0, (Sprite)null, false); return; } PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); Vector3 val = (playerProfile.HaveCustomSpawnPoint() ? playerProfile.GetCustomSpawnPoint() : playerProfile.GetHomePoint()); TeleportPlayer(player, val + Vector3.up * 1.5f, structureTransition: true); ((Character)player).Message((MessageType)2, "Returning home.", 0, (Sprite)null, false); } private static void RecoverCorpseFromEffigy(Player player, ZDO corpse) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown byte[] byteArray = corpse.GetByteArray(ZDOVars.s_items, (byte[])null); if (byteArray == null || byteArray.Length == 0) { ((Character)player).Message((MessageType)2, "Your most recent corpse has no items to recover.", 0, (Sprite)null, false); return; } Inventory val = new Inventory("Tombstone", (Sprite)null, 8, 4); val.Load(new ZPackage(byteArray)); int num = val.NrOfItemsIncludingStacks(); ((Humanoid)player).GetInventory().MoveAll(val); if (val.NrOfItems() == 0) { DestroyRecoveredCorpse(corpse); ((Character)player).Message((MessageType)2, string.Format("Recovered {0} item{1} from your most recent corpse.", num, (num == 1) ? string.Empty : "s"), 0, (Sprite)null, false); return; } ZPackage val2 = new ZPackage(); val.Save(val2); corpse.Set(ZDOVars.s_items, val2.GetArray()); int num2 = val.NrOfItemsIncludingStacks(); ((Character)player).Message((MessageType)2, string.Format("Recovered {0} item{1}. {2} remain in your corpse because your inventory is full.", num - num2, (num - num2 == 1) ? string.Empty : "s", num2), 0, (Sprite)null, false); } private static void RecoverCorpse(ZDO corpse, ConsoleEventArgs args) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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 //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown byte[] byteArray = corpse.GetByteArray(ZDOVars.s_items, (byte[])null); if (byteArray == null || byteArray.Length == 0) { Reply(args, "Your most recent corpse has no items to recover."); return; } Inventory val = new Inventory("Tombstone", (Sprite)null, 8, 4); val.Load(new ZPackage(byteArray)); int num = val.NrOfItemsIncludingStacks(); ((Humanoid)Player.m_localPlayer).GetInventory().MoveAll(val); if (val.NrOfItems() == 0) { DestroyRecoveredCorpse(corpse); Reply(args, string.Format("Recovered {0} item{1} from your most recent corpse.", num, (num == 1) ? string.Empty : "s")); return; } ZPackage val2 = new ZPackage(); val.Save(val2); corpse.Set(ZDOVars.s_items, val2.GetArray()); int num2 = val.NrOfItemsIncludingStacks(); Reply(args, string.Format("Recovered {0} item{1}. {2} remain in your corpse because your inventory is full.", num - num2, (num - num2 == 1) ? string.Empty : "s", num2)); } private static void DestroyRecoveredCorpse(ZDO corpse) { corpse.Set(ZDOVars.s_items, (byte[])null); ZDOMan.instance.DestroyZDO(corpse); } private static void HomeCommand(ConsoleEventArgs args) { //IL_0064: 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_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_0070: 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) if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || !Object.op_Implicit((Object)(object)Game.instance) || !Object.op_Implicit((Object)(object)ZNet.instance)) { Reply(args, "Join a world before using tp home."); return; } if (!ZNet.instance.IsServer()) { Reply(args, "tp home currently requires a single-player world or the hosting player."); return; } PlayerProfile playerProfile = Game.instance.GetPlayerProfile(); Vector3 val = (playerProfile.HaveCustomSpawnPoint() ? playerProfile.GetCustomSpawnPoint() : playerProfile.GetHomePoint()); TeleportPlayer(Player.m_localPlayer, val + Vector3.up * 1.5f); Reply(args, playerProfile.HaveCustomSpawnPoint() ? "Teleported to your spawn point." : "No custom spawn point is set; teleported to your world home point."); } private static void SetLocationCommand(ConsoleEventArgs args) { //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_0113: 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_0137: 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_00e4: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || !Object.op_Implicit((Object)(object)ZoneSystem.instance) || !Object.op_Implicit((Object)(object)ZNet.instance)) { Reply(args, "Join a world before using set."); return; } if (!ZNet.instance.IsServer()) { Reply(args, "set currently requires a single-player world or the hosting player."); return; } LoadSavedLocations(); if ((args.Length != 2 && args.Length != 4) || !IsValidLocationName(args[1])) { Reply(args, "Usage: set <name> (current position) or set <name> <x> <z>. Names may use letters, numbers, _ and -."); return; } string text = args[1]; if (IsReservedTeleportName(text)) { Reply(args, "'" + text + "' is reserved and cannot be used as a location name."); return; } Vector3 position = default(Vector3); if (args.Length == 4) { if (!TryParseCoordinate(args[2], out var value) || !TryParseCoordinate(args[3], out var value2)) { Reply(args, "Coordinates must be numbers. Usage: set <name> <x> <z>."); return; } ((Vector3)(ref position))..ctor(value, ZoneSystem.instance.GetGroundHeight(new Vector3(value, 0f, value2)), value2); } else { position = ((Component)Player.m_localPlayer).transform.position; } RemoveSavedLocation(text); SavedLocations[text] = position; SaveSavedLocations(); AddOrUpdateLocationPin(text, position); Reply(args, $"Saved '{text}' at X {position.x:0.##}, Z {position.z:0.##}. Use /tp {text} to return here."); } private static void DeleteLocationCommand(ConsoleEventArgs args) { if (!Object.op_Implicit((Object)(object)ZoneSystem.instance) || !Object.op_Implicit((Object)(object)ZNet.instance)) { Reply(args, "Join a world before using delete."); return; } if (!ZNet.instance.IsServer()) { Reply(args, "delete currently requires a single-player world or the h