using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using ComputerysModdingUtilities;
using FishNet.Object;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ProMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ProMod")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: StraftatMod(true)]
[assembly: ComVisible(false)]
[assembly: Guid("c916158d-6264-41e8-bf8a-a4db8c0f97c2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[HarmonyPatch(typeof(Weapon))]
public static class MeleeHeadshots
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void SetMeleeHeadMultiplier(Weapon __instance)
{
string weaponName = __instance.behaviour.weaponName;
switch (weaponName)
{
default:
if (!(weaponName == "Stylus"))
{
break;
}
goto case "Baseball Bat";
case "Baseball Bat":
case "Couperet":
case "Curved Knife":
case "Flamberge":
case "GodSword":
case "Impetus":
case "Javal Mahmaer":
case "Katana":
case "Nizeh":
case "Oklahoma":
__instance.headMultiplier = 1f;
break;
}
}
}
[HarmonyPatch(typeof(Screenshake))]
public static class ScreenMovement
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void ScreenShake(Screenshake __instance)
{
__instance.duration = 0f;
__instance.bigFallDuration = 0f;
__instance.smallFallDuration = 0f;
}
}
public static class ScreenWobble
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void Wobble(Wobble __instance)
{
__instance.MaxWobble = 0f;
__instance.WobbleSpeed = 0f;
}
}
public static class Effects
{
[HarmonyPatch(typeof(CameraEffect), "Awake")]
[HarmonyPostfix]
public static void DisableCameraEffect(CameraEffect __instance)
{
CameraEffect.Intensity = 0f;
FieldInfo fieldInfo = AccessTools.Field(typeof(CameraEffect), "speed");
FieldInfo fieldInfo2 = AccessTools.Field(typeof(CameraEffect), "suppSpeed");
FieldInfo fieldInfo3 = AccessTools.Field(typeof(CameraEffect), "suppStart");
if (fieldInfo != null)
{
fieldInfo.SetValue(__instance, 0f);
}
if (fieldInfo2 != null)
{
fieldInfo2.SetValue(__instance, 0f);
}
if (fieldInfo3 != null)
{
fieldInfo3.SetValue(__instance, 0f);
}
}
}
[HarmonyPatch(typeof(Weapon))]
public static class aaa12
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void Setaaa12(Weapon __instance)
{
if (__instance.behaviour.weaponName == "AAA-12")
{
__instance.damage = 0.6f;
}
}
}
[HarmonyPatch(typeof(Weapon))]
public static class BayshorePatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void SetBayshore(Weapon __instance)
{
if (__instance.behaviour.weaponName == "Bayshore")
{
__instance.maxWallJumps = 2;
}
}
}
[HarmonyPatch(typeof(Weapon))]
public static class Bukanee
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void SetBuk(Weapon __instance)
{
if (__instance.behaviour.weaponName == "Bukanee")
{
__instance.requireBothHands = false;
}
}
}
[HarmonyPatch(typeof(Weapon))]
public static class Keso
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void SetKeso(Weapon __instance)
{
if (__instance.behaviour.weaponName == "Keso")
{
__instance.requireBothHands = false;
}
}
}
[HarmonyPatch(typeof(Weapon))]
public static class Prophet
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void SetDualLauncher(Weapon __instance)
{
if (__instance.behaviour.weaponName == "Prophet")
{
__instance.damage = 6f;
__instance.currentAmmo = 20;
__instance.timeBetweenFire = 0.2f;
}
}
}
[HarmonyPatch(typeof(Weapon))]
public static class Elephant
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void SetElephant(Weapon __instance)
{
if (__instance.behaviour.weaponName == "Elephant")
{
__instance.damage = 6f;
}
}
}
[HarmonyPatch(typeof(Weapon))]
public static class WeaponPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void SetKatana(Weapon __instance)
{
if (__instance.behaviour.weaponName == "Katana")
{
__instance.maxWallJumps = 2;
}
}
}
[HarmonyPatch(typeof(Weapon), "Awake")]
public static class Mac10DamagePatch
{
[HarmonyPostfix]
public static void Postfix(Weapon __instance)
{
string text = __instance?.behaviour?.weaponName;
if (text != null && (string.Equals(text, "mac10", StringComparison.OrdinalIgnoreCase) || string.Equals(text, "mac 10", StringComparison.OrdinalIgnoreCase) || string.Equals(text, "mac-10", StringComparison.OrdinalIgnoreCase)))
{
__instance.damage = 0.32f;
}
}
}
[HarmonyPatch(typeof(Weapon), "Awake")]
public static class M2000DamagePatch
{
private static void Postfix(Weapon __instance)
{
string a = __instance?.behaviour?.weaponName;
if (string.Equals(a, "M2000", StringComparison.OrdinalIgnoreCase))
{
__instance.damage = 6f;
}
}
}
[HarmonyPatch(typeof(Weapon))]
public static class MinigunMod
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void SetMinigun(Weapon __instance)
{
if (__instance.behaviour.weaponName == "minigun")
{
__instance.damage = 0.4f;
}
}
}
[HarmonyPatch(typeof(Weapon))]
public static class Revolver
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void SetRev(Weapon __instance)
{
if (__instance.behaviour.weaponName == "Revolver")
{
__instance.requireBothHands = false;
}
}
}
[HarmonyPatch(typeof(Weapon))]
public static class SawedOff
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void SetSawed(Weapon __instance)
{
if (__instance.behaviour.weaponName == "sawed off")
{
__instance.requireBothHands = false;
}
}
}
[HarmonyPatch(typeof(Shotgun), "Awake")]
public static class ShotgunPatch
{
[HarmonyPostfix]
public static void Postfix(Shotgun __instance)
{
if (((Weapon)__instance).behaviour.weaponName == "shotgun")
{
((Weapon)__instance).damage = 0.48f;
Traverse.Create((object)__instance).Field("bulletAmount").SetValue((object)16);
((Weapon)__instance).headMultiplier = 1f;
}
if (((Weapon)__instance).behaviour.weaponName == "sawed off")
{
Traverse.Create((object)__instance).Field("bulletAmount").SetValue((object)8);
}
}
}
[HarmonyPatch(typeof(Weapon))]
public static class SmithCarbine
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void SetCarbine(Weapon __instance)
{
if (__instance.behaviour.weaponName == "Smith Carbine")
{
__instance.damage = 3f;
__instance.headMultiplier = 2f;
}
}
}
public static class DamageNumbersSpawner
{
internal const float DisplayScale = 25f;
public static void TrySpawn(Weapon weapon, float damage, PlayerHealth target, string hitName)
{
//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_00a4: 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_00ae: 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_00ba: Expected O, but got Unknown
//IL_00c0: 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_010a: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)weapon == (Object)null) && !((Object)(object)target == (Object)null) && ((NetworkBehaviour)weapon).IsOwner && !(damage <= 0f) && !RollingDamageNumbers.TryAdd(weapon, damage, target, hitName))
{
float num = damage * 25f;
bool flag = hitName == "Head_Col" || hitName == "Neck_1_Col";
Vector3 position = ((Component)target).transform.position + Vector3.up * (flag ? 2.05f : 1.6f);
GameObject val = new GameObject("DamageNumber");
val.transform.position = position;
TextMeshPro val2 = val.AddComponent<TextMeshPro>();
((TMP_Text)val2).text = Mathf.CeilToInt(num).ToString();
((TMP_Text)val2).fontSize = 3.2f;
((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
((Graphic)val2).color = (flag ? DamageNumbersConfig.HeadshotColor.Value : DamageNumbersConfig.BodyColor.Value);
((TMP_Text)val2).enableWordWrapping = false;
((TMP_Text)val2).richText = false;
DamageNumberStyling.Apply(val2);
val.AddComponent<DamageNumber>();
}
}
public static void TrySpawnProp(Weapon weapon, GameObject obj)
{
//IL_006c: 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_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: 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_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Expected O, but got Unknown
//IL_0097: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)weapon == (Object)null || (Object)(object)obj == (Object)null || !((NetworkBehaviour)weapon).IsOwner)
{
return;
}
bool flag = DamageNumbersUtils.IsBarrel(obj);
float num = weapon.damage * 25f;
if (flag || !(num <= 0f))
{
Vector3 position = obj.transform.position + Vector3.up * 1f;
GameObject val = new GameObject("DamageNumber");
val.transform.position = position;
TextMeshPro val2 = val.AddComponent<TextMeshPro>();
((TMP_Text)val2).text = (flag ? ";)" : Mathf.CeilToInt(num).ToString());
((TMP_Text)val2).fontSize = 3f;
((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
((Graphic)val2).color = (Color)(flag ? new Color(0.65f, 0.65f, 0.65f, 1f) : DamageNumbersConfig.BodyColor.Value);
((TMP_Text)val2).enableWordWrapping = false;
((TMP_Text)val2).richText = false;
DamageNumberStyling.Apply(val2);
DamageNumber damageNumber = val.AddComponent<DamageNumber>();
if (flag)
{
damageNumber.SuppressBackdrop = true;
damageNumber.OverrideOutlineColor = Color.white;
damageNumber.ApplyOverrideOutline = true;
}
}
}
}
public static class RollingDamageNumbers
{
private static readonly Dictionary<int, RollingDamageNumber> activeByTarget = new Dictionary<int, RollingDamageNumber>(32);
public static bool TryAdd(Weapon weapon, float damage, PlayerHealth target, string hitName)
{
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
if (!DamageNumbersConfig.EnableRollingDamage.Value)
{
return false;
}
if ((Object)(object)weapon == (Object)null || (Object)(object)target == (Object)null)
{
return false;
}
if (!((NetworkBehaviour)weapon).IsOwner)
{
return false;
}
if (damage <= 0f)
{
return false;
}
int instanceID = ((Object)target).GetInstanceID();
if (!activeByTarget.TryGetValue(instanceID, out var value) || (Object)(object)value == (Object)null)
{
GameObject val = new GameObject("RollingDamageNumber");
value = val.AddComponent<RollingDamageNumber>();
value.SetTarget(target);
activeByTarget[instanceID] = value;
}
bool isHeadshot = hitName == "Head_Col" || hitName == "Neck_1_Col";
value.AddDamage(damage * 25f, isHeadshot);
return true;
}
public static void RemoveForTarget(int id, RollingDamageNumber instance)
{
if (activeByTarget.TryGetValue(id, out var value) && (Object)(object)value == (Object)(object)instance)
{
activeByTarget.Remove(id);
}
}
}
public sealed class DamageNumber : MonoBehaviour
{
private TextMeshPro text;
private Color baseColor;
private Vector3 velocity;
private float lifetime = 1f;
private float elapsed;
private Camera cam;
private float scale = 1f;
public bool SuppressBackdrop;
public bool ApplyOverrideOutline;
public Color OverrideOutlineColor = Color.white;
private void Awake()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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_0104: Unknown result type (might be due to invalid IL or missing references)
text = ((Component)this).GetComponent<TextMeshPro>();
baseColor = (((Object)(object)text != (Object)null) ? ((Graphic)text).color : Color.white);
velocity = new Vector3(Random.Range(-0.35f, 0.35f), Random.Range(1.2f, 1.7f), Random.Range(-0.35f, 0.35f));
if (DamageNumbersConfig.LifetimeSeconds != null)
{
lifetime = DamageNumbersConfig.GetLifetimeSeconds();
}
if (DamageNumbersConfig.NumberScale != null)
{
scale = DamageNumbersConfig.GetNumberScale();
}
((Component)this).transform.localScale = Vector3.one * scale;
if ((Object)(object)text != (Object)null)
{
if (!SuppressBackdrop)
{
DamageNumberStyling.AttachBackdrop(text.transform, scale);
}
if (ApplyOverrideOutline)
{
DamageNumberStyling.OverrideOutlineColor(text, OverrideOutlineColor);
}
}
}
private void Update()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: 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_002f: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
elapsed += Time.deltaTime;
Transform transform = ((Component)this).transform;
transform.position += velocity * Time.deltaTime;
velocity.y += 0.6f * Time.deltaTime;
float num = Mathf.Clamp01(elapsed / lifetime);
if ((Object)(object)text != (Object)null)
{
((Graphic)text).color = new Color(baseColor.r, baseColor.g, baseColor.b, Mathf.Lerp(1f, 0f, num));
}
cam = GetActiveCamera(cam);
if ((Object)(object)cam != (Object)null)
{
((Component)this).transform.rotation = Quaternion.LookRotation(((Component)this).transform.position - ((Component)cam).transform.position, ((Component)cam).transform.up);
((Component)this).transform.localScale = Vector3.one * scale;
}
if (elapsed >= lifetime)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
internal static Camera GetActiveCamera(Camera current)
{
if ((Object)(object)current != (Object)null && ((Behaviour)current).isActiveAndEnabled)
{
return current;
}
Camera main = Camera.main;
if ((Object)(object)main != (Object)null && ((Behaviour)main).isActiveAndEnabled)
{
return main;
}
Camera result = null;
float num = float.MinValue;
Camera[] array = Object.FindObjectsOfType<Camera>();
foreach (Camera val in array)
{
if (!((Object)(object)val == (Object)null) && ((Behaviour)val).isActiveAndEnabled && val.depth >= num)
{
num = val.depth;
result = val;
}
}
return result;
}
}
public sealed class RollingDamageNumber : MonoBehaviour
{
private TextMeshPro text;
private PlayerHealth target;
private int targetId;
private float totalDamage;
private float inactivity;
private float fadeElapsed;
private bool fading;
private Camera cam;
private Vector3 velocity;
private float windowSeconds;
private float fadeSeconds;
private float scale;
private bool headshot;
private void Awake()
{
//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_00b9: 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)
text = ((Component)this).gameObject.AddComponent<TextMeshPro>();
((TMP_Text)text).fontSize = 3.2f;
((TMP_Text)text).alignment = (TextAlignmentOptions)514;
((TMP_Text)text).enableWordWrapping = false;
((TMP_Text)text).richText = false;
DamageNumberStyling.Apply(text);
velocity = new Vector3(Random.Range(-0.25f, 0.25f), Random.Range(0.9f, 1.2f), Random.Range(-0.25f, 0.25f));
windowSeconds = DamageNumbersConfig.GetRollingWindowSeconds();
fadeSeconds = DamageNumbersConfig.GetLifetimeSeconds();
scale = DamageNumbersConfig.GetNumberScale();
((Component)this).transform.localScale = Vector3.one * scale;
DamageNumberStyling.AttachBackdrop(text.transform, scale);
}
public void SetTarget(PlayerHealth newTarget)
{
target = newTarget;
targetId = (((Object)(object)newTarget != (Object)null) ? ((Object)newTarget).GetInstanceID() : 0);
}
public void AddDamage(float damage, bool isHeadshot)
{
//IL_0082: 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)
totalDamage += damage;
headshot = isHeadshot;
inactivity = 0f;
fading = false;
fadeElapsed = 0f;
if ((Object)(object)text != (Object)null)
{
((TMP_Text)text).text = Mathf.CeilToInt(totalDamage).ToString();
((Graphic)text).color = (headshot ? DamageNumbersConfig.HeadshotColor.Value : DamageNumbersConfig.BodyColor.Value);
}
UpdatePosition();
SpriteRenderer componentInChildren = ((Component)this).GetComponentInChildren<SpriteRenderer>();
if ((Object)(object)componentInChildren != (Object)null)
{
DamageNumberStyling.ResizeBackdrop(componentInChildren, text);
}
}
private void Update()
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: 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)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: 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_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: 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_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: 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)
if ((Object)(object)target == (Object)null)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
inactivity += Time.deltaTime;
Transform transform = ((Component)this).transform;
transform.position += velocity * Time.deltaTime;
velocity.y += 0.4f * Time.deltaTime;
if (!fading && inactivity >= windowSeconds)
{
fading = true;
fadeElapsed = 0f;
}
if (fading)
{
fadeElapsed += Time.deltaTime;
float num = ((fadeSeconds > 0f) ? Mathf.Clamp01(fadeElapsed / fadeSeconds) : 1f);
if ((Object)(object)text != (Object)null)
{
Color color = ((Graphic)text).color;
((Graphic)text).color = new Color(color.r, color.g, color.b, Mathf.Lerp(1f, 0f, num));
}
if (num >= 1f)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
}
else if ((Object)(object)text != (Object)null)
{
Color color2 = ((Graphic)text).color;
if (color2.a != 1f)
{
((Graphic)text).color = new Color(color2.r, color2.g, color2.b, 1f);
}
}
cam = DamageNumber.GetActiveCamera(cam);
if ((Object)(object)cam != (Object)null)
{
((Component)this).transform.rotation = Quaternion.LookRotation(((Component)this).transform.position - ((Component)cam).transform.position, ((Component)cam).transform.up);
((Component)this).transform.localScale = Vector3.one * scale;
}
}
private void UpdatePosition()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//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_004e: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)target == (Object)null))
{
Vector3 position = ((Component)target).transform.position + Vector3.up * (headshot ? 2.05f : 1.6f);
((Component)this).transform.position = position;
}
}
private void OnDestroy()
{
if (targetId != 0)
{
RollingDamageNumbers.RemoveForTarget(targetId, this);
}
}
}
public static class DamageNumberStyling
{
private static Sprite backdropSprite;
public static void Apply(TextMeshPro text)
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)text == (Object)null)
{
return;
}
Renderer renderer = text.renderer;
if ((Object)(object)renderer != (Object)null)
{
renderer.sortingOrder = 1;
}
if (DamageNumbersConfig.EnableOutline.Value)
{
Material fontMaterial = ((TMP_Text)text).fontMaterial;
if ((Object)(object)fontMaterial != (Object)null)
{
Material val = Object.Instantiate<Material>(fontMaterial);
val.SetColor("_OutlineColor", DamageNumbersConfig.OutlineColor.Value);
val.SetFloat("_OutlineWidth", DamageNumbersConfig.GetOutlineWidth());
((TMP_Text)text).fontMaterial = val;
}
}
}
public static void AttachBackdrop(Transform parent, float scale)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_0051: 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_0086: Unknown result type (might be due to invalid IL or missing references)
if (DamageNumbersConfig.EnableBackdrop.Value && !((Object)(object)parent == (Object)null))
{
GameObject val = new GameObject("DamageNumberBackdrop");
val.transform.SetParent(parent, false);
val.transform.localPosition = new Vector3(0f, 0f, -0.02f);
val.transform.localRotation = Quaternion.identity;
SpriteRenderer val2 = val.AddComponent<SpriteRenderer>();
val2.sprite = GetBackdropSprite();
val2.color = DamageNumbersConfig.BackdropColor.Value;
((Renderer)val2).sortingOrder = 0;
Renderer val3 = default(Renderer);
if (((Component)parent).TryGetComponent<Renderer>(ref val3))
{
((Renderer)val2).sortingLayerID = val3.sortingLayerID;
}
TextMeshPro component = ((Component)parent).GetComponent<TextMeshPro>();
if ((Object)(object)component != (Object)null)
{
ResizeBackdrop(val2, component);
}
}
}
public static void OverrideOutlineColor(TextMeshPro text, Color outlineColor)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)text == (Object)null))
{
Material fontMaterial = ((TMP_Text)text).fontMaterial;
if (!((Object)(object)fontMaterial == (Object)null))
{
Material val = Object.Instantiate<Material>(fontMaterial);
val.SetColor("_OutlineColor", outlineColor);
val.SetFloat("_OutlineWidth", DamageNumbersConfig.GetOutlineWidth());
((TMP_Text)text).fontMaterial = val;
}
}
}
public static void ResizeBackdrop(SpriteRenderer renderer, TextMeshPro text)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: 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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)renderer == (Object)null) && !((Object)(object)text == (Object)null))
{
((TMP_Text)text).ForceMeshUpdate(false, false);
Vector2 renderedValues = ((TMP_Text)text).GetRenderedValues(false);
float num = Mathf.Max(renderedValues.x, renderedValues.y) * 1.15f;
((Component)renderer).transform.localScale = new Vector3(num * 0.5f, num * 0.5f, 1f);
}
}
private static Sprite GetBackdropSprite()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)backdropSprite != (Object)null)
{
return backdropSprite;
}
Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false);
((Texture)val).wrapMode = (TextureWrapMode)1;
((Texture)val).filterMode = (FilterMode)1;
float num = 31f;
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(num, num);
for (int i = 0; i < 64; i++)
{
for (int j = 0; j < 64; j++)
{
float num2 = Vector2.Distance(new Vector2((float)j, (float)i), val2);
float num3 = Mathf.Clamp01(1f - (num2 - (num - 2f)) / 2f);
if (num2 > num)
{
num3 = 0f;
}
val.SetPixel(j, i, new Color(1f, 1f, 1f, num3));
}
}
val.Apply();
backdropSprite = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 32f);
return backdropSprite;
}
}
public sealed class ShotgunDamageAggregator : MonoBehaviour
{
private struct Pending
{
public Weapon weapon;
public PlayerHealth target;
public float damage;
public bool headshot;
public int frame;
}
private static ShotgunDamageAggregator instance;
private static readonly Dictionary<int, Pending> pendingByTarget = new Dictionary<int, Pending>(32);
private static readonly List<int> pendingKeys = new List<int>(32);
public static void Add(Weapon weapon, float damage, PlayerHealth target, string hitName)
{
if (!((Object)(object)weapon == (Object)null) && !((Object)(object)target == (Object)null) && ((NetworkBehaviour)weapon).IsOwner && !(damage <= 0f))
{
EnsureInstance();
int instanceID = ((Object)target).GetInstanceID();
if (!pendingByTarget.TryGetValue(instanceID, out var value) || value.frame != Time.frameCount)
{
value = new Pending
{
weapon = weapon,
target = target,
damage = 0f,
headshot = false,
frame = Time.frameCount
};
}
value.damage += damage;
if (hitName == "Head_Col" || hitName == "Neck_1_Col")
{
value.headshot = true;
}
pendingByTarget[instanceID] = value;
}
}
private static void EnsureInstance()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
if (!((Object)(object)instance != (Object)null))
{
GameObject val = new GameObject("ShotgunDamageAggregator");
Object.DontDestroyOnLoad((Object)(object)val);
instance = val.AddComponent<ShotgunDamageAggregator>();
}
}
private void LateUpdate()
{
if (pendingByTarget.Count == 0)
{
return;
}
pendingKeys.Clear();
foreach (KeyValuePair<int, Pending> item in pendingByTarget)
{
pendingKeys.Add(item.Key);
}
for (int i = 0; i < pendingKeys.Count; i++)
{
int key = pendingKeys[i];
if (pendingByTarget.TryGetValue(key, out var value) && (Object)(object)value.weapon != (Object)null && (Object)(object)value.target != (Object)null)
{
DamageNumbersSpawner.TrySpawn(value.weapon, value.damage, value.target, value.headshot ? "Head_Col" : "Body");
}
}
pendingByTarget.Clear();
}
}
[DamageNumbersPatch]
[HarmonyPatch(typeof(Gun), "GiveDamage")]
public static class Gun_DamageNumbers
{
private static void Prefix(Gun __instance, float damageToGive, PlayerHealth enemyHealth, string name)
{
DamageNumbersSpawner.TrySpawn((Weapon)(object)__instance, damageToGive, enemyHealth, name);
}
}
[DamageNumbersPatch]
[HarmonyPatch(typeof(Shotgun), "GiveDamage")]
public static class Shotgun_DamageNumbers
{
private static void Prefix(Shotgun __instance, float damageToGive, PlayerHealth enemyHealth, string name)
{
ShotgunDamageAggregator.Add((Weapon)(object)__instance, damageToGive, enemyHealth, name);
}
}
[DamageNumbersPatch]
[HarmonyPatch(typeof(Minigun), "GiveDamage")]
public static class Minigun_DamageNumbers
{
private static void Prefix(Minigun __instance, float damageToGive, PlayerHealth enemyHealth, string name)
{
DamageNumbersSpawner.TrySpawn((Weapon)(object)__instance, damageToGive, enemyHealth, name);
}
}
[DamageNumbersPatch]
[HarmonyPatch(typeof(BeamGun), "GiveDamage")]
public static class BeamGun_DamageNumbers
{
private static void Prefix(BeamGun __instance, float damageToGive, PlayerHealth enemyHealth, string name)
{
DamageNumbersSpawner.TrySpawn((Weapon)(object)__instance, damageToGive, enemyHealth, name);
}
}
[DamageNumbersPatch]
[HarmonyPatch(typeof(ChargeGun), "GiveDamage")]
public static class ChargeGun_DamageNumbers
{
private static void Prefix(ChargeGun __instance, float damageToGive, PlayerHealth enemyHealth, string name)
{
DamageNumbersSpawner.TrySpawn((Weapon)(object)__instance, damageToGive, enemyHealth, name);
}
}
[DamageNumbersPatch]
[HarmonyPatch(typeof(LargeRaycastGun), "GiveDamage")]
public static class LargeRaycastGun_DamageNumbers
{
private static void Prefix(LargeRaycastGun __instance, float damageToGive, PlayerHealth enemyHealth, string name)
{
DamageNumbersSpawner.TrySpawn((Weapon)(object)__instance, damageToGive, enemyHealth, name);
}
}
[DamageNumbersPatch]
[HarmonyPatch(typeof(RepulsiveGun), "GiveDamage")]
public static class RepulsiveGun_DamageNumbers
{
private static void Prefix(RepulsiveGun __instance, float damageToGive, PlayerHealth enemyHealth, string name)
{
DamageNumbersSpawner.TrySpawn((Weapon)(object)__instance, damageToGive, enemyHealth, name);
}
}
[DamageNumbersPatch]
[HarmonyPatch(typeof(MeleeWeapon), "GiveDamage")]
public static class MeleeWeapon_DamageNumbers
{
private static void Prefix(MeleeWeapon __instance, float damageToGive, PlayerHealth enemyHealth, string name)
{
DamageNumbersSpawner.TrySpawn((Weapon)(object)__instance, damageToGive, enemyHealth, name);
}
}
[DamageNumbersPatch]
[HarmonyPatch(typeof(Weapon), "CmdDamageProp")]
public static class Weapon_PropDamageNumbers
{
private static void Prefix(Weapon __instance, GameObject obj)
{
DamageNumbersSpawner.TrySpawnProp(__instance, obj);
}
}
public static class DamageNumbersUtils
{
public static bool IsBarrel(GameObject obj)
{
if ((Object)(object)obj == (Object)null)
{
return false;
}
if (HasBarrelName(((Object)obj).name))
{
return true;
}
Transform val = (((Object)(object)obj.transform != (Object)null) ? obj.transform.root : null);
if ((Object)(object)val != (Object)null && HasBarrelName(((Object)val).name))
{
return true;
}
return false;
}
private static bool HasBarrelName(string name)
{
if (string.IsNullOrEmpty(name))
{
return false;
}
return name.IndexOf("barrel", StringComparison.OrdinalIgnoreCase) >= 0;
}
public static Transform GetLocalPlayerTransform()
{
FirstPersonController[] array = Object.FindObjectsOfType<FirstPersonController>();
foreach (FirstPersonController val in array)
{
if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).IsOwner)
{
return ((Component)val).transform;
}
}
return null;
}
}
[BepInPlugin("com.glizzmn.damagenumbers", "PM DamageNumbers", "1.0.0")]
public sealed class DamageNumbersPlugin : BaseUnityPlugin
{
private Harmony harmony;
private void Awake()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
DamageNumbersConfig.Bind(((BaseUnityPlugin)this).Config);
harmony = new Harmony("com.glizzmn.damagenumbers");
PatchDamageNumbers();
}
private void PatchDamageNumbers()
{
Assembly assembly = typeof(DamageNumbersPlugin).Assembly;
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
if (Attribute.IsDefined(type, typeof(DamageNumbersPatchAttribute), inherit: false))
{
harmony.CreateClassProcessor(type).Patch();
}
}
}
}
public static class DamageNumbersConfig
{
public static ConfigEntry<float> LifetimeSeconds;
public static ConfigEntry<float> NumberScale;
public static ConfigEntry<Color> BodyColor;
public static ConfigEntry<Color> HeadshotColor;
public static ConfigEntry<bool> EnableRollingDamage;
public static ConfigEntry<float> RollingWindowSeconds;
public static ConfigEntry<bool> EnableOutline;
public static ConfigEntry<Color> OutlineColor;
public static ConfigEntry<float> OutlineWidth;
public static ConfigEntry<bool> EnableBackdrop;
public static ConfigEntry<Color> BackdropColor;
public const float LifetimeMin = 0.2f;
public const float LifetimeMax = 5f;
public const float ScaleMin = 0.5f;
public const float ScaleMax = 4f;
public const float RollingWindowMin = 0.1f;
public const float RollingWindowMax = 2f;
public const float OutlineWidthMin = 0f;
public const float OutlineWidthMax = 0.5f;
public const float BackdropScale = 0.5f;
public static void Bind(ConfigFile config)
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: 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)
LifetimeSeconds = config.Bind<float>("Display", "LifetimeSeconds", 1f, "How long damage numbers stay on screen in seconds.");
NumberScale = config.Bind<float>("Display", "NumberScale", 1f, "Visual scale multiplier for damage numbers.");
BodyColor = config.Bind<Color>("Colors", "BodyColor", new Color(1f, 1f, 1f, 1f), "Color for regular damage numbers.");
HeadshotColor = config.Bind<Color>("Colors", "HeadshotColor", new Color(1f, 0.25f, 0.25f, 1f), "Color for headshot damage numbers.");
OutlineColor = config.Bind<Color>("Style", "OutlineColor", new Color(0f, 0f, 0f, 0.9f), "Outline color for damage numbers.");
OutlineWidth = config.Bind<float>("Style", "OutlineWidth", 0.15f, "Outline width for damage numbers.");
EnableOutline = config.Bind<bool>("Style", "EnableOutline", true, "Enable text outline for damage numbers.");
BackdropColor = config.Bind<Color>("Style", "BackdropColor", new Color(0f, 0f, 0f, 0.45f), "Color of the circle backdrop behind damage numbers.");
EnableBackdrop = config.Bind<bool>("Style", "EnableBackdrop", true, "Enable a circle backdrop behind damage numbers.");
EnableRollingDamage = config.Bind<bool>("RollingDamage", "EnableRollingDamage", false, "When enabled, rapid damage stacks into a single floating number per target.");
RollingWindowSeconds = config.Bind<float>("RollingDamage", "RollingWindowSeconds", 0.4f, "How long (seconds) to wait for another hit before the rolling number fades.");
}
public static float GetLifetimeSeconds()
{
return Mathf.Clamp(LifetimeSeconds.Value, 0.2f, 5f);
}
public static float GetNumberScale()
{
return Mathf.Clamp(NumberScale.Value, 0.5f, 4f);
}
public static float GetRollingWindowSeconds()
{
return Mathf.Clamp(RollingWindowSeconds.Value, 0.1f, 2f);
}
public static float GetOutlineWidth()
{
return Mathf.Clamp(OutlineWidth.Value, 0f, 0.5f);
}
}
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
internal sealed class DamageNumbersPatchAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
internal sealed class HitmarkersPatchAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
internal sealed class HitSoundsPatchAttribute : Attribute
{
}
public static class HitmarkerManager
{
private static HitmarkerController instance;
public static void Play(bool headshot, bool kill)
{
if (HitmarkerConfig.EnableCustomHitmarkers.Value && !((Object)(object)Crosshair.Instance == (Object)null))
{
VanillaHitmarkerCleaner.Ensure();
EnsureInstance();
instance.Play(headshot, kill, barrel: false);
}
}
public static void PlayBarrel(bool kill)
{
if (HitmarkerConfig.EnableCustomHitmarkers.Value && HitmarkerConfig.EnableBarrelHitmarker.Value && !((Object)(object)Crosshair.Instance == (Object)null))
{
VanillaHitmarkerCleaner.Ensure();
EnsureInstance();
instance.Play(headshot: false, kill, barrel: true);
}
}
private static void EnsureInstance()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0045: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)instance != (Object)null))
{
GameObject val = new GameObject("CustomHitmarker");
RectTransform val2 = val.AddComponent<RectTransform>();
((Transform)val2).SetParent(((Component)Crosshair.Instance).transform, false);
val2.anchorMin = new Vector2(0.5f, 0.5f);
val2.anchorMax = new Vector2(0.5f, 0.5f);
val2.pivot = new Vector2(0.5f, 0.5f);
val2.anchoredPosition = Vector2.zero;
((Transform)val2).localScale = Vector3.one;
instance = val.AddComponent<HitmarkerController>();
instance.Initialize();
}
}
}
public sealed class VanillaHitmarkerCleaner : MonoBehaviour
{
private static VanillaHitmarkerCleaner instance;
private static readonly string[] MarkerNameHints = new string[2] { "HitMarker", "KillMarker" };
public static void Ensure()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
if (!((Object)(object)instance != (Object)null) && !((Object)(object)PauseManager.Instance == (Object)null))
{
GameObject val = new GameObject("VanillaHitmarkerCleaner");
RectTransform val2 = val.AddComponent<RectTransform>();
((Transform)val2).SetParent(((Component)PauseManager.Instance).transform, false);
instance = val.AddComponent<VanillaHitmarkerCleaner>();
}
}
private void LateUpdate()
{
if (!HitmarkerConfig.EnableCustomHitmarkers.Value || !HitmarkerConfig.HideVanillaHitmarkers.Value || (Object)(object)PauseManager.Instance == (Object)null)
{
return;
}
Transform transform = ((Component)PauseManager.Instance).transform;
for (int num = transform.childCount - 1; num >= 0; num--)
{
Transform child = transform.GetChild(num);
if (!((Object)(object)child == (Object)null) && LooksLikeVanillaHitmarker(((Component)child).gameObject))
{
Object.Destroy((Object)(object)((Component)child).gameObject);
}
}
}
private static bool LooksLikeVanillaHitmarker(GameObject obj)
{
string name = ((Object)obj).name;
for (int i = 0; i < MarkerNameHints.Length; i++)
{
if (name.IndexOf(MarkerNameHints[i], StringComparison.OrdinalIgnoreCase) >= 0)
{
return true;
}
}
return false;
}
}
public sealed class HitmarkerController : MonoBehaviour
{
private sealed class Segment
{
public RectTransform root;
public RectTransform outlineRect;
public RectTransform innerRect;
public Image outlineImage;
public Image innerImage;
public float angle;
}
private readonly List<Segment> segments = new List<Segment>(4);
private CanvasGroup canvasGroup;
private RectTransform rect;
private HitmarkerShape currentShape;
private float elapsed;
private bool active;
private const float DisplaySeconds = 0.18f;
private const float StartScale = 1.18f;
public void Initialize()
{
ref RectTransform reference = ref rect;
Transform transform = ((Component)this).transform;
reference = (RectTransform)(object)((transform is RectTransform) ? transform : null);
canvasGroup = ((Component)this).gameObject.AddComponent<CanvasGroup>();
canvasGroup.alpha = 0f;
canvasGroup.blocksRaycasts = false;
canvasGroup.interactable = false;
currentShape = (HitmarkerShape)(-1);
ApplyConfig();
((Component)this).gameObject.SetActive(false);
}
public void Play(bool headshot, bool kill, bool barrel)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
ApplyConfig();
ApplyColors(headshot, kill, barrel);
elapsed = 0f;
active = true;
canvasGroup.alpha = 1f;
if ((Object)(object)rect != (Object)null)
{
((Transform)rect).localScale = Vector3.one * 1.18f;
}
((Component)this).gameObject.SetActive(true);
}
private void Update()
{
//IL_0083: 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)
if (active)
{
elapsed += Time.unscaledDeltaTime;
float num = Mathf.Clamp01(elapsed / 0.18f);
float num2 = num * num;
canvasGroup.alpha = 1f - num2;
if ((Object)(object)rect != (Object)null)
{
float num3 = Mathf.Lerp(1.18f, 1f, Mathf.Clamp01(num * 2.2f));
((Transform)rect).localScale = Vector3.one * num3;
}
if (num >= 1f)
{
active = false;
((Component)this).gameObject.SetActive(false);
}
}
}
private void ApplyConfig()
{
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: 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_00e6: 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)
if (currentShape != HitmarkerConfig.Shape.Value)
{
BuildSegments(HitmarkerConfig.Shape.Value);
}
int length = HitmarkerConfig.GetLength();
int thickness = HitmarkerConfig.GetThickness();
int gap = HitmarkerConfig.GetGap();
bool value = HitmarkerConfig.EnableOutline.Value;
int num = (value ? HitmarkerConfig.GetOutlineThickness() : 0);
Vector2 val = default(Vector2);
for (int i = 0; i < segments.Count; i++)
{
Segment segment = segments[i];
float num2 = segment.angle * ((float)Math.PI / 180f);
((Vector2)(ref val))..ctor(Mathf.Cos(num2), Mathf.Sin(num2));
float num3 = (float)gap + (float)length * 0.5f;
segment.root.anchoredPosition = val * num3;
((Transform)segment.root).localRotation = Quaternion.Euler(0f, 0f, segment.angle);
segment.innerRect.sizeDelta = new Vector2((float)length, (float)thickness);
segment.outlineRect.sizeDelta = new Vector2((float)(length + num * 2), (float)(thickness + num * 2));
((Behaviour)segment.outlineImage).enabled = value && num > 0;
}
}
private void ApplyColors(bool headshot, bool kill, bool barrel)
{
//IL_0033: 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)
//IL_0027: 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_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: 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_0053: 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_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
Color color = (kill ? HitmarkerConfig.KillColor.Value : (barrel ? HitmarkerConfig.BarrelColor.Value : (headshot ? HitmarkerConfig.HeadshotColor.Value : HitmarkerConfig.Color.Value)));
Color color2 = (kill ? HitmarkerConfig.KillOutlineColor.Value : (barrel ? HitmarkerConfig.BarrelOutlineColor.Value : (headshot ? HitmarkerConfig.HeadshotOutlineColor.Value : HitmarkerConfig.OutlineColor.Value)));
for (int i = 0; i < segments.Count; i++)
{
((Graphic)segments[i].innerImage).color = color;
((Graphic)segments[i].outlineImage).color = color2;
}
}
private void BuildSegments(HitmarkerShape shape)
{
for (int num = ((Component)this).transform.childCount - 1; num >= 0; num--)
{
Object.Destroy((Object)(object)((Component)((Component)this).transform.GetChild(num)).gameObject);
}
segments.Clear();
float[] array = ((shape != HitmarkerShape.Plus) ? new float[4] { 45f, 135f, 225f, 315f } : new float[4] { 0f, 90f, 180f, 270f });
for (int i = 0; i < array.Length; i++)
{
segments.Add(CreateSegment(array[i]));
}
currentShape = shape;
}
private Segment CreateSegment(float angle)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: 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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: 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_00dd: Expected O, but got Unknown
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("Segment");
RectTransform val2 = val.AddComponent<RectTransform>();
((Transform)val2).SetParent(((Component)this).transform, false);
val2.anchorMin = new Vector2(0.5f, 0.5f);
val2.anchorMax = new Vector2(0.5f, 0.5f);
val2.pivot = new Vector2(0.5f, 0.5f);
GameObject val3 = new GameObject("Outline");
RectTransform val4 = val3.AddComponent<RectTransform>();
((Transform)val4).SetParent((Transform)(object)val2, false);
val4.anchorMin = new Vector2(0.5f, 0.5f);
val4.anchorMax = new Vector2(0.5f, 0.5f);
val4.pivot = new Vector2(0.5f, 0.5f);
Image val5 = val3.AddComponent<Image>();
((Graphic)val5).raycastTarget = false;
GameObject val6 = new GameObject("Inner");
RectTransform val7 = val6.AddComponent<RectTransform>();
((Transform)val7).SetParent((Transform)(object)val2, false);
val7.anchorMin = new Vector2(0.5f, 0.5f);
val7.anchorMax = new Vector2(0.5f, 0.5f);
val7.pivot = new Vector2(0.5f, 0.5f);
Image val8 = val6.AddComponent<Image>();
((Graphic)val8).raycastTarget = false;
return new Segment
{
root = val2,
outlineRect = val4,
innerRect = val7,
outlineImage = val5,
innerImage = val8,
angle = angle
};
}
}
internal static class HitmarkerEvents
{
private static readonly Dictionary<Type, FieldInfo> enemyHealthFieldByType = new Dictionary<Type, FieldInfo>(8);
private static int lastFrame = -1;
private static int lastTargetId;
private static int lastPriority = -1;
public static void PlayWeaponDamage(Weapon weapon, float damageToGive, PlayerHealth target, string hitName)
{
if (CanShowWeaponHit(weapon, target))
{
bool headshot = IsHeadshot(hitName);
bool kill = IsKill(target, damageToGive);
PlayForTarget(target, headshot, kill, barrel: false);
ClearVanillaMarker(weapon);
}
}
public static void PlayWeaponKill(Weapon weapon, PlayerHealth target)
{
if (CanShowWeaponHit(weapon, target))
{
PlayForTarget(target, headshot: false, kill: true, barrel: false);
ClearVanillaMarker(weapon);
}
}
public static void PlayWeaponContact(Weapon weapon, PlayerHealth target)
{
if (CanShowWeaponHit(weapon, target))
{
PlayForTarget(target, headshot: false, kill: false, barrel: false);
ClearVanillaMarker(weapon);
}
}
public static void PlayWeaponMarker(Weapon weapon)
{
if (!HitmarkerConfig.EnableCustomHitmarkers.Value || !IsLocalWeapon(weapon))
{
return;
}
GameObject marker = weapon.marker;
if (!((Object)(object)marker == (Object)null))
{
PlayerHealth enemyHealth = GetEnemyHealth(weapon);
if (IsLocalTarget(enemyHealth))
{
ClearVanillaMarker(weapon);
return;
}
bool headshot = IsHeadshotMarker(marker);
bool kill = (Object)(object)enemyHealth != (Object)null && IsKill(enemyHealth, 0f);
PlayForTarget(enemyHealth, headshot, kill, barrel: false);
ClearVanillaMarker(weapon);
}
}
public static void PlayProjectileHit(bool headshot)
{
if (HitmarkerConfig.EnableCustomHitmarkers.Value)
{
PlayForTarget(null, headshot, kill: false, barrel: false);
}
}
public static void PlayPhysicsPropHit(PlayerHealth target, bool kill)
{
if (HitmarkerConfig.EnableCustomHitmarkers.Value && HitmarkerConfig.EnableBarrelHitmarker.Value && !IsLocalTarget(target))
{
PlayForTarget(target, headshot: false, kill, barrel: true);
}
}
public static void PlayRemoveHealthFallback(PlayerHealth target, float beforeHealth, float damage)
{
if (HitmarkerConfig.EnableCustomHitmarkers.Value && !((Object)(object)target == (Object)null) && !(damage <= 0f) && !IsLocalTarget(target))
{
float num = target.sync___get_value_health();
if (!(num >= beforeHealth) && TargetHasLocalKiller(target))
{
bool kill = target.sync___get_value_isKilled() || num <= 0f || beforeHealth - damage <= 0f;
PlayForTarget(target, headshot: false, kill, barrel: false);
}
}
}
public static bool ShouldWatchPhysicsProp(PhysicsProp prop)
{
if ((Object)(object)prop == (Object)null)
{
return false;
}
if (PhysicsPropHitmarkerTracker.IsTracked(prop))
{
return true;
}
if (((NetworkBehaviour)prop).IsOwner)
{
return true;
}
FirstPersonController val = prop.sync___get_value_playerThatHasGrabbedBarrel();
return (Object)(object)val != (Object)null && ((NetworkBehaviour)val).IsOwner;
}
private static bool CanShowWeaponHit(Weapon weapon, PlayerHealth target)
{
if (!HitmarkerConfig.EnableCustomHitmarkers.Value)
{
return false;
}
if (!IsLocalWeapon(weapon))
{
return false;
}
return (Object)(object)target != (Object)null && !IsLocalTarget(target);
}
private static bool IsLocalWeapon(Weapon weapon)
{
if ((Object)(object)weapon == (Object)null)
{
return false;
}
if (((NetworkBehaviour)weapon).IsOwner)
{
return true;
}
FirstPersonController playerController = weapon.playerController;
if ((Object)(object)playerController != (Object)null && ((NetworkBehaviour)playerController).IsOwner)
{
return true;
}
Transform val = (((Object)(object)((Component)weapon).transform != (Object)null) ? ((Component)weapon).transform.root : null);
playerController = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<FirstPersonController>() : null);
return (Object)(object)playerController != (Object)null && ((NetworkBehaviour)playerController).IsOwner;
}
private static bool IsLocalTarget(PlayerHealth target)
{
if ((Object)(object)target == (Object)null)
{
return false;
}
if (((NetworkBehaviour)target).IsOwner)
{
return true;
}
FirstPersonController val = target.controller;
if ((Object)(object)val == (Object)null)
{
val = ((Component)target).GetComponent<FirstPersonController>();
}
return (Object)(object)val != (Object)null && ((NetworkBehaviour)val).IsOwner;
}
private static bool TargetHasLocalKiller(PlayerHealth target)
{
Transform val = target.sync___get_value_killer();
if ((Object)(object)val == (Object)null)
{
return false;
}
FirstPersonController val2 = ((Component)val).GetComponent<FirstPersonController>();
if ((Object)(object)val2 == (Object)null)
{
val2 = ((Component)val).GetComponentInParent<FirstPersonController>();
}
return (Object)(object)val2 != (Object)null && ((NetworkBehaviour)val2).IsOwner;
}
private static bool IsHeadshot(string hitName)
{
return string.Equals(hitName, "Head_Col", StringComparison.Ordinal) || string.Equals(hitName, "Neck_1_Col", StringComparison.Ordinal);
}
private static bool IsKill(PlayerHealth target, float damageToGive)
{
if ((Object)(object)target == (Object)null)
{
return false;
}
float num = target.sync___get_value_health();
return target.sync___get_value_isKilled() || num <= 0f || (damageToGive > 0f && num - damageToGive <= 0f);
}
private static void PlayForTarget(PlayerHealth target, bool headshot, bool kill, bool barrel)
{
int targetId = (((Object)(object)target != (Object)null) ? ((Object)target).GetInstanceID() : 0);
int priority = (kill ? 3 : (headshot ? 2 : (barrel ? 1 : 0)));
if (ShouldPlay(targetId, priority))
{
if (barrel)
{
HitmarkerManager.PlayBarrel(kill);
}
else
{
HitmarkerManager.Play(headshot, kill);
}
}
}
private static bool ShouldPlay(int targetId, int priority)
{
int frameCount = Time.frameCount;
if (lastFrame == frameCount && lastTargetId == targetId && priority <= lastPriority)
{
return false;
}
lastFrame = frameCount;
lastTargetId = targetId;
lastPriority = priority;
return true;
}
private static bool IsHeadshotMarker(GameObject marker)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: 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_0039: Unknown result type (might be due to invalid IL or missing references)
Image component = marker.GetComponent<Image>();
if ((Object)(object)component == (Object)null)
{
return false;
}
Color color = ((Graphic)component).color;
return color.r > 0.9f && color.g < 0.2f && color.b < 0.2f;
}
private static PlayerHealth GetEnemyHealth(Weapon weapon)
{
if ((Object)(object)weapon == (Object)null)
{
return null;
}
Type type = ((object)weapon).GetType();
if (!enemyHealthFieldByType.TryGetValue(type, out var value))
{
value = AccessTools.Field(type, "enemyHealth");
enemyHealthFieldByType[type] = value;
}
return (PlayerHealth)((value != null) ? /*isinst with value type is only supported in some contexts*/: null);
}
private static void ClearVanillaMarker(Weapon weapon)
{
if (!((Object)(object)weapon == (Object)null) && HitmarkerConfig.HideVanillaHitmarkers.Value && (Object)(object)weapon.marker != (Object)null)
{
Object.Destroy((Object)(object)weapon.marker);
weapon.marker = null;
}
}
}
internal static class PhysicsPropHitmarkerTracker
{
private static readonly Dictionary<PhysicsProp, float> trackedProps = new Dictionary<PhysicsProp, float>();
private const float TrackSeconds = 4f;
public static void Mark(PhysicsProp prop, Transform player)
{
if (!((Object)(object)prop == (Object)null) && IsLocalPlayer(player))
{
trackedProps[prop] = Time.time + 4f;
}
}
public static bool IsTracked(PhysicsProp prop)
{
if ((Object)(object)prop == (Object)null)
{
return false;
}
if (!trackedProps.TryGetValue(prop, out var value))
{
return false;
}
if (Time.time <= value)
{
return true;
}
trackedProps.Remove(prop);
return false;
}
private static bool IsLocalPlayer(Transform player)
{
if ((Object)(object)player == (Object)null)
{
return false;
}
FirstPersonController val = ((Component)player).GetComponent<FirstPersonController>();
if ((Object)(object)val == (Object)null)
{
val = ((Component)player).GetComponentInParent<FirstPersonController>();
}
return (Object)(object)val != (Object)null && ((NetworkBehaviour)val).IsOwner;
}
}
internal static class HitmarkerPatchUtils
{
private static readonly Dictionary<Type, FieldInfo> audioFieldByType = new Dictionary<Type, FieldInfo>(3);
private static readonly Dictionary<Type, FieldInfo> sfxFieldByType = new Dictionary<Type, FieldInfo>(3);
public static bool Handle(object instance, bool headshot)
{
if (!HitmarkerConfig.EnableCustomHitmarkers.Value)
{
return true;
}
HitmarkerEvents.PlayProjectileHit(headshot);
if (!HitmarkerConfig.HideVanillaHitmarkers.Value)
{
return true;
}
PlayVanillaAudio(instance, headshot);
return false;
}
private static void PlayVanillaAudio(object instance, bool headshot)
{
if (instance != null)
{
Type type = instance.GetType();
FieldInfo fieldCached = GetFieldCached(audioFieldByType, type, "audio");
FieldInfo fieldCached2 = GetFieldCached(sfxFieldByType, type, "hitSfx");
AudioSource val = (AudioSource)((fieldCached != null) ? /*isinst with value type is only supported in some contexts*/: null);
AudioClip val2 = (AudioClip)((fieldCached2 != null) ? /*isinst with value type is only supported in some contexts*/: null);
if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null)
{
val.PlayOneShot(val2);
}
if (headshot && (Object)(object)Crosshair.Instance != (Object)null && (Object)(object)Crosshair.Instance.headshotHitClip != (Object)null && (Object)(object)val != (Object)null)
{
val.PlayOneShot(Crosshair.Instance.headshotHitClip);
}
}
}
private static FieldInfo GetFieldCached(Dictionary<Type, FieldInfo> cache, Type type, string fieldName)
{
if (cache.TryGetValue(type, out var value))
{
return value;
}
return cache[type] = AccessTools.Field(type, fieldName);
}
}
internal static class HitmarkerWeaponPatchUtils
{
public static void HandleWeaponMarker(Weapon weapon)
{
HitmarkerEvents.PlayWeaponMarker(weapon);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(Weapon), "CmdDamageProp")]
public static class Weapon_BarrelHitmarker
{
private static void Prefix(Weapon __instance, GameObject obj)
{
if (!((Object)(object)__instance == (Object)null) && !((Object)(object)obj == (Object)null) && ((NetworkBehaviour)__instance).IsOwner && BarrelHitmarkerUtils.IsBarrel(obj))
{
HitmarkerManager.PlayBarrel(kill: false);
}
}
}
internal static class BarrelHitmarkerUtils
{
public static bool IsBarrel(GameObject obj)
{
if ((Object)(object)obj == (Object)null)
{
return false;
}
if (HasBarrelName(((Object)obj).name))
{
return true;
}
Transform val = (((Object)(object)obj.transform != (Object)null) ? obj.transform.root : null);
if ((Object)(object)val != (Object)null && HasBarrelName(((Object)val).name))
{
return true;
}
return false;
}
private static bool HasBarrelName(string name)
{
if (string.IsNullOrEmpty(name))
{
return false;
}
return name.IndexOf("barrel", StringComparison.OrdinalIgnoreCase) >= 0;
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(Gun), "GiveDamage", new Type[]
{
typeof(float),
typeof(PlayerHealth),
typeof(string)
})]
public static class Gun_GiveDamage_Hitmarker
{
private static void Prefix(Gun __instance, float damageToGive, PlayerHealth enemyHealth, string name)
{
HitmarkerEvents.PlayWeaponDamage((Weapon)(object)__instance, damageToGive, enemyHealth, name);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(Shotgun), "GiveDamage", new Type[]
{
typeof(float),
typeof(PlayerHealth),
typeof(string)
})]
public static class Shotgun_GiveDamage_Hitmarker
{
private static void Prefix(Shotgun __instance, float damageToGive, PlayerHealth enemyHealth, string name)
{
HitmarkerEvents.PlayWeaponDamage((Weapon)(object)__instance, damageToGive, enemyHealth, name);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(Minigun), "GiveDamage", new Type[]
{
typeof(float),
typeof(PlayerHealth),
typeof(string)
})]
public static class Minigun_GiveDamage_Hitmarker
{
private static void Prefix(Minigun __instance, float damageToGive, PlayerHealth enemyHealth, string name)
{
HitmarkerEvents.PlayWeaponDamage((Weapon)(object)__instance, damageToGive, enemyHealth, name);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(BeamGun), "GiveDamage", new Type[]
{
typeof(float),
typeof(PlayerHealth),
typeof(string)
})]
public static class BeamGun_GiveDamage_Hitmarker
{
private static void Prefix(BeamGun __instance, float damageToGive, PlayerHealth enemyHealth, string name)
{
HitmarkerEvents.PlayWeaponDamage((Weapon)(object)__instance, damageToGive, enemyHealth, name);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(ChargeGun), "GiveDamage", new Type[]
{
typeof(float),
typeof(PlayerHealth),
typeof(string)
})]
public static class ChargeGun_GiveDamage_Hitmarker
{
private static void Prefix(ChargeGun __instance, float damageToGive, PlayerHealth enemyHealth, string name)
{
HitmarkerEvents.PlayWeaponDamage((Weapon)(object)__instance, damageToGive, enemyHealth, name);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(LargeRaycastGun), "GiveDamage", new Type[]
{
typeof(float),
typeof(PlayerHealth),
typeof(string)
})]
public static class LargeRaycastGun_GiveDamage_Hitmarker
{
private static void Prefix(LargeRaycastGun __instance, float damageToGive, PlayerHealth enemyHealth, string name)
{
HitmarkerEvents.PlayWeaponDamage((Weapon)(object)__instance, damageToGive, enemyHealth, name);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(RepulsiveGun), "GiveDamage", new Type[]
{
typeof(float),
typeof(PlayerHealth),
typeof(string)
})]
public static class RepulsiveGun_GiveDamage_Hitmarker
{
private static void Prefix(RepulsiveGun __instance, float damageToGive, PlayerHealth enemyHealth, string name)
{
HitmarkerEvents.PlayWeaponDamage((Weapon)(object)__instance, damageToGive, enemyHealth, name);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(MeleeWeapon), "GiveDamage", new Type[]
{
typeof(float),
typeof(PlayerHealth),
typeof(string)
})]
public static class MeleeWeapon_GiveDamage_Hitmarker
{
private static void Prefix(MeleeWeapon __instance, float damageToGive, PlayerHealth enemyHealth, string name)
{
HitmarkerEvents.PlayWeaponDamage((Weapon)(object)__instance, damageToGive, enemyHealth, name);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(Gun), "KillServer", new Type[] { typeof(PlayerHealth) })]
public static class Gun_KillServer_Hitmarker
{
private static void Prefix(Gun __instance, PlayerHealth enemyHealth)
{
HitmarkerEvents.PlayWeaponKill((Weapon)(object)__instance, enemyHealth);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(Shotgun), "KillServer", new Type[] { typeof(PlayerHealth) })]
public static class Shotgun_KillServer_Hitmarker
{
private static void Prefix(Shotgun __instance, PlayerHealth enemyHealth)
{
HitmarkerEvents.PlayWeaponKill((Weapon)(object)__instance, enemyHealth);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(Minigun), "KillServer", new Type[] { typeof(PlayerHealth) })]
public static class Minigun_KillServer_Hitmarker
{
private static void Prefix(Minigun __instance, PlayerHealth enemyHealth)
{
HitmarkerEvents.PlayWeaponKill((Weapon)(object)__instance, enemyHealth);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(BeamGun), "KillServer", new Type[] { typeof(PlayerHealth) })]
public static class BeamGun_KillServer_Hitmarker
{
private static void Prefix(BeamGun __instance, PlayerHealth enemyHealth)
{
HitmarkerEvents.PlayWeaponKill((Weapon)(object)__instance, enemyHealth);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(ChargeGun), "KillServer", new Type[] { typeof(PlayerHealth) })]
public static class ChargeGun_KillServer_Hitmarker
{
private static void Prefix(ChargeGun __instance, PlayerHealth enemyHealth)
{
HitmarkerEvents.PlayWeaponKill((Weapon)(object)__instance, enemyHealth);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(LargeRaycastGun), "KillServer", new Type[] { typeof(PlayerHealth) })]
public static class LargeRaycastGun_KillServer_Hitmarker
{
private static void Prefix(LargeRaycastGun __instance, PlayerHealth enemyHealth)
{
HitmarkerEvents.PlayWeaponKill((Weapon)(object)__instance, enemyHealth);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(RepulsiveGun), "KillServer", new Type[] { typeof(PlayerHealth) })]
public static class RepulsiveGun_KillServer_Hitmarker
{
private static void Prefix(RepulsiveGun __instance, PlayerHealth enemyHealth)
{
HitmarkerEvents.PlayWeaponKill((Weapon)(object)__instance, enemyHealth);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(MeleeWeapon), "KillServer", new Type[] { typeof(PlayerHealth) })]
public static class MeleeWeapon_KillServer_Hitmarker
{
private static void Prefix(MeleeWeapon __instance, PlayerHealth enemyHealth)
{
HitmarkerEvents.PlayWeaponKill((Weapon)(object)__instance, enemyHealth);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(Taser), "TaserEnemy", new Type[] { typeof(PlayerHealth) })]
public static class Taser_TaserEnemy_Hitmarker
{
private static void Prefix(Taser __instance, PlayerHealth enemyHealth)
{
HitmarkerEvents.PlayWeaponContact((Weapon)(object)__instance, enemyHealth);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(RepulsiveGun), "BumpPlayerServer", new Type[]
{
typeof(Vector3),
typeof(float),
typeof(PlayerHealth)
})]
public static class RepulsiveGun_BumpPlayerServer_Hitmarker
{
private static void Prefix(RepulsiveGun __instance, PlayerHealth ph)
{
HitmarkerEvents.PlayWeaponContact((Weapon)(object)__instance, ph);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(PlayerHealth), "RemoveHealth", new Type[] { typeof(float) })]
public static class PlayerHealth_RemoveHealth_Hitmarker
{
private static void Prefix(PlayerHealth __instance, ref float __state)
{
__state = (((Object)(object)__instance != (Object)null) ? __instance.sync___get_value_health() : 0f);
}
private static void Postfix(PlayerHealth __instance, float damage, float __state)
{
HitmarkerEvents.PlayRemoveHealthFallback(__instance, __state, damage);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(PhysicsProp), "OnInteract", new Type[] { typeof(Transform) })]
public static class PhysicsProp_OnInteract_Hitmarker
{
private static void Prefix(PhysicsProp __instance, Transform player)
{
PhysicsPropHitmarkerTracker.Mark(__instance, player);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(PhysicsProp), "OnControllerColliderHit", new Type[] { typeof(ControllerColliderHit) })]
public static class PhysicsProp_OnControllerColliderHit_Hitmarker
{
public struct HitState
{
public PlayerHealth target;
public float beforeHealth;
public float damage;
}
private static readonly FieldInfo damageField = AccessTools.Field(typeof(PhysicsProp), "damage");
private static void Prefix(PhysicsProp __instance, ControllerColliderHit collision, ref HitState __state)
{
__state = default(HitState);
if (HitmarkerEvents.ShouldWatchPhysicsProp(__instance) && collision != null && !((Object)(object)collision.transform == (Object)null))
{
PlayerHealth componentInParent = ((Component)collision.transform).GetComponentInParent<PlayerHealth>();
if (!((Object)(object)componentInParent == (Object)null) && !((NetworkBehaviour)componentInParent).IsOwner)
{
__state.target = componentInParent;
__state.beforeHealth = componentInParent.sync___get_value_health();
__state.damage = GetDamage(__instance);
}
}
}
private static void Postfix(HitState __state)
{
PlayerHealth target = __state.target;
if (!((Object)(object)target == (Object)null) && !(__state.beforeHealth <= 0f))
{
float num = target.sync___get_value_health();
if (!(num >= __state.beforeHealth))
{
bool kill = target.sync___get_value_isKilled() || num <= 0f || __state.beforeHealth - __state.damage <= 0f;
HitmarkerEvents.PlayPhysicsPropHit(target, kill);
}
}
}
private static float GetDamage(PhysicsProp prop)
{
if ((Object)(object)prop == (Object)null || damageField == null)
{
return 0f;
}
object value = damageField.GetValue(prop);
return (value is float) ? ((float)value) : 0f;
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(PredictedProjectile), "HitMarker")]
public static class PredictedProjectile_HitMarker
{
private static bool Prefix(PredictedProjectile __instance, bool head)
{
return HitmarkerPatchUtils.Handle(__instance, head);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(ProximityMine), "HitMarker")]
public static class ProximityMine_HitMarker
{
private static bool Prefix(ProximityMine __instance, bool head)
{
return HitmarkerPatchUtils.Handle(__instance, head);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(ShrapnelBallistic), "HitMarker")]
public static class ShrapnelBallistic_HitMarker
{
private static bool Prefix(ShrapnelBallistic __instance, bool head)
{
return HitmarkerPatchUtils.Handle(__instance, head);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(Gun), "ShootServer", new Type[]
{
typeof(float),
typeof(Vector3),
typeof(Vector3)
})]
public static class Gun_ShootServer
{
private static void Postfix(Gun __instance)
{
HitmarkerWeaponPatchUtils.HandleWeaponMarker((Weapon)(object)__instance);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(BeamGun), "ShootServer", new Type[]
{
typeof(float),
typeof(Vector3),
typeof(Vector3)
})]
public static class BeamGun_ShootServer
{
private static void Postfix(BeamGun __instance)
{
HitmarkerWeaponPatchUtils.HandleWeaponMarker((Weapon)(object)__instance);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(ChargeGun), "ShootServer", new Type[]
{
typeof(float),
typeof(Vector3),
typeof(Vector3)
})]
public static class ChargeGun_ShootServer
{
private static void Postfix(ChargeGun __instance)
{
HitmarkerWeaponPatchUtils.HandleWeaponMarker((Weapon)(object)__instance);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(Shotgun), "ShootServer", new Type[]
{
typeof(float),
typeof(Vector3),
typeof(Vector3)
})]
public static class Shotgun_ShootServer
{
private static void Postfix(Shotgun __instance)
{
HitmarkerWeaponPatchUtils.HandleWeaponMarker((Weapon)(object)__instance);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(Minigun), "ShootServer", new Type[]
{
typeof(float),
typeof(Vector3),
typeof(Vector3)
})]
public static class Minigun_ShootServer
{
private static void Postfix(Minigun __instance)
{
HitmarkerWeaponPatchUtils.HandleWeaponMarker((Weapon)(object)__instance);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(LargeRaycastGun), "ShootServer", new Type[]
{
typeof(float),
typeof(Vector3),
typeof(Vector3),
typeof(PlayerHealth)
})]
public static class LargeRaycastGun_ShootServer
{
private static void Postfix(LargeRaycastGun __instance)
{
HitmarkerWeaponPatchUtils.HandleWeaponMarker((Weapon)(object)__instance);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(LargeRaycastGun), "ShootServerBox", new Type[]
{
typeof(float),
typeof(Vector3),
typeof(Vector3),
typeof(PlayerHealth)
})]
public static class LargeRaycastGun_ShootServerBox
{
private static void Postfix(LargeRaycastGun __instance)
{
HitmarkerWeaponPatchUtils.HandleWeaponMarker((Weapon)(object)__instance);
}
}
[HitmarkersPatch]
[HarmonyPatch(typeof(MeleeWeapon), "HitServer", new Type[]
{
typeof(PlayerHealth),
typeof(Vector3),
typeof(Vector3),
typeof(string)
})]
public static class MeleeWeapon_HitServer
{
private static void Postfix(MeleeWeapon __instance)
{
HitmarkerWeaponPatchUtils.HandleWeaponMarker((Weapon)(object)__instance);
}
}
[BepInPlugin("com.glizzmn.hitmarkers", "PM Hitmarkers", "1.0.0")]
public sealed class HitmarkersPlugin : BaseUnityPlugin
{
private Harmony harmony;
private void Awake()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
HitmarkerConfig.Bind(((BaseUnityPlugin)this).Config);
harmony = new Harmony("com.glizzmn.hitmarkers");
PatchHitmarkers();
}
private void PatchHitmarkers()
{
Assembly assembly = typeof(HitmarkersPlugin).Assembly;
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
if (Attribute.IsDefined(type, typeof(HitmarkersPatchAttribute), inherit: false))
{
harmony.CreateClassProcessor(type).Patch();
}
}
}
}
public enum HitmarkerShape
{
Cross,
Plus
}
public static class HitmarkerConfig
{
public static ConfigEntry<bool> EnableCustomHitmarkers;
public static ConfigEntry<bool> HideVanillaHitmarkers;
public static ConfigEntry<HitmarkerShape> Shape;
public static ConfigEntry<int> Length;
public static ConfigEntry<int> Thickness;
public static ConfigEntry<int> Gap;
public static ConfigEntry<bool> EnableOutline;
public static ConfigEntry<int> OutlineThickness;
public static ConfigEntry<bool> EnableBarrelHitmarker;
public static ConfigEntry<Color> Color;
public static ConfigEntry<Color> HeadshotColor;
public static ConfigEntry<Color> OutlineColor;
public static ConfigEntry<Color> HeadshotOutlineColor;
public static ConfigEntry<Color> KillColor;
public static ConfigEntry<Color> KillOutlineColor;
public static ConfigEntry<Color> BarrelColor;
public static ConfigEntry<Color> BarrelOutlineColor;
public const int LengthMin = 4;
public const int LengthMax = 40;
public const int ThicknessMin = 2;
public const int ThicknessMax = 12;
public const int GapMin = 0;
public const int GapMax = 20;
public const int OutlineThicknessMin = 0;
public const int OutlineThicknessMax = 6;
public static void Bind(ConfigFile config)
{
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: 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)
EnableCustomHitmarkers = config.Bind<bool>("General", "EnableCustomHitmarkers", true, "Enable custom hitmarkers.");
HideVanillaHitmarkers = config.Bind<bool>("General", "HideVanillaHitmarkers", true, "Hide the game's default hitmarkers when custom hitmarkers are enabled.");
Shape = config.Bind<HitmarkerShape>("Style", "Shape", HitmarkerShape.Cross, "Hitmarker shape.");
Length = config.Bind<int>("Style", "Length", 16, "Line length (even numbers only).");
Thickness = config.Bind<int>("Style", "Thickness", 4, "Line thickness (even numbers only).");
Gap = config.Bind<int>("Style", "Gap", 4, "Distance from center (even numbers only).");
EnableOutline = config.Bind<bool>("Style", "EnableOutline", true, "Enable outline behind the hitmarker.");
OutlineThickness = config.Bind<int>("Style", "OutlineThickness", 2, "Outline thickness (even numbers only).");
EnableBarrelHitmarker = config.Bind<bool>("Style", "EnableBarrelHitmarker", true, "Enable barrel and physics prop hitmarkers.");
Color = config.Bind<Color>("Colors", "Color", new Color(1f, 1f, 1f, 1f), "Hitmarker color.");
HeadshotColor = config.Bind<Color>("Colors", "HeadshotColor", new Color(1f, 0.25f, 0.25f, 1f), "Headshot hitmarker color.");
OutlineColor = config.Bind<Color>("Colors", "OutlineColor", new Color(0f, 0f, 0f, 0.9f), "Outline color.");
HeadshotOutlineColor = config.Bind<Color>("Colors", "HeadshotOutlineColor", new Color(0.1f, 0f, 0f, 0.9f), "Headshot outline color.");
KillColor = config.Bind<Color>("Colors", "KillColor", new Color(0.2f, 1f, 0.2f, 1f), "Kill hitmarker color.");
KillOutlineColor = config.Bind<Color>("Colors", "KillOutlineColor", new Color(0f, 0.2f, 0f, 0.9f), "Kill hitmarker outline color.");
BarrelColor = config.Bind<Color>("Colors", "BarrelColor", new Color(0.75f, 0.78f, 0.82f, 1f), "Physics prop/barrel hitmarker color.");
BarrelOutlineColor = config.Bind<Color>("Colors", "BarrelOutlineColor", new Color(0.05f, 0.06f, 0.07f, 0.95f), "Physics prop/barrel hitmarker outline color.");
HookEven(Length, 4, 40);
HookEven(Thickness, 2, 12);
HookEven(Gap, 0, 20);
HookEven(OutlineThickness, 0, 6);
}
private static void HookEven(ConfigEntry<int> entry, int min, int max)
{
entry.SettingChanged += delegate
{
EnforceEven(entry, min, max);
};
EnforceEven(entry, min, max);
}
private static void EnforceEven(ConfigEntry<int> entry, int min, int max)
{
int num = Mathf.Clamp(entry.Value, min, max);
if ((num & 1) != 0)
{
num = ((num == max) ? (num - 1) : (num + 1));
}
if (num != entry.Value)
{
entry.Value = num;
}
}
public static int GetLength()
{
return ClampEven(Length.Value, 4, 40);
}
public static int GetThickness()
{
return ClampEven(Thickness.Value, 2, 12);
}
public static int GetGap()
{
return ClampEven(Gap.Value, 0, 20);
}
public static int GetOutlineThickness()
{
return ClampEven(OutlineThickness.Value, 0, 6);
}
private static int ClampEven(int value, int min, int max)
{
value = Mathf.Clamp(value, min, max);
if ((value & 1) != 0)
{
value = ((value == max) ? (value - 1) : (value + 1));
}
return value;
}
}
[HarmonyPatch(typeof(Weapon))]
public static class Tromblonj
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void SetTromb(Weapon __instance)
{
if (__instance.behaviour.weaponName == "tromblonj")
{
__instance.requireBothHands = true;
}
}
}
[HarmonyPatch(typeof(Weapon))]
public static class Webley
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void SetWebley(Weapon __instance)
{
if (__instance.behaviour.weaponName == "Webley")
{
__instance.damage = 2f;
__instance.headMultiplier = 2f;
__instance.requireBothHands = false;
}
}
}
[HarmonyPatch(typeof(ShatterableGlass))]
public static class Glass
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void PatchGlass(ShatterableGlass __instance)
{
__instance.Force = 1000f;
}
}
namespace StraftatMods;
[HarmonyPatch(typeof(FirstPersonController))]
public static class FirstPersonController_AdsSprint_Patch
{
private static readonly FieldInfo F_move = AccessTools.Field(typeof(FirstPersonController), "move");
private static readonly FieldInfo F_isLeaning = AccessTools.Field(typeof(FirstPersonController), "isLeaning");
private static readonly FieldInfo F_isCrouching = AccessTools.Field(typeof(FirstPersonController), "isCrouching");
private static readonly FieldInfo F_funcSprint = AccessTools.Field(typeof(FirstPersonController), "funcSprint");
private static readonly FieldInfo F_isSprinting = AccessTools.Field(typeof(FirstPersonController), "isSprinting");
private static readonly FieldInfo F_isSlideSprinting = AccessTools.Field(typeof(FirstPersonController), "isSlideSprinting");
private static readonly FieldInfo F_isAiming = AccessTools.Field(typeof(FirstPersonController), "isAiming");
[HarmonyPostfix]
[HarmonyPatch("Update")]
private static void Post_Update(FirstPersonController __instance)
{
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
try
{
if (__instance.sync___get_value_canMove() && F_isAiming != null && (bool)F_isAiming.GetValue(__instance))
{
bool flag = F_isLeaning != null && (bool)F_isLeaning.GetValue(__instance);
bool flag2 = F_isCrouching != null && (bool)F_isCrouching.GetValue(__instance);
bool flag3 = F_funcSprint != null && (bool)F_funcSprint.GetValue(__instance);
object? obj = F_move?.GetValue(__instance);
InputAction val = (InputAction)((obj is InputAction) ? obj : null);
bool flag4 = val != null && val.ReadValue<Vector2>() != Vector2.zero;
bool flag5 = !flag && flag4 && !flag2 && flag3;
bool flag6 = !flag && flag4 && flag3;
F_isSprinting?.SetValue(__instance, flag5);
F_isSlideSprinting?.SetValue(__instance, flag6);
}
}
catch (Exception arg)
{
Debug.LogError((object)$"ADS Sprint Fix: {arg}");
}
}
}
[HarmonyPatch(typeof(PlayerHealth), "Awake___UserLogic")]
public static class PlayerHealthPatch
{
[HarmonyPostfix]
public static void Awake(PlayerHealth __instance)
{
__instance.health = 8f;
}
}
[HarmonyPatch(typeof(PlayerPickup), "Update")]
public static class PlayerPickupPatch
{
[HarmonyPostfix]
public static void Awake(PlayerPickup __instance)
{
FirstPersonController value = Traverse.Create((object)__instance).Field("playerController").GetValue<FirstPersonController>();
value.maxWallJumps = 2;
}
}
[BepInPlugin("com.glizzmn.promod", "ProMod", "1.0.0")]
public sealed class PluginMain : BaseUnityPlugin
{
private const int LocalVersion = 3;
private const string VersionApiUrl = "https://api.github.com/repos/GlizzmnDEV/RotateEnvironment/contents/version.md?ref=main";
private Harmony harmony;
private void Awake()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"ProMod loaded.");
harmony = new Harmony("com.glizzmn.promod");
PatchAllProMod();
}
private void OnGUI()
{
ProModBanner.OnGUI();
}
private void PatchAllProMod()
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
Type[] types = executingAssembly.GetTypes();
foreach (Type type in types)
{
if (Attribute.IsDefined(type, typeof(HarmonyPatch), inherit: false) && !Attribute.IsDefined(type, typeof(DamageNumbersPatchAttribute), inherit: false) && !Attribute.IsDefined(type, typeof(HitmarkersPatchAttribute), inherit: false) && !Attribute.IsDefined(type, typeof(HitSoundsPatchAttribute), inherit: false))
{
harmony.CreateClassProcessor(type).Patch();
}
}
}
}
public static class ProModBanner
{
public static void OnGUI()
{
}
}
public static class ProModStartScreen
{
private const string TitleText = "ProMod";
private const string SubText = "by Glizzmn";
private static readonly Regex VersionRegex = new Regex("(?i)\\b(version|v)\\s*\\d", RegexOptions.Compiled);
public static void Apply(MenuController controller)
{
if ((Object)(object)controller == (Object)null || (Object)(object)controller.startMenu == (Object)null)
{
return;
}
TextMeshProUGUI[] componentsInChildren = controller.startMenu.GetComponentsInChildren<TextMeshProUGUI>(true);
if (componentsInChildren == null || componentsInChildren.Length == 0)
{
return;
}
TextMeshProUGUI val = null;
float num = -1f;
foreach (TextMeshProUGUI val2 in componentsInChildren)
{
if (!((Object)(object)val2 == (Object)null))
{
if (!string.IsNullOrWhiteSpace(((TMP_Text)val2).text) && ((TMP_Text)val2).fontSize > num)
{
num = ((TMP_Text)val2).fontSize;
val = val2;
}
if (!string.IsNullOrEmpty(((TMP_Text)val2).text) && VersionRegex.IsMatch(((TMP_Text)val2).text))
{
((Component)val2).gameObject.SetActive(false);
}
}
}
if (!((Object)(object)val == (Object)null))
{
((TMP_Text)val).text = "ProMod\n<size=30%>by Glizzmn</size>";
((TMP_Text)val).alignment = (TextAlignmentOptions)514;
}
}
}
[HarmonyPatch(typeof(MenuController), "Start")]
public static class ProMod_MenuController_Start
{
private static void Postfix(MenuController __instance)
{
ProModStartScreen.Apply(__instance);
}
}
[HarmonyPatch(typeof(MenuController), "OpenStartMenu")]
public static class ProMod_MenuController_OpenStartMenu
{
private static void Postfix(MenuController __instance)
{
ProModStartScreen.Apply(__instance);
}
}
[HarmonyPatch(typeof(PauseManager), "ShowInfoPopup")]
public static class ProMod_HideNonVanillaPopup
{
private static bool Prefix(string text)
{
if (string.IsNullOrEmpty(text))
{
return true;
}
return !text.StartsWith("Non-vanilla friendly mods detected");
}
}
[HarmonyPatch(typeof(FirstPersonController), "Awake___UserLogic")]
public static class WallJump
{
[HarmonyPostfix]
public static void Awake(FirstPersonController __instance)
{
__instance.maxWallJumps = 2;
}
}
[HarmonyPatch(typeof(Weapon), "Awake___UserLogic")]
public static class WeaponNoSpreadPatch
{
[HarmonyPostfix]
public static void Awake(Weapon __instance)
{
__instance.minSpread = 0f;
__instance.maxSpread = 0f;
__instance.notAimingAccuracy = 0f;
}
}