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 HurtColliderVisualizer v0.1.1
HurtColliderVisualizer.dll
Decompiled 5 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; using UnityEngine.Events; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("HurtColliderVisualizer")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("HurtColliderVisualizer")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("33990afd-5bb4-4943-a7bf-a02f8a047481")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace HurtColliderVisualizer { public class HurtColliderDetector : MonoBehaviour { public readonly List<HurtColliderVisualizer> activeVisualizers = new List<HurtColliderVisualizer>(); public HurtCollider hurtCollider; public HurtColliderVisualizer.HitStatus currentStatus = HurtColliderVisualizer.HitStatus.Miss; public bool skipNext; public bool isSphere; public bool isTumble; public bool isDeathPit; public int curIndex; public bool HasLogic { get { if (!hurtCollider.playerLogic) { return hurtCollider.enemyLogic; } return true; } } private void Awake() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown hurtCollider = ((Component)this).GetComponent<HurtCollider>(); hurtCollider.onImpactPlayer.AddListener(new UnityAction(OnSuccessfulHitPlayer)); hurtCollider.onImpactEnemy.AddListener(new UnityAction(OnSuccessfulHitEnemy)); } public void Cleanup() { activeVisualizers.RemoveAll((HurtColliderVisualizer m) => (Object)(object)m == (Object)null); } private void OnSuccessfulHitPlayer() { if (AddNew()) { skipNext = true; SetHit(HurtColliderVisualizer.HitStatus.Hit, HurtColliderVisualizer.HitType.Player); } } private void OnSuccessfulHitEnemy() { if (Plugin.SimulateEnemies.Value > Plugin.HitEnemyType.Dont && AddNew()) { skipNext = true; SetHit(HurtColliderVisualizer.HitStatus.Hit, HurtColliderVisualizer.HitType.Enemy); } } public bool AddNew() { if (skipNext) { skipNext = false; return false; } if (isTumble && !Plugin.PlayerTumble.Value) { return false; } if (isDeathPit && !Plugin.DeathPits.Value) { return false; } if (!HasLogic && !Plugin.AllowAll.Value) { return false; } curIndex++; currentStatus = HurtColliderVisualizer.HitStatus.Miss; if (!isSphere) { activeVisualizers.Add(HurtColliderVisualizer.CreateBox(hurtCollider)); return true; } activeVisualizers.Add(HurtColliderVisualizer.CreateSphere(hurtCollider)); return true; } public void SetHit(HurtColliderVisualizer.HitStatus hit, HurtColliderVisualizer.HitType type) { if (activeVisualizers.Count >= 1) { activeVisualizers[activeVisualizers.Count - 1].MarkAsHit(hit, type); currentStatus = hit; } } public bool IsObjectHit(GameObject obj) { foreach (Hit hit in hurtCollider.hits) { if ((Object)(object)hit.hitObject == (Object)(object)obj) { return true; } } return false; } } public class HurtColliderVisualizer : MonoBehaviour { public enum HitStatus { Unknown, Miss, None, Partial, Hit } public enum HitType { None, Enemy, Player } public static readonly Vector3[] boundsEdges = (Vector3[])(object)new Vector3[8] { new Vector3(-1f, -1f, -1f), new Vector3(1f, -1f, -1f), new Vector3(1f, 1f, -1f), new Vector3(-1f, 1f, -1f), new Vector3(-1f, -1f, 1f), new Vector3(1f, -1f, 1f), new Vector3(1f, 1f, 1f), new Vector3(-1f, 1f, 1f) }; public static Color missColor = new Color(1f, 0f, 0f, 0.35f); public static Color partialColor = new Color(1f, 0.5f, 0f, 0.45f); public static Color hitColor = new Color(0f, 1f, 0f, 0.67f); public static Color hitColorEnemy = new Color(0.1f, 0.2f, 1f, 0.67f); private static Material _matCache = null; public float timer; public float fadeTimer; public List<LineRenderer> lineRenderers = new List<LineRenderer>(); public MeshRenderer fillBox; public Color color = missColor; public Color fadeColor = missColor; public HitStatus hit; public HitType hitType; public static Material Mat { get { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)_matCache)) { return _matCache; } _matCache = new Material(Shader.Find("Sprites/Default")); return _matCache; } } public Color HitColor { get { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (hitType != HitType.Enemy || Plugin.SimulateEnemies.Value != Plugin.HitEnemyType.ShowAsBlue) { return hitColor; } return hitColorEnemy; } } public static float LRWidth(bool multiplier = false) { if (multiplier) { return Plugin.LineWidth.Value * Plugin.LineWidthMultiplier.Value; } return Plugin.LineWidth.Value; } public static HurtColliderVisualizer CreateBox(HurtCollider hc) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //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_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Hurt Collider Box Visualizer - " + ((Object)((Component)hc).gameObject).name); LineRenderer val2 = val.AddComponent<LineRenderer>(); float startWidth = (val2.endWidth = LRWidth()); val2.startWidth = startWidth; ((Renderer)val2).material = Mat; HurtColliderVisualizer hurtColliderVisualizer = val.AddComponent<HurtColliderVisualizer>(); BoxCollider component = ((Component)hc).GetComponent<BoxCollider>(); Vector3 val3 = Vector3.Scale(component.size, ((Component)hc).gameObject.transform.lossyScale); Vector3 val4 = val3 * 0.5f; List<Vector3> list = new List<Vector3>(); Vector3[] array = boundsEdges; foreach (Vector3 val5 in array) { list.Add(((Component)hc).transform.rotation * Vector3.Scale(val4, val5) + ((Component)hc).transform.rotation * Vector3.Scale(component.center, val3) + ((Component)hc).transform.position); } Vector3[] array2 = (Vector3[])(object)new Vector3[16] { list[0], list[1], list[2], list[3], list[0], list[4], list[5], list[6], list[7], list[4], list[5], list[1], list[2], list[6], list[7], list[3] }; val2.positionCount = array2.Length; val2.SetPositions(array2); hurtColliderVisualizer.lineRenderers.Add(val2); GameObject val6 = GameObject.CreatePrimitive((PrimitiveType)3); Object.Destroy((Object)(object)val6.GetComponent<BoxCollider>()); ((Object)val6).name = "Hurt Collider Box Fill - " + ((Object)((Component)hc).gameObject).name; val6.transform.SetParent(val.transform, false); val6.transform.rotation = ((Component)hc).transform.rotation; val6.transform.position = ((Component)hc).transform.rotation * Vector3.Scale(component.center, val3) + ((Component)hc).transform.position; val6.transform.localScale = val3; hurtColliderVisualizer.fillBox = val6.GetComponent<MeshRenderer>(); return hurtColliderVisualizer; } public static HurtColliderVisualizer CreateSphere(HurtCollider hc) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Hurt Collider Sphere Visualizer - " + ((Object)((Component)hc).gameObject).name); List<LineRenderer> list = new List<LineRenderer>(); HurtColliderVisualizer hurtColliderVisualizer = val.AddComponent<HurtColliderVisualizer>(); SphereCollider component = ((Component)hc).GetComponent<SphereCollider>(); Vector3 val2 = component.radius * ((Component)hc).gameObject.transform.lossyScale; Vector3 positionOffset = Vector3.Scale(component.center, val2) + ((Component)hc).transform.position; for (int i = 0; i <= 1; i++) { for (int j = 0; j < Plugin.SphereEdges.Value; j++) { LineRenderer val3 = AppendDiameter(val, j, i == 1, ((Component)hc).gameObject.transform.lossyScale.x * component.radius, positionOffset); float startWidth = (val3.endWidth = LRWidth()); val3.startWidth = startWidth; ((Renderer)val3).material = Mat; Color startColor = (val3.endColor = missColor); val3.startColor = startColor; list.Add(val3); } } hurtColliderVisualizer.lineRenderers = list; GameObject val5 = GameObject.CreatePrimitive((PrimitiveType)0); Object.Destroy((Object)(object)val5.GetComponent<SphereCollider>()); ((Object)val5).name = "Hurt Collider Sphere Fill - " + ((Object)((Component)hc).gameObject).name; val5.transform.SetParent(val.transform, false); val5.transform.rotation = Quaternion.identity; val5.transform.position = Vector3.Scale(component.center, val2) + ((Component)hc).transform.position; val5.transform.localScale = Vector3.one * 2f * component.radius * ((Component)hc).gameObject.transform.lossyScale.x; hurtColliderVisualizer.fillBox = val5.GetComponent<MeshRenderer>(); return hurtColliderVisualizer; } private static LineRenderer AppendDiameter(GameObject originalObject, int index, bool vertical, float size, Vector3 positionOffset) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(((Object)originalObject).name + $" (Line Renderer #{index + 1})"); val.transform.SetParent(originalObject.transform); LineRenderer val2 = val.AddComponent<LineRenderer>(); float num = (float)index * (float)Math.PI / (float)Plugin.SphereEdges.Value; val2.loop = true; val2.positionCount = Plugin.SphereResolution.Value; Vector3[] array = (Vector3[])(object)new Vector3[Plugin.SphereResolution.Value]; for (int i = 0; i < array.Length; i++) { float num2 = (float)Math.PI * 2f * (float)i / (float)Plugin.SphereResolution.Value; if (vertical) { float num3 = size * Mathf.Sin(num2) * Mathf.Cos(num); float num4 = size * Mathf.Cos(num2); float num5 = size * Mathf.Sin(num2) * Mathf.Sin(num); array[i] = new Vector3(num3, num4, num5) + positionOffset; } else { float num6 = size * Mathf.Sin(num); float num7 = num6 * Mathf.Cos(num2); float num8 = size * Mathf.Cos(num); float num9 = num6 * Mathf.Sin(num2); array[i] = new Vector3(num7, num8, num9) + positionOffset; } } val2.SetPositions(array); return val2; } private void Start() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (lineRenderers.Count == 0 && Object.op_Implicit((Object)(object)((Component)this).GetComponent<LineRenderer>())) { lineRenderers.Add(((Component)this).GetComponent<LineRenderer>()); } timer = Plugin.BaseTimer.Value; fadeTimer = 0f; if (hit == HitStatus.Unknown) { hit = HitStatus.Miss; SetColor(missColor); } } private void Update() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) timer -= Time.deltaTime; if (timer > 0f) { fadeTimer = 0f; return; } fadeTimer += Time.deltaTime; fadeColor = Color.Lerp(color, new Color(color.r, color.g, color.b, 0f), Mathf.InverseLerp(0f, Plugin.FadeTimer.Value, fadeTimer)); SetColor(fadeColor, setMain: false); if (fadeTimer > Plugin.FadeTimer.Value) { Object.Destroy((Object)(object)((Component)this).gameObject); } } private void OnDestroy() { if (Object.op_Implicit((Object)(object)fillBox)) { Object.Destroy((Object)(object)((Renderer)fillBox).material); } } private void SetColor(Color color, bool setMain = true) { //IL_0004: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0059: 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_0071: 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_0148: Unknown result type (might be due to invalid IL or missing references) if (setMain) { this.color = color; } foreach (LineRenderer lineRenderer in lineRenderers) { Color startColor = (lineRenderer.endColor = color); lineRenderer.startColor = startColor; } if (Object.op_Implicit((Object)(object)fillBox)) { Color val2 = default(Color); ((Color)(ref val2))..ctor(color.r + 0.2f, color.g + 0.2f, color.b + 0.2f, color.a / 1.4f); ((Renderer)fillBox).material.SetInt("_SrcBlend", 5); ((Renderer)fillBox).material.SetInt("_DstBlend", 10); ((Renderer)fillBox).material.SetInt("_ZWrite", 0); ((Renderer)fillBox).material.DisableKeyword("_ALPHATEST_ON"); ((Renderer)fillBox).material.EnableKeyword("_ALPHABLEND_ON"); ((Renderer)fillBox).material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); ((Renderer)fillBox).material.renderQueue = 3000; ((Renderer)fillBox).receiveShadows = false; ((Renderer)fillBox).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)fillBox).material.color = val2; } } private void SetColorConditional() { //IL_0021: 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_003b: 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) switch (hit) { case HitStatus.Miss: SetColor(missColor); break; case HitStatus.None: SetColor(Color.clear); break; case HitStatus.Partial: SetColor(partialColor); break; case HitStatus.Hit: SetColor(HitColor); break; } } public void MarkAsHit(HitStatus status, HitType hittype) { if (status < hit) { return; } if (status == HitStatus.Hit && hittype > hitType) { hitType = hittype; } hit = status; timer = Plugin.BaseTimerHit.Value; SetColorConditional(); foreach (LineRenderer lineRenderer in lineRenderers) { float startWidth = (lineRenderer.endWidth = LRWidth(multiplier: true)); lineRenderer.startWidth = startWidth; } } } [BepInPlugin("Swaggies.HurtColliderVisualizer", "HurtColliderVisualizer", "0.1.1")] public class Plugin : BaseUnityPlugin { public enum HitEnemyType { Dont, ShowAsGreen, ShowAsBlue } private const string _guid = "Swaggies.HurtColliderVisualizer"; private const string _name = "HurtColliderVisualizer"; public const string _ver = "0.1.1"; private readonly Harmony harmony = new Harmony("Swaggies.HurtColliderVisualizer"); public static ManualLogSource loggy; public static ConfigEntry<bool> DeathPits; public static ConfigEntry<bool> PlayerTumble; public static ConfigEntry<bool> AllowAll; public static ConfigEntry<HitEnemyType> SimulateEnemies; public static ConfigEntry<float> CheckTime; public static ConfigEntry<float> LineWidth; public static ConfigEntry<float> LineWidthMultiplier; public static ConfigEntry<int> SphereResolution; public static ConfigEntry<int> SphereEdges; public static ConfigEntry<float> BaseTimer; public static ConfigEntry<float> BaseTimerHit; public static ConfigEntry<float> FadeTimer; private void Awake() { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Expected O, but got Unknown //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Expected O, but got Unknown //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Expected O, but got Unknown //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Expected O, but got Unknown //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Expected O, but got Unknown loggy = Logger.CreateLogSource("Swaggies.HurtColliderVisualizer"); loggy.LogMessage((object)"HurtColliderVisualizer's up and runnin' on 0.1.1"); harmony.PatchAll(Assembly.GetExecutingAssembly()); DeathPits = ((BaseUnityPlugin)this).Config.Bind<bool>("Whitelist", "Show Death Pits?", false, "Whether death pit hurt colliders are shown too. (not recommended, might be buggy and hurt performance)"); PlayerTumble = ((BaseUnityPlugin)this).Config.Bind<bool>("Whitelist", "Show Player Tumble?", false, "Whether tumble hurt colliders are shown too. (not recommended cuz like why)"); AllowAll = ((BaseUnityPlugin)this).Config.Bind<bool>("Whitelist", "Show When Logic Disabled?", false, "Whether hurt colliders with player logic and enemy logic disabled are shown too. (not recommended cuz they dont DO anything but ig if you wanted to see them)"); SimulateEnemies = ((BaseUnityPlugin)this).Config.Bind<HitEnemyType>("Whitelist", "Show Enemy Hits? (Host Only)", HitEnemyType.ShowAsBlue, "Should hits on enemies count as successful hits too? (only works as lobby host)"); CheckTime = ((BaseUnityPlugin)this).Config.Bind<float>("Visualization", "Draw Interval", 0.05f, new ConfigDescription("How often hurt collider \"screenshots\" are created. In-game, hurt colliders are checked every 0.05 seconds, so by default this should make the visualizers line up with when the colliders get checked. In any case, if a hurt collider check succeeds (like, is green), a visualizer will be created immediately at its current position regardless of interval.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 0.33f), Array.Empty<object>())); LineWidth = ((BaseUnityPlugin)this).Config.Bind<float>("Visualization", "Line Width", 0.05f, new ConfigDescription("Width of the visualizer edges. (for visibility)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 0.2f), Array.Empty<object>())); LineWidthMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Visualization", "Successful Hit Line Width Multiplier", 1.5f, new ConfigDescription("Edge width multiplier for when a hit lands.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); SphereResolution = ((BaseUnityPlugin)this).Config.Bind<int>("Visualization", "Sphere Resolution", 16, new ConfigDescription("How many points along the diameter of a sphere to use when displaying a spherical hurt collider. Higher values means smoother edges but a bit less performance.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 100), Array.Empty<object>())); SphereEdges = ((BaseUnityPlugin)this).Config.Bind<int>("Visualization", "Sphere Edges", 8, new ConfigDescription("How many grid lines to draw on spheres (for example, 10 would draw a line every 36 degrees). Higher values means more accurate edges but a bit less performance.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(4, 60), Array.Empty<object>())); BaseTimer = ((BaseUnityPlugin)this).Config.Bind<float>("Visualization", "Display Time", 0.33f, new ConfigDescription("How long (in seconds) to display the visualizer at full opacity before it begins to fade.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); BaseTimerHit = ((BaseUnityPlugin)this).Config.Bind<float>("Visualization", "Display Time On Hit", 0.67f, new ConfigDescription("Same as previous but for successful hits.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); FadeTimer = ((BaseUnityPlugin)this).Config.Bind<float>("Visualization", "Fade Time", 0.33f, new ConfigDescription("How long the visualizers fade out for before disappearing into the endless void forever.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); } } public class Visualizer { } } namespace HurtColliderVisualizer.Patches { [HarmonyPatch(typeof(HurtCollider))] internal class HurtColliderPatch { public static readonly Dictionary<HurtCollider, HurtColliderDetector> HurtColliderDict = new Dictionary<HurtCollider, HurtColliderDetector>(); [HarmonyPatch("Awake")] [HarmonyPostfix] private static void Awake(ref HurtCollider __instance) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((Component)__instance).gameObject == (Object)null)) { HurtColliderDetector hurtColliderDetector = ((Component)__instance).gameObject.AddComponent<HurtColliderDetector>(); hurtColliderDetector.isSphere = !__instance.ColliderIsBox; Transform transform = ((Component)__instance).transform; object obj; if (transform == null) { obj = null; } else { Transform parent = transform.parent; obj = ((parent != null) ? ((Component)parent).GetComponent<PlayerTumble>() : null); } hurtColliderDetector.isTumble = (Object)obj != (Object)null; hurtColliderDetector.isDeathPit = __instance.deathPit; HurtColliderDict.Add(__instance, hurtColliderDetector); } } [HarmonyPatch("OnEnable")] [HarmonyPostfix] private static void OnEnable(ref HurtCollider __instance) { if (HurtColliderDict.TryGetValue(__instance, out var value)) { value.Cleanup(); ((MonoBehaviour)value).StartCoroutine(EnabledCollider(value)); } } [HarmonyPatch("PlayerHurt")] [HarmonyPrefix] private static void PlayerHurt(ref HurtCollider __instance, ref PlayerAvatar _player) { if (HurtColliderDict.TryGetValue(__instance, out var value) && !__instance.ignorePlayers.Contains(_player) && (!__instance.ignoreLocalPlayer || !_player.isLocal)) { if (value.IsObjectHit(((Component)_player).gameObject)) { ColliderHit(value, HurtColliderVisualizer.HitStatus.None); } else { ColliderHit(value, HurtColliderVisualizer.HitStatus.Partial); } } } private static void ColliderHit(HurtColliderDetector hcd, HurtColliderVisualizer.HitStatus status) { if (hcd.currentStatus == HurtColliderVisualizer.HitStatus.Partial && status == HurtColliderVisualizer.HitStatus.Hit) { hcd.SetHit(HurtColliderVisualizer.HitStatus.Hit, HurtColliderVisualizer.HitType.Player); } else if (status == HurtColliderVisualizer.HitStatus.None) { hcd.SetHit(status, HurtColliderVisualizer.HitType.Player); } else if (hcd.AddNew()) { hcd.skipNext = status == HurtColliderVisualizer.HitStatus.Hit; hcd.SetHit(status, HurtColliderVisualizer.HitType.Player); } } private static IEnumerator EnabledCollider(HurtColliderDetector hcd) { yield return null; while (!Object.op_Implicit((Object)(object)LevelGenerator.Instance) || !LevelGenerator.Instance.Generated) { yield return (object)new WaitForSeconds(0.1f); } yield return null; while (hcd.hurtCollider.colliderCheckRunning) { hcd.AddNew(); yield return (object)new WaitForSeconds(Plugin.CheckTime.Value); } hcd.Cleanup(); } } }