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 ValheimQuickWarp v0.1.0
ValheimQuickWarp.dll
Decompiled 3 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [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("ValheimQuickWarp")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("ValheimQuickWarp")] [assembly: AssemblyTitle("ValheimQuickWarp")] [assembly: AssemblyVersion("0.1.0.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 ValheimQuickWarp { [BepInPlugin("pl.valheimquickwarp", "Valheim Quick Warp", "0.1.0")] [BepInDependency("com.jotunn.jotunn", "2.30.2")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "pl.valheimquickwarp"; public const string Version = "0.1.0"; public const string PrefabName = "qw_stone_floor_2x2"; public const string TagKey = "qw_pair_tag"; public const float Range = 30f; internal static Plugin Instance; private Harmony harmony; private void Awake() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown Instance = this; PrefabManager.OnVanillaPrefabsAvailable += RegisterPiece; harmony = new Harmony("pl.valheimquickwarp"); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Quick Warp 0.1.0: zasieg 30 m; wymagany na serwerze i klientach."); } private void RegisterPiece() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown PieceConfig val = new PieceConfig(); val.Name = "Kamień szybkiego przejścia"; val.Description = "Wejdź na płytę, aby przejść do sparowanej płyty. Zasięg: 30 m. E: nazwa pary."; val.PieceTable = "Hammer"; val.Category = "BuildingStone"; val.CraftingStation = "piece_stonecutter"; val.Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig("Stone", 6, 0, true), new RequirementConfig("GreydwarfEye", 2, 0, true) }; PieceConfig val2 = val; CustomPiece val3 = new CustomPiece("qw_stone_floor_2x2", "stone_floor_2x2", val2); val3.PiecePrefab.AddComponent<WarpPad>(); RuneVisual.AddTo(val3.PiecePrefab); if (!PieceManager.Instance.AddPiece(val3)) { throw new InvalidOperationException("Nie udało się zarejestrować płyty Quick Warp."); } PrefabManager.OnVanillaPrefabsAvailable -= RegisterPiece; } internal static void Log(string message) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)message); } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= RegisterPiece; Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } Instance = null; } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class SceneStart { private static void Postfix(ZNetScene __instance) { if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<WarpService>())) { ((Component)__instance).gameObject.AddComponent<WarpService>(); } } } internal static class RuneVisual { internal static void AddTo(GameObject pad) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) float num = 0f; Collider[] componentsInChildren = pad.GetComponentsInChildren<Collider>(true); foreach (Collider val in componentsInChildren) { if (!val.isTrigger) { Transform transform = pad.transform; Bounds bounds = val.bounds; Vector3 val2 = transform.InverseTransformPoint(((Bounds)(ref bounds)).max); num = Mathf.Max(num, val2.y); } } GameObject val3 = new GameObject("qw_runes"); val3.transform.SetParent(pad.transform, false); val3.transform.localPosition = new Vector3(0f, num + 0.008f, 0f); val3.layer = pad.layer; MeshFilter val4 = val3.AddComponent<MeshFilter>(); MeshRenderer val5 = val3.AddComponent<MeshRenderer>(); if (TryVanillaRune(out var mesh, out var material)) { val4.sharedMesh = mesh; ((Renderer)val5).sharedMaterial = material; Plugin.Log("Runy: wykorzystano płaski mesh oznaczenia Vegvisira."); } else { val4.sharedMesh = MakeRuneRing(); MeshRenderer componentInChildren = pad.GetComponentInChildren<MeshRenderer>(); material = ((!Object.op_Implicit((Object)(object)componentInChildren) || !Object.op_Implicit((Object)(object)((Renderer)componentInChildren).sharedMaterial)) ? ((Material)null) : new Material(((Renderer)componentInChildren).sharedMaterial)); if (!Object.op_Implicit((Object)(object)material)) { throw new InvalidOperationException("Brak materiału kamiennej płyty."); } ((Object)material).name = "qw_rune_material"; if (material.HasProperty("_MainTex")) { material.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture); } if (material.HasProperty("_BumpMap")) { material.SetTexture("_BumpMap", (Texture)null); } material.EnableKeyword("_EMISSION"); material.SetColor("_Color", new Color(0.25f, 0.7f, 1f)); material.SetColor("_EmissionColor", new Color(0.1f, 0.55f, 0.9f)); ((Renderer)val5).sharedMaterial = material; Plugin.Log("Runy: brak osobnego mesha Vegvisira; użyto proceduralnego kręgu runicznego i materiału gry."); } ((Renderer)val5).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val5).receiveShadows = false; } private static bool TryVanillaRune(out Mesh mesh, out Material material) { //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: 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_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_026a: 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_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Expected O, but got Unknown //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Expected O, but got Unknown mesh = null; material = null; string[] array = new string[5] { "Vegvisir_Eikthyr", "Vegvisir_GDKing", "Vegvisir_Bonemass", "Vegvisir_DragonQueen", "Vegvisir_GoblinKing" }; foreach (string text in array) { GameObject prefab = PrefabManager.Instance.GetPrefab(text); if (!Object.op_Implicit((Object)(object)prefab)) { continue; } MeshRenderer[] componentsInChildren = prefab.GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val in componentsInChildren) { string text2 = ((Object)val).name.ToLowerInvariant(); if (!text2.Contains("rune") && !text2.Contains("symbol")) { continue; } MeshFilter component = ((Component)val).GetComponent<MeshFilter>(); if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.sharedMesh) || !component.sharedMesh.isReadable || ((Renderer)val).sharedMaterials.Length != 1) { continue; } Mesh sharedMesh = component.sharedMesh; Bounds bounds = sharedMesh.bounds; Vector3 size = ((Bounds)(ref bounds)).size; int num = ((!(size.x < size.y)) ? ((size.y < size.z) ? 1 : 2) : ((!(size.x < size.z)) ? 2 : 0)); int num2 = (num + 1) % 3; int num3 = (num + 2) % 3; float num4 = Mathf.Max(((Vector3)(ref size))[num2], ((Vector3)(ref size))[num3]); if (!(num4 < 0.01f) && !(((Vector3)(ref size))[num] > num4 * 0.1f)) { Vector3[] vertices = sharedMesh.vertices; for (int k = 0; k < vertices.Length; k++) { Vector3 val2 = vertices[k] - ((Bounds)(ref bounds)).center; vertices[k] = new Vector3(((Vector3)(ref val2))[num2] / num4 * 1.55f, 0f, ((Vector3)(ref val2))[num3] / num4 * 1.55f); } int[] triangles = sharedMesh.triangles; int[] array2 = new int[triangles.Length * 2]; Array.Copy(triangles, array2, triangles.Length); for (int l = 0; l < triangles.Length; l += 3) { array2[triangles.Length + l] = triangles[l + 2]; array2[triangles.Length + l + 1] = triangles[l + 1]; array2[triangles.Length + l + 2] = triangles[l]; } mesh = new Mesh { name = "qw_vanilla_runes", vertices = vertices, uv = sharedMesh.uv, triangles = array2 }; mesh.RecalculateNormals(); mesh.RecalculateBounds(); material = new Material(((Renderer)val).sharedMaterial); ((Object)material).name = "qw_vanilla_rune_material"; return true; } } } return false; } private static Mesh MakeRuneRing() { //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Expected O, but got Unknown //IL_018a: 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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0202: 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_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0213: 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_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: 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) List<Vector3> vertices = new List<Vector3>(); List<int> triangles = new List<int>(); Action<Vector2, Vector2, float> action = delegate(Vector2 a, Vector2 b, float width) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) Vector2 val5 = new Vector2(0f - (b - a).y, (b - a).x); Vector2 val6 = ((Vector2)(ref val5)).normalized * width * 0.5f; int count = vertices.Count; Vector2[] array = (Vector2[])(object)new Vector2[4] { a + val6, b + val6, b - val6, a - val6 }; foreach (Vector2 val7 in array) { vertices.Add(new Vector3(val7.x, 0f, val7.y)); } triangles.AddRange(new int[6] { count, count + 1, count + 2, count, count + 2, count + 3 }); }; for (int num = 0; num < 2; num++) { float num2 = ((num == 0) ? 0.77f : 0.53f); for (int num3 = 0; num3 < 96; num3++) { float num4 = (float)num3 * MathF.PI * 2f / 96f; float num5 = (float)(num3 + 1) * MathF.PI * 2f / 96f; action(new Vector2(Mathf.Cos(num4), Mathf.Sin(num4)) * num2, new Vector2(Mathf.Cos(num5), Mathf.Sin(num5)) * num2, 0.018f); } } Vector2 val = default(Vector2); Vector2 val2 = default(Vector2); for (int num6 = 0; num6 < 16; num6++) { float num7 = (float)num6 * MathF.PI * 2f / 16f; ((Vector2)(ref val))..ctor(Mathf.Cos(num7), Mathf.Sin(num7)); ((Vector2)(ref val2))..ctor(0f - val.y, val.x); Vector2 val3 = val * 0.65f; action(val3 - val * 0.075f, val3 + val * 0.075f, 0.017f); action(val3 + val * 0.075f, val3 + val2 * 0.047f, 0.017f); if (num6 % 3 == 0) { action(val3, val3 - val * 0.045f + val2 * 0.047f, 0.017f); } else if (num6 % 3 == 1) { action(val3 + val * 0.075f, val3 - val2 * 0.047f, 0.017f); } else { action(val3, val3 - val * 0.055f - val2 * 0.047f, 0.017f); } } Mesh val4 = new Mesh { name = "qw_procedural_rune_ring", vertices = vertices.ToArray(), triangles = triangles.ToArray() }; val4.RecalculateNormals(); val4.RecalculateBounds(); return val4; } } public sealed class WarpPad : MonoBehaviour, Hoverable, Interactable, TextReceiver { internal static readonly List<WarpPad> Live = new List<WarpPad>(); internal ZNetView View; internal float Top; internal Vector3 Center; internal bool Supported; private string status = "Ustaw nazwę pary"; private Renderer rune; private MaterialPropertyBlock properties; private readonly List<Collider> floors = new List<Collider>(); internal bool Valid { get { if (Object.op_Implicit((Object)(object)View) && View.IsValid()) { return Supported; } return false; } } internal ZDOID Id => View.GetZDO().m_uid; private void Awake() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Expected O, but got Unknown View = ((Component)this).GetComponent<ZNetView>(); if (!Object.op_Implicit((Object)(object)View) || !View.IsValid()) { return; } View.Register<string>("QW_SetTag", (Action<long, string>)SetTagRpc); Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(); foreach (Collider val in componentsInChildren) { if (!val.isTrigger) { floors.Add(val); } } float num = float.NegativeInfinity; Bounds val2 = default(Bounds); bool flag = true; foreach (Collider floor in floors) { if (flag) { val2 = floor.bounds; flag = false; } else { ((Bounds)(ref val2)).Encapsulate(floor.bounds); } float num2 = num; Bounds bounds = floor.bounds; num = Mathf.Max(num2, ((Bounds)(ref bounds)).max.y); } Top = num; Center = new Vector3(((Bounds)(ref val2)).center.x, num, ((Bounds)(ref val2)).center.z); Supported = !flag && Vector3.Dot(((Component)this).transform.up, Vector3.up) > 0.995f; Transform val3 = ((Component)this).transform.Find("qw_runes"); if (Object.op_Implicit((Object)(object)val3)) { rune = ((Component)val3).GetComponent<Renderer>(); } properties = new MaterialPropertyBlock(); SetStatus(status, paired: false); Live.Add(this); } private void OnDestroy() { Live.Remove(this); } public string GetText() { if (!Object.op_Implicit((Object)(object)View) || !View.IsValid()) { return ""; } return View.GetZDO().GetString("qw_pair_tag", ""); } public float GetHoverOffset() { return 0f; } public string GetHoverName() { return "Kamień szybkiego przejścia"; } public string GetHoverText() { string text = GetText(); return GetHoverName() + "\nPara: " + ((text.Length == 0) ? "—" : text) + "\n" + (Supported ? status : "Płyta musi leżeć poziomo") + "\n[<color=yellow><b>$KEY_Use</b></color>] Nazwa pary"; } public bool Interact(Humanoid user, bool hold, bool alt) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (hold || !Object.op_Implicit((Object)(object)View) || !View.IsValid()) { return false; } if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { return false; } TextInput.instance.RequestText((TextReceiver)(object)this, "Nazwa pary (dokładnie dwie płyty)", 32); return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } public void SetText(string text) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)View) && View.IsValid() && PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { View.InvokeRPC("QW_SetTag", new object[1] { Normalize(text) }); } } private void SetTagRpc(long sender, string text) { if (Object.op_Implicit((Object)(object)View) && View.IsValid() && View.IsOwner()) { View.GetZDO().Set("qw_pair_tag", Normalize(text)); } } internal static string Normalize(string text) { text = (text ?? "").Trim(); StringBuilder stringBuilder = new StringBuilder(); string text2 = text; foreach (char c in text2) { if (!char.IsControl(c) && c != '<' && c != '>') { stringBuilder.Append(c); } } return stringBuilder.ToString(0, Math.Min(stringBuilder.Length, 32)); } internal bool Contains(Player player, bool standing) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00dd: Unknown result type (might be due to invalid IL or missing references) if (!Valid) { return false; } Vector3 val = ((Component)this).transform.InverseTransformPoint(((Component)player).transform.position); Vector3 val2 = ((Component)this).transform.InverseTransformPoint(Center); if (Mathf.Abs(val.x - val2.x) > (standing ? 0.93f : 1.18f) || Mathf.Abs(val.z - val2.z) > (standing ? 0.93f : 1.18f)) { return false; } float num = ((Component)player).transform.position.y - Top; if (!standing) { return num >= -0.3f; } if (num < -0.12f || num > 0.28f) { return false; } if (!((Character)player).IsOnGround()) { return false; } RaycastHit val3 = default(RaycastHit); if (!Physics.Raycast(((Component)player).transform.position + Vector3.up * 0.2f, Vector3.down, ref val3, 0.5f, WarpService.SolidMask, (QueryTriggerInteraction)1)) { return false; } return floors.Contains(((RaycastHit)(ref val3)).collider); } internal void SetStatus(string message, bool paired) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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) status = message; if (Object.op_Implicit((Object)(object)rune)) { properties.SetColor("_Color", paired ? new Color(0.25f, 0.7f, 1f) : new Color(0.2f, 0.28f, 0.32f)); properties.SetColor("_EmissionColor", (Color)(paired ? new Color(0.1f, 0.55f, 0.9f) : Color.black)); rune.SetPropertyBlock(properties); } } internal static WarpPad Find(ZDOID id) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) foreach (WarpPad item in Live) { if (Object.op_Implicit((Object)(object)item) && item.Valid && item.Id == id) { return item; } } return null; } } internal enum PairState { Ready, Updating, NoTag, Missing, Duplicate, TooFar, Invalid } public sealed class WarpService : MonoBehaviour { private const string QueryRpc = "QW_QueryPair_v1"; private const string ReplyRpc = "QW_PairReply_v1"; internal static readonly int SolidMask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "piece", "terrain", "vehicle" }); private static readonly int BlockingMask = SolidMask | LayerMask.GetMask(new string[3] { "character", "character_net", "character_ghost" }); private static readonly FieldInfo MaxAltitude = AccessTools.Field(typeof(Character), "m_maxAirAltitude"); private static readonly FieldInfo LastGround = AccessTools.Field(typeof(Character), "m_lastGroundTouch"); private static readonly FieldInfo FallTimer = AccessTools.Field(typeof(Character), "m_fallTimer"); private static readonly MethodInfo ResetGround = AccessTools.Method(typeof(Character), "ResetGroundContact", (Type[])null, (Type[])null); private static readonly MethodInfo InvalidateLiquid = AccessTools.Method(typeof(Character), "InvalidateCachedLiquidDepth", (Type[])null, (Type[])null); private static readonly MethodInfo ResetCloth = AccessTools.Method(typeof(Character), "ResetCloth", (Type[])null, (Type[])null); private ZRoutedRpc router; private ZDOMan world; private readonly List<ZDO> scanning = new List<ZDO>(); private readonly List<ZDO> snapshot = new List<ZDO>(); private readonly Dictionary<long, float> lastQueries = new Dictionary<long, float>(); private int scanCursor; private bool scanActive; private bool snapshotReady; private float nextScan; private float nextQuery; private float cooldown; private WarpPad occupied; private WarpPad blocked; private int sequence; private int pending; private Player lastPlayer; private void Update() { //IL_0276: Unknown result type (might be due to invalid IL or missing references) if (ZRoutedRpc.instance == null || (Object)(object)ZNet.instance == (Object)null || ZDOMan.instance == null) { return; } if (router != ZRoutedRpc.instance) { router = ZRoutedRpc.instance; router.Register<ZDOID, int>("QW_QueryPair_v1", (Action<long, ZDOID, int>)Query); router.Register<ZDOID, ZDOID, int, int>("QW_PairReply_v1", (Method<ZDOID, ZDOID, int, int>)Reply); } if (world != ZDOMan.instance) { world = ZDOMan.instance; snapshot.Clear(); scanning.Clear(); lastQueries.Clear(); snapshotReady = (scanActive = false); scanCursor = 0; nextScan = 0f; } if (ZNet.instance.IsServer()) { Scan(); } Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer)) { occupied = (blocked = null); lastPlayer = null; return; } if ((Object)(object)localPlayer != (Object)(object)lastPlayer) { occupied = (blocked = null); lastPlayer = localPlayer; nextQuery = 0f; } if (Object.op_Implicit((Object)(object)blocked) && !blocked.Contains(localPlayer, standing: false)) { blocked = null; } if (!Eligible(localPlayer)) { occupied = null; return; } WarpPad warpPad = null; foreach (WarpPad item in WarpPad.Live) { if (Object.op_Implicit((Object)(object)item) && item.Contains(localPlayer, standing: true)) { warpPad = item; break; } } if ((Object)(object)warpPad != (Object)(object)occupied) { occupied = warpPad; nextQuery = 0f; } if (Object.op_Implicit((Object)(object)occupied) && !((Object)(object)occupied == (Object)(object)blocked) && !(Time.time < cooldown) && !(Time.time < nextQuery)) { nextQuery = Time.time + 1f; pending = ++sequence; router.InvokeRoutedRPC(ZNet.instance.IsServer() ? ZNet.GetUID() : (ZNet.instance.GetServerPeer()?.m_uid ?? 0), "QW_QueryPair_v1", new object[2] { occupied.Id, pending }); } } private static bool Eligible(Player p) { if (((Character)p).IsOwner() && !((Character)p).IsDead() && !((Character)p).InIntro() && !((Character)p).IsTeleporting() && !((Character)p).IsAttached()) { return !((Character)p).InDodge(); } return false; } private void Scan() { if (scanActive || !(Time.time < nextScan)) { if (!scanActive) { scanning.Clear(); scanCursor = 0; scanActive = true; } if (world.GetAllZDOsWithPrefabIterative("qw_stone_floor_2x2", scanning, ref scanCursor)) { snapshot.Clear(); snapshot.AddRange(scanning); snapshotReady = true; scanActive = false; nextScan = Time.time + 2f; } } } private void Query(long sender, ZDOID sourceId, int token) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00c5: 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_010c: 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) if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer() || (lastQueries.TryGetValue(sender, out var value) && Time.time - value < 0.4f)) { return; } lastQueries[sender] = Time.time; ZDO zDO = world.GetZDO(sourceId); ZDOID val; if (sender == ZNet.GetUID() && Object.op_Implicit((Object)(object)Player.m_localPlayer)) { val = ((Character)Player.m_localPlayer).GetZDOID(); } else { ZNetPeer peer = ZNet.instance.GetPeer(sender); if (peer == null) { return; } val = peer.m_characterID; } ZDO zDO2 = world.GetZDO(val); if (zDO != null && zDO.IsValid() && zDO.GetPrefab() == StringExtensionMethods.GetStableHashCode("qw_stone_floor_2x2") && zDO2 != null && !(Vector3.Distance(zDO2.GetPosition(), zDO.GetPosition()) > 4f)) { ZDO target; PairState pairState = Resolve(zDO, out target); router.InvokeRoutedRPC(sender, "QW_PairReply_v1", new object[4] { sourceId, target?.m_uid ?? ZDOID.None, (int)pairState, token }); } } private PairState Resolve(ZDO source, out ZDO target) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) target = null; string text = source.GetString("qw_pair_tag", ""); if (text.Length == 0) { return PairState.NoTag; } if (!snapshotReady) { return PairState.Updating; } int num = 0; bool flag = false; foreach (ZDO item in snapshot) { if (item != null && item.IsValid() && !(item.GetString("qw_pair_tag", "") != text)) { num++; if (item.m_uid == source.m_uid) { flag = true; } else { target = item; } } } if (!flag) { return PairState.Updating; } if (num > 2) { target = null; return PairState.Duplicate; } if (num < 2 || target == null) { return PairState.Missing; } if (Vector3.Distance(source.GetPosition(), target.GetPosition()) > 30f) { return PairState.TooFar; } return PairState.Ready; } private void Reply(long sender, ZDOID sourceId, ZDOID targetId, int stateValue, int token) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: 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_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: 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_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) if (router == null || sender != (ZNet.instance.IsServer() ? ZNet.GetUID() : (ZNet.instance.GetServerPeer()?.m_uid ?? 0)) || token != pending) { return; } Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer) || !Object.op_Implicit((Object)(object)occupied) || !occupied.Valid || occupied.Id != sourceId || (Object)(object)occupied == (Object)(object)blocked || !occupied.Contains(localPlayer, standing: true) || !Eligible(localPlayer)) { return; } if (stateValue != 0) { occupied.SetStatus(Status((PairState)stateValue), paired: false); return; } WarpPad warpPad = WarpPad.Find(targetId); if (!Object.op_Implicit((Object)(object)warpPad) || warpPad.GetText() != occupied.GetText() || Vector3.Distance(((Component)occupied).transform.position, ((Component)warpPad).transform.position) > 30f || !ZNetScene.instance.IsAreaReady(warpPad.Center)) { occupied.SetStatus("Otoczenie celu nie jest jeszcze gotowe", paired: false); return; } if (!PrivateArea.CheckAccess(((Component)occupied).transform.position, 0f, false, false) || !PrivateArea.CheckAccess(((Component)warpPad).transform.position, 0f, false, false)) { occupied.SetStatus("Brak dostępu do chronionej płyty", paired: false); return; } Rigidbody component = ((Component)localPlayer).GetComponent<Rigidbody>(); CapsuleCollider component2 = ((Component)localPlayer).GetComponent<CapsuleCollider>(); if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component2) || MaxAltitude == null || LastGround == null || ResetGround == null) { occupied.SetStatus("Nieobsługiwana fizyka gracza", paired: false); return; } Vector3 val = warpPad.Center + Vector3.up * 0.06f; if (!ClearDestination(localPlayer, component2, val, warpPad)) { occupied.SetStatus("Miejsce docelowe jest zablokowane", paired: false); return; } occupied.SetStatus("Połączono", paired: true); warpPad.SetStatus("Połączono", paired: true); blocked = warpPad; occupied = null; cooldown = Time.time + 0.7f; localPlayer.StopDoodadControl(); AccessTools.Method(typeof(Player), "StopEmote", (Type[])null, (Type[])null)?.Invoke(localPlayer, null); ((Character)localPlayer).SetVelocity(Vector3.zero); component.angularVelocity = Vector3.zero; RigidbodyInterpolation interpolation = component.interpolation; component.interpolation = (RigidbodyInterpolation)0; component.position = val; ((Component)localPlayer).transform.position = val; MaxAltitude.SetValue(localPlayer, val.y); LastGround.SetValue(localPlayer, 1f); FallTimer?.SetValue(localPlayer, 0f); ResetGround.Invoke(localPlayer, null); InvalidateLiquid?.Invoke(localPlayer, null); ZNetView component3 = ((Component)localPlayer).GetComponent<ZNetView>(); if (component3 != null) { ZDO zDO = component3.GetZDO(); if (zDO != null) { zDO.SetPosition(val); } } ZNet.instance.SetReferencePosition(val); Physics.SyncTransforms(); component.interpolation = interpolation; ResetCloth?.Invoke(localPlayer, null); } private static bool ClearDestination(Player player, CapsuleCollider capsule, Vector3 feet, WarpPad target) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_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_006b: 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_0071: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) Vector3 lossyScale = ((Component)player).transform.lossyScale; float num = capsule.radius * Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.z)); float num2 = Mathf.Max(capsule.height * Mathf.Abs(lossyScale.y), num * 2f); Vector3 val = feet + ((Component)player).transform.rotation * Vector3.Scale(capsule.center, lossyScale); Vector3 val2 = Vector3.up * (num2 * 0.5f - num); Collider[] array = Physics.OverlapCapsule(val - val2, val + val2, num, BlockingMask, (QueryTriggerInteraction)1); foreach (Collider val3 in array) { if (Object.op_Implicit((Object)(object)val3) && (Object)(object)((Component)val3).transform.root != (Object)(object)((Component)player).transform.root) { return false; } } RaycastHit val4 = default(RaycastHit); if (!Physics.Raycast(feet + Vector3.up * 0.15f, Vector3.down, ref val4, 0.4f, SolidMask, (QueryTriggerInteraction)1)) { return false; } return (Object)(object)((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent<WarpPad>() == (Object)(object)target; } private static string Status(PairState s) { return s switch { PairState.NoTag => "Ustaw nazwę pary", PairState.Missing => "Brak drugiej płyty", PairState.Duplicate => "Ta nazwa występuje na więcej niż dwóch płytach", PairState.TooFar => "Druga płyta jest dalej niż 30 m", PairState.Updating => "Serwer aktualizuje listę płyt", _ => "Płyta niedostępna", }; } } }