using 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.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("HitBoxVisualizerPlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright (c) 2024 Jo912345/J0912345. released under MIT license (see LICENSE.txt file)")]
[assembly: AssemblyDescription("A mod for bopl battle that draws lines around hitboxes.")]
[assembly: AssemblyFileVersion("1.0.0.1")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HitBoxVisualizerPlugin")]
[assembly: AssemblyTitle("HitBoxVisualizerPlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.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", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public enum hitboxVisRenderImplementation
{
unityLineRenderObj
}
public static Dictionary<int, DPhysicsBox> DPhysBoxDict = new Dictionary<int, DPhysicsBox>();
public static listOfLineHolderGameObjs poolOfLineHolderGameObjs = new listOfLineHolderGameObjs();
public ConfigEntry<bool> CONFIG_isUsingNoDistortionLineRenderers;
public ConfigEntry<bool> CONFIG_useBothRectRenderImplementationsAtOnce;
public ConfigEntry<float> CONFIG_drawingThickness;
public static bool isUsingNoDistortionLineRenderers = true;
public static bool useBothRectRenderImplementationsAtOnce = false;
public static Dictionary<int, DPhysicsCircle> DPhysCircleDict = new Dictionary<int, DPhysicsCircle>();
public static List<hitboxVisualizerLine> DPhysCirclesToDraw = new List<hitboxVisualizerLine>();
public static List<object> externalLogMessageQueue = new List<object>();
public static float drawingThickness = 0.5f;
public static int circleDrawing_AmountOfLines = 18;
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);
CONFIG_isUsingNoDistortionLineRenderers = ((BaseUnityPlugin)this).Config.Bind<bool>("Drawing Settings", "UseNoDistortionRects", true, "A flag which enables using an implementation for drawing rectangles that doesn't have any distortion, but the lines also stop a bit short of meeting at the corners.\nThis uses one LineRenderer per line and is how LineRenderer's issues of just not being very good is often worked around.If set to false, one LineRenderer will be used per rectangle. This will draw an actual rectangle with corners that meet, but will also cause distortion effects.\nDistortion effects should be less noticable with lower drawing thicknesses.");
CONFIG_useBothRectRenderImplementationsAtOnce = ((BaseUnityPlugin)this).Config.Bind<bool>("Drawing Settings", "useBothRectRenderImplementationsAtOnce", false, "A flag which will make rectangles draw with both the distortion and no distortion implementations at once (see UseNoDistortionRects).\nThis is only really going to be visible at higher line thicknesses. Expect to still see some distortion, at least on corners.");
CONFIG_drawingThickness = ((BaseUnityPlugin)this).Config.Bind<float>("Drawing Settings", "drawingThickness", 0.3f, "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.\nAnother thing to note: the real hitbox for rectangles will always be in the center of the line, so smaller values will look more accurate for rectangles.\nThe real hitbox of a circle is always accurate to the outer part of the line.");
isUsingNoDistortionLineRenderers = CONFIG_isUsingNoDistortionLineRenderers.Value;
useBothRectRenderImplementationsAtOnce = CONFIG_useBothRectRenderImplementationsAtOnce.Value;
drawingThickness = CONFIG_drawingThickness.Value;
harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"all DPhysics<shape> objects should now have their hitboxes drawn!");
}
public void OnDestroy()
{
harmony.UnpatchSelf();
((BaseUnityPlugin)this).Logger.LogInfo((object)"hitboxVisualizer has been unloaded.");
}
public static void AddExternalLogPrintToQueue(object data)
{
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);
if (isUsingNoDistortionLineRenderers && !useBothRectRenderImplementationsAtOnce)
{
LineDrawing.drawLineGroupAsSplitIntoIndividualLines(item);
return;
}
if (!isUsingNoDistortionLineRenderers && !useBothRectRenderImplementationsAtOnce)
{
LineDrawing.drawLinesLineRender(item);
return;
}
LineDrawing.drawLinesLineRender(item);
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_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: 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_00e4: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00fd: 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_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: 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_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_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: 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_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: 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_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: 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_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_020f: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_02af: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: 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_026a: 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_027e: 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_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: 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_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_029e: 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_02a7: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_030d: Unknown result type (might be due to invalid IL or missing references)
//IL_0312: Unknown result type (might be due to invalid IL or missing references)
//IL_0317: Unknown result type (might be due to invalid IL or missing references)
//IL_0319: Unknown result type (might be due to invalid IL or missing references)
//IL_0322: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Unknown result type (might be due to invalid IL or missing references)
//IL_032c: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_033a: Unknown result type (might be due to invalid IL or missing references)
//IL_0347: Unknown result type (might be due to invalid IL or missing references)
//IL_0349: 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;
}
float lineWidth = drawingThickness;
Vec2 val4 = val3 * (center + up - right);
Vec2 val5 = val3 * (center - up - right);
Vec2 val6 = val3 * (center + up + right);
Vec2 val7 = val3 * (center - up + right);
hitboxVisualizerLineStyling.lineDrawingStyle lineStyle = hitboxLineGroup.pickLineStyling((IPhysicsCollider)(object)val);
list.Add(new hitboxLineGroup(new List<hitboxVisualizerLine>(4)
{
new hitboxVisualizerLine(val4, val6),
new hitboxVisualizerLine(val6, val7),
new hitboxVisualizerLine(val7, val5),
new hitboxVisualizerLine(val5, val4)
}, lineStyle, ((Component)val).gameObject, lineWidth));
}
Vec2 point_ = default(Vec2);
Vec2 val12 = default(Vec2);
for (int j = 0; j < inputDPhysCircleDict.Values.ToList().Count; j++)
{
DPhysicsCircle val8 = inputDPhysCircleDict.Values.ToList()[j];
if ((Object)(object)val8 == (Object)null)
{
inputDPhysCircleDict.Remove(inputDPhysCircleDict.Keys.ToList()[j]);
continue;
}
Circle val9 = val8.Circle();
Fix val10 = val9.radius * val8.Scale;
Vec2 center2 = val9.center;
int num = 360 / circleDrawing_AmountOfLines;
Fix x = ((Circle)(ref val9)).Pos().x;
Fix y = ((Circle)(ref val9)).Pos().y;
if (val8.initHasBeenCalled)
{
Circle val11 = DetPhysics.Get().circles.colliders[DetPhysics.Get().circles.ColliderIndex(val8.pp.instanceId)];
val10 = val11.radius;
center2 = val11.center;
x = ((Circle)(ref val11)).Pos().x;
y = ((Circle)(ref val11)).Pos().y;
}
val10 -= (Fix)drawingThickness / (Fix)2L;
List<hitboxVisualizerLine> list3 = new List<hitboxVisualizerLine>();
((Vec2)(ref point_))..ctor(x + val10, y);
for (int k = 1; k < circleDrawing_AmountOfLines + 1; k++)
{
float num2 = (float)(k * num) * ((float)Math.PI / 180f);
((Vec2)(ref val12))..ctor(x + val10 * (Fix)Mathf.Cos(num2), y + val10 * (Fix)Mathf.Sin(num2));
list3.Add(new hitboxVisualizerLine(point_, val12));
point_ = val12;
}
list2.Add(new hitboxLineGroup(list3, hitboxLineGroup.pickLineStyling((IPhysicsCollider)(object)val8), ((Component)val8).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.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.DPhysCircleDict.Add(instanceID, __instance);
}
}
}
[HarmonyPatch(typeof(MonoUpdatable))]
internal class Patch_MonoUpdatable_AddDPhysObjDeleteHook
{
[HarmonyPostfix]
[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_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
LineRenderer val = default(LineRenderer);
for (int i = startIndex; i < gameObjsList.Count; i++)
{
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
{
defaultV,
disabledPhys
}
public static Color RedColor = new Color(1f, 0f, 0f, 0.8f);
public static Color BlueColor = new Color(0f, 0f, 1f, 0.8f);
public static Color GreenColor = new Color(0f, 1f, 0f, 0.8f);
public static Color YellowColor = new Color(1f, 0.92f, 0.016f, 0.8f);
public static Color MagentaColor = new Color(1f, 0f, 1f, 0.8f);
public static Color WhiteColor = new Color(1f, 1f, 1f, 0.8f);
public static Color BlackColor = new Color(0f, 0f, 0f, 0.8f);
public static Dictionary<lineDrawingStyle, List<Color>> drawingStyleToLineColors = new Dictionary<lineDrawingStyle, List<Color>>
{
{
lineDrawingStyle.defaultV,
new List<Color>(5) { RedColor, BlueColor, GreenColor, YellowColor, MagentaColor }
},
{
lineDrawingStyle.disabledPhys,
new List<Color>(2) { BlackColor, WhiteColor }
}
};
}
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 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;
UpdateLineColorsToMatchStyle(lineStyle);
}
}
public static hitboxVisualizerLineStyling.lineDrawingStyle pickLineStyling(IPhysicsCollider DPhysObj)
{
if (!DPhysObj.enabled)
{
return hitboxVisualizerLineStyling.lineDrawingStyle.disabledPhys;
}
return hitboxVisualizerLineStyling.lineDrawingStyle.defaultV;
}
public void UpdateLineColorsToMatchStyle(hitboxVisualizerLineStyling.lineDrawingStyle lineStyle)
{
//IL_0039: 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)
int num = 0;
List<Color> list = hitboxVisualizerLineStyling.drawingStyleToLineColors[lineStyle];
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.point2.x, (float)hitboxVisualizerLine2.point2.y, 0f));
}
return list.ToArray();
}
public Gradient getLineGradientForLineColors()
{
//IL_006b: 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_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
List<GradientColorKey> list = new List<GradientColorKey>();
List<GradientAlphaKey> list2 = new List<GradientAlphaKey>();
float num = 1f / (float)hitboxVisualLines.Count;
float num2 = hitboxVisualLines.Count;
if (num2 > 8f)
{
num2 = 8f;
num = 1f / num2;
}
for (int i = 0; (float)i < num2; i++)
{
float num3 = (float)i * num;
hitboxVisualizerLine hitboxVisualizerLine2 = hitboxVisualLines[i];
list.Add(new GradientColorKey(hitboxVisualizerLine2.lineColor, num3));
list2.Add(new GradientAlphaKey(0.8f, num3));
}
Gradient val = new Gradient();
val.SetKeys(list.ToArray(), list2.ToArray());
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_0096: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: 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];
GameObject val = poolOfLineHolderGameObjs.gameObjsList[num];
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 = "1.0.0";
}
}