Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of SafetyNet v1.0.0
SafetyNet.dll
Decompiled 7 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("SafetyNet")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Riintouge")] [assembly: AssemblyProduct("SafetyNet")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("35101263-734a-416b-8dd5-d02f3033ea98")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace SafetyNet; public class WireframeCapsule { public Vector3 top { get; protected set; } public Vector3[][] latitudes { get; protected set; } public Vector3 bottom { get; protected set; } public bool isSphere { get; protected set; } public WireframeCapsule(Vector3 center, float radius, float cylinderHeight, int latitudeFidelity, int longitudeFidelity) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) if (radius <= 0f) { throw new ArgumentException("Radius is less than or equal to zero!"); } if (cylinderHeight < 0f) { throw new ArgumentException("Capsule height is smaller than twice the radius!"); } if (cylinderHeight == 0f) { isSphere = true; } latitudeFidelity = (isSphere ? 3 : 4) + 2 * Mathf.Max(0, latitudeFidelity); longitudeFidelity = 8 + 4 * Mathf.Max(0, longitudeFidelity); float num = cylinderHeight / 2f; float num2 = num + radius; top = new Vector3(center.x, center.y + num2, center.z); bottom = new Vector3(center.x, center.y - num2, center.z); latitudes = new Vector3[latitudeFidelity][]; for (int i = 0; i < latitudes.Length; i++) { latitudes[i] = (Vector3[])(object)new Vector3[longitudeFidelity]; } if (isSphere) { int num3 = (latitudes.Length - 1) / 2; computeLatitude(ref center, radius, 0f, 0f, ref latitudes[num3]); float num4 = 180f / (float)(latitudes.Length + 1); for (int num5 = num3 - 1; num5 >= 0; num5--) { Vector3[] latitude = latitudes[num5]; int num6 = num3 - num5; computeLatitude(ref center, radius, num4 * (float)num6, 0f, ref latitude); Vector3[] dstLatitude = latitudes[latitudes.Length - 1 - num5]; mirrorLatitude(ref latitude, ref dstLatitude, center); } } else { int num7 = latitudes.Length / 2 - 1; float num8 = 180f / (float)latitudes.Length; for (int num9 = num7; num9 >= 0; num9--) { Vector3[] latitude2 = latitudes[num9]; int num10 = num7 - num9; computeLatitude(ref center, radius, num8 * (float)num10, num, ref latitude2); Vector3[] dstLatitude2 = latitudes[latitudes.Length - 1 - num9]; mirrorLatitude(ref latitude2, ref dstLatitude2, center); } } } protected float heightForLatitude(float latitudeAngle, float equatorRadius) { return Mathf.Sin(latitudeAngle * ((float)Math.PI / 180f)) * equatorRadius; } protected float radiusForLatitude(float latitudeAngle, float equatorRadius) { return Mathf.Cos(latitudeAngle * ((float)Math.PI / 180f)) * equatorRadius; } protected void computeLatitude(ref Vector3 center, float equatorRadius, float latitudeAngle, float halfCylinderHeight, ref Vector3[] latitude) { //IL_004c: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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) float num = radiusForLatitude(latitudeAngle, equatorRadius); float num2 = center.y + heightForLatitude(latitudeAngle, equatorRadius) + halfCylinderHeight; float num3 = 360f / (float)latitude.Length; int num4 = latitude.Length / 4; float x = center.x; float z = center.z; latitude[0] = new Vector3(x - num, num2, z); latitude[num4] = new Vector3(x, num2, z + num); latitude[2 * num4] = new Vector3(x + num, num2, z); latitude[3 * num4] = new Vector3(x, num2, z - num); float[] array = new float[num4 - 1]; float[] array2 = new float[num4 - 1]; for (int i = 0; i < array.Length; i++) { float num5 = 90f - num3 * (float)(i + 1); array[i] = num * Mathf.Sin(num5 * ((float)Math.PI / 180f)); array2[i] = num * Mathf.Cos(num5 * ((float)Math.PI / 180f)); } for (int j = 1; j < num4; j++) { float num6 = center.x - array[j - 1]; float num7 = array2[j - 1]; latitude[j] = new Vector3(num6, num2, center.z + num7); latitude[latitude.Length - j] = new Vector3(num6, num2, center.z - num7); } for (int k = num4 + 1; k < 2 * num4; k++) { int num8 = latitude.Length / 2 - (k + 1); float num9 = center.x + array[num8]; float num10 = array2[num8]; latitude[k] = new Vector3(num9, num2, center.z + num10); latitude[latitude.Length - k] = new Vector3(num9, num2, center.z - num10); } } protected void mirrorLatitude(ref Vector3[] srcLatitude, ref Vector3[] dstLatitude, Vector3 center) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //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) float num = center.y - (srcLatitude[0].y - center.y); for (int i = 0; i < srcLatitude.Length; i++) { dstLatitude[i] = new Vector3(srcLatitude[i].x, num, srcLatitude[i].z); } } public List<Vector3> linePoints() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) int num = latitudes[0].Length; List<Vector3> list = new List<Vector3>(1 + num + latitudes.Length * num * 2); list.Add(top); Vector3[][] array = latitudes; foreach (Vector3[] array2 in array) { list.AddRange(array2); list.Add(array2[0]); } list.Add(bottom); for (int num2 = latitudes.Length - 1; num2 >= 0; num2--) { list.Add(latitudes[num2][1]); } list.Add(top); int num3; for (num3 = 2; num3 < num; num3++) { for (int j = 0; j < latitudes.Length; j++) { list.Add(latitudes[j][num3]); } list.Add(bottom); num3++; for (int num4 = latitudes.Length - 1; num4 >= 0; num4--) { list.Add(latitudes[num4][num3]); } list.Add(top); } return list; } } [BepInPlugin("com.riintouge.safetynet", "Safety Net", "1.0.0")] [BepInProcess("valheim.exe")] public class SafetyNet : BaseUnityPlugin { [HarmonyPatch(typeof(Hud))] public class HudPatch { [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdatePostfix(Hud __instance) { //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_0018: 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) KeyCode value = VisiblityToggleKey.Value; if ((Object)(object)Player.m_localPlayer != (Object)null && (int)value != 0 && ZInput.GetKeyDown(value, true)) { IsEnabled.Value = !IsEnabled.Value; } } } [HarmonyPatch(typeof(EffectArea))] public class EffectAreaPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakePostfix(Hud __instance) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 EffectArea[] componentsInChildren = ((Component)__instance).gameObject.GetComponentsInChildren<EffectArea>(); foreach (EffectArea val in componentsInChildren) { if ((int)val.m_type == 4 || (int)val.m_type == 32) { SafetyNetBehaviour.CreateOnFor(((Component)val).gameObject, val); } } } } public class SafetyNetBehaviour : MonoBehaviour, IComparable<SafetyNetBehaviour> { protected static Shader MaterialShader; protected static Mesh SharedSphereMesh; public static WireframeMeshHelper WireframeMeshFactory { get; private set; } protected static List<SafetyNetBehaviour> SafetyNets { get; private set; } public Collider collider { get; private set; } public bool considerForRender { get; private set; } public EffectArea effectArea { get; private set; } public Type effectAreaType { get; private set; } public MeshRenderer meshRenderer { get; private set; } public MeshFilter meshFilter { get; private set; } public CircleProjector projector { get; private set; } protected float distanceFactor { get; private set; } = float.PositiveInfinity; protected float capsuleColliderRadius { get; private set; } = -1f; static SafetyNetBehaviour() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown WireframeMeshFactory = new WireframeMeshHelper(); SafetyNets = new List<SafetyNetBehaviour>(); MaterialShader = null; SharedSphereMesh = new Mesh(); WireframeMeshFactory.latitudeFidelity = LatitudeFidelity.Value; WireframeMeshFactory.longitudeFidelity = LongitudeFidelity.Value; WireframeMeshFactory.RegenerateMeshForSphere(SharedSphereMesh); } public void Start() { //IL_0018: 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_0097: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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) GameObject gameObject = ((Component)((Component)this).gameObject.transform.parent).gameObject; effectArea = GetWidestEffectAreaOfTypeOn(effectAreaType, gameObject); collider = GetColliderFromEffectArea(effectArea); projector = ((Component)((Component)this).gameObject.transform.root).GetComponentInChildren<CircleProjector>(true); MaterialShader = MaterialShader ?? ((IEnumerable<Shader>)Resources.FindObjectsOfTypeAll<Shader>()).FirstOrDefault((Func<Shader, bool>)((Shader x) => ((Object)x).name == "Unlit/Color")); Material val = new Material(MaterialShader); float num = 0.5f + Mathf.Abs(((Component)this).gameObject.transform.position.x % 0.5f); float num2 = 0.5f + Mathf.Abs(((Component)this).gameObject.transform.position.y % 0.5f); float num3 = 0.5f + Mathf.Abs(((Component)this).gameObject.transform.position.z % 0.5f); val.SetColor("_Color", new Color(num, num2, num3)); meshRenderer = ((Component)this).gameObject.AddComponent<MeshRenderer>(); ((Renderer)meshRenderer).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)meshRenderer).receiveShadows = false; ((Renderer)meshRenderer).material = val; ((Renderer)meshRenderer).enabled = false; meshFilter = ((Component)this).gameObject.AddComponent<MeshFilter>(); CreateOrUpdateMesh(); SafetyNets.Add(this); } public void FixedUpdate() { if (!IsEnabled.Value) { considerForRender = false; ((Renderer)meshRenderer).enabled = false; if (Object.op_Implicit((Object)(object)projector)) { ((Behaviour)projector).enabled = false; ((Component)projector).gameObject.SetActive(false); } } } public void OnDestroy() { SafetyNets.Remove(this); collider = null; effectArea = null; meshRenderer = null; meshFilter = null; projector = null; } protected bool CreateOrUpdateMesh() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) if (collider is SphereCollider) { if ((Object)(object)meshFilter.sharedMesh != (Object)(object)SharedSphereMesh) { meshFilter.mesh = null; meshFilter.sharedMesh = SharedSphereMesh; return true; } } else { Collider obj = collider; CapsuleCollider val = (CapsuleCollider)(object)((obj is CapsuleCollider) ? obj : null); if (val != null && val.radius != capsuleColliderRadius) { meshFilter.sharedMesh = null; meshFilter.mesh = (Mesh)(((object)meshFilter.mesh) ?? ((object)new Mesh())); WireframeMeshFactory.RegenerateMeshForCapsule(meshFilter.mesh, val); capsuleColliderRadius = val.radius; return true; } } return false; } protected void UpdateRenderConsiderations() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) if (IsEnabled.Value && Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)effectArea)) { CraftingStation? obj = ((Component)((Component)this).gameObject.transform.root).GetComponentsInChildren<CraftingStation>().FirstOrDefault(); if (obj != null) { obj.GetLevel(true); } float radius = effectArea.GetRadius(); float num = Mathf.Min(radius, 50f) * 2f; float num2 = num * num; Vector3 val = ((Component)Player.m_localPlayer).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude <= num2) { distanceFactor = sqrMagnitude - radius * radius; considerForRender = true; if (collider is SphereCollider) { ((Component)this).gameObject.transform.localScale = new Vector3(radius, radius, radius); } else if (CreateOrUpdateMesh()) { ((Component)this).gameObject.transform.localScale = Vector3.one; } return; } } considerForRender = false; } public int CompareTo(SafetyNetBehaviour other) { if (!(distanceFactor < other.distanceFactor)) { if (!(other.distanceFactor < distanceFactor)) { return 0; } return 1; } return -1; } public static void CreateOnFor(GameObject parent, EffectArea effectArea) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject((((int)effectArea.m_type == 4) ? "PlayerBase" : "NoMonsters") + "SafetyNet"); val.transform.parent = parent.transform; val.transform.localPosition = new Vector3(0f, 0f, 0f); val.transform.localRotation = Quaternion.identity; val.transform.localScale = new Vector3(1f, 1f, 1f); val.AddComponent<SafetyNetBehaviour>().effectAreaType = effectArea.m_type; } protected static Collider GetColliderFromEffectArea(EffectArea effectArea) { return Traverse.Create((object)effectArea).Field("m_collider").GetValue<Collider>(); } protected static EffectArea GetWidestEffectAreaOfTypeOn(Type effectAreaType, GameObject go) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return (from x in go.GetComponentsInChildren<EffectArea>() where x.m_type == effectAreaType orderby x.GetRadius() descending select x).FirstOrDefault(); } public static void UpdateMeshes() { WireframeMeshFactory.RegenerateMeshForSphere(SharedSphereMesh); foreach (SafetyNetBehaviour safetyNet in SafetyNets) { safetyNet.CreateOrUpdateMesh(); } } public static IEnumerable<SafetyNetBehaviour> UpdateRenderConsiderationsAndSort() { foreach (SafetyNetBehaviour safetyNet in SafetyNets) { safetyNet.UpdateRenderConsiderations(); } SafetyNets.Sort(); return SafetyNets; } } public static SafetyNet Instance; public static ConfigEntry<bool> IsEnabled; public static ConfigEntry<bool> LoadOnStart; public static ConfigEntry<int> LatitudeFidelity; public static ConfigEntry<int> LongitudeFidelity; public static ConfigEntry<int> MaximumObjects; public static ConfigEntry<float> UpdateFrequencyInSeconds; public static ConfigEntry<KeyCode> VisiblityToggleKey; private static Coroutine UpdateRenderCoroutine; private readonly Harmony Harmony = new Harmony("com.riintouge.safetynet"); private void Awake() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown IsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("0 - Core", "Enable", false, "Whether this plugin has any effect when loaded."); LoadOnStart = ((BaseUnityPlugin)this).Config.Bind<bool>("0 - Core", "LoadOnStart", true, "Whether this plugin loads on game start."); LatitudeFidelity = ((BaseUnityPlugin)this).Config.Bind<int>("1 - General", "LatitudeFidelity", 2, new ConfigDescription("The number of additional latitudes per hemisphere.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), Array.Empty<object>())); LongitudeFidelity = ((BaseUnityPlugin)this).Config.Bind<int>("1 - General", "LongitudeFidelity", 2, new ConfigDescription("The number of additional longitudes per sphere quadrant.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), Array.Empty<object>())); MaximumObjects = ((BaseUnityPlugin)this).Config.Bind<int>("1 - General", "MaximumObjects", 3, new ConfigDescription("The maximum number of objects for which to show safety visuals.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>())); UpdateFrequencyInSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("1 - General", "UpdateFrequencyInSeconds", 1000f, new ConfigDescription("How often to recalculate visibility when enabled, in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); VisiblityToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("1 - General", "VisiblityToggleKey", (KeyCode)288, "The key to toggle wireframe visibility (effectively toggling IsEnabled)."); if (LoadOnStart.Value) { Instance = this; Harmony.PatchAll(); ((BaseUnityPlugin)this).Config.SettingChanged += Config_SettingChanged; UpdateRenderCoroutine = ((MonoBehaviour)Instance).StartCoroutine(CoUpdateNetRendering()); } } private void OnDestroy() { if (UpdateRenderCoroutine != null) { ((MonoBehaviour)Instance).StopCoroutine(UpdateRenderCoroutine); } Harmony.UnpatchSelf(); } private void Config_SettingChanged(object sender, SettingChangedEventArgs e) { if (e.ChangedSetting == LatitudeFidelity || e.ChangedSetting == LongitudeFidelity) { SafetyNetBehaviour.WireframeMeshFactory.latitudeFidelity = LatitudeFidelity.Value; SafetyNetBehaviour.WireframeMeshFactory.longitudeFidelity = LongitudeFidelity.Value; SafetyNetBehaviour.UpdateMeshes(); } } private IEnumerator CoUpdateNetRendering() { while (true) { if (!IsEnabled.Value) { yield return (object)new WaitForSecondsRealtime(0.5f); continue; } int num = 0; foreach (SafetyNetBehaviour item in SafetyNetBehaviour.UpdateRenderConsiderationsAndSort()) { bool flag = num < MaximumObjects.Value && item.considerForRender; ((Renderer)item.meshRenderer).enabled = flag; if (flag) { num++; } CircleProjector projector = item.projector; if (Object.op_Implicit((Object)(object)projector)) { ((Behaviour)projector).enabled = flag; ((Component)projector).gameObject.SetActive(flag); } } yield return (object)new WaitForSecondsRealtime(UpdateFrequencyInSeconds.Value); } } } public class WireframeMeshHelper { public int latitudeFidelity { get; set; } public int longitudeFidelity { get; set; } public void RegenerateMeshForSphere(Mesh mesh) { //IL_0009: 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) if (Object.op_Implicit((Object)(object)mesh)) { WireframeCapsule wireframeCapsule = new WireframeCapsule(Vector3.zero, 1f, 0f, latitudeFidelity, longitudeFidelity); List<Vector3> list = wireframeCapsule.linePoints(); list.Add(wireframeCapsule.bottom); RegenerateMesh(mesh, list); } } public void RegenerateMeshForCapsule(Mesh mesh, CapsuleCollider collider) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)mesh)) { if (Object.op_Implicit((Object)(object)collider)) { WireframeCapsule wireframeCapsule = new WireframeCapsule(Vector3.zero, collider.radius, collider.height - 2f * collider.radius, latitudeFidelity, longitudeFidelity); List<Vector3> list = wireframeCapsule.linePoints(); list.Add(wireframeCapsule.bottom); RegenerateMesh(mesh, list); } else { mesh.Clear(); } } } protected void RegenerateMesh(Mesh mesh, List<Vector3> points) { int[] array = new int[points.Count]; for (int i = 0; i < points.Count; i++) { array[i] = i; } mesh.Clear(false); mesh.vertices = points.ToArray(); mesh.SetIndices(array, (MeshTopology)4, 0); mesh.RecalculateNormals(); } }