Due to update 2.4.3, some mods may no longer function. FixedConfig may be necessary.
Decompiled source of HitboxVisualizer v3.0.0
HitBoxVisualizerPlugin.dll
Decompiled 3 weeks agousing System; 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 System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BoplFixedMath; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("HitBoxVisualizerPlugin")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyCopyright("Copyright (c) 2024/2025 Jo912345/J0912345. released under MIT license (see LICENSE.txt file)")] [assembly: AssemblyDescription("A mod for bopl battle that draws lines around hitboxes.")] [assembly: AssemblyFileVersion("3.0.0.0")] [assembly: AssemblyInformationalVersion("3.0.0")] [assembly: AssemblyProduct("HitBoxVisualizerPlugin")] [assembly: AssemblyTitle("HitBoxVisualizerPlugin")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("3.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace HitBoxVisualizerPlugin { [BepInPlugin("com.jo912345.hitboxVisualizePlugin", "HitBoxVisualizer", "3.0.0")] public class Plugin : BaseUnityPlugin { public enum hitboxVisRenderImplementation { unityLineRenderObj } public static Dictionary<int, DPhysicsBox> DPhysBoxDict = new Dictionary<int, DPhysicsBox>(); public static Dictionary<int, DPhysicsCircle> DPhysCircleDict = new Dictionary<int, DPhysicsCircle>(); public static Dictionary<int, Circle> CirlceDict = new Dictionary<int, Circle>(); public static listOfLineHolderGameObjs poolOfLineHolderGameObjs = new listOfLineHolderGameObjs(); public ConfigEntry<float> CONFIG_drawingThickness; public ConfigEntry<string> CONFIG_rectColors; public ConfigEntry<string> CONFIG_circleColors; public ConfigEntry<string> CONFIG_disabledColors; public static List<object> externalLogMessageQueue = new List<object>(); public static float drawingThickness = 0.5f; public static int circleDrawingMinAmountOfLines = 14; public static hitboxVisRenderImplementation currHitBoxVisRendImplementation = hitboxVisRenderImplementation.unityLineRenderObj; private readonly Harmony harmony = new Harmony("com.jo912345.hitboxVisualizePlugin"); public void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin HitBoxVisualizerPlugin is loaded!"); LineDrawing.setUpLineRendererMaterialToDefault(); poolOfLineHolderGameObjs.setAllLineRendererMaterials(LineDrawing.lineRendererBaseMaterial); loadConfigValues(); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"all `DPhysicsBox`es/`DPhysicsCircle`s should now have their hitboxes drawn!"); } public void loadConfigValues() { CONFIG_drawingThickness = ((BaseUnityPlugin)this).Config.Bind<float>("Drawing Settings", "drawingThickness", 0.2f, "How thick should hitbox lines be drawn? Note that this value is in unity world units and not pixels. For reference, 0.2 is relatively thin, and 0.5 is large.\nRectangular hitboxes are now always drawn accurately, never extending past the real hitbox edge (excluding small artifacts caused by a lack of anti-aliasing)."); CONFIG_rectColors = ((BaseUnityPlugin)this).Config.Bind<string>("Line Color Settings", "rectangleColors", "#FF0000CC,#FFEB04CC,#00FF00CC,#0000FFCC", "What colors should rectangles use? Colors are separated by commas. Any colors after the 4th option will be ignored.\nYou can use #RGB, #RRGGBB, #RGBA, or #RRGGBBAA formatting, or one of the color words specified here:\nhttps://docs.unity3d.com/2022.3/Documentation/ScriptReference/ColorUtility.TryParseHtmlString.html"); CONFIG_circleColors = ((BaseUnityPlugin)this).Config.Bind<string>("Line Color Settings", "circleColors", "#FF0000CC,#FFEB04CC,#00FF00CC,#0000FFCC,#FF00FFCC", "What colors should circles use? Colors are separated by commas. You may only use up to 7 colors per the limitations of Unity's `Gradient` class.\nThe first color is also used as the last color to loop the gradient.\nYou can use #RGB, #RRGGBB, #RGBA, or #RRGGBBAA formatting, or one of the color words specified here:\nhttps://docs.unity3d.com/2022.3/Documentation/ScriptReference/ColorUtility.TryParseHtmlString.html"); CONFIG_disabledColors = ((BaseUnityPlugin)this).Config.Bind<string>("Line Color Settings", "disabledColors", "#000000CC,#FFFFFFCC,#000000CC,#FFFFFFCC", "What colors should disabled objects use? This includes rectanges and circles. Colors are separated by commas.\nYou may only use up to 7 colors (the gradient is looped), per the limitations of Unity's `Gradient` class.\nYou can use #RGB, #RRGGBB, #RGBA, or #RRGGBBAA formatting, or one of the color words specified here:\nhttps://docs.unity3d.com/2022.3/Documentation/ScriptReference/ColorUtility.TryParseHtmlString.html"); hitboxVisualizerLineStyling.drawingStyleToLineColors[hitboxVisualizerLineStyling.lineDrawingStyle.defaultColors] = loadConfigColorsFromString(CONFIG_rectColors.Value, "rectangleColors", hitboxVisualizerLineStyling.drawingStyleToLineColors[hitboxVisualizerLineStyling.lineDrawingStyle.defaultColors], gradientColorLimit: false); hitboxVisualizerLineStyling.drawingStyleToLineColors[hitboxVisualizerLineStyling.lineDrawingStyle.circleColors] = loadConfigColorsFromString(CONFIG_circleColors.Value, "circleColors", hitboxVisualizerLineStyling.drawingStyleToLineColors[hitboxVisualizerLineStyling.lineDrawingStyle.circleColors]); hitboxVisualizerLineStyling.drawingStyleToLineColors[hitboxVisualizerLineStyling.lineDrawingStyle.disabledPhys] = loadConfigColorsFromString(CONFIG_disabledColors.Value, "disabledColors", hitboxVisualizerLineStyling.drawingStyleToLineColors[hitboxVisualizerLineStyling.lineDrawingStyle.disabledPhys]); drawingThickness = CONFIG_drawingThickness.Value; } public List<Color> loadConfigColorsFromString(string listString, string categoryName, List<Color> normalColors, bool gradientColorLimit = true) { //IL_001b: 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) string[] array = listString.Split(new char[1] { ',' }); List<Color> list = new List<Color>(); Color item = default(Color); string[] array2 = array; foreach (string text in array2) { if (!ColorUtility.TryParseHtmlString(text, ref item)) { ((BaseUnityPlugin)this).Logger.LogError((object)("color string \"" + text + "\" is invalid, falling back to default colors for " + categoryName + " instead. Check the config file or https://docs.unity3d.com/2022.3/Documentation/ScriptReference/ColorUtility.TryParseHtmlString.html for formatting options.")); return normalColors; } list.Add(item); } if (gradientColorLimit && list.Count() > 7) { ((BaseUnityPlugin)this).Logger.LogError((object)("color string \"" + listString + "\" is invalid, falling back to default colors for " + categoryName + " instead. Using more than 7 colors (the gradient is looped) in a gradient is not supported, due to a unity limitation.")); return normalColors; } return list; } public void Start() { poolOfLineHolderGameObjs = new listOfLineHolderGameObjs(); } public void OnDestroy() { harmony.UnpatchSelf(); ((BaseUnityPlugin)this).Logger.LogError((object)"hitboxVisualizer has been unloaded. (if you see this when starting the game, it's likely that `HideManagerGameObject = false` in `BepInEx.cfg`. please enable it!)"); } public static void AddExternalLogPrintToQueue(object data) { if (externalLogMessageQueue == null) { externalLogMessageQueue = new List<object>(); } externalLogMessageQueue.Add(data); } private void PrintAllExternalLogsInQueue() { for (int i = 0; i < externalLogMessageQueue.Count; i++) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("ASYNC* MESSAGE DUMP: " + externalLogMessageQueue[i].ToString())); } externalLogMessageQueue = new List<object>(); } public void LateUpdate() { PrintAllExternalLogsInQueue(); Tuple<List<hitboxLineGroup>, List<hitboxLineGroup>> tuple = calculateHitBoxShapeComponentLines(DPhysBoxDict, DPhysCircleDict); List<hitboxLineGroup> item = tuple.Item1; List<hitboxLineGroup> item2 = tuple.Item2; LineDrawing.drawLinesLineRender(item2); LineDrawing.drawLineGroupAsSplitIntoIndividualLines(item); } public Tuple<List<hitboxLineGroup>, List<hitboxLineGroup>> calculateHitBoxShapeComponentLines(Dictionary<int, DPhysicsBox> inputDPhysBoxDict, Dictionary<int, DPhysicsCircle> inputDPhysCircleDict) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_006b: 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_0072: 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_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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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) //IL_00d2: 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_00d6: 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) //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_00e7: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_0104: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_011d: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: 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_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019d: 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_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: 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_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0279: 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_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) List<hitboxLineGroup> list = new List<hitboxLineGroup>(); List<hitboxLineGroup> list2 = new List<hitboxLineGroup>(); for (int i = 0; i < inputDPhysBoxDict.Values.ToList().Count; i++) { DPhysicsBox val = inputDPhysBoxDict.Values.ToList()[i]; if ((Object)(object)val == (Object)null) { inputDPhysBoxDict.Remove(inputDPhysBoxDict.Keys.ToList()[i]); continue; } Box val2 = val.Box(); Fix val3 = val.Scale; Vec2 up = val2.up; Vec2 right = val2.right; Vec2 center = val2.center; if (val.initHasBeenCalled) { val2 = val.physicsBox; right = val2.right; up = val2.up; center = val2.center; val3 = (Fix)1L; } Vec2 val4 = val3 * (center + up - right); Vec2 val5 = val3 * (center - up - right); Vec2 val6 = val3 * (center + up + right); Vec2 val7 = val3 * (center - up + right); hitboxVisualizerLine hitboxVisualizerLine2 = new hitboxVisualizerLine(val4, val6); hitboxVisualizerLine hitboxVisualizerLine3 = new hitboxVisualizerLine(val6, val7); hitboxVisualizerLine hitboxVisualizerLine4 = new hitboxVisualizerLine(val7, val5); hitboxVisualizerLine hitboxVisualizerLine5 = new hitboxVisualizerLine(val5, val4); hitboxVisualizerLine[] array = new hitboxVisualizerLine[4] { hitboxVisualizerLine2, hitboxVisualizerLine3, hitboxVisualizerLine4, hitboxVisualizerLine5 }; for (int j = 0; j < array.Length; j++) { Vector2 val8 = (Vector2)array[j].point1; Vector2 val9 = (Vector2)array[j].point2; float num = Mathf.Atan2(val9.y - val8.y, val9.x - val8.x) + (float)Math.PI / 2f; array[j].point1.x = array[j].point1.x - (Fix)drawingThickness / (Fix)2L * (Fix)Mathf.Cos(num); array[j].point1.y = array[j].point1.y - (Fix)drawingThickness / (Fix)2L * (Fix)Mathf.Sin(num); array[j].point2.x = array[j].point2.x - (Fix)drawingThickness / (Fix)2L * (Fix)Mathf.Cos(num); array[j].point2.y = array[j].point2.y - (Fix)drawingThickness / (Fix)2L * (Fix)Mathf.Sin(num); } list.Add(new hitboxLineGroup(new List<hitboxVisualizerLine>(4) { hitboxVisualizerLine2, hitboxVisualizerLine3, hitboxVisualizerLine4, hitboxVisualizerLine5 }, hitboxLineGroup.pickLineStyling((IPhysicsCollider)(object)val), ((Component)val).gameObject, drawingThickness)); } Vec2 point_ = default(Vec2); Vec2 val14 = default(Vec2); for (int k = 0; k < inputDPhysCircleDict.Values.ToList().Count; k++) { DPhysicsCircle val10 = inputDPhysCircleDict.Values.ToList()[k]; if ((Object)(object)val10 == (Object)null) { inputDPhysCircleDict.Remove(inputDPhysCircleDict.Keys.ToList()[k]); continue; } Circle val11 = val10.Circle(); Fix val12 = val11.radius * val10.Scale; Fix x = ((Circle)(ref val11)).Pos().x; Fix y = ((Circle)(ref val11)).Pos().y; if (val10.initHasBeenCalled) { Circle val13 = DetPhysics.Get().circles.colliders[DetPhysics.Get().circles.ColliderIndex(val10.pp.instanceId)]; val12 = val13.radius; x = ((Circle)(ref val13)).Pos().x; y = ((Circle)(ref val13)).Pos().y; } val12 -= (Fix)drawingThickness / (Fix)2L; int num2 = circleDrawingMinAmountOfLines + (int)(long)(val12 * (Fix)4L); float num3 = 360f / (float)num2; List<hitboxVisualizerLine> list3 = new List<hitboxVisualizerLine>(); ((Vec2)(ref point_))..ctor(x + val12, y); for (int l = 1; l < num2 + 2; l++) { float num4 = (float)l * num3 * ((float)Math.PI / 180f); ((Vec2)(ref val14))..ctor(x + val12 * (Fix)Mathf.Cos(num4), y + val12 * (Fix)Mathf.Sin(num4)); list3.Add(new hitboxVisualizerLine(point_, val14)); point_ = val14; } list2.Add(new hitboxLineGroup(list3, hitboxLineGroup.pickLineStyling((IPhysicsCollider)(object)val10), ((Component)val10).gameObject, drawingThickness)); } return Tuple.Create(list, list2); } } [HarmonyPatch(typeof(DPhysicsBox))] internal class Patch_AddDPhysBoxBoundsTracking { [HarmonyPostfix] [HarmonyPatch("Initialize")] [HarmonyPatch("Init")] [HarmonyPatch("ManualInit")] [HarmonyPatch("Awake")] private static void Postfix(DPhysicsBox __instance) { int instanceID = ((Object)__instance).GetInstanceID(); if (!Plugin.DPhysBoxDict.ContainsKey(instanceID)) { Plugin.AddExternalLogPrintToQueue("adding instanceID DPhysicsBox to list:" + instanceID); Plugin.DPhysBoxDict.Add(instanceID, __instance); } } } [HarmonyPatch(typeof(DPhysicsCircle))] internal class Patch_AddDPhysCircleBoundsTracking { [HarmonyPostfix] [HarmonyPatch("Initialize")] [HarmonyPatch("Init")] [HarmonyPatch("ManualInit")] [HarmonyPatch("Awake")] private static void Postfix(DPhysicsCircle __instance) { int instanceID = ((Object)__instance).GetInstanceID(); if (!Plugin.DPhysCircleDict.ContainsKey(instanceID)) { Plugin.AddExternalLogPrintToQueue("adding instanceID DPhysicsCircle to list:" + instanceID); Plugin.DPhysCircleDict.Add(instanceID, __instance); } } } [HarmonyPatch(typeof(MonoUpdatable))] internal class Patch_MonoUpdatable_AddDPhysObjDeleteHook { [HarmonyPostfix] [HarmonyPatch("OnDestroyUpdatable")] [HarmonyPatch("OnDestroyUpdatable")] private static void Postfix_addPhysBoxDelHook(MonoUpdatable __instance) { if (!((Object)(object)__instance == (Object)null)) { string scriptClassName = ((MonoBehaviour)__instance).GetScriptClassName(); if (scriptClassName == "DPhysicsBox") { Plugin.DPhysBoxDict.Remove(((Object)__instance).GetInstanceID()); } else if (scriptClassName == "DPhysicsCircle") { Plugin.DPhysCircleDict.Remove(((Object)__instance).GetInstanceID()); } } } } public class listOfLineHolderGameObjs { public List<GameObject> gameObjsList = new List<GameObject>(); public int minCapacity = 4; public int currUsedAmountOfGameObjs = 0; public Material lineMaterial = new Material(Shader.Find("Legacy Shaders/Particles/Alpha Blended")); public void addGameObjects(int amount) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown for (int i = 0; i < amount; i++) { GameObject val = new GameObject(); Object.DontDestroyOnLoad((Object)(object)val); Component obj = val.AddComponent(typeof(LineRenderer)); LineRenderer val2 = (LineRenderer)(object)((obj is LineRenderer) ? obj : null); ((Renderer)val2).material = lineMaterial; ((Renderer)val2).sortingLayerID = SortingLayer.NameToID("PostProcessing"); ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; gameObjsList.Add(val); } } public void setAllLineRendererMaterials(Material newMaterial) { LineRenderer val = default(LineRenderer); for (int i = 0; i < gameObjsList.Count; i++) { gameObjsList[i].TryGetComponent<LineRenderer>(ref val); ((Renderer)val).material = newMaterial; } } public listOfLineHolderGameObjs(bool useLineDrawingClassMaterial = true) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown if (useLineDrawingClassMaterial) { lineMaterial = LineDrawing.lineRendererBaseMaterial; } addGameObjects(minCapacity); } public void setLineRendererPropsAt(int objListIndex, Vector3 startPos, Vector3 endPos, float thickness, Color lineColor, bool objIsActive = true) { //IL_0029: 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_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_0050: 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) GameObject val = gameObjsList[objListIndex]; val.SetActive(objIsActive); LineRenderer val2 = default(LineRenderer); val.TryGetComponent<LineRenderer>(ref val2); val2.SetPositions((Vector3[])(object)new Vector3[2] { startPos, endPos }); val2.startWidth = thickness; val2.endWidth = thickness; val2.startColor = lineColor; val2.endColor = lineColor; ((Renderer)val2).forceRenderingOff = false; } public void deleteGameObjectsAfterIndex(int baseIndex) { int num = gameObjsList.Count - baseIndex; for (int i = 0; i < num; i++) { GameObject val = gameObjsList[baseIndex]; gameObjsList.Remove(val); Object.Destroy((Object)(object)val); } } public void cleanUpOldLineRendererPositionsFromGameObjsAfter(int startIndex) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) LineRenderer val = default(LineRenderer); for (int i = startIndex; i < gameObjsList.Count; i++) { if (gameObjsList[i].TryGetComponent<LineRenderer>(ref val)) { val.SetPositions((Vector3[])(object)new Vector3[2] { new Vector3(0f, 0f), new Vector3(0f, 0f) }); ((Renderer)val).forceRenderingOff = true; } } } public void cleanUpAllLineRenderers() { LineRenderer val = default(LineRenderer); for (int i = 0; i < gameObjsList.Count; i++) { gameObjsList[i].TryGetComponent<LineRenderer>(ref val); val.SetPositions(Array.Empty<Vector3>()); ((Renderer)val).forceRenderingOff = true; } } } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct hitboxVisualizerLineStyling { public enum lineDrawingStyle { defaultColors, disabledPhys, circleColors } public static Color RedColor = new Color(1f, 0f, 0f, 1f); public static Color BlueColor = new Color(0f, 0f, 1f, 1f); public static Color GreenColor = new Color(0f, 1f, 0f, 1f); public static Color YellowColor = new Color(1f, 0.92f, 0.016f, 1f); public static Color MagentaColor = new Color(1f, 0f, 1f, 1f); public static Color WhiteColor = new Color(1f, 1f, 1f, 1f); public static Color BlackColor = new Color(0f, 0f, 0f, 1f); public static Color DarkGrey = new Color(0.2f, 0.2f, 0.2f, 1f); public static Color lightGrey = new Color(0.8f, 0.8f, 0.8f, 1f); public static Dictionary<lineDrawingStyle, List<Color>> drawingStyleToLineColors = new Dictionary<lineDrawingStyle, List<Color>> { { lineDrawingStyle.defaultColors, new List<Color>(5) { RedColor, YellowColor, GreenColor, BlueColor, MagentaColor } }, { lineDrawingStyle.disabledPhys, new List<Color>(2) { BlackColor, WhiteColor } }, { lineDrawingStyle.circleColors, new List<Color>(5) { RedColor, YellowColor, GreenColor, BlueColor, MagentaColor } } }; } public class hitboxVisualizerLine { public Vec2 point1; public Vec2 point2; public Color lineColor; public hitboxVisualizerLine(Vec2 point_1, Vec2 point_2) { //IL_0009: 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_0010: 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) point1 = point_1; point2 = point_2; } } public class hitboxLineGroup { public float lineThickness; public List<hitboxVisualizerLine> hitboxVisualLines; public GameObject parentGameObj; public hitboxVisualizerLineStyling.lineDrawingStyle lineGroupStyle; public hitboxLineGroup(List<hitboxVisualizerLine> hitboxLines, hitboxVisualizerLineStyling.lineDrawingStyle lineStyle, GameObject parentGameObject, float lineWidth = 0.5f) { if (!((Object)(object)parentGameObject == (Object)null)) { hitboxVisualLines = hitboxLines; parentGameObj = parentGameObject; lineThickness = lineWidth; lineGroupStyle = lineStyle; UpdateLineColorsToMatchStyle(lineStyle); } } public static hitboxVisualizerLineStyling.lineDrawingStyle pickLineStyling(IPhysicsCollider DPhysObj) { if (!DPhysObj.enabled) { return hitboxVisualizerLineStyling.lineDrawingStyle.disabledPhys; } if (DPhysObj is DPhysicsCircle) { return hitboxVisualizerLineStyling.lineDrawingStyle.circleColors; } return hitboxVisualizerLineStyling.lineDrawingStyle.defaultColors; } public void UpdateLineColorsToMatchStyle(hitboxVisualizerLineStyling.lineDrawingStyle lineStyle) { //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) lineGroupStyle = lineStyle; int num = 0; List<Color> list = hitboxVisualizerLineStyling.drawingStyleToLineColors[lineGroupStyle]; for (int i = 0; i < hitboxVisualLines.Count; i++) { if (num > list.Count - 1) { num = 0; } hitboxVisualizerLine hitboxVisualizerLine2 = hitboxVisualLines[i]; hitboxVisualizerLine2.lineColor = list[num]; num++; } } public Vector3[] getListOfComponentPoints() { //IL_0019: 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_0045: 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_007a: 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) List<Vector3> list = new List<Vector3>(); list.Add(new Vector3((float)hitboxVisualLines[0].point1.x, (float)hitboxVisualLines[0].point1.y, 0f)); for (int i = 0; i < hitboxVisualLines.Count - 1; i++) { hitboxVisualizerLine hitboxVisualizerLine2 = hitboxVisualLines[i]; list.Add(new Vector3((float)hitboxVisualizerLine2.point1.x, (float)hitboxVisualizerLine2.point1.y, 0f)); } return list.ToArray(); } public Gradient getLineGradientForLineColors() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0084: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown List<GradientColorKey> list = new List<GradientColorKey>(); List<GradientAlphaKey> list2 = new List<GradientAlphaKey>(); List<Color> list3 = hitboxVisualizerLineStyling.drawingStyleToLineColors[lineGroupStyle]; float num = 1f / (float)list3.Count(); for (int i = 0; i < list3.Count(); i++) { float num2 = (float)i * num; list.Add(new GradientColorKey(list3[i], num2)); list2.Add(new GradientAlphaKey(list3[i].a, num2)); } list.Add(new GradientColorKey(list3[0], 1f)); list2.Add(new GradientAlphaKey(list3[0].a, 1f)); Gradient val = new Gradient(); val.SetKeys(list.ToArray(), list2.ToArray()); val.mode = (GradientMode)2; return val; } } public class LineDrawing { public static Material lineRendererBaseMaterial = new Material(Shader.Find("Legacy Shaders/Particles/Alpha Blended")); public static void setUpLineRendererMaterialToDefault() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown lineRendererBaseMaterial = new Material(Shader.Find("Legacy Shaders/Particles/Alpha Blended")); lineRendererBaseMaterial.SetOverrideTag("RenderType", "Fade"); lineRendererBaseMaterial.renderQueue = 5000; lineRendererBaseMaterial.SetInt("_ZWrite", 1); lineRendererBaseMaterial.SetInt("_ZTest", 8); } public static void drawLinesLineRender(List<hitboxLineGroup> lineGroups) { LineRenderer val = default(LineRenderer); for (int i = 0; i < lineGroups.Count; i++) { hitboxLineGroup hitboxLineGroup2 = lineGroups[i]; GameObject parentGameObj = hitboxLineGroup2.parentGameObj; if ((Object)(object)parentGameObj == (Object)null) { Plugin.AddExternalLogPrintToQueue("lineParentObj is null"); continue; } LineRenderer val2 = ((!parentGameObj.TryGetComponent<LineRenderer>(ref val)) ? parentGameObj.AddComponent<LineRenderer>() : val); Vector3[] listOfComponentPoints = hitboxLineGroup2.getListOfComponentPoints(); ((Renderer)val2).sortingLayerID = SortingLayer.NameToID("PostProcessing"); val2.loop = true; ((Renderer)val2).material = lineRendererBaseMaterial; val2.colorGradient = hitboxLineGroup2.getLineGradientForLineColors(); val2.startWidth = hitboxLineGroup2.lineThickness; val2.endWidth = hitboxLineGroup2.lineThickness; val2.positionCount = listOfComponentPoints.Length; ((Renderer)val2).material.renderQueue = 4999; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; val2.SetPositions(listOfComponentPoints); val2.Simplify(0f); } } public static void drawLineGroupAsSplitIntoIndividualLines(List<hitboxLineGroup> lineGroups) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_00a6: Unknown result type (might be due to invalid IL or missing references) int num = 0; listOfLineHolderGameObjs poolOfLineHolderGameObjs = Plugin.poolOfLineHolderGameObjs; for (int i = 0; i < lineGroups.Count; i++) { hitboxLineGroup hitboxLineGroup2 = lineGroups[i]; GameObject parentGameObj = hitboxLineGroup2.parentGameObj; if ((Object)(object)parentGameObj == (Object)null) { Plugin.AddExternalLogPrintToQueue("lineParentObj is null"); continue; } List<hitboxVisualizerLine> hitboxVisualLines = hitboxLineGroup2.hitboxVisualLines; int count = hitboxVisualLines.Count; if (num + count > poolOfLineHolderGameObjs.gameObjsList.Count) { poolOfLineHolderGameObjs.addGameObjects(count); } for (int j = 0; j < count; j++) { hitboxVisualizerLine hitboxVisualizerLine2 = hitboxVisualLines[j]; poolOfLineHolderGameObjs.setLineRendererPropsAt(num, (Vector3)hitboxVisualizerLine2.point1, (Vector3)hitboxVisualizerLine2.point2, hitboxLineGroup2.lineThickness, hitboxVisualizerLine2.lineColor, parentGameObj.activeSelf); num++; } } if (num < poolOfLineHolderGameObjs.gameObjsList.Count && poolOfLineHolderGameObjs.gameObjsList.Count > poolOfLineHolderGameObjs.minCapacity) { poolOfLineHolderGameObjs.deleteGameObjectsAfterIndex(poolOfLineHolderGameObjs.minCapacity); } poolOfLineHolderGameObjs.cleanUpOldLineRendererPositionsFromGameObjsAfter(num); } } public static class PluginInfo { public const string PLUGIN_GUID = "HitBoxVisualizerPlugin"; public const string PLUGIN_NAME = "HitBoxVisualizerPlugin"; public const string PLUGIN_VERSION = "3.0.0"; } }