Decompiled source of ESP v1.30.0
ESP.dll
Decompiled 3 weeks 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.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Data; using HarmonyLib; using Microsoft.CodeAnalysis; using Service; using TMPro; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; using Visualization; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("ESP")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+f44c16dbcbcffd7948a59e6ea845407a7aa0b37f")] [assembly: AssemblyProduct("ESP")] [assembly: AssemblyTitle("ESP")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 Visualization { public class Draw { public const string TriggerLayer = "character_trigger"; private static readonly Texture2D Texture = new Texture2D(1, 1); private static Shader? lineShader; private static string shaderName = "Sprites/Default"; private static readonly Dictionary<Color, Material> materials = new Dictionary<Color, Material>(); private static readonly Dictionary<string, Color> colors = new Dictionary<string, Color>(); private static readonly Dictionary<string, int> lineWidths = new Dictionary<string, int>(); private static Shader LineShader => lineShader ?? (lineShader = ((IEnumerable<Shader>)Resources.FindObjectsOfTypeAll<Shader>()).FirstOrDefault((Func<Shader, bool>)((Shader shader) => ((Object)shader).name == shaderName)) ?? ((IEnumerable<Shader>)Resources.FindObjectsOfTypeAll<Shader>()).FirstOrDefault((Func<Shader, bool>)((Shader shader) => ((Object)shader).name == "Sprites/Default")) ?? throw new Exception("Shader not found.")); private static int GetSegments(float angle) { return (int)Math.Floor(32f * angle / 360f); } private static Vector3 GetArcSegmentX(float angle, float radius) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) return new Vector3(0f, Mathf.Sin((float)Math.PI / 180f * angle) * radius, Mathf.Cos((float)Math.PI / 180f * angle) * radius); } private static Vector3 GetArcSegmentY(float angle, float radius) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) return new Vector3(Mathf.Sin((float)Math.PI / 180f * angle) * radius, 0f, Mathf.Cos((float)Math.PI / 180f * angle) * radius); } private static Vector3 GetArcSegmentZ(float angle, float radius) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) return new Vector3(Mathf.Sin((float)Math.PI / 180f * angle) * radius, Mathf.Cos((float)Math.PI / 180f * angle) * radius, 0f); } private static Vector3[] GetArcSegmentsX(Vector3 position, float angle, float radius) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) float num = (0f - angle) / 2f; int segments = GetSegments(angle); Vector3[] array = (Vector3[])(object)new Vector3[segments + 1]; for (int i = 0; i <= segments; i++) { array[i] = position + GetArcSegmentX(num, radius); num += angle / (float)segments; } return array; } private static Vector3[] GetArcSegmentsY(Vector3 position, float angle, float radius) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) float num = (0f - angle) / 2f; int segments = GetSegments(angle); Vector3[] array = (Vector3[])(object)new Vector3[segments + 1]; for (int i = 0; i <= segments; i++) { array[i] = position + GetArcSegmentY(num, radius); num += angle / (float)segments; } return array; } private static Vector3[] GetArcSegmentsZ(Vector3 position, float angle, float radius) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) float num = (0f - angle) / 2f; int segments = GetSegments(angle); Vector3[] array = (Vector3[])(object)new Vector3[segments + 1]; for (int i = 0; i <= segments; i++) { array[i] = position + GetArcSegmentZ(num, radius); num += angle / (float)segments; } return array; } private static void UpdateArcX(LineRenderer renderer, Vector3 position, float radius, float angle, float width) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Vector3[] arcSegmentsX = GetArcSegmentsX(position, angle, radius - width / 2f); renderer.positionCount = arcSegmentsX.Length; renderer.SetPositions(arcSegmentsX); } public static void DrawArcX(GameObject obj, Vector3 position, float radius, float angle) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) UpdateArcX(CreateRenderer(obj), position, radius, angle, GetLineWidth(((Object)obj).name)); } private static void UpdateArcY(LineRenderer renderer, Vector3 position, float radius, float angle, float width) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Vector3[] arcSegmentsY = GetArcSegmentsY(position, angle, radius - width / 2f); renderer.positionCount = arcSegmentsY.Length; renderer.SetPositions(arcSegmentsY); } public static void DrawArcY(GameObject obj, Vector3 position, float radius, float angle) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) UpdateArcY(CreateRenderer(obj), position, radius, angle, GetLineWidth(((Object)obj).name)); } private static void UpdateArcZ(LineRenderer renderer, Vector3 position, float radius, float angle, float width) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Vector3[] arcSegmentsZ = GetArcSegmentsZ(position, angle, radius - width / 2f); renderer.positionCount = arcSegmentsZ.Length; renderer.SetPositions(arcSegmentsZ); } public static void DrawArcZ(GameObject obj, Vector3 position, float radius, float angle) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) UpdateArcZ(CreateRenderer(obj), position, radius, angle, GetLineWidth(((Object)obj).name)); } public static GameObject DrawArc(string tag, MonoBehaviour parent, Vector3 position, float radius, float angle) { //IL_0025: 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) GameObject obj = CreateObject(((Component)parent).gameObject, tag); DrawArcY(CreateObject(obj, tag), position, radius, angle); DrawArcX(CreateObject(obj, tag), position, radius, angle); AddMeshCollider(obj); return obj; } public static void DrawConeX(GameObject obj, Vector3 position, float radius, float angle) { //IL_0013: 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_0041: 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) LineRenderer val = CreateRenderer(obj); float lineWidth = GetLineWidth(((Object)obj).name); Vector3[] arcSegmentsX = GetArcSegmentsX(position, angle, radius - lineWidth / 2f); val.positionCount = arcSegmentsX.Length + 2; val.SetPosition(0, position); for (int i = 0; i < arcSegmentsX.Length; i++) { val.SetPosition(i + 1, arcSegmentsX[i]); } val.SetPosition(arcSegmentsX.Length + 1, position); } public static void DrawConeY(GameObject obj, Vector3 position, float radius, float angle) { //IL_0013: 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_0041: 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) LineRenderer val = CreateRenderer(obj); float lineWidth = GetLineWidth(((Object)obj).name); Vector3[] arcSegmentsY = GetArcSegmentsY(position, angle, radius - lineWidth / 2f); val.positionCount = arcSegmentsY.Length + 2; val.SetPosition(0, position); for (int i = 0; i < arcSegmentsY.Length; i++) { val.SetPosition(i + 1, arcSegmentsY[i]); } val.SetPosition(arcSegmentsY.Length + 1, position); } public static void DrawConeZ(GameObject obj, Vector3 position, float radius, float angle) { //IL_0013: 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_0041: 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) LineRenderer val = CreateRenderer(obj); float lineWidth = GetLineWidth(((Object)obj).name); Vector3[] arcSegmentsZ = GetArcSegmentsZ(position, angle, radius - lineWidth / 2f); val.positionCount = arcSegmentsZ.Length + 2; val.SetPosition(0, position); for (int i = 0; i < arcSegmentsZ.Length; i++) { val.SetPosition(i + 1, arcSegmentsZ[i]); } val.SetPosition(arcSegmentsZ.Length + 1, position); } public static GameObject DrawCone(string tag, MonoBehaviour parent, Vector3 position, float radius, float angle) { //IL_0025: 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) GameObject obj = CreateObject(((Component)parent).gameObject, tag); DrawConeY(CreateObject(obj, tag), position, radius, angle); DrawConeX(CreateObject(obj, tag), position, radius, angle); AddMeshCollider(obj); return obj; } public static void SetShader(string name) { shaderName = name; lineShader = null; materials.Clear(); Visualization[] visualizations = Utils.GetVisualizations(); for (int i = 0; i < visualizations.Length; i++) { ChangeColor(((Component)visualizations[i]).gameObject); } } public static void Init() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Texture.SetPixel(0, 0, Color.gray); } private static GameObject CreateObject(GameObject parent, string tag, Quaternion? fixedRotation = null) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_002d: 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_0075: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject { layer = LayerMask.NameToLayer("character_trigger") }; val.transform.parent = parent.transform; val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; if (tag != "") { ((Object)val).name = tag; Visualization visualization = val.AddComponent<Visualization>(); visualization.Tag = tag; if (fixedRotation.HasValue) { visualization.SetFixed(fixedRotation.Value); } val.SetActive(Visibility.IsTag(tag)); } return val; } private static Material GetMaterial(Color color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_002a: 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_0012: Unknown result type (might be due to invalid IL or missing references) if (materials.ContainsKey(color)) { return materials[color]; } Material val = new Material(LineShader); val.SetColor("_Color", color); val.SetFloat("_BlendOp", 1f); val.SetTexture("_MainTex", (Texture)(object)Texture); materials[color] = val; return val; } private static LineRenderer CreateRenderer(GameObject obj) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) LineRenderer obj2 = obj.AddComponent<LineRenderer>(); obj2.useWorldSpace = false; ((Renderer)obj2).sharedMaterial = GetMaterial(GetColor(((Object)obj).name)); ((Renderer)obj2).shadowCastingMode = (ShadowCastingMode)0; obj2.widthMultiplier = GetLineWidth(((Object)obj).name); return obj2; } private static void ChangeColor(GameObject obj) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) LineRenderer component = obj.GetComponent<LineRenderer>(); if (Object.op_Implicit((Object)(object)component)) { ((Renderer)component).sharedMaterial = GetMaterial(GetColor(((Object)obj).name)); } } private static void ChangeLineWidth(GameObject obj) { float lineWidth = GetLineWidth(((Object)obj).name); LineRenderer component = obj.GetComponent<LineRenderer>(); if (Object.op_Implicit((Object)(object)component)) { component.widthMultiplier = lineWidth; } } public static void AddMeshCollider(GameObject obj) { GameObject obj2 = obj; Array.ForEach(obj2.GetComponentsInChildren<LineRenderer>(), delegate(LineRenderer renderer) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown MeshCollider obj3 = obj2.AddComponent<MeshCollider>(); obj3.convex = true; ((Collider)obj3).isTrigger = true; Mesh val = new Mesh(); renderer.BakeMesh(val, false); obj3.sharedMesh = val; }); } public static void AddText(GameObject obj, string title, string text) { StaticText staticText = obj.AddComponent<StaticText>(); staticText.text = text; staticText.title = title; } public static LineRenderer[] GetRenderers(MonoBehaviour obj, string tag) { return GetRenderers(obj, new string[1] { tag }); } public static LineRenderer[] GetRenderers(MonoBehaviour obj, string[] tags) { HashSet<string> set = tags.ToHashSet(); return ((Component)obj).GetComponentsInChildren<LineRenderer>(true).Where(delegate(LineRenderer renderer) { Visualization component = ((Component)renderer).GetComponent<Visualization>(); return Object.op_Implicit((Object)(object)component) && set.Contains(component.Tag); }).ToArray(); } public static Color GetColor(string tag) { //IL_0019: 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) if (!colors.ContainsKey(tag)) { return Color.white; } return colors[tag]; } public static void SetColor(string tag, Color color) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) colors[tag] = color; Visualization[] visualizations = Utils.GetVisualizations(); foreach (Visualization visualization in visualizations) { if (visualization.Tag == tag) { ChangeColor(((Component)visualization).gameObject); } } } public static float GetLineWidth(string tag) { return (float)Math.Max(1, lineWidths.ContainsKey(tag) ? lineWidths[tag] : 0) / 100f; } public static void SetLineWidth(string tag, int width) { lineWidths[tag] = width; Visualization[] visualizations = Utils.GetVisualizations(); foreach (Visualization visualization in visualizations) { if (visualization.Tag == tag) { ChangeLineWidth(((Component)visualization).gameObject); } } } public static GameObject DrawCylinder(string tag, MonoBehaviour parent, float radius) { //IL_0025: 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_0080: 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_00c2: 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_0102: 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_0144: Unknown result type (might be due to invalid IL or missing references) GameObject obj = CreateObject(((Component)parent).gameObject, tag); DrawArcY(CreateObject(obj, tag), Vector3.zero, radius, 360f); float lineWidth = GetLineWidth(tag); AddSphereCollider(obj, radius - lineWidth / 2f); Vector3 start = default(Vector3); ((Vector3)(ref start))..ctor(radius, -500f, 0f); Vector3 end = default(Vector3); ((Vector3)(ref end))..ctor(radius, 500f, 0f); AddBoxCollider(DrawLineSub(CreateObject(obj, tag), start, end)); ((Vector3)(ref start))..ctor(0f - radius, -500f, 0f); ((Vector3)(ref end))..ctor(0f - radius, 500f, 0f); AddBoxCollider(DrawLineSub(CreateObject(obj, tag), start, end)); ((Vector3)(ref start))..ctor(0f, -500f, radius); ((Vector3)(ref end))..ctor(0f, 500f, radius); AddBoxCollider(DrawLineSub(CreateObject(obj, tag), start, end)); ((Vector3)(ref start))..ctor(0f, -500f, 0f - radius); ((Vector3)(ref end))..ctor(0f, 500f, 0f - radius); AddBoxCollider(DrawLineSub(CreateObject(obj, tag), start, end)); return obj; } private static void AddBoxCollider(GameObject obj) { GameObject obj2 = obj; Array.ForEach(obj2.GetComponentsInChildren<LineRenderer>(), delegate(LineRenderer renderer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_0031: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_007b: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) Vector3 position = renderer.GetPosition(0); Vector3 position2 = renderer.GetPosition(renderer.positionCount - 1); float widthMultiplier = renderer.widthMultiplier; BoxCollider obj3 = obj2.AddComponent<BoxCollider>(); ((Collider)obj3).isTrigger = true; obj3.center = position + (position2 - position) / 2f; Vector3 val = position2 - position; val.x = Math.Abs(val.x); val.y = Math.Abs(val.y); val.z = Math.Abs(val.z); obj3.size = val + 2f * new Vector3(widthMultiplier, widthMultiplier, widthMultiplier); }); } private static void AddBoxCollider(GameObject obj, Vector3 center, Vector3 size) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) BoxCollider obj2 = obj.AddComponent<BoxCollider>(); ((Collider)obj2).isTrigger = true; obj2.center = center; obj2.size = size; } private static GameObject DrawLineSub(GameObject obj, Vector3 start, Vector3 end) { //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) LineRenderer obj2 = CreateRenderer(obj); obj2.SetPosition(0, start); obj2.SetPosition(1, end); return obj; } public static GameObject DrawLine(string tag, MonoBehaviour parent, Vector3 start, Vector3 end) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) GameObject obj = DrawLineSub(CreateObject(((Component)parent).gameObject, tag), start, end); AddBoxCollider(obj); return obj; } public static GameObject DrawLineWithFixedRotation(string tag, MonoBehaviour parent, Vector3 start, Vector3 end) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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) Quaternion val = Quaternion.FromToRotation(Vector3.forward, end - start); GameObject obj = CreateObject(((Component)parent).gameObject, tag, val); Vector3 start2 = Quaternion.Inverse(val) * start; Vector3 end2 = Quaternion.Inverse(val) * end; GameObject obj2 = DrawLineSub(obj, start2, end2); AddBoxCollider(obj2); return obj2; } public static GameObject DrawMarkerLine(string tag, MonoBehaviour parent) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return DrawMarkerLine(tag, parent, Vector3.zero); } public static GameObject DrawMarkerLine(string tag, MonoBehaviour parent, Vector3 start) { //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_001f: 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_002f: Unknown result type (might be due to invalid IL or missing references) Vector3 end = default(Vector3); ((Vector3)(ref end))..ctor(start.x, 500f, start.z); GameObject obj = DrawLineSub(CreateObject(((Component)parent).gameObject, tag, Quaternion.identity), start, end); AddBoxCollider(obj); return obj; } public static GameObject DrawBox(string tag, MonoBehaviour parent, Vector3 size) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_003a: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_00fa: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: 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_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: 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_0220: Unknown result type (might be due to invalid IL or missing references) Vector3 val = size / 2f; float num = GetLineWidth(tag) / 2f; if (num > val.x) { num = val.x; } if (num > val.y) { num = val.y; } if (num > val.z) { num = val.z; } Vector3[] array = (Vector3[])(object)new Vector3[8] { new Vector3(0f - val.x + num, 0f - val.y + num, 0f - val.z + num), new Vector3(0f - val.x + num, 0f - val.y + num, val.z - num), new Vector3(0f - val.x + num, val.y - num, 0f - val.z + num), new Vector3(0f - val.x + num, val.y - num, val.z - num), new Vector3(val.x - num, 0f - val.y + num, 0f - val.z + num), new Vector3(val.x - num, 0f - val.y + num, val.z - num), new Vector3(val.x - num, val.y - num, 0f - val.z + num), new Vector3(val.x - num, val.y - num, val.z - num) }; GameObject val2 = CreateObject(((Component)parent).gameObject, tag); for (int i = 0; i < array.Length; i++) { Vector3 val3 = array[i]; for (int j = i + 1; j < array.Length; j++) { Vector3 val4 = array[j]; int num2 = 0; if (val3.x == val4.x) { num2++; } if (val3.y == val4.y) { num2++; } if (val3.z == val4.z) { num2++; } if (num2 == 2) { DrawLineSub(CreateObject(val2, tag), array[i], array[j]); } } } return val2; } public static void AddSphereCollider(GameObject obj, float radius) { GameObject obj2 = obj; Array.ForEach(obj2.GetComponentsInChildren<LineRenderer>(), delegate { //IL_0013: Unknown result type (might be due to invalid IL or missing references) SphereCollider obj3 = obj2.AddComponent<SphereCollider>(); ((Collider)obj3).isTrigger = true; obj3.center = Vector3.zero; obj3.radius = radius; }); } public static void UpdateSphereCollider(MonoBehaviour obj, float radius) { Array.ForEach(((Component)obj).GetComponentsInChildren<SphereCollider>(), delegate(SphereCollider collider) { collider.radius = radius; }); } public static void UpdateSphere(MonoBehaviour parent, float radius) { //IL_001a: 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_0042: Unknown result type (might be due to invalid IL or missing references) LineRenderer[] componentsInChildren = ((Component)parent).GetComponentsInChildren<LineRenderer>(); if (componentsInChildren.Length == 3) { float widthMultiplier = componentsInChildren[0].widthMultiplier; UpdateArcX(componentsInChildren[0], Vector3.zero, radius, 360f, widthMultiplier); UpdateArcY(componentsInChildren[1], Vector3.zero, radius, 360f, widthMultiplier); UpdateArcZ(componentsInChildren[2], Vector3.zero, radius, 360f, widthMultiplier); UpdateSphereCollider(parent, radius - widthMultiplier / 2f); } } public static GameObject DrawSphere(string tag, MonoBehaviour parent, float radius) { return DrawSphere(tag, ((Component)parent).gameObject, radius); } public static GameObject DrawSphere(string tag, GameObject parent, float radius) { //IL_0020: 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_0076: Unknown result type (might be due to invalid IL or missing references) GameObject obj = CreateObject(parent, tag); DrawArcX(CreateObject(obj, tag), Vector3.zero, radius, 360f); float lineWidth = GetLineWidth(tag); AddSphereCollider(obj, radius - lineWidth / 2f); DrawArcY(CreateObject(obj, tag), Vector3.zero, radius, 360f); DrawArcZ(CreateObject(obj, tag), Vector3.zero, radius, 360f); return obj; } public static GameObject DrawCapsule(string tag, MonoBehaviour parent, float radius, float height) { return DrawCapsule(tag, ((Component)parent).gameObject, radius, height); } public static GameObject DrawCapsule(string tag, GameObject parent, float radius, float height) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_0105: 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_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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: 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_01cd: Unknown result type (might be due to invalid IL or missing references) GameObject obj = CreateObject(parent, tag); Vector3 val = Vector3.up * (height - radius); Vector3 val2 = Vector3.up * radius; float num = GetLineWidth(tag) / 2f; float num2 = Mathf.Max(0f, radius - num); DrawArcX(CreateObject(obj, tag), val, radius, 360f); DrawArcY(CreateObject(obj, tag), val, radius, 360f); DrawArcZ(CreateObject(obj, tag), val, radius, 360f); DrawArcX(CreateObject(obj, tag), val2, radius, 360f); DrawArcY(CreateObject(obj, tag), val2, radius, 360f); DrawArcZ(CreateObject(obj, tag), val2, radius, 360f); DrawLineSub(CreateObject(obj, tag), val + Vector3.left * num2, val2 + Vector3.left * num2); DrawLineSub(CreateObject(obj, tag), val + Vector3.right * num2, val2 + Vector3.right * num2); DrawLineSub(CreateObject(obj, tag), val + Vector3.forward * num2, val2 + Vector3.forward * num2); DrawLineSub(CreateObject(obj, tag), val + Vector3.back * num2, val2 + Vector3.back * num2); return obj; } } public class Utils { public static Visualization[] GetVisualizations() { return Resources.FindObjectsOfTypeAll<Visualization>(); } } [HarmonyPatch(typeof(Player), "UpdateHover")] public class Player_AddHoverForVisuals { private static void Postfix(ref GameObject ___m_hovering, ref GameObject ___m_hoveringCreature) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)___m_hovering) || Object.op_Implicit((Object)(object)___m_hoveringCreature)) { return; } float num = 100f; int mask = LayerMask.GetMask(new string[1] { "character_trigger" }); RaycastHit[] array = Physics.RaycastAll(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, num, mask); RaycastHit[] array2 = Physics.RaycastAll(((Component)GameCamera.instance).transform.position + ((Component)GameCamera.instance).transform.forward * num, -((Component)GameCamera.instance).transform.forward, num, mask); RaycastHit[] array3 = CollectionExtensions.AddRangeToArray<RaycastHit>(array, array2); Array.Sort(array3, (RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance)); RaycastHit[] array4 = array3; for (int i = 0; i < array4.Length; i++) { RaycastHit val = array4[i]; if ((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponent<Visualization>() != (Object)null) { ___m_hovering = ((Component)((RaycastHit)(ref val)).collider).gameObject; break; } } } } public class StaticText : MonoBehaviour, Hoverable { public string title = ""; public string text = ""; public string GetHoverText() { return Format.String(title) + "\n" + text; } public string GetHoverName() { return title; } } public class Visualization : MonoBehaviour { public string Tag = ""; private static readonly List<Visualization> Visualizations = new List<Visualization>(); private Quaternion? FixedRotation; public static void SharedUpdate() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) foreach (Visualization visualization in Visualizations) { ((Component)visualization).transform.rotation = visualization.FixedRotation.Value; } } public void OnDestroy() { if (Visualizations.Contains(this)) { Visualizations.Remove(this); } } public void SetFixed(Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) FixedRotation = rotation; Visualizations.Add(this); } } public class Visibility : Component { private static bool visible = false; private static readonly HashSet<string> visibleTags = new HashSet<string>(); private static readonly HashSet<string> tags = new HashSet<string>(); private static readonly Dictionary<string, string> tagToGroup = new Dictionary<string, string>(); public static List<string> GetTags { get { HashSet<string> hashSet = tags; List<string> list = new List<string>(hashSet.Count); list.AddRange(hashSet); return list; } } public static bool IsTag(string name) { if (visible && visibleTags.Contains(name)) { return !tagToGroup.ContainsKey(name); } return false; } public static void Set(bool visibility) { visible = visibility; UpdateVisibility(); } public static void ToggleTag(string tag) { SetTag(tag, !visibleTags.Contains(tag)); } public static void SetTag(string tag, bool visibility) { tags.Add(tag); if (visibility) { visibleTags.Add(tag); } else { visibleTags.Remove(tag); } UpdateTagVisibility(tag); } private static void UpdateTagVisibility(string name) { Visualization[] visualizations = Utils.GetVisualizations(); foreach (Visualization visualization in visualizations) { if (!(visualization.Tag != name)) { UpdateVisibility(visualization); } } } private static void UpdateVisibility() { Visualization[] visualizations = Utils.GetVisualizations(); for (int i = 0; i < visualizations.Length; i++) { UpdateVisibility(visualizations[i]); } } private static void UpdateVisibility(Visualization obj) { GameObject gameObject = ((Component)obj).gameObject; bool flag = IsTag(obj.Tag); if (gameObject.activeSelf != flag) { gameObject.SetActive(flag); } } } } namespace Data { public class Calculator { public static Vector3 EvaluateVector3(string expression) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; string[] array = Parse.Split(expression); zero.x = EvaluateFloat(array[0]).GetValueOrDefault(); if (array.Length > 1) { zero.z = EvaluateFloat(array[1]).GetValueOrDefault(); } if (array.Length > 2) { zero.y = EvaluateFloat(array[2]).GetValueOrDefault(); } return zero; } public static Vector3 EvaluateVector3(string[] s, int index) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; if (s.Length > index) { zero.x = EvaluateFloat(s[index]).GetValueOrDefault(); } if (s.Length > index + 1) { zero.z = EvaluateFloat(s[index + 1]).GetValueOrDefault(); } if (s.Length > index + 2) { zero.y = EvaluateFloat(s[index + 2]).GetValueOrDefault(); } return zero; } public static Quaternion EvaluateQuaternion(string expression) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; string[] array = Parse.Split(expression); zero.y = EvaluateFloat(array[0]).GetValueOrDefault(); if (array.Length > 1) { zero.x = EvaluateFloat(array[1]).GetValueOrDefault(); } if (array.Length > 2) { zero.z = EvaluateFloat(array[2]).GetValueOrDefault(); } return Quaternion.Euler(zero); } public static Quaternion EvaluateQuaternion(string[] s, int index) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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) Vector3 zero = Vector3.zero; if (s.Length > index) { zero.y = EvaluateFloat(s[index]).GetValueOrDefault(); } if (s.Length > index + 1) { zero.x = EvaluateFloat(s[index + 1]).GetValueOrDefault(); } if (s.Length > index + 2) { zero.z = EvaluateFloat(s[index + 2]).GetValueOrDefault(); } return Quaternion.Euler(zero); } public static int? EvaluateInt(string expression) { try { return (int?)EvaluateLong(expression); } catch { return null; } } public static float? EvaluateFloat(string expression) { try { return (float)EvaluateDouble(expression); } catch { return null; } } private static double EvaluateDouble(string expression) { string[] array = expression.Split(new char[1] { '+' }); if (array.Length > 1) { double num = 0.0; string[] array2 = array; foreach (string expression2 in array2) { num += EvaluateDouble(expression2); } return num; } string[] array3 = expression.Split(new char[1] { '-' }); if (array3.Where((string s) => s != "").Count() > 1) { double? num2 = null; for (int j = 0; j < array3.Length; j++) { if (!(array3[j] == "") || j + 1 >= array3.Length) { num2 = (num2.HasValue ? (num2 - EvaluateDouble(array3[j])) : new double?(EvaluateDouble(array3[j]))); } else { array3[j + 1] = "-" + array3[j + 1]; } } return num2.GetValueOrDefault(); } string[] array4 = expression.Split(new char[1] { '*' }); if (array4.Length > 1) { double num3 = 1.0; string[] array2 = array4; foreach (string expression3 in array2) { num3 *= EvaluateDouble(expression3); } return num3; } string[] array5 = expression.Split(new char[1] { '/' }); if (array5.Length > 1) { double num4 = EvaluateDouble(array5[0]); for (int k = 1; k < array5.Length; k++) { num4 /= EvaluateDouble(array5[k]); } return num4; } try { return double.Parse(expression.Trim(), NumberFormatInfo.InvariantInfo); } catch { throw new InvalidOperationException("Failed to parse expression: " + expression); } } public static long? EvaluateLong(string expression) { try { return EvalLong(expression); } catch { return null; } } private static long EvalLong(string expression) { string[] array = expression.Split(new char[1] { '+' }); if (array.Length > 1) { long num = 0L; string[] array2 = array; foreach (string expression2 in array2) { num += EvalLong(expression2); } return num; } string[] array3 = expression.Split(new char[1] { '-' }); if (array3.Where((string s) => s != "").Count() > 1) { long? num2 = null; for (int j = 0; j < array3.Length; j++) { if (!(array3[j] == "") || j + 1 >= array3.Length) { num2 = (num2.HasValue ? (num2 - EvalLong(array3[j])) : new long?(EvalLong(array3[j]))); } else { array3[j + 1] = "-" + array3[j + 1]; } } return num2.GetValueOrDefault(); } string[] array4 = expression.Split(new char[1] { '*' }); if (array4.Length > 1) { long num3 = 1L; string[] array2 = array4; foreach (string expression3 in array2) { num3 *= EvalLong(expression3); } return num3; } string[] array5 = expression.Split(new char[1] { '/' }); if (array5.Length > 1) { long num4 = EvalLong(array5[0]); for (int k = 1; k < array5.Length; k++) { num4 /= EvalLong(array5[k]); } return num4; } try { return long.Parse(expression.Trim()); } catch { throw new InvalidOperationException("Failed to parse expression: " + expression); } } } public class Parameters { [CompilerGenerated] private string <prefab>P; [CompilerGenerated] private string <arg>P; [CompilerGenerated] private Vector3 <pos>P; public static Func<string, string?> ExecuteCode = (string key) => null; public static Func<string, string, string?> ExecuteCodeWithValue = (string key, string value) => null; protected string[]? args; private readonly double time; public Parameters(string prefab, string arg, Vector3 pos) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) <prefab>P = prefab; <arg>P = arg; <pos>P = pos; time = ZNet.instance.GetTimeSeconds(); base..ctor(); } public string Replace(string str) { StringBuilder stringBuilder = new StringBuilder(); int num = 0; int num2 = 0; for (int i = 0; i < str.Length; i++) { if (str[i] == '<') { if (num == 0) { stringBuilder.Append(str.Substring(num2, i - num2)); num2 = i; } num++; } if (str[i] == '>') { if (num == 1) { string str2 = str.Substring(num2, i - num2 + 1); stringBuilder.Append(ResolveParameters(str2)); num2 = i + 1; } if (num > 0) { num--; } } } if (num2 < str.Length) { stringBuilder.Append(str.Substring(num2)); } return stringBuilder.ToString(); } private string ResolveParameters(string str) { int num; for (num = 0; num < str.Length; num++) { int num2 = str.IndexOf(">", num); if (num2 == -1) { break; } num = num2; int num3 = str.LastIndexOf("<", num2); if (num3 != -1) { int num4 = num2 - num3 + 1; if (TryReplaceParameter(str.Substring(num3, num4), out string resolved)) { str = str.Remove(num3, num4); str = str.Insert(num3, resolved); num = num3 - 1; } else { num = num2; } } } return str; } private bool TryReplaceParameter(string key, out string resolved) { resolved = GetParameter(key) ?? key; return resolved != key; } protected virtual string? GetParameter(string key) { string text = ExecuteCode(key.Substring(1, key.Length - 2)); if (text != null) { return text; } text = GetGeneralParameter(key); if (text != null) { return text; } KeyValuePair<string, string> keyValuePair = Parse.Kvp(key, '_'); if (keyValuePair.Value == "") { return null; } key = keyValuePair.Key.Substring(1); string str = keyValuePair.Value.Substring(0, keyValuePair.Value.Length - 1); KeyValuePair<string, string> keyValuePair2 = Parse.Kvp(str, '='); str = keyValuePair2.Key; string value = keyValuePair2.Value; text = ExecuteCodeWithValue(key, str); if (text != null) { return text; } return GetValueParameter(key, str, value); } private string? GetGeneralParameter(string key) { return key switch { "<prefab>" => <prefab>P, "<par>" => <arg>P, "<par0>" => GetArg(0), "<par1>" => GetArg(1), "<par2>" => GetArg(2), "<par3>" => GetArg(3), "<par4>" => GetArg(4), "<par5>" => GetArg(5), "<par6>" => GetArg(6), "<par7>" => GetArg(7), "<par8>" => GetArg(8), "<par9>" => GetArg(9), "<time>" => Format(time), "<day>" => EnvMan.instance.GetDay(time).ToString(), "<ticks>" => ((long)(time * 10000000.0)).ToString(), "<x>" => Format(<pos>P.x), "<y>" => Format(<pos>P.y), "<z>" => Format(<pos>P.z), "<snap>" => Format(WorldGenerator.instance.GetHeight(<pos>P.x, <pos>P.z)), _ => null, }; } protected virtual string? GetValueParameter(string key, string value, string defaultValue) { float result; float result2; float result3; float result4; float result5; float result6; float result7; float result8; float result9; float result10; KeyValuePair<string, string> kvp; float result11; float result12; float result13; KeyValuePair<string, string> kvp2; float result14; float result15; KeyValuePair<string, string> kvp3; float result16; float result17; KeyValuePair<string, string> kvp4; float result18; float result19; KeyValuePair<string, string> kvp5; float result20; float result21; KeyValuePair<string, string> kvp6; float result22; float result23; KeyValuePair<string, string> kvp7; float result24; float result25; KeyValuePair<string, string> kvp8; float result26; float result27; KeyValuePair<string, string> kvp9; float result28; float result29; KeyValuePair<string, string> kvp10; int result30; int result31; int result32; int result33; return key switch { "sqrt" => Parse.TryFloat(value, out result) ? Mathf.Sqrt(result).ToString(CultureInfo.InvariantCulture) : defaultValue, "round" => Parse.TryFloat(value, out result2) ? Mathf.Round(result2).ToString(CultureInfo.InvariantCulture) : defaultValue, "ceil" => Parse.TryFloat(value, out result3) ? Mathf.Ceil(result3).ToString(CultureInfo.InvariantCulture) : defaultValue, "floor" => Parse.TryFloat(value, out result4) ? Mathf.Floor(result4).ToString(CultureInfo.InvariantCulture) : defaultValue, "abs" => Parse.TryFloat(value, out result5) ? Mathf.Abs(result5).ToString(CultureInfo.InvariantCulture) : defaultValue, "sin" => Parse.TryFloat(value, out result6) ? Mathf.Sin(result6).ToString(CultureInfo.InvariantCulture) : defaultValue, "cos" => Parse.TryFloat(value, out result7) ? Mathf.Cos(result7).ToString(CultureInfo.InvariantCulture) : defaultValue, "tan" => Parse.TryFloat(value, out result8) ? Mathf.Tan(result8).ToString(CultureInfo.InvariantCulture) : defaultValue, "asin" => Parse.TryFloat(value, out result9) ? Mathf.Asin(result9).ToString(CultureInfo.InvariantCulture) : defaultValue, "acos" => Parse.TryFloat(value, out result10) ? Mathf.Acos(result10).ToString(CultureInfo.InvariantCulture) : defaultValue, "atan" => Atan(value, defaultValue), "pow" => (Parse.TryKvp(value, out kvp, '_') && Parse.TryFloat(kvp.Key, out result11) && Parse.TryFloat(kvp.Value, out result12)) ? Mathf.Pow(result11, result12).ToString(CultureInfo.InvariantCulture) : defaultValue, "log" => Log(value, defaultValue), "exp" => Parse.TryFloat(value, out result13) ? Mathf.Exp(result13).ToString(CultureInfo.InvariantCulture) : defaultValue, "min" => (Parse.TryKvp(value, out kvp2, '_') && Parse.TryFloat(kvp2.Key, out result14) && Parse.TryFloat(kvp2.Value, out result15)) ? Mathf.Min(result14, result15).ToString(CultureInfo.InvariantCulture) : defaultValue, "max" => (Parse.TryKvp(value, out kvp3, '_') && Parse.TryFloat(kvp3.Key, out result16) && Parse.TryFloat(kvp3.Value, out result17)) ? Mathf.Max(result16, result17).ToString(CultureInfo.InvariantCulture) : defaultValue, "add" => (Parse.TryKvp(value, out kvp4, '_') && Parse.TryFloat(kvp4.Key, out result18) && Parse.TryFloat(kvp4.Value, out result19)) ? (result18 + result19).ToString(CultureInfo.InvariantCulture) : defaultValue, "sub" => (Parse.TryKvp(value, out kvp5, '_') && Parse.TryFloat(kvp5.Key, out result20) && Parse.TryFloat(kvp5.Value, out result21)) ? (result20 - result21).ToString(CultureInfo.InvariantCulture) : defaultValue, "mul" => (Parse.TryKvp(value, out kvp6, '_') && Parse.TryFloat(kvp6.Key, out result22) && Parse.TryFloat(kvp6.Value, out result23)) ? (result22 * result23).ToString(CultureInfo.InvariantCulture) : defaultValue, "div" => (Parse.TryKvp(value, out kvp7, '_') && Parse.TryFloat(kvp7.Key, out result24) && Parse.TryFloat(kvp7.Value, out result25)) ? (result24 / result25).ToString(CultureInfo.InvariantCulture) : defaultValue, "mod" => (Parse.TryKvp(value, out kvp8, '_') && Parse.TryFloat(kvp8.Key, out result26) && Parse.TryFloat(kvp8.Value, out result27)) ? (result26 % result27).ToString(CultureInfo.InvariantCulture) : defaultValue, "randf" => (Parse.TryKvp(value, out kvp9, '_') && Parse.TryFloat(kvp9.Key, out result28) && Parse.TryFloat(kvp9.Value, out result29)) ? Random.Range(result28, result29).ToString(CultureInfo.InvariantCulture) : defaultValue, "randi" => (Parse.TryKvp(value, out kvp10, '_') && Parse.TryInt(kvp10.Key, out result30) && Parse.TryInt(kvp10.Value, out result31)) ? Random.Range(result30, result31).ToString(CultureInfo.InvariantCulture) : defaultValue, "hash" => Hash(value).ToString(), "len" => value.Length.ToString(CultureInfo.InvariantCulture), "lower" => value.ToLowerInvariant(), "upper" => value.ToUpperInvariant(), "trim" => value.Trim(), "calcf" => Calculator.EvaluateFloat(value)?.ToString(CultureInfo.InvariantCulture) ?? defaultValue, "calci" => Calculator.EvaluateInt(value)?.ToString(CultureInfo.InvariantCulture) ?? defaultValue, "par" => Parse.TryInt(value, out result32) ? GetArg(result32, defaultValue) : defaultValue, "rest" => Parse.TryInt(value, out result33) ? GetRest(result33, defaultValue) : defaultValue, _ => null, }; } private string GetRest(int index, string defaultValue = "") { if (args == null) { args = <arg>P.Split(new char[1] { ' ' }); } if (index < 0 || index >= args.Length) { return defaultValue; } return string.Join(" ", args, index, args.Length - index); } private string Atan(string value, string defaultValue) { KeyValuePair<string, string> keyValuePair = Parse.Kvp(value, '_'); if (!Parse.TryFloat(keyValuePair.Key, out var result)) { return defaultValue; } if (keyValuePair.Value == "") { return Mathf.Atan(result).ToString(CultureInfo.InvariantCulture); } if (!Parse.TryFloat(keyValuePair.Value, out var result2)) { return defaultValue; } return Mathf.Atan2(result, result2).ToString(CultureInfo.InvariantCulture); } private string Log(string value, string defaultValue) { KeyValuePair<string, string> keyValuePair = Parse.Kvp(value, '_'); if (!Parse.TryFloat(keyValuePair.Key, out var result)) { return defaultValue; } if (keyValuePair.Value == "") { return Mathf.Log(result).ToString(CultureInfo.InvariantCulture); } if (!Parse.TryFloat(keyValuePair.Value, out var result2)) { return defaultValue; } return Mathf.Log(result, result2).ToString(CultureInfo.InvariantCulture); } private string GetArg(int index, string defaultValue = "") { if (args == null) { args = <arg>P.Split(new char[1] { ' ' }); } if (args.Length > index) { return args[index]; } return defaultValue; } protected static string Format(float value) { return value.ToString("0.#####", NumberFormatInfo.InvariantInfo); } protected static string Format(double value) { return value.ToString("0.#####", NumberFormatInfo.InvariantInfo); } public static string PrintVectorXZY(Vector3 vector) { return vector.x.ToString("0.##", CultureInfo.InvariantCulture) + " " + vector.z.ToString("0.##", CultureInfo.InvariantCulture) + " " + vector.y.ToString("0.##", CultureInfo.InvariantCulture); } public static string PrintAngleYXZ(Quaternion quaternion) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return PrintVectorYXZ(((Quaternion)(ref quaternion)).eulerAngles); } private static string PrintVectorYXZ(Vector3 vector) { return vector.y.ToString("0.##", CultureInfo.InvariantCulture) + " " + vector.x.ToString("0.##", CultureInfo.InvariantCulture) + " " + vector.z.ToString("0.##", CultureInfo.InvariantCulture); } public static int Hash(string key) { if (Parse.TryInt(key, out var result)) { return result; } if (key.StartsWith("$", StringComparison.InvariantCultureIgnoreCase)) { int hash = ZSyncAnimation.GetHash(key.Substring(1)); if (key == "$anim_speed") { return hash; } return 438569 + hash; } return StringExtensionMethods.GetStableHashCode(key); } public static string GetGlobalKey(string key) { string lower = key.ToLowerInvariant(); return ZoneSystem.instance.m_globalKeysValues.FirstOrDefault((KeyValuePair<string, string> kvp) => kvp.Key.ToLowerInvariant() == lower).Value ?? "0"; } } public class ObjectParameters : Parameters { [CompilerGenerated] private ZDO <zdo>P; private Inventory? inventory; public ObjectParameters(string prefab, string arg, ZDO zdo) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) <zdo>P = zdo; base..ctor(prefab, arg, <zdo>P.m_position); } protected override string? GetParameter(string key) { string parameter = base.GetParameter(key); if (parameter != null) { return parameter; } parameter = GetGeneralParameter(key); if (parameter != null) { return parameter; } KeyValuePair<string, string> keyValuePair = Parse.Kvp(key, '_'); if (keyValuePair.Value == "") { return null; } key = keyValuePair.Key.Substring(1); string str = keyValuePair.Value.Substring(0, keyValuePair.Value.Length - 1); KeyValuePair<string, string> keyValuePair2 = Parse.Kvp(str, '='); str = keyValuePair2.Key; string value = keyValuePair2.Value; parameter = Parameters.ExecuteCodeWithValue(key, str); if (parameter != null) { return parameter; } parameter = base.GetValueParameter(key, str, value); if (parameter != null) { return parameter; } return GetValueParameter(key, str, value); } private string? GetGeneralParameter(string key) { //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: 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) return key switch { "<zdo>" => ((object)(ZDOID)(ref <zdo>P.m_uid)).ToString(), "<pos>" => Parameters.Format(<zdo>P.m_position.x) + "," + Parameters.Format(<zdo>P.m_position.z) + "," + Parameters.Format(<zdo>P.m_position.y), "<i>" => ZoneSystem.GetZone(<zdo>P.m_position).x.ToString(), "<j>" => ZoneSystem.GetZone(<zdo>P.m_position).y.ToString(), "<a>" => Parameters.Format(<zdo>P.m_rotation.y), "<rot>" => Parameters.Format(<zdo>P.m_rotation.y) + "," + Parameters.Format(<zdo>P.m_rotation.x) + "," + Parameters.Format(<zdo>P.m_rotation.z), "<pid>" => GetPid(<zdo>P), "<pname>" => GetPname(<zdo>P), "<pchar>" => GetPchar(<zdo>P), "<owner>" => <zdo>P.GetOwner().ToString(), _ => null, }; } private static string GetPid(ZDO zdo) { ZNetPeer peer = GetPeer(zdo); if (peer != null) { return peer.m_rpc.GetSocket().GetHostName(); } if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return "Server"; } return ""; } private static string GetPname(ZDO zdo) { ZNetPeer peer = GetPeer(zdo); if (peer != null) { return peer.m_playerName; } if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return Player.m_localPlayer.GetPlayerName(); } return ""; } private static string GetPchar(ZDO zdo) { ZNetPeer peer = GetPeer(zdo); if (peer != null) { return ((object)(ZDOID)(ref peer.m_characterID)).ToString(); } if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return Player.m_localPlayer.GetPlayerID().ToString(); } return ""; } private static ZNetPeer? GetPeer(ZDO zdo) { if (zdo.GetOwner() == 0L) { return null; } return ZNet.instance.GetPeer(zdo.GetOwner()); } protected override string? GetValueParameter(string key, string value, string defaultValue) { //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) switch (key) { case "key": return Parameters.GetGlobalKey(value); case "string": return GetString(value, defaultValue); case "float": return GetFloat(value, defaultValue).ToString(CultureInfo.InvariantCulture); case "int": return GetInt(value, defaultValue).ToString(CultureInfo.InvariantCulture); case "long": return GetLong(value, defaultValue).ToString(CultureInfo.InvariantCulture); case "bool": return GetBool(value, defaultValue) ? "true" : "false"; case "hash": { GameObject prefab = ZNetScene.instance.GetPrefab(<zdo>P.GetInt(value, 0)); return ((prefab != null) ? ((Object)prefab).name : null) ?? ""; } case "vec": return Parameters.PrintVectorXZY(GetVec3(value, defaultValue)); case "quat": return Parameters.PrintAngleYXZ(GetQuaternion(value, defaultValue)); case "byte": return Convert.ToBase64String(<zdo>P.GetByteArray(value, (byte[])null)); case "zdo": { ZDOID zDOID = <zdo>P.GetZDOID(value); return ((object)(ZDOID)(ref zDOID)).ToString(); } case "item": return GetAmountOfItems(value).ToString(); case "pos": return Parameters.PrintVectorXZY(GetPos(value)); case "pdata": return GetPlayerData(<zdo>P, value); default: return null; } } private string GetString(string value, string defaultValue) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) string result = default(string); if (!ZDOExtraData.s_strings.TryGetValue(<zdo>P.m_uid, out var value2) || !value2.TryGetValue(Parameters.Hash(value), ref result)) { return GetStringField(value, defaultValue); } return result; } private float GetFloat(string value, string defaultValue) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) float result = default(float); if (!ZDOExtraData.s_floats.TryGetValue(<zdo>P.m_uid, out var value2) || !value2.TryGetValue(Parameters.Hash(value), ref result)) { return GetFloatField(value, defaultValue); } return result; } private int GetInt(string value, string defaultValue) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) int result = default(int); if (!ZDOExtraData.s_ints.TryGetValue(<zdo>P.m_uid, out var value2) || !value2.TryGetValue(Parameters.Hash(value), ref result)) { return GetIntField(value, defaultValue); } return result; } private long GetLong(string value, string defaultValue) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) long result = default(long); if (!ZDOExtraData.s_longs.TryGetValue(<zdo>P.m_uid, out var value2) || !value2.TryGetValue(Parameters.Hash(value), ref result)) { return GetLongField(value, defaultValue); } return result; } private bool GetBool(string value, string defaultValue) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) int num = default(int); if (!ZDOExtraData.s_ints.TryGetValue(<zdo>P.m_uid, out var value2) || !value2.TryGetValue(Parameters.Hash(value), ref num)) { return GetBoolField(value, defaultValue); } return num > 0; } private Vector3 GetVec3(string value, string defaultValue) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) Vector3 result = default(Vector3); if (!ZDOExtraData.s_vec3.TryGetValue(<zdo>P.m_uid, out var value2) || !value2.TryGetValue(Parameters.Hash(value), ref result)) { return GetVecField(value, defaultValue); } return result; } private Quaternion GetQuaternion(string value, string defaultValue) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) Quaternion result = default(Quaternion); if (!ZDOExtraData.s_quats.TryGetValue(<zdo>P.m_uid, out var value2) || !value2.TryGetValue(Parameters.Hash(value), ref result)) { return GetQuatField(value, defaultValue); } return result; } private string GetStringField(string value, string defaultValue) { if (!(GetField(value) is string result)) { return defaultValue; } return result; } private float GetFloatField(string value, string defaultValue) { object field = GetField(value); if (field is float) { return (float)field; } return Parse.Float(defaultValue); } private int GetIntField(string value, string defaultValue) { object field = GetField(value); if (field is int) { return (int)field; } return Parse.Int(defaultValue); } private bool GetBoolField(string value, string defaultValue) { object field = GetField(value); if (field is bool) { return (bool)field; } return Parse.Boolean(defaultValue); } private long GetLongField(string value, string defaultValue) { object field = GetField(value); if (field is long) { return (long)field; } return Parse.Long(defaultValue, 0L); } private Vector3 GetVecField(string value, string defaultValue) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) object field = GetField(value); if (field is Vector3) { return (Vector3)field; } return Parse.VectorXZY(defaultValue); } private Quaternion GetQuatField(string value, string defaultValue) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) object field = GetField(value); if (field is Quaternion) { return (Quaternion)field; } return Parse.AngleYXZ(defaultValue); } private object? GetField(string value) { KeyValuePair<string, string> keyValuePair = Parse.Kvp(value, '.'); if (keyValuePair.Value == "") { return null; } GameObject prefab = ZNetScene.instance.GetPrefab(<zdo>P.m_prefab); if ((Object)(object)prefab == (Object)null) { return null; } Component component = prefab.GetComponent(keyValuePair.Key); if ((Object)(object)component == (Object)null) { return null; } string[] array = keyValuePair.Value.Split(new char[1] { '.' }); object obj = component; string[] array2 = array; foreach (string name in array2) { FieldInfo field = obj.GetType().GetField(name); if (field == null) { return null; } obj = field.GetValue(obj); if (obj == null) { return null; } } return obj; } private int GetAmountOfItems(string prefab) { LoadInventory(); if (inventory == null) { return 0; } int num = 0; foreach (ItemData item in inventory.m_inventory) { GameObject dropPrefab = item.m_dropPrefab; if ((((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? item.m_shared.m_name) == prefab) { num += item.m_stack; } } return num; } private void LoadInventory() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown if (inventory == null) { string @string = <zdo>P.GetString(ZDOVars.s_items, ""); if (!(@string == "")) { inventory = new Inventory("", (Sprite)null, 4, 2); inventory.Load(new ZPackage(@string)); } } } private Vector3 GetPos(string value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Parse.VectorXZY(value); return <zdo>P.GetPosition() + <zdo>P.GetRotation() * val; } public static string GetPlayerData(ZDO zdo, string key) { ZNetPeer peer = GetPeer(zdo); if (peer != null) { if (!peer.m_serverSyncedPlayerData.TryGetValue(key, out var value)) { return ""; } return value; } if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { if (!ZNet.instance.m_serverSyncedPlayerData.TryGetValue(key, out var value2)) { return ""; } return value2; } return ""; } } public class PrefabHelper { private static readonly Dictionary<string, List<int>> ResultCache = new Dictionary<string, List<int>>(); private static readonly Dictionary<int, List<int>> Groups = new Dictionary<int, List<int>>(); private static readonly int WearNTearHash = StringExtensionMethods.GetStableHashCode("wearntear"); private static readonly int HumanoidHash = StringExtensionMethods.GetStableHashCode("humanoid"); private static readonly int CreatureHash = StringExtensionMethods.GetStableHashCode("creature"); private static readonly int StructureHash = StringExtensionMethods.GetStableHashCode("structure"); private static Dictionary<string, int> PrefabCache = new Dictionary<string, int>(); public static int? GetPrefab(string value) { List<int> prefabs = GetPrefabs(value); if (prefabs.Count == 0) { return null; } if (prefabs.Count == 1) { return prefabs[0]; } return prefabs[Random.Range(0, prefabs.Count)]; } public static void ClearCache() { ResultCache.Clear(); PrefabCache.Clear(); LoadGroups(); } private static void LoadGroups() { if (Groups.Count > 0) { return; } foreach (KeyValuePair<int, GameObject> namedPrefab in ZNetScene.instance.m_namedPrefabs) { if (!Object.op_Implicit((Object)(object)namedPrefab.Value)) { continue; } namedPrefab.Value.GetComponentsInChildren<MonoBehaviour>(ZNetView.m_tempComponents); foreach (MonoBehaviour tempComponent in ZNetView.m_tempComponents) { int stableHashCode = StringExtensionMethods.GetStableHashCode(((object)tempComponent).GetType().Name.ToLowerInvariant()); if (!Groups.ContainsKey(stableHashCode)) { Groups[stableHashCode] = new List<int>(); } Groups[stableHashCode].Add(namedPrefab.Key); } } Groups[CreatureHash] = Groups[HumanoidHash]; Groups[StructureHash] = Groups[WearNTearHash]; } public static List<int> GetPrefabs(string value) { if (ResultCache.ContainsKey(value)) { return ResultCache[value]; } List<int> prefabs = GetPrefabs(Parse.ToList(value)); if (prefabs == null) { return new List<int>(); } ResultCache[value] = prefabs; return prefabs; } public static List<int>? GetPrefabs(List<string> values) { if (values.Count == 0) { return null; } if (values.Count == 1) { return ParsePrefabs(values[0]); } List<List<int>> list = (from s in values.Select(ParsePrefabs) where s != null select s).ToList(); HashSet<int> hashSet = new HashSet<int>(); foreach (List<int> item in list) { if (item == null) { continue; } foreach (int item2 in item) { hashSet.Add(item2); } } if (hashSet.Count != 0) { HashSet<int> hashSet2 = hashSet; List<int> list2 = new List<int>(hashSet2.Count); list2.AddRange(hashSet2); return list2; } return null; } private static List<int>? ParsePrefabs(string prefab) { string p = prefab.ToLowerInvariant(); if (PrefabCache.Count == 0) { PrefabCache = ZNetScene.instance.m_namedPrefabs.ToDictionary((KeyValuePair<int, GameObject> pair) => ((Object)pair.Value).name, (KeyValuePair<int, GameObject> pair) => pair.Key); } if (p == "*") { Dictionary<string, int>.ValueCollection values = PrefabCache.Values; List<int> list = new List<int>(values.Count); list.AddRange(values); return list; } if (p[0] == '*' && p[p.Length - 1] == '*') { p = p.Substring(1, p.Length - 2); return (from pair in PrefabCache where pair.Key.ToLowerInvariant().Contains(p) select pair.Value).ToList(); } if (p[0] == '*') { p = p.Substring(1); return (from pair in PrefabCache where pair.Key.EndsWith(p, StringComparison.OrdinalIgnoreCase) select pair.Value).ToList(); } if (p[p.Length - 1] == '*') { p = p.Substring(0, p.Length - 1); return (from pair in PrefabCache where pair.Key.StartsWith(p, StringComparison.OrdinalIgnoreCase) select pair.Value).ToList(); } if (PrefabCache.ContainsKey(prefab)) { return new List<int>(1) { PrefabCache[prefab] }; } int stableHashCode = StringExtensionMethods.GetStableHashCode(p); if (Groups.ContainsKey(stableHashCode)) { return Groups[stableHashCode]; } Log.Warning("Failed to resolve prefab: " + prefab); return null; } } } namespace Service { public static class Admin { public static IAdmin Instance = new DefaultAdmin(); public static bool Enabled { get { return Instance.Enabled; } set { Instance.Enabled = value; } } public static bool Checking { get { return Instance.Checking; } set { Instance.Checking = value; } } public static void Check() { Instance.Check(); } public static void Verify(string text) { Instance.Verify(text); } } public interface IAdmin { bool Enabled { get; set; } bool Checking { get; set; } void Check(); void Verify(string text); } public class DefaultAdmin : IAdmin { public virtual bool Enabled { get; set; } public virtual bool Checking { get; set; } public void Check() { if (Object.op_Implicit((Object)(object)ZNet.instance)) { Checking = true; if (ZNet.instance.IsServer()) { OnSuccess(); } else { ZNet.instance.Unban("admintest"); } } } public void Verify(string text) { if (text == "Unbanning user admintest") { OnSuccess(); } else { OnFail(); } } protected virtual void OnSuccess() { Checking = false; Enabled = true; } protected virtual void OnFail() { Checking = false; Enabled = false; } } [HarmonyPatch(typeof(ZNet), "RPC_RemotePrint")] public class ZNet_RPC_RemotePrint { private static bool Prefix(string text) { if (!Admin.Checking) { return true; } Admin.Verify(text); return false; } } [HarmonyPatch(typeof(Game), "UpdateRespawn")] public class CheckAdmin { private static void Prefix(bool ___m_firstSpawn, ref bool __state) { if (___m_firstSpawn) { Admin.Enabled = false; } __state = ___m_firstSpawn; } private static void Postfix(bool ___m_firstSpawn, bool __state) { if (__state && !___m_firstSpawn && !Admin.Checking) { Admin.Check(); } } } public class Format { public const string FORMAT = "0.##"; public static string GetValidColor(bool valid) { if (!valid) { return "#B2BEB5"; } return "#FFFF00"; } public static string String(string value, string color = "#FFFF00") { return "<color=" + color + ">" + value + "</color>"; } public static string String(string value, bool valid) { return "<color=" + GetValidColor(valid) + ">" + value + "</color>"; } public static string Float(double value, string format = "0.##", string color = "#FFFF00") { return String(value.ToString(format, CultureInfo.InvariantCulture), color); } public static string Multiplier(double value, string color = "#FFFF00") { return String(value.ToString("0.##", CultureInfo.InvariantCulture) + "x", color); } public static string Meters(double value, string color = "#FFFF00") { return String(value.ToString("0.##", CultureInfo.InvariantCulture) + " meters", color); } public static string Degrees(double value, string color = "#FFFF00") { return String(value.ToString("0.##", CultureInfo.InvariantCulture) + " degrees", color); } public static string Fixed(double value) { return String(value.ToString("N2", CultureInfo.InvariantCulture).PadLeft(5, '0')); } public static string Percent(double value, string color = "#FFFF00") { return String((100.0 * value).ToString("0.##", CultureInfo.InvariantCulture) + " %", color); } public static string PercentInt(double value, string color = "#FFFF00") { return String(value.ToString("P0", CultureInfo.InvariantCulture), color); } public static string Range(double min, double max, string color = "#FFFF00") { if (min == max) { return String(max.ToString("0.##", CultureInfo.InvariantCulture), color); } return String(min.ToString("0.##", CultureInfo.InvariantCulture), color) + "-" + String(max.ToString("0.##", CultureInfo.InvariantCulture), color); } public static string PercentRange(double min, double max) { if (min == max) { return max.ToString("P0", CultureInfo.InvariantCulture); } return min.ToString("P0", CultureInfo.InvariantCulture) + "-" + max.ToString("P0", CultureInfo.InvariantCulture); } public static string Progress(double value, double limit, bool percent = false) { return String(value.ToString("N0")) + "/" + String(limit.ToString("N0")) + (percent ? (" (" + PercentInt(value / limit) + ")") : ""); } public static string Int(double value, string color = "#FFFF00") { return String(value.ToString("N0"), color); } public static string ProgressPercent(string header, double value, double limit) { return header + ": " + Progress(value, limit) + " seconds (" + Percent(value / limit) + ")"; } public static string Coordinates(Vector3 coordinates, string format = "F0", string color = "#FFFF00") { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) string color2 = color; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(coordinates.x, coordinates.z, coordinates.y); return JoinRow(from value in ((Vector3)(ref val)).ToString(format).Replace("(", "").Replace(")", "") .Split(new char[1] { ',' }) select String(value.Trim(), color2)); } public static string JoinLines(IEnumerable<string> lines) { return string.Join("\n", lines.Where((string line) => line != "")); } public static string JoinRow(IEnumerable<string> lines) { return string.Join(", ", lines.Where((string line) => line != "")); } } public class Helper { private static T Get<T>(object obj, string field) { return Traverse.Create(obj).Field<T>(field).Value; } public static ZNetView Nview(MonoBehaviour obj) { return Get<ZNetView>(obj, "m_nview"); } public static double GetElapsed(MonoBehaviour obj, string key, long defaultValue = 0L) { DateTime time = ZNet.instance.GetTime(); DateTime dateTime = GetDateTime(obj, key, defaultValue); return (time - dateTime).TotalSeconds; } public static double GetElapsed(MonoBehaviour obj, int key, long defaultValue = 0L) { DateTime time = ZNet.instance.GetTime(); DateTime dateTime = GetDateTime(obj, key, defaultValue); return (time - dateTime).TotalSeconds; } public static DateTime GetDateTime(MonoBehaviour obj, string key, long defaultValue = 0L) { return new DateTime(GetLong(obj, key, defaultValue)); } public static DateTime GetDateTime(MonoBehaviour obj, int key, long defaultValue = 0L) { return new DateTime(GetLong(obj, key, defaultValue)); } public static float GetFloat(MonoBehaviour obj, string key, float defaultValue = 0f) { return Nview(obj).GetZDO().GetFloat(key, defaultValue); } public static long GetLong(MonoBehaviour obj, string key, long defaultValue = 0L) { return Nview(obj).GetZDO().GetLong(key, defaultValue); } public static long GetLong(MonoBehaviour obj, int key, long defaultValue = 0L) { return Nview(obj).GetZDO().GetLong(key, defaultValue); } public static int GetInt(MonoBehaviour obj, string key, int defaultValue = 0) { return Nview(obj).GetZDO().GetInt(key, defaultValue); } public static bool GetBool(MonoBehaviour obj, string key, bool defaultValue = false) { return Nview(obj).GetZDO().GetBool(key, defaultValue); } public static string GetString(MonoBehaviour obj, string key, string defaultValue = "") { return Nview(obj).GetZDO().GetString(key, defaultValue); } public static GameObject GetPrefab(MonoBehaviour obj) { return ZNetScene.instance.GetPrefab(Nview(obj).GetZDO().GetPrefab()); } public static bool IsValid(MonoBehaviour obj) { if (!Object.op_Implicit((Object)(object)obj)) { return false; } ZNetView val = Nview(obj); if (!Object.op_Implicit((Object)(object)val)) { return false; } return val.IsValid(); } } public class Log { private static ManualLogSource Logger; public static void Init(ManualLogSource logger) { Logger = logger; } public static void Error(string message) { Logger.LogError((object)message); } public static void Warning(string message) { Logger.LogWarning((object)message); } public static void Info(string message) { Logger.LogInfo((object)message); } public static void Debug(string message) { Logger.LogDebug((object)message); } } [HarmonyPatch(typeof(Hud), "Awake")] public class HudAwake { private static void Postfix(Hud __instance) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) RectTransform component = ((Component)__instance.m_hoverName).GetComponent<RectTransform>(); component.sizeDelta += new Vector2(100f, 0f); } } [HarmonyPatch(typeof(MessageHud), "Update")] [HarmonyPriority(200)] public class MessageHud_UpdateMessage : MonoBehaviour { public static Func<List<string>> GetMessage = () => new List<string> { "Default message. Replace with your own function." }; private static void Postfix(MessageHud __instance) { if ((Object)(object)Player.m_localPlayer == (Object)null || Hud.IsUserHidden()) { return; } __instance.m_messageText.alignment = (TextAlignmentOptions)257; string text = __instance.m_messageText.text; List<string> list = GetMessage(); if (list.Count != 0) { if (text != "") { list.Add(" "); list.Add(text); } __instance.m_messageText.text = Format.JoinLines(list); ((Graphic)__instance.m_messageText).CrossFadeAlpha(1f, 0f, true); ((Graphic)__instance.m_messageIcon).canvasRenderer.SetAlpha(0f); ((Graphic)__instance.m_messageIcon).CrossFadeAlpha(0f, 0f, true); } } } [HarmonyPatch(typeof(MessageHud), "UpdateMessage")] public class MessageHud_GetBaseMessage : MonoBehaviour { private static string BaseMessage = ""; private static void Prefix(out string __state) { __state = MessageHud.instance.m_messageText.text; } private static void Postfix(MessageHud __instance, float ___m_msgQueueTimer, string __state) { if (__instance.m_messageText.text != __state) { BaseMessage = __instance.m_messageText.text; } if (___m_msgQueueTimer >= 4f) { BaseMessage = ""; } __instance.m_messageText.text = BaseMessage; } } public class Range<T> { public T Min; public T Max; public bool Uniform = true; public Range(T value) { Min = value; Max = value; } public Range(T min, T max) { Min = min; Max = max; } } public static class Parse { public static List<string> ToList(string str, bool removeEmpty = true) { string[] array = Split(str, removeEmpty); List<string> list = new List<string>(array.Length); list.AddRange(array); return list; } public static Vector2i Vector2Int(string arg) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) string[] array = SplitWithEmpty(arg); return new Vector2i(Int(array[0]), (array.Length > 1) ? Int(array[1]) : 0); } public static int Int(string arg, int defaultValue = 0) { if (!TryInt(arg, out var result)) { return defaultValue; } return result; } public static uint UInt(string arg, uint defaultValue = 0u) { if (!TryUInt(arg, out var result)) { return defaultValue; } return result; } public static long Long(string arg, long defaultValue = 0L) { if (!long.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return defaultValue; } return result; } public static bool TryLong(string arg, out long result) { return long.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out result); } public static int Int(string[] args, int index, int defaultValue = 0) { if (args.Length <= index) { return defaultValue; } return Int(args[index], defaultValue); } public static bool TryUInt(string arg, out uint result) { return uint.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out result); } public static bool TryInt(string arg, out int result) { return int.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out result); } public static float Float(string arg, float defaultValue = 0f) { if (!TryFloat(arg, out var result)) { return defaultValue; } return result; } public static float Float(string[] args, int index, float defaultValue = 0f) { if (args.Length <= index) { return defaultValue; } return Float(args[index], defaultValue); } public static bool TryFloat(string arg, out float result) { return float.TryParse(arg, NumberStyles.Float, CultureInfo.InvariantCulture, out result); } public static bool TryBoolean(string arg, out bool result) { result = false; if (arg.ToLowerInvariant() == "true") { result = true; return true; } if (arg.ToLowerInvariant() == "false") { return true; } return false; } public static Quaternion AngleYXZ(string arg) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) return AngleYXZ(Split(arg), 0, Vector3.zero); } public static Quaternion AngleYXZ(string[] args, int index) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return AngleYXZ(args, index, Vector3.zero); } public static Quaternion AngleYXZ(string[] args, int index, Vector3 defaultValue) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; zero.y = Float(args, index, defaultValue.y); zero.x = Float(args, index + 1, defaultValue.x); zero.z = Float(args, index + 2, defaultValue.z); return Quaternion.Euler(zero); } public static string[] Split(string arg, bool removeEmpty = true, char split = ',') { return (from s in arg.Split(new char[1] { split }) select s.Trim() into s where !removeEmpty || s != "" select s).ToArray(); } public static KeyValuePair<string, string> Kvp(string str, char separator = ',') { string[] array = str.Split(new char[1] { separator }, 2); if (array.Length < 2) { return new KeyValuePair<string, string>(array[0], ""); } return new KeyValuePair<string, string>(array[0], array[1].Trim()); } public static bool TryKvp(string str, out KeyValuePair<string, string> kvp, char separator = ',') { kvp = Kvp(str, separator); return kvp.Value != ""; } public static string[] SplitWithEmpty(string arg, char split = ',') { return (from s in arg.Split(new char[1] { split }) select s.Trim()).ToArray(); } public static string[] SplitWithEscape(string arg, char separator = ',') { List<string> list = new List<string>(); string[] array = arg.Split(new char[1] { separator }); for (int i = 0; i < array.Length; i++) { string text = array[i].TrimStart(Array.Empty<char>()); if (text.StartsWith("\"")) { array[i] = text.Substring(1); int j; for (j = i; j < array.Length; j++) { text = array[j].TrimEnd(Array.Empty<char>()); if (text.EndsWith("\"")) { array[j] = text.Substring(0, text.Length - 1); break; } } list.Add(string.Join(separator.ToString(), array.Skip(i).Take(j - i + 1))); i = j; } else { list.Add(array[i].Trim()); } } return list.ToArray(); } public static string Name(string arg) { return arg.Split(new char[1] { ':' })[0]; } public static Vector3 VectorXZY(string arg) { //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) return VectorXZY(arg, Vector3.zero); } public static Vector3 VectorXZY(string arg, Vector3 defaultValue) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) return VectorXZY(Split(arg), 0, defaultValue); } public static Vector3 VectorXZY(string[] args, int index) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return VectorXZY(args, index, Vector3.zero); } public static Vector3 VectorXZY(string[] args, int index, Vector3 defaultValue) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; zero.x = Float(args, index, defaultValue.x); zero.z = Float(args, index + 1, defaultValue.z); zero.y = Float(args, index + 2, defaultValue.y); return zero; } public static Vector2 VectorXY(string arg) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) Vector2 zero = Vector2.zero; string[] args = Split(arg); zero.x = Float(args, 0); zero.y = Float(args, 1); return zero; } public static Vector3 Scale(string args) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) return Scale(Split(args), 0); } public static Vector3 Scale(string[] args) { //IL_0002: Unknown result type (might be due to invalid