using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CConsole.Commands;
using CConsole.Interop;
using CullingSystem;
using Enemies;
using GameData;
using HarmonyLib;
using IRF;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("EnemyHitboxView")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+gitcbe18aa-dirty-main")]
[assembly: AssemblyProduct("EnemyHitboxView")]
[assembly: AssemblyTitle("EnemyHitboxView")]
[assembly: TargetPlatform("Windows7.0")]
[assembly: SupportedOSPlatform("Windows7.0")]
[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 EnemyHitboxView
{
[BepInPlugin("JarheadHME.EnemyHitboxView", "EnemyHitboxView", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class EntryPoint : BasePlugin
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static OnCommandUsedDelegate <>9__1_0;
internal void <Load>b__1_0(in CustomCmdContext context, string[] args)
{
if (args.Length != 0 && bool.TryParse(args[0], out var result))
{
EnemyHitboxes.ShowHitboxes = result;
}
else
{
EnemyHitboxes.ShowHitboxes = !EnemyHitboxes.ShowHitboxes;
}
context.Log($"DisplayEnemyHitboxes: {EnemyHitboxes.ShowHitboxes}");
}
}
private Harmony _Harmony = null;
public override void Load()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
//IL_006f: 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_00a9: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Expected O, but got Unknown
ClassInjector.RegisterTypeInIl2Cpp<EnemyHitboxes>();
ClassInjector.RegisterTypeInIl2Cpp<EnemyHitboxCuller>();
_Harmony = new Harmony("EnemyHitboxView.Harmony");
_Harmony.PatchAll();
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin has loaded with ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_Harmony.GetPatchedMethods().Count());
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" patches!");
}
Logger.Info(val);
CustomCommandSetting val2 = default(CustomCommandSetting);
val2.Command = "DisplayEnemyHitboxes";
val2.Description = "Show spheres and capsules on enemies to mark their (approximate) hitboxes. Normal hitboxes are green, weakpoints are red, and armor is grey.";
val2.Usage = "DisplayEnemyHitboxes [true/false]";
val2.Category = (CategoryType)2;
val2.MinArgumentCount = 0;
CustomCommandSetting val3 = val2;
object obj = <>c.<>9__1_0;
if (obj == null)
{
OnCommandUsedDelegate val4 = delegate(in CustomCmdContext context, string[] args)
{
if (args.Length != 0 && bool.TryParse(args[0], out var result))
{
EnemyHitboxes.ShowHitboxes = result;
}
else
{
EnemyHitboxes.ShowHitboxes = !EnemyHitboxes.ShowHitboxes;
}
context.Log($"DisplayEnemyHitboxes: {EnemyHitboxes.ShowHitboxes}");
};
<>c.<>9__1_0 = val4;
obj = (object)val4;
}
CustomCommands.Register(val3, (OnCommandUsedDelegate)obj);
}
public override bool Unload()
{
_Harmony.UnpatchSelf();
return ((BasePlugin)this).Unload();
}
}
[HarmonyPatch]
internal class Patches
{
[HarmonyPatch(typeof(EnemyAgent), "Setup")]
[HarmonyPostfix]
public static void Setup_Patch(EnemyAgent __instance)
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
bool flag = default(bool);
foreach (Dam_EnemyDamageLimb item in (Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)__instance.Damage.DamageLimbs)
{
GameObject gameObject = ((Component)item).gameObject;
if ((Object)(object)gameObject.GetComponent<EnemyHitboxes>() != (Object)null)
{
return;
}
Collider component = gameObject.GetComponent<Collider>();
if ((Object)(object)component == (Object)null)
{
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(50, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Damage Limb ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)gameObject).name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" on enemy ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(__instance.EnemyDataID);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((GameDataBlockBase<EnemyDataBlock>)(object)__instance.EnemyData).name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") doesn't have a collider?");
}
Logger.Warn(val);
}
else
{
EnemyHitboxes enemyHitboxes = gameObject.AddComponent<EnemyHitboxes>();
enemyHitboxes.Setup(item, component);
}
}
if ((Object)(object)((Component)__instance).gameObject.GetComponent<EnemyHitboxCuller>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<EnemyHitboxCuller>();
}
foreach (InstancedRenderFeature componentsInChild in ((Component)__instance).gameObject.GetComponentsInChildren<InstancedRenderFeature>())
{
((Behaviour)componentsInChild).enabled = !EnemyHitboxes.ShowHitboxes;
}
}
}
internal class EnemyHitboxes : MonoBehaviour
{
public static Dictionary<eLimbDamageType, Color> TypeToColor = new Dictionary<eLimbDamageType, Color>
{
{
(eLimbDamageType)0,
Color.green
},
{
(eLimbDamageType)1,
Color.red
},
{
(eLimbDamageType)2,
Color.grey
}
};
public static bool ShowHitboxes = false;
public static bool DoUpdate = true;
public List<Renderer> m_renderers = new List<Renderer>();
public Material m_material;
public Transform m_dummyTransform;
private Dam_EnemyDamageLimb m_limb;
private Collider m_collider;
private FleshBulbs m_bulbController = null;
private Transform HitboxRoot;
public void Setup(Dam_EnemyDamageLimb limb, Collider collider)
{
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
m_limb = limb;
m_collider = collider;
FleshBulbLimb component = ((Component)limb).gameObject.GetComponent<FleshBulbLimb>();
if ((Object)(object)component != (Object)null)
{
m_bulbController = component.m_fleshBulbController;
}
SphereCollider OutComp2;
if (collider.TryCastAtHome<Collider, CapsuleCollider>(out CapsuleCollider OutComp))
{
SetupAsCapsule(OutComp);
}
else if (collider.TryCastAtHome<Collider, SphereCollider>(out OutComp2))
{
SetupAsSphere(OutComp2);
}
else
{
if (!collider.TryCastAtHome<Collider, BoxCollider>(out BoxCollider OutComp3))
{
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(27, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("UNSUPPORTED COLLIDER TYPE: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Type>(((object)collider).GetType());
}
Logger.Error(val);
Object.Destroy((Object)(object)this);
return;
}
SetupAsBox(OutComp3);
}
((Object)((Component)HitboxRoot).gameObject).name = ((Object)((Component)m_limb).gameObject).name + " - " + ((Object)((Component)HitboxRoot).gameObject).name;
foreach (Renderer renderer in m_renderers)
{
renderer.material = m_material;
Object.Destroy((Object)(object)((Component)renderer).gameObject.GetComponent<Collider>());
}
}
public void SetupAsBox(BoxCollider bc)
{
//IL_0013: 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_0047: 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_0066: 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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
//IL_0086: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
Transform transform = ((Component)m_limb).transform;
m_dummyTransform = new GameObject("Hitbox Dummy Obj").transform;
m_dummyTransform.parent = transform;
m_dummyTransform.localRotation = Quaternion.identity;
m_dummyTransform.localPosition = bc.center;
GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
val.transform.localScale = bc.size.Multi(transform.lossyScale);
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(4, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(transform.lossyScale.x);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(transform.lossyScale.y);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(transform.lossyScale.z);
}
Logger.Info(val2);
Renderer component = val.GetComponent<Renderer>();
m_material = component.material;
m_renderers.Add(component);
val.transform.parent = ((Component)m_limb.m_base.Owner).transform;
HitboxRoot = val.transform;
}
public void SetupAsSphere(SphereCollider sc)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: 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_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
Transform transform = ((Component)m_limb).transform;
Vector3 lossyScale = transform.lossyScale;
float num = sc.radius * 2f * Mathf.Max(new float[3] { lossyScale.x, lossyScale.y, lossyScale.z });
m_dummyTransform = new GameObject("Hitbox Dummy Obj").transform;
m_dummyTransform.parent = transform;
m_dummyTransform.localPosition = sc.center;
m_dummyTransform.localRotation = Quaternion.identity;
GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
val.transform.localScale = new Vector3(num, num, num);
Renderer component = val.GetComponent<Renderer>();
m_material = component.material;
m_renderers.Add(component);
val.transform.parent = ((Component)m_limb.m_base.Owner).transform;
HitboxRoot = val.transform;
}
public void SetupAsCapsule(CapsuleCollider cap)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: 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_02c4: Unknown result type (might be due to invalid IL or missing references)
Transform transform = ((Component)m_limb).transform;
float num = cap.radius * 2f;
float num2 = cap.height / 2f;
Vector3 lossyScale = transform.lossyScale;
m_dummyTransform = new GameObject("Hitbox Dummy Obj").transform;
m_dummyTransform.parent = transform;
m_dummyTransform.localPosition = cap.center;
switch (cap.direction)
{
case 0:
m_dummyTransform.localRotation = Quaternion.Euler(0f, 0f, 90f);
num *= Mathf.Max(lossyScale.y, lossyScale.z);
num2 *= lossyScale.x;
break;
case 1:
m_dummyTransform.localRotation = Quaternion.Euler(0f, 0f, 0f);
num *= Mathf.Max(lossyScale.x, lossyScale.z);
num2 *= lossyScale.y;
break;
case 2:
m_dummyTransform.localRotation = Quaternion.Euler(90f, 0f, 0f);
num *= Mathf.Max(lossyScale.x, lossyScale.y);
num2 *= lossyScale.z;
break;
}
num2 = Mathf.Max(0f, num2 - num / 2f);
HitboxRoot = new GameObject("Capsule").transform;
HitboxRoot.parent = ((Component)m_limb.m_base.Owner).transform;
GameObject val = GameObject.CreatePrimitive((PrimitiveType)2);
val.transform.parent = ((Component)HitboxRoot).transform;
val.transform.localRotation = Quaternion.identity;
val.transform.localPosition = Vector3.zero;
val.transform.localScale = new Vector3(num, num2, num);
GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)0);
((Object)val2).name = "CapsuleTop";
val2.transform.parent = ((Component)HitboxRoot).transform;
val2.transform.localRotation = Quaternion.identity;
val2.transform.localPosition = new Vector3(0f, num2, 0f);
val2.transform.localScale = new Vector3(num, num, num);
GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)0);
((Object)val3).name = "CapsuleBottom";
val3.transform.parent = ((Component)HitboxRoot).transform;
val3.transform.localRotation = Quaternion.identity;
val3.transform.localPosition = new Vector3(0f, 0f - num2, 0f);
val3.transform.localScale = new Vector3(num, num, num);
Renderer component = val.GetComponent<Renderer>();
m_material = component.material;
m_renderers.Add(component);
m_renderers.Add(val2.GetComponent<Renderer>());
m_renderers.Add(val3.GetComponent<Renderer>());
}
public void OnDisable()
{
foreach (Renderer renderer in m_renderers)
{
renderer.enabled = false;
((Component)renderer).gameObject.SetActive(false);
}
}
public void Update()
{
//IL_0042: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
if (!DoUpdate || !m_limb.m_base.Owner.MovingCuller.IsShown)
{
return;
}
m_material.color = TypeToColor[m_limb.m_type];
foreach (Renderer renderer in m_renderers)
{
renderer.enabled = ShowHitboxes;
GameObject gameObject = ((Component)renderer).gameObject;
gameObject.SetActive(m_collider.enabled && ShowHitboxes);
}
if ((Object)(object)m_bulbController != (Object)null)
{
m_bulbController.ForceRenderingOff = ShowHitboxes;
}
HitboxRoot.position = m_dummyTransform.position;
HitboxRoot.rotation = m_dummyTransform.rotation;
}
}
internal class EnemyHitboxCuller : MonoBehaviour
{
private EnemyAgent m_agent;
private InstancedRenderFeature[] m_allIRFs;
public void Start()
{
m_agent = ((Component)this).GetComponent<EnemyAgent>();
m_allIRFs = Il2CppArrayBase<InstancedRenderFeature>.op_Implicit(((Component)this).GetComponentsInChildren<InstancedRenderFeature>());
}
public void LateUpdate()
{
Enumerator<Renderer> enumerator = ((C_CullBucket)m_agent.MovingCuller.Culler).Renderers.GetEnumerator();
while (enumerator.MoveNext())
{
Renderer current = enumerator.Current;
current.enabled = !EnemyHitboxes.ShowHitboxes;
}
InstancedRenderFeature[] allIRFs = m_allIRFs;
foreach (InstancedRenderFeature val in allIRFs)
{
((Behaviour)val).enabled = !EnemyHitboxes.ShowHitboxes;
}
}
}
internal static class Extension
{
public static bool TryCastAtHome<T, O>(this T InComp, out O OutComp) where T : Il2CppObjectBase where O : Il2CppObjectBase
{
OutComp = ((Il2CppObjectBase)InComp).TryCast<O>();
return OutComp != null;
}
public static Vector3 Multi(this Vector3 arg1, Vector3 arg2)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
arg1.x *= arg2.x;
arg1.y *= arg2.y;
arg1.z *= arg2.z;
return arg1;
}
}
internal static class Logger
{
private static readonly ManualLogSource _Logger;
static Logger()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
_Logger = new ManualLogSource("EnemyHitboxView");
Logger.Sources.Add((ILogSource)(object)_Logger);
}
private static string Format(object msg)
{
return msg.ToString();
}
public static void Info(BepInExInfoLogInterpolatedStringHandler handler)
{
_Logger.LogInfo(handler);
}
public static void Info(string str)
{
_Logger.LogMessage((object)str);
}
public static void Info(object data)
{
_Logger.LogMessage((object)Format(data));
}
public static void Debug(BepInExDebugLogInterpolatedStringHandler handler)
{
_Logger.LogDebug(handler);
}
public static void Debug(string str)
{
_Logger.LogDebug((object)str);
}
public static void Debug(object data)
{
_Logger.LogDebug((object)Format(data));
}
public static void Error(BepInExErrorLogInterpolatedStringHandler handler)
{
_Logger.LogError(handler);
}
public static void Error(string str)
{
_Logger.LogError((object)str);
}
public static void Error(object data)
{
_Logger.LogError((object)Format(data));
}
public static void Fatal(BepInExFatalLogInterpolatedStringHandler handler)
{
_Logger.LogFatal(handler);
}
public static void Fatal(string str)
{
_Logger.LogFatal((object)str);
}
public static void Fatal(object data)
{
_Logger.LogFatal((object)Format(data));
}
public static void Warn(BepInExWarningLogInterpolatedStringHandler handler)
{
_Logger.LogWarning(handler);
}
public static void Warn(string str)
{
_Logger.LogWarning((object)str);
}
public static void Warn(object data)
{
_Logger.LogWarning((object)Format(data));
}
[Conditional("DEBUG")]
public static void DebugOnly(object data)
{
_Logger.LogDebug((object)Format(data));
}
}
[GeneratedCode("VersionInfoGenerator", "2.1.3+git35c0c2a-master")]
[CompilerGenerated]
internal static class VersionInfo
{
public const string RootNamespace = "EnemyHitboxView";
public const string Version = "1.0.0";
public const string VersionPrerelease = null;
public const string VersionMetadata = "gitcbe18aa-dirty-main";
public const string SemVer = "1.0.0+gitcbe18aa-dirty-main";
public const string GitRevShort = "cbe18aa-dirty";
public const string GitRevLong = "cbe18aa78c2941cbe9a07ef675dd46b1bfd7e4dd-dirty";
public const string GitBranch = "main";
public const string GitTag = null;
public const int GitCommitsSinceTag = 0;
public const bool GitIsDirty = true;
}
}