using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using FishNet.Connection;
using FishNet.Managing;
using FishNet.Object;
using HarmonyLib;
using HitMarker.Console.Commands.Give;
using HitMarker.Core;
using HitMarker.MarkerHit;
using HitMarker.Patches;
using HitMarker.Utils;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HitMarker")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HitMarker")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6bcdf685-bc02-46e9-b62f-e25f0e027d3b")]
[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")]
public class TorchHandler : BasePatchHandler
{
public override string[] ValidTags => new string[6] { "Player", "PlayerNpc", "hitable", "wormhole", "brazier", "tutbrazier" };
public override string PatchName => "Torch";
public override bool MoreCheckHit(GameObject target)
{
if ((Object)(object)target != (Object)null)
{
return ((Object)target).name.Contains("duende");
}
return false;
}
public override bool ProcessHit(GameObject target, GameObject owner)
{
return base.ProcessHit(target, owner);
}
}
namespace HitMarker
{
[BepInPlugin("HitMarker.Mod", "HitMarker", "0.1.4")]
[BepInProcess("MageArena")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Mod : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <InitializeHitmarkerCoroutine>d__15 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Texture2D texture;
public Mod <>4__this;
private float <timeout>5__2;
private float <elapsed>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <InitializeHitmarkerCoroutine>d__15(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
Mod mod = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
if ((Object)(object)texture == (Object)null || (Object)(object)mod._hitMarkerManager == (Object)null)
{
LoggerUtils.LogError("Mod", "Cannot initialize hitmarker: invalid parameters");
return false;
}
LoggerUtils.LogDebug("Mod", "Starting hitmarker initialization...");
<timeout>5__2 = 10f;
<elapsed>5__3 = 0f;
break;
case 1:
<>1__state = -1;
break;
}
if (!mod._hitMarkerManager.IsInitialized && <elapsed>5__3 < <timeout>5__2)
{
<elapsed>5__3 += Time.deltaTime;
<>2__current = null;
<>1__state = 1;
return true;
}
if (mod._hitMarkerManager.IsInitialized)
{
LoggerUtils.LogInfo("Mod", "Hitmarker system ready");
}
else
{
LoggerUtils.LogError("Mod", "Hitmarker initialization timeout");
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <TestHitMarker>d__10 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Mod <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <TestHitMarker>d__10(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Expected O, but got Unknown
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Expected O, but got Unknown
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Expected O, but got Unknown
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Expected O, but got Unknown
//IL_0303: Unknown result type (might be due to invalid IL or missing references)
//IL_030d: Expected O, but got Unknown
//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
//IL_03ac: Expected O, but got Unknown
//IL_0441: Unknown result type (might be due to invalid IL or missing references)
//IL_044b: Expected O, but got Unknown
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Expected O, but got Unknown
int num = <>1__state;
Mod mod = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
if (!mod.testHitmarker)
{
mod.testHitmarker = true;
LoggerUtils.LogDebug("Mod", "Test Hitmarker 1");
Instance.ShowHitmarkerInstance();
Instance.ShowHitmarkerInstance("Spike", HitMarkerType.Secondary);
<>2__current = (object)new WaitForSeconds(10f);
<>1__state = 1;
return true;
}
goto IL_043b;
case 1:
<>1__state = -1;
LoggerUtils.LogDebug("Mod", "Test Hitmarker 2");
Instance.ShowHitmarkerInstance();
Instance.ShowHitmarkerInstance("Spike", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike1", HitMarkerType.Secondary);
<>2__current = (object)new WaitForSeconds(10f);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
LoggerUtils.LogDebug("Mod", "Test Hitmarker 3");
Instance.ShowHitmarkerInstance();
Instance.ShowHitmarkerInstance("Spike", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike1", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike2", HitMarkerType.Secondary);
<>2__current = (object)new WaitForSeconds(10f);
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
LoggerUtils.LogDebug("Mod", "Test Hitmarker 4");
Instance.ShowHitmarkerInstance();
Instance.ShowHitmarkerInstance("Spike", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike1", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike2", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike3", HitMarkerType.Secondary);
<>2__current = (object)new WaitForSeconds(10f);
<>1__state = 4;
return true;
case 4:
<>1__state = -1;
LoggerUtils.LogDebug("Mod", "Test Hitmarker 5");
Instance.ShowHitmarkerInstance();
Instance.ShowHitmarkerInstance("Spike", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike1", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike2", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike3", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike4", HitMarkerType.Secondary);
<>2__current = (object)new WaitForSeconds(10f);
<>1__state = 5;
return true;
case 5:
<>1__state = -1;
LoggerUtils.LogDebug("Mod", "Test Hitmarker 6");
Instance.ShowHitmarkerInstance();
Instance.ShowHitmarkerInstance("Spike", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike1", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike2", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike3", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike4", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike5", HitMarkerType.Secondary);
<>2__current = (object)new WaitForSeconds(10f);
<>1__state = 6;
return true;
case 6:
<>1__state = -1;
LoggerUtils.LogDebug("Mod", "Test Hitmarker 5 after mezzo secondo");
Instance.ShowHitmarkerInstance();
Instance.ShowHitmarkerInstance("Spike", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike1", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike2", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike3", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike4", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike5", HitMarkerType.Secondary);
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 7;
return true;
case 7:
<>1__state = -1;
LoggerUtils.LogDebug("Mod", "Test Hitmarker 6 after mezzo secondo");
Instance.ShowHitmarkerInstance();
Instance.ShowHitmarkerInstance("Spike", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike1", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike2", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike3", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike4", HitMarkerType.Secondary);
Instance.ShowHitmarkerInstance("Spike5", HitMarkerType.Secondary);
goto IL_043b;
case 8:
{
<>1__state = -1;
return false;
}
IL_043b:
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 8;
return true;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private HitMarkerManager _hitMarkerManager;
public static string modsync = "client";
private bool testHitmarker;
public static Mod Instance { get; private set; }
public HitMarkerManager HitMarkerManager => _hitMarkerManager;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
Initialize();
}
else
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
[IteratorStateMachine(typeof(<TestHitMarker>d__10))]
public IEnumerator TestHitMarker()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <TestHitMarker>d__10(0)
{
<>4__this = this
};
}
private void Initialize()
{
LoggerUtils.MinLogLevel = LogLevel.Info;
LoggerUtils.Initialize(((BaseUnityPlugin)this).Logger);
LoggerUtils.LogInfo("Mod", "HITMARKER MOD STARTUP - Version: 0.1.4");
try
{
InitializeCore();
ApplyHarmonyPatches();
LoggerUtils.LogInfo("Mod", "Initialization completed successfully");
}
catch (Exception ex)
{
LoggerUtils.LogCriticalError("Mod", "Failed to initialize mod", ex);
}
}
private void InitializeCore()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
LoggerUtils.LogDebug("Mod", "Initializing core components...");
GameObject val = new GameObject("HitMarkerManager");
Object.DontDestroyOnLoad((Object)(object)val);
_hitMarkerManager = val.AddComponent<HitMarkerManager>();
_hitMarkerManager.Initialize();
LoggerUtils.LogDebug("Mod", "Core components initialized");
}
private void ApplyHarmonyPatches()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
LoggerUtils.LogDebug("Mod", "Applying Harmony patches...");
try
{
new Harmony("HitMarker.Mod").PatchAll();
LoggerUtils.LogDebug("Mod", "Harmony patches applied successfully");
}
catch (Exception ex)
{
LoggerUtils.LogCriticalError("Mod", "Failed to apply Harmony patches", ex);
}
}
public void ShowHitmarkerInstance(string weaponName = "default", HitMarkerType type = HitMarkerType.Primary)
{
if ((Object)(object)_hitMarkerManager == (Object)null || !_hitMarkerManager.IsInitialized)
{
LoggerUtils.LogDebug("Mod", "Hitmarker not ready");
return;
}
try
{
_hitMarkerManager.ShowHitmarker(weaponName, type);
}
catch (Exception ex)
{
LoggerUtils.LogError("Mod", "Failed to show hitmarker: " + ex.Message);
}
}
[IteratorStateMachine(typeof(<InitializeHitmarkerCoroutine>d__15))]
public IEnumerator InitializeHitmarkerCoroutine(Texture2D texture)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <InitializeHitmarkerCoroutine>d__15(0)
{
<>4__this = this,
texture = texture
};
}
private void OnDestroy()
{
LoggerUtils.LogInfo("Mod", "Mod shutting down");
}
}
}
namespace HitMarker.Utils
{
public static class ColliderUtils
{
public static string GetTargetInfo(GameObject target)
{
if ((Object)(object)target == (Object)null)
{
return "Target is null";
}
return $"Name: {((Object)target).name}, Tag: {target.tag}, Layer: {target.layer}";
}
}
public enum LogLevel
{
Debug,
Info,
Warning,
Error
}
public static class LoggerUtils
{
private static ManualLogSource _logger;
public static LogLevel MinLogLevel { get; set; }
public static void Initialize(ManualLogSource logger)
{
_logger = logger;
ManualLogSource logger2 = _logger;
if (logger2 != null)
{
logger2.LogInfo((object)string.Format("{0} Logger initialized - Level: {1}", "[HITMARKER]", MinLogLevel));
}
}
private static bool ShouldLog(LogLevel level)
{
return level >= MinLogLevel;
}
public static void LogInfo(string context, string message)
{
if (ShouldLog(LogLevel.Info))
{
ManualLogSource logger = _logger;
if (logger != null)
{
logger.LogInfo((object)("[HITMARKER] [" + context + "] " + message));
}
}
}
public static void LogWarning(string context, string message)
{
if (ShouldLog(LogLevel.Warning))
{
ManualLogSource logger = _logger;
if (logger != null)
{
logger.LogWarning((object)("[HITMARKER] [" + context + "] " + message));
}
}
}
public static void LogError(string context, string message)
{
if (ShouldLog(LogLevel.Error))
{
ManualLogSource logger = _logger;
if (logger != null)
{
logger.LogError((object)("[HITMARKER] [" + context + "] " + message));
}
}
}
public static void LogDebug(string context, string message)
{
if (ShouldLog(LogLevel.Debug))
{
ManualLogSource logger = _logger;
if (logger != null)
{
logger.LogInfo((object)("[HITMARKER] [DEBUG] [" + context + "] " + message));
}
}
}
public static void LogPatch(string patchName, string message)
{
if (ShouldLog(LogLevel.Debug))
{
ManualLogSource logger = _logger;
if (logger != null)
{
logger.LogInfo((object)("[HITMARKER] [PATCH] [" + patchName + "] " + message));
}
}
}
public static void LogHitmarker(string message)
{
if (ShouldLog(LogLevel.Debug))
{
ManualLogSource logger = _logger;
if (logger != null)
{
logger.LogInfo((object)("[HITMARKER] [HITMARKER] " + message));
}
}
}
public static void LogResource(string message)
{
if (ShouldLog(LogLevel.Debug))
{
ManualLogSource logger = _logger;
if (logger != null)
{
logger.LogInfo((object)("[HITMARKER] [RESOURCE] " + message));
}
}
}
public static void LogHitDetection(string detectorName, string targetInfo, bool hitSuccessful)
{
if (ShouldLog(LogLevel.Debug))
{
string text = (hitSuccessful ? "HIT" : "MISS");
LogPatch(detectorName, text + " - " + targetInfo);
}
}
public static void LogCriticalError(string context, string message, Exception ex = null)
{
string text = ((ex != null) ? (message + " - Exception: " + ex.Message) : message);
ManualLogSource logger = _logger;
if (logger != null)
{
logger.LogError((object)("[HITMARKER] [CRITICAL] [" + context + "] " + text));
}
}
}
public static class NetworkUtils
{
public static bool IsLocalPlayerOwner(GameObject gameObject)
{
if ((Object)(object)gameObject == (Object)null)
{
LoggerUtils.LogDebug("NetworkUtils", "GameObject is null in ownership check");
return false;
}
NetworkObject component = gameObject.GetComponent<NetworkObject>();
if ((Object)(object)component != (Object)null)
{
return component.IsOwner;
}
return false;
}
public static NetworkObject GetNetworkObject(GameObject gameObject)
{
if (gameObject == null)
{
return null;
}
return gameObject.GetComponent<NetworkObject>();
}
public static bool IsValidLocalOwner(NetworkObject networkObject)
{
if ((Object)(object)networkObject != (Object)null)
{
return networkObject.IsOwner;
}
return false;
}
}
}
namespace HitMarker.Patches
{
public abstract class BasePatchHandler
{
public abstract string[] ValidTags { get; }
public abstract string PatchName { get; }
public virtual bool IsLocalPlayerOwner(GameObject owner)
{
bool num = NetworkUtils.IsLocalPlayerOwner(owner);
if (!num)
{
LoggerUtils.LogDebug(PatchName, "Not owned by local player, skipping");
}
return num;
}
public virtual bool IsValidHit(GameObject target)
{
if ((Object)(object)target == (Object)null)
{
return false;
}
bool num = ValidTags.Contains(target.tag);
bool flag = MoreCheckHit(target);
return num || flag;
}
public virtual bool ProcessHit(GameObject target, GameObject owner)
{
if (IsValidHit(target))
{
OnValidHit(target);
return true;
}
OnInvalidHit(target);
return false;
}
public abstract bool MoreCheckHit(GameObject target);
public void LogPatch(string message)
{
LoggerUtils.LogPatch(PatchName, message);
}
public void LogError(string message)
{
LoggerUtils.LogError(PatchName, message);
}
public void LogDebug(string message)
{
LoggerUtils.LogDebug(PatchName, message);
}
public virtual void OnValidHit(GameObject target)
{
try
{
Mod.Instance?.ShowHitmarkerInstance();
LoggerUtils.LogHitDetection(PatchName, ColliderUtils.GetTargetInfo(target), hitSuccessful: true);
}
catch (Exception ex)
{
LoggerUtils.LogError(PatchName, "Failed to show hitmarker: " + ex.Message);
}
}
public virtual void OnInvalidHit(GameObject target)
{
LoggerUtils.LogHitDetection(PatchName, ColliderUtils.GetTargetInfo(target), hitSuccessful: false);
}
}
}
namespace HitMarker.Patches.WeaponPatches
{
public class ExcaliburSwordHandler : BasePatchHandler
{
public override string[] ValidTags => new string[3] { "Player", "PlayerNpc", "hitable" };
public override string PatchName => "ExcaliburSword";
public override bool MoreCheckHit(GameObject target)
{
return false;
}
public override bool ProcessHit(GameObject target, GameObject owner)
{
return base.ProcessHit(target, owner);
}
}
public class FrogBladeHandler : BasePatchHandler
{
public override string[] ValidTags => new string[3] { "Player", "PlayerNpc", "hitable" };
public override string PatchName => "FrogBlade";
public override bool MoreCheckHit(GameObject target)
{
return false;
}
public override bool ProcessHit(GameObject target, GameObject owner)
{
return base.ProcessHit(target, owner);
}
}
public class FrogSpearHandler : BasePatchHandler
{
public override string[] ValidTags => new string[2] { "Player", "hitable" };
public override string PatchName => "FrogSpear";
public override bool MoreCheckHit(GameObject target)
{
return false;
}
public override bool ProcessHit(GameObject target, GameObject owner)
{
return base.ProcessHit(target, owner);
}
}
public class MushroomSwordHandler : BasePatchHandler
{
public override string[] ValidTags => new string[3] { "Player", "PlayerNpc", "hitable" };
public override string PatchName => "MushroomSword";
public override bool MoreCheckHit(GameObject target)
{
if ((Object)(object)target == (Object)null)
{
return false;
}
if (!((Object)target).name.Contains("duende"))
{
return target.layer == 3;
}
return true;
}
public override bool ProcessHit(GameObject target, GameObject owner)
{
return base.ProcessHit(target, owner);
}
}
public class SwordOwnerTracker : MonoBehaviour
{
public GameObject owner;
public SwordController swordController;
private void OnDestroy()
{
if ((Object)(object)swordController != (Object)null && Swords_Patches.weaponOwners.ContainsKey(swordController))
{
Swords_Patches.weaponOwners.Remove(swordController);
LoggerUtils.LogDebug("SwordOwnerTracker", "Auto-cleaned sword from dictionary on destroy");
}
}
}
[HarmonyPatch]
public static class Swords_Patches
{
public static Dictionary<SwordController, GameObject> weaponOwners = new Dictionary<SwordController, GameObject>();
private static MushroomSwordHandler patchHandlerMushroomSword = new MushroomSwordHandler();
private static FrogBladeHandler patchHandlerFrogBladeHandler = new FrogBladeHandler();
private static ExcaliburSwordHandler patchHandlerExcaliburSword = new ExcaliburSwordHandler();
private static FrogSpearHandler patchHandlerFrogSpearHandler = new FrogSpearHandler();
private static void SetWeaponOwner(SwordController weapon, GameObject player, string weaponType)
{
weaponOwners[weapon] = player;
SwordOwnerTracker swordOwnerTracker = ((Component)weapon).GetComponent<SwordOwnerTracker>();
if ((Object)(object)swordOwnerTracker == (Object)null)
{
swordOwnerTracker = ((Component)weapon).gameObject.AddComponent<SwordOwnerTracker>();
swordOwnerTracker.swordController = weapon;
}
swordOwnerTracker.owner = player;
LoggerUtils.LogDebug("Swords_Patches", "Owner set for " + weaponType + ": " + ((Object)player).name);
}
[HarmonyPatch(typeof(MushroomSword), "Interaction")]
[HarmonyPrefix]
public static void MushroomSword_OnInteraction_Prefix(MushroomSword __instance, GameObject player)
{
SetWeaponOwner((SwordController)(object)__instance, player, "MushroomSword");
}
[HarmonyPatch(typeof(FrogBladeController), "Interaction")]
[HarmonyPrefix]
public static void FrogBladeController_OnInteraction_Prefix(FrogBladeController __instance, GameObject player)
{
SetWeaponOwner((SwordController)(object)__instance, player, "FrogBladeController");
}
[HarmonyPatch(typeof(ExcaliburController), "Interaction")]
[HarmonyPrefix]
public static void ExcaliburSword_OnInteraction_Prefix(ExcaliburController __instance, GameObject player)
{
SetWeaponOwner((SwordController)(object)__instance, player, " ExcaliburSword");
}
[HarmonyPatch(typeof(FrogSpear), "Interaction")]
[HarmonyPrefix]
public static void FrogSpear_OnInteraction_Prefix(FrogSpear __instance, GameObject player)
{
SetWeaponOwner((SwordController)(object)__instance, player, " FrogSpear");
}
[HarmonyPatch(typeof(WeaponHitDetection), "OnTriggerEnter")]
[HarmonyPostfix]
public static void OnTriggerEnter_Postfix(WeaponHitDetection __instance, Collider other)
{
try
{
if (!Input.GetKey((KeyCode)323) || (Object)(object)__instance.swerd == (Object)null)
{
return;
}
if (!weaponOwners.TryGetValue(__instance.swerd, out var value))
{
LoggerUtils.LogDebug("Swords_Patches", "No owner found for weapon");
}
else if (NetworkUtils.IsLocalPlayerOwner(value))
{
if (__instance.swerd is MushroomSword)
{
patchHandlerMushroomSword.ProcessHit(__instance.swerd.HitSubject, null);
}
else if (__instance.swerd is FrogBladeController)
{
patchHandlerFrogBladeHandler.ProcessHit(__instance.swerd.HitSubject, null);
}
else if (__instance.swerd is ExcaliburController)
{
patchHandlerExcaliburSword.ProcessHit(__instance.swerd.HitSubject, null);
}
else if (__instance.swerd is FrogSpear)
{
patchHandlerFrogSpearHandler.ProcessHit(__instance.swerd.HitSubject, null);
}
}
}
catch (Exception ex)
{
LoggerUtils.LogError("Swords_Patches", "Patch error: " + ex.Message);
}
}
}
}
namespace HitMarker.Patches.WeaponPatches.Torch
{
[HarmonyPatch]
public static class Torch_Patches
{
private static TorchHandler patchHandler = new TorchHandler();
[HarmonyPatch(typeof(TorchHitDetection), "OnTriggerEnter")]
[HarmonyPostfix]
public static void OnTriggerEnter_Postfix(TorchHitDetection __instance, Collider other)
{
try
{
if (Input.GetKey((KeyCode)323))
{
patchHandler.ProcessHit(__instance.toerch.HitSubject, null);
}
}
catch (Exception ex)
{
patchHandler.LogError("Patch error: " + ex.Message);
}
}
}
}
namespace HitMarker.Patches.WeaponPatches.Spike
{
public class SpikesCollision : MonoBehaviour
{
public GameObject owner;
private void OnEnable()
{
LoggerUtils.LogDebug("SpikesCollision", "SpikesCollision component enabled.");
}
private void OnDisable()
{
LoggerUtils.LogDebug("SpikesCollision", "SpikesCollision component disabled. Clearing owner reference.");
if ((Object)(object)owner != (Object)null)
{
owner = null;
}
}
private void OnDestroy()
{
LoggerUtils.LogDebug("SpikesCollision", "SpikesCollision component destroyed.");
}
private void OnTriggerEnter(Collider other)
{
LoggerUtils.LogDebug("SpikesCollision", "Trigger detected with " + ((Object)((Component)other).gameObject).name + ".");
if ((Object)(object)owner == (Object)null)
{
LoggerUtils.LogWarning("SpikesCollision", "Owner is null. Cannot process collision.");
return;
}
LoggerUtils.LogDebug("SpikesCollision", "Owner is " + ((Object)owner).name + ".");
if (!((Component)other).gameObject.CompareTag("Player"))
{
LoggerUtils.LogDebug("SpikesCollision", "Collision target is not a player. Skipping.");
return;
}
LoggerUtils.LogDebug("SpikesCollision", "Collision target is player: " + ((Object)((Component)other).gameObject).name + ".");
if (((Object)((Component)other).gameObject).GetInstanceID() == ((Object)owner).GetInstanceID())
{
LoggerUtils.LogDebug("SpikesCollision", "Collided with self. Skipping.");
return;
}
bool flag = NetworkUtils.IsLocalPlayerOwner(owner);
LoggerUtils.LogDebug("SpikesCollision", $"Is local player owner: {flag}");
if (flag)
{
LoggerUtils.LogHitmarker("Hit registered! Attacker: " + ((Object)owner).name + ", Victim: " + ((Object)((Component)other).gameObject).name + ".");
Mod.Instance?.ShowHitmarkerInstance("Spike", HitMarkerType.Secondary);
}
else
{
LoggerUtils.LogDebug("SpikesCollision", "Not local player owner. Hitmarker not shown.");
}
}
}
[HarmonyPatch]
public static class Spike_Patches
{
[HarmonyPatch(typeof(SpikedRootController), "Interaction")]
[HarmonyPrefix]
public static void SpikedRootController_OnInteraction_Prefix(SpikedRootController __instance, GameObject player)
{
LoggerUtils.LogDebug("Spike", "SpikedRootController.Interaction called by player: " + ((Object)player).name + ". Starting to process spikes.");
try
{
if ((Object)(object)__instance == (Object)null || (Object)(object)player == (Object)null)
{
LoggerUtils.LogError("Spike", "Null reference in Interaction prefix. Aborting patch.");
return;
}
GameObject[] spikes = __instance.spikes;
foreach (GameObject val in spikes)
{
if ((Object)(object)val == (Object)null)
{
LoggerUtils.LogWarning("Spike", "Skipping null spikePrefab in array.");
continue;
}
LoggerUtils.LogDebug("Spike", "Processing spikePrefab: " + ((Object)val).name + ".");
if ((Object)(object)val.GetComponent<SpikesCollision>() == (Object)null)
{
Collider val2 = val.GetComponent<Collider>();
if ((Object)(object)val2 == (Object)null)
{
val2 = (Collider)(object)val.AddComponent<BoxCollider>();
}
val2.isTrigger = true;
val.AddComponent<SpikesCollision>();
}
else
{
LoggerUtils.LogDebug("Spike", "SpikesCollision already exists on " + ((Object)val).name + ". Skipping.");
}
val.GetComponent<SpikesCollision>().owner = player;
}
LoggerUtils.LogDebug("Spike", "SpikedRootController.Interaction prefix finished successfully.");
}
catch (Exception ex)
{
LoggerUtils.LogError("Spike", "Exception in Interaction patch prefix: " + ex.Message);
}
}
}
}
namespace HitMarker.Patches.WeaponPatches.Gun
{
[HarmonyPatch]
public static class Dart_Patches
{
private static DartGunHandler patchHandler = new DartGunHandler();
private static readonly Dictionary<int, GameObject> dartGunLastUsers = new Dictionary<int, GameObject>();
private static readonly Dictionary<int, bool> processedDartHits = new Dictionary<int, bool>();
[HarmonyPatch(typeof(DartGunController), "Interaction")]
[HarmonyPrefix]
private static void Interaction_Prefix(DartGunController __instance, GameObject player)
{
try
{
if (!((Object)(object)__instance == (Object)null) && !((Object)(object)player == (Object)null))
{
int instanceID = ((Object)__instance).GetInstanceID();
dartGunLastUsers[instanceID] = player;
patchHandler.LogDebug($"[Interaction] Player {((Object)player).name} is using dart gun {instanceID}.");
}
}
catch (Exception ex)
{
patchHandler.LogError("[Interaction] CRITICAL ERROR: " + ex.Message);
}
}
[HarmonyPatch(typeof(DartController), "OnTriggerEnter")]
[HarmonyPrefix]
private static void OnTriggerEnter_Prefix(DartController __instance, Collider other)
{
try
{
if (processedDartHits.ContainsKey(((Object)__instance).GetInstanceID()))
{
patchHandler.LogDebug("[OnTriggerEnter] Already processed collision for this dart. Skipping.");
return;
}
if (((Component)other).CompareTag("Ignorable") || ((Component)other).CompareTag("hex"))
{
patchHandler.LogDebug("[OnTriggerEnter] Hit ignorable object: " + ((Object)other).name + ". Skipping.");
return;
}
processedDartHits[((Object)__instance).GetInstanceID()] = true;
DartGunController dgc = __instance.dgc;
if ((Object)(object)dgc == (Object)null)
{
patchHandler.LogDebug("[OnTriggerEnter] No DartGunController found. Skipping.");
return;
}
int instanceID = ((Object)dgc).GetInstanceID();
if (!dartGunLastUsers.ContainsKey(instanceID))
{
patchHandler.LogDebug("[OnTriggerEnter] No recorded user for this dart gun. Skipping.");
return;
}
GameObject val = dartGunLastUsers[instanceID];
if ((Object)(object)val == (Object)null)
{
patchHandler.LogError("[OnTriggerEnter] Recorded owner is NULL.");
}
else if (!patchHandler.IsLocalPlayerOwner(val))
{
patchHandler.LogDebug("[OnTriggerEnter] Owner is not the local player. Skipping hit marker.");
}
else
{
patchHandler.ProcessHit(((Component)other).gameObject, val);
}
}
catch (Exception ex)
{
patchHandler.LogError("[OnTriggerEnter] CRITICAL ERROR: " + ex.Message);
}
}
[HarmonyPatch(typeof(DartController), "HitSomething")]
[HarmonyPostfix]
private static void HitSomething_Postfix(DartController __instance)
{
try
{
((Object)__instance.dgc).GetInstanceID();
int instanceID = ((Object)__instance).GetInstanceID();
if (processedDartHits.ContainsKey(instanceID))
{
processedDartHits.Remove(instanceID);
patchHandler.LogDebug($"[HitSomething_Postfix] Removed hit tracking for dart {instanceID}.");
}
}
catch (Exception ex)
{
patchHandler.LogError("[HitSomething_Postfix] CRITICAL ERROR: " + ex.Message);
}
}
}
public class DartGunHandler : BasePatchHandler
{
public override string[] ValidTags => new string[3] { "Player", "PlayerNpc", "hitable" };
public override string PatchName => "DarkGun";
public override bool MoreCheckHit(GameObject target)
{
return false;
}
public override bool ProcessHit(GameObject target, GameObject owner)
{
return base.ProcessHit(target, owner);
}
}
}
namespace HitMarker.Patches.SpellPatches.Rock
{
public class RockHandler : BasePatchHandler
{
public override string[] ValidTags => new string[5] { "Player", "PlayerNpc", "hitable", "wormhole", "brazier" };
public override string PatchName => "Rock";
public override bool MoreCheckHit(GameObject target)
{
return false;
}
}
[HarmonyPatch]
public static class Rock_Patches
{
private static RockHandler patchHandler = new RockHandler();
private static readonly Queue<int> processedInstanceQueue = new Queue<int>();
private static readonly HashSet<int> processedInstanceIDs = new HashSet<int>();
private const int MAX_PROCESSED_INSTANCES = 100;
[HarmonyPatch(typeof(RockSpellController), "StartRockRoutine")]
[HarmonyPostfix]
private static void StartRockRoutine_Postfix(RockSpellController __instance, GameObject playerOwner)
{
patchHandler.LogDebug("[StartRockRoutine] Patch started. Instance: " + (((__instance != null) ? ((Object)__instance).name : null) ?? "NULL") + ", Owner: " + (((playerOwner != null) ? ((Object)playerOwner).name : null) ?? "NULL") + ".");
try
{
if ((Object)(object)__instance == (Object)null || (Object)(object)playerOwner == (Object)null)
{
patchHandler.LogError("[StartRockRoutine] __instance or playerOwner is NULL. Aborting.");
return;
}
patchHandler.LogDebug($"[StartRockRoutine] Attempting to set owner on grpo for instance {((Object)__instance).GetInstanceID()}.");
if ((Object)(object)__instance.grpo == (Object)null)
{
patchHandler.LogError("[StartRockRoutine] __instance.grpo is NULL. Cannot assign owner.");
return;
}
__instance.grpo.owner = playerOwner;
RockHandler rockHandler = patchHandler;
GameObject owner = __instance.grpo.owner;
rockHandler.LogDebug("[StartRockRoutine] Owner successfully assigned. Current owner: " + (((owner != null) ? ((Object)owner).name : null) ?? "NULL") + ".");
}
catch (Exception ex)
{
patchHandler.LogError("[StartRockRoutine] CRITICAL ERROR: " + ex.Message);
}
}
[HarmonyPatch(typeof(RockCheckSphere), "FixedUpdate")]
[HarmonyPostfix]
private static void FixedUpdate_Postfix(RockCheckSphere __instance)
{
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)__instance == (Object)null)
{
patchHandler.LogError("[FixedUpdate] __instance is NULL. Aborting.");
return;
}
int instanceID = ((Object)__instance).GetInstanceID();
if (processedInstanceIDs.Contains(instanceID))
{
return;
}
if ((Object)(object)__instance.grpo == (Object)null)
{
patchHandler.LogError($"[FixedUpdate] grpo is NULL for instance {instanceID}. Cannot check owner.");
return;
}
GameObject owner = __instance.grpo.owner;
patchHandler.LogDebug(string.Format("[FixedUpdate] Owner found for instance {0}: {1}.", instanceID, ((owner != null) ? ((Object)owner).name : null) ?? "NULL"));
if ((Object)(object)owner == (Object)null || !patchHandler.IsLocalPlayerOwner(owner))
{
patchHandler.LogDebug("[FixedUpdate] Owner is not the local player or is NULL. Skipping hit check.");
return;
}
patchHandler.LogDebug($"[FixedUpdate] Owner is local player. Performing OverlapSphere check at position {((Component)__instance).transform.position}.");
Collider[] array = Physics.OverlapSphere(((Component)__instance).transform.position, __instance.radius, LayerMask.op_Implicit(__instance.playerLayer));
patchHandler.LogDebug($"[FixedUpdate] Found {array.Length} colliders.");
Collider[] array2 = array;
foreach (Collider val in array2)
{
if ((Object)(object)((Component)val).gameObject == (Object)null)
{
patchHandler.LogError("[FixedUpdate] Skipping NULL collider in list.");
continue;
}
patchHandler.LogDebug("[FixedUpdate] Checking collider: " + ((Object)((Component)val).gameObject).name + ".");
if (patchHandler.ProcessHit(((Component)val).gameObject, owner))
{
patchHandler.LogDebug($"[FixedUpdate] Hit processed successfully for instance {instanceID} with {((Object)((Component)val).gameObject).name}.");
processedInstanceQueue.Enqueue(instanceID);
processedInstanceIDs.Add(instanceID);
if (processedInstanceQueue.Count > 100)
{
int num = processedInstanceQueue.Dequeue();
processedInstanceIDs.Remove(num);
patchHandler.LogDebug($"[FixedUpdate] Removed oldest processed instance {num} to maintain size limit.");
}
break;
}
}
}
catch (Exception ex)
{
patchHandler.LogError("[FixedUpdate] CRITICAL ERROR: " + ex.Message);
}
}
}
}
namespace HitMarker.Patches.SpellPatches.MagicMissle
{
public class MagicMissileHandler : BasePatchHandler
{
public override string[] ValidTags => new string[4] { "Player", "PlayerNpc", "hitable", "wormhole" };
public override string PatchName => "MagicMissile";
public override bool MoreCheckHit(GameObject target)
{
return false;
}
public override bool ProcessHit(GameObject target, GameObject owner)
{
if (!IsLocalPlayerOwner(owner))
{
return false;
}
return base.ProcessHit(target, owner);
}
}
[HarmonyPatch]
public static class MagicMissle_Patches
{
private static MagicMissileHandler patchHandler = new MagicMissileHandler();
[HarmonyPatch(typeof(MagicMissleController), "OnCollisionEnter")]
[HarmonyPostfix]
private static void OnCollisionEnter_Postfix(MagicMissleController __instance, Collision other)
{
try
{
FieldInfo field = typeof(MagicMissleController).GetField("shotByAi", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeof(MagicMissleController).GetField("collided", BindingFlags.Instance | BindingFlags.NonPublic);
if (field == null || field2 == null)
{
LoggerUtils.LogError("MagicMissile", "Required fields not found via reflection");
return;
}
bool num = (bool)field.GetValue(__instance);
bool flag = (bool)field2.GetValue(__instance);
if (!num && flag)
{
patchHandler.ProcessHit(other.gameObject, __instance.playerOwner);
}
}
catch (Exception ex)
{
patchHandler.LogError("Patch error: " + ex.Message);
}
}
}
}
namespace HitMarker.Patches.SpellPatches.LightningBolt
{
[HarmonyPatch]
public static class LightningBolt_Patches
{
private static LightningHandler patchHandler = new LightningHandler();
[HarmonyPatch(typeof(LightningBoltDamage), "DoDmg")]
[HarmonyPostfix]
public static void DoDmg_Postfix(LightningBoltDamage __instance, GameObject OwnerObj)
{
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
patchHandler.LogPatch("LightningBolt detected, checking for hits");
try
{
if (!patchHandler.IsLocalPlayerOwner(OwnerObj))
{
return;
}
FieldInfo field = typeof(LightningBoltDamage).GetField("height", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeof(LightningBoltDamage).GetField("width", BindingFlags.Instance | BindingFlags.NonPublic);
if (field == null || field2 == null)
{
patchHandler.LogError("Required fields not found via reflection");
return;
}
float num = (float)field.GetValue(__instance);
float num2 = (float)field2.GetValue(__instance);
Vector3 val = ((Component)__instance).transform.position + Vector3.up * (num / 2f);
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(num2 / 2f, num / 2f, num2 / 2f);
Collider[] array = Physics.OverlapBox(val, val2, Quaternion.identity, LayerMask.op_Implicit(__instance.lrm));
foreach (Collider val3 in array)
{
patchHandler.ProcessHit(((Component)val3).gameObject, OwnerObj);
}
}
catch (Exception ex)
{
patchHandler.LogError("Patch error: " + ex.Message);
}
}
}
public class LightningHandler : BasePatchHandler
{
public override string[] ValidTags => new string[4] { "Player", "PlayerNpc", "hitable", "wormhole" };
public override string PatchName => "Lightning";
public override bool MoreCheckHit(GameObject target)
{
return false;
}
}
}
namespace HitMarker.Patches.SpellPatches.FrostBolt
{
[HarmonyPatch]
public static class FrostBolt_Patches
{
private static FrostBoltHandler patchHandler = new FrostBoltHandler();
[HarmonyPatch(typeof(FrostBoltController), "OnTriggerEnter")]
[HarmonyPostfix]
private static void OnTriggerEnter_Postfix(FrostBoltController __instance, Collider other)
{
patchHandler.LogPatch("FrostBolt trigger detected");
try
{
FieldInfo field = typeof(FrostBoltController).GetField("ShotByAi", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeof(FrostBoltController).GetField("collided", BindingFlags.Instance | BindingFlags.NonPublic);
if (field == null || field2 == null)
{
LoggerUtils.LogError("FrostBolt", "Required fields not found via reflection");
return;
}
bool num = (bool)field.GetValue(__instance);
bool flag = (bool)field2.GetValue(__instance);
if (!num && flag && patchHandler.IsLocalPlayerOwner(__instance.playerOwner))
{
patchHandler.ProcessHit(((Component)other).gameObject, __instance.playerOwner);
}
}
catch (Exception ex)
{
patchHandler.LogError("Patch error: " + ex.Message);
}
}
}
public class FrostBoltHandler : BasePatchHandler
{
public override string[] ValidTags => new string[4] { "Player", "PlayerNpc", "hitable", "wormhole" };
public override string PatchName => "FrostBolt";
public override bool MoreCheckHit(GameObject target)
{
return false;
}
}
}
namespace HitMarker.Patches.SpellPatches.Fireball
{
[HarmonyPatch]
public static class Fireball_Patches
{
private static FireballHandler patchHandler = new FireballHandler();
[HarmonyPatch(typeof(ExplosionController), "Explode")]
[HarmonyPostfix]
private static void Explode_Postfix(ExplosionController __instance, GameObject owner)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
try
{
if (patchHandler.IsLocalPlayerOwner(owner))
{
float num = 8f + (float)__instance.level * 0.4f;
Collider[] array = Physics.OverlapSphere(((Component)__instance).transform.position, num, LayerMask.op_Implicit(__instance.PlayerLayer));
foreach (Collider val in array)
{
patchHandler.ProcessHit(((Component)val).gameObject, owner);
}
}
}
catch (Exception ex)
{
patchHandler.LogError("Patch error: " + ex.Message);
}
}
}
public class FireballHandler : BasePatchHandler
{
public override string[] ValidTags => new string[3] { "Player", "PlayerNpc", "hitable" };
public override string PatchName => "Fireball";
public override bool MoreCheckHit(GameObject target)
{
return false;
}
}
}
namespace HitMarker.Patches.SpellPatches.DarkBlast
{
public class DarkBlastHandler : BasePatchHandler
{
public override string[] ValidTags => new string[6] { "Player", "PlayerNpc", "hitable", "tutbrazier", "brazier", "wormhole" };
public override string PatchName => "DarkBlast";
public override bool MoreCheckHit(GameObject target)
{
if ((Object)(object)target != (Object)null)
{
return ((Object)target).name.Contains("duende");
}
return false;
}
public override bool ProcessHit(GameObject target, GameObject owner)
{
if (!IsLocalPlayerOwner(owner))
{
return false;
}
return base.ProcessHit(target, owner);
}
}
[HarmonyPatch]
public static class DarkBlast_Patches
{
[CompilerGenerated]
private sealed class <CastDarkBlast_HitDetectionRoutine>d__2 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public DarkBlastController instance;
public GameObject owner;
private Vector3 <boxHalfExtents>5__2;
private Vector3 <boxCenter>5__3;
private Quaternion <lookrot>5__4;
private float <timer>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CastDarkBlast_HitDetectionRoutine>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
//IL_005a: 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_0070: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(0.25f);
<>1__state = 1;
return true;
case 1:
{
<>1__state = -1;
float num = 70f;
<boxHalfExtents>5__2 = new Vector3(0.9f, 0.9f, num / 2f);
Vector3 position = ((Component)instance).transform.position;
Vector3 forward = ((Component)instance).transform.forward;
<boxCenter>5__3 = position + ((Vector3)(ref forward)).normalized * (num / 2f);
<lookrot>5__4 = Quaternion.LookRotation(((Component)instance).transform.forward, ((Component)instance).transform.up);
<timer>5__5 = 0f;
break;
}
case 2:
<>1__state = -1;
<timer>5__5 += 0.1f;
break;
}
if (<timer>5__5 <= 0.8f)
{
Collider[] array = Physics.OverlapBox(<boxCenter>5__3, <boxHalfExtents>5__2, <lookrot>5__4, LayerMask.op_Implicit(instance.playerLayerMask));
foreach (Collider val in array)
{
patchHandler.ProcessHit(((Component)val).gameObject, owner);
}
<>2__current = (object)new WaitForSeconds(0.1f);
<>1__state = 2;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static DarkBlastHandler patchHandler = new DarkBlastHandler();
[HarmonyPatch(typeof(DarkBlastController), "CastDarkBlast")]
[HarmonyPostfix]
public static void CastDarkBlast_Postfix(DarkBlastController __instance, Vector3 fwdVector, GameObject ownerob)
{
try
{
((MonoBehaviour)__instance).StartCoroutine(CastDarkBlast_HitDetectionRoutine(__instance, ownerob));
}
catch (Exception ex)
{
patchHandler.LogError("Patch error: " + ex.Message);
}
}
[IteratorStateMachine(typeof(<CastDarkBlast_HitDetectionRoutine>d__2))]
private static IEnumerator CastDarkBlast_HitDetectionRoutine(DarkBlastController instance, GameObject owner)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CastDarkBlast_HitDetectionRoutine>d__2(0)
{
instance = instance,
owner = owner
};
}
}
}
namespace HitMarker.Patches.GamePatches
{
[HarmonyPatch(typeof(MainMenuManager), "ActuallyStartGameActually")]
public static class MainMenuManagerPatch
{
private static void Postfix()
{
LoggerUtils.LogDebug("MainMenuManager", "Game started, initializing hitmarker system");
try
{
if (Mod.Instance.HitMarkerManager.IsInitialized)
{
LoggerUtils.LogDebug("MainMenuManager", "Hitmarker is initializated");
return;
}
LoggerUtils.LogDebug("MainMenuManager", "Hitmarker initialization started");
((MonoBehaviour)Mod.Instance).StartCoroutine(Mod.Instance.HitMarkerManager.InitializeHitmarkerCoroutine());
}
catch (Exception ex)
{
LoggerUtils.LogCriticalError("MainMenuManagerPatch", "Failed to start hitmarker initialization", ex);
}
}
}
}
namespace HitMarker.MarkerHit
{
[Serializable]
public enum HitMarkerType
{
Primary,
Secondary
}
[Serializable]
public class HitMarkerConfig
{
public readonly float Duration;
public readonly float ScaleStart;
public readonly float ScaleEnd;
public readonly Vector2 Size;
public readonly Color Color;
public HitMarkerType Type { get; set; }
public HitMarkerConfig(HitMarkerType type)
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
Type = type;
if (type == HitMarkerType.Primary)
{
Duration = 0.7f;
ScaleStart = 1.5f;
ScaleEnd = 1f;
Size = new Vector2(50f, 50f);
Color = ModConstants.HITMARKER_PRIMARY_COLOR;
}
else
{
Duration = 1.5f;
ScaleStart = 1f;
ScaleEnd = 0.7f;
Size = new Vector2(70f, 70f);
Color = ModConstants.HITMARKER_SECONDARY_COLOR;
}
}
public HitMarkerConfig(HitMarkerType type, float duration, float scaleStart, float scaleEnd, Vector2 size, Color color)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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_002e: Unknown result type (might be due to invalid IL or missing references)
Type = type;
Duration = duration;
ScaleStart = scaleStart;
ScaleEnd = scaleEnd;
Size = size;
Color = color;
}
public static HitMarkerConfig CreatePrimaryConfig()
{
return new HitMarkerConfig(HitMarkerType.Primary);
}
public static HitMarkerConfig CreateSecondaryConfig()
{
return new HitMarkerConfig(HitMarkerType.Secondary);
}
}
public class HitMarkerManager : MonoBehaviour
{
private struct SecondaryMarkersSlot
{
public HitMarkerBehaviour Marker;
public string WeaponName;
public int SlotIndex;
public SecondaryMarkersSlot(HitMarkerBehaviour marker, string weaponName, int slotIndex)
{
Marker = marker;
WeaponName = weaponName;
SlotIndex = slotIndex;
}
}
[CompilerGenerated]
private sealed class <InitializeHitmarkerCoroutine>d__30 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public HitMarkerManager <>4__this;
private GameObject <canvasObj>5__2;
private int <attempts>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <InitializeHitmarkerCoroutine>d__30(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<canvasObj>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
HitMarkerManager hitMarkerManager = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
LoggerUtils.LogDebug("HitMarkerManager", "Searching for Canvas...");
<canvasObj>5__2 = null;
<attempts>5__3 = 0;
break;
case 1:
<>1__state = -1;
break;
}
while ((Object)(object)<canvasObj>5__2 == (Object)null && <attempts>5__3 < 15)
{
<canvasObj>5__2 = GameObject.Find("Canvas");
if ((Object)(object)<canvasObj>5__2 == (Object)null)
{
<attempts>5__3++;
LoggerUtils.LogDebug("HitMarkerManager", $"Canvas search attempt {<attempts>5__3}/{15}");
<>2__current = hitMarkerManager._canvasWait;
<>1__state = 1;
return true;
}
}
if ((Object)(object)<canvasObj>5__2 == (Object)null)
{
LoggerUtils.LogError("HitMarkerManager", $"Canvas not found after {15} attempts");
return false;
}
hitMarkerManager._canvas = <canvasObj>5__2;
LoggerUtils.LogDebug("HitMarkerManager", "Canvas found, creating hitmarker");
hitMarkerManager.CreatePrimaryMarker(<canvasObj>5__2);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private Vector2 _primaryPosition = Vector2.zero;
private Vector2 _secondaryStartPosition = new Vector2(-80f, 40f);
private float _secondaryVerticalSpacing = 70f;
private HitMarkerConfig _primaryConfig;
private HitMarkerConfig _secondaryConfig;
private Dictionary<string, Sprite> _weaponSprite = new Dictionary<string, Sprite>();
private Sprite _weaponPrimarySprite;
private HitMarkerBehaviour _primaryMarker;
private List<SecondaryMarkersSlot> _activeSecondaryMarkers;
private Queue<HitMarkerBehaviour> _inactiveSecondaryMarkersPool;
private WaitForSeconds _canvasWait;
private GameObject _canvas;
public bool IsInitialized
{
get
{
if ((Object)(object)_canvas != (Object)null)
{
return (Object)(object)_primaryMarker != (Object)null;
}
return false;
}
}
public GameObject Canvas => _canvas;
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
_canvasWait = new WaitForSeconds(2f);
}
public void Initialize()
{
InitializeCollections();
SetupDefaultConfigs();
LoadTextureAndCreateSprite();
((MonoBehaviour)this).StartCoroutine(InitializeHitmarkerCoroutine());
LoggerUtils.LogDebug("HitMarkerManager", "Manager initialized with texture");
}
private void InitializeCollections()
{
_weaponSprite = new Dictionary<string, Sprite>();
_activeSecondaryMarkers = new List<SecondaryMarkersSlot>();
_inactiveSecondaryMarkersPool = new Queue<HitMarkerBehaviour>();
}
private void SetupDefaultConfigs()
{
_primaryConfig = HitMarkerConfig.CreatePrimaryConfig();
_secondaryConfig = HitMarkerConfig.CreateSecondaryConfig();
}
private void LoadTextureAndCreateSprite()
{
Texture2D val = ResourceLoader.LoadTextureFromResources("HitMarker.Resources.hitmarker.png");
if ((Object)(object)val == (Object)null)
{
throw new Exception("Failed to load hitmarker texture - mod cannot function without it");
}
_weaponPrimarySprite = ResourceLoader.CreateSpriteFromTexture(val);
if ((Object)(object)_weaponPrimarySprite == (Object)null)
{
throw new Exception("Failed to create hitmarker sprite - mod cannot function without it");
}
val = ResourceLoader.LoadTextureFromResources("HitMarker.Resources.spike.png");
if ((Object)(object)val == (Object)null)
{
throw new Exception("Failed to load hitmarker texture - mod cannot function without it");
}
Sprite val2 = ResourceLoader.CreateSpriteFromTexture(val);
if ((Object)(object)val2 == (Object)null)
{
throw new Exception("Failed to create hitmarker sprite - mod cannot function without it");
}
_weaponSprite["Spike"] = val2;
}
public void ShowHitmarker(string weaponName, HitMarkerType type)
{
if (!IsInitialized)
{
LoggerUtils.LogDebug("HitMarkerManager", "Cannot show hitmarker: not initialized");
return;
}
try
{
switch (type)
{
case HitMarkerType.Primary:
ShowPrimaryHitmarker();
break;
case HitMarkerType.Secondary:
ShowSecondaryHitmarker(weaponName);
break;
}
LoggerUtils.LogDebug("ModularHitMarkerManager", $"Hitmarker displayed for {weaponName} (Type: {type})");
}
catch (Exception ex)
{
LoggerUtils.LogError("HitMarkerManager", "Failed to show hitmarker: " + ex.Message);
}
}
private void ShowPrimaryHitmarker()
{
if ((Object)(object)_primaryMarker == (Object)null)
{
LoggerUtils.LogError("ModularHitMarkerManager", "Primary marker not initialized");
return;
}
_primaryMarker.ShowHitMark();
LoggerUtils.LogDebug("ModularHitMarkerManager", "Primary hitmarker shown");
}
private void ShowSecondaryHitmarker(string weaponName)
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
int num = _activeSecondaryMarkers.FindIndex((SecondaryMarkersSlot slot) => slot.WeaponName == weaponName);
if (num >= 0)
{
_activeSecondaryMarkers[num].Marker.ShowHitMark();
LoggerUtils.LogDebug("ModularHitMarkerManager", "Restarted existing secondary marker for " + weaponName);
return;
}
HitMarkerBehaviour secondaryMarkerFromPool = GetSecondaryMarkerFromPool();
int count = _activeSecondaryMarkers.Count;
Vector2 position = CalculateSecondaryMarkerPosition(count);
Sprite value = null;
if (!_weaponSprite.TryGetValue(weaponName, out value))
{
LoggerUtils.LogWarning("ModularHitMarkerManager", "No texture found for " + weaponName + ", using primary texture");
value = _weaponPrimarySprite;
}
SecondaryMarkersSlot item = new SecondaryMarkersSlot(secondaryMarkerFromPool, weaponName, count);
_activeSecondaryMarkers.Add(item);
secondaryMarkerFromPool.Initialize(_secondaryConfig, value, position, delegate
{
OnSecondaryMarkerComplete(weaponName);
});
secondaryMarkerFromPool.ShowHitMark();
LoggerUtils.LogDebug("ModularHitMarkerManager", $"Secondary marker shown for {weaponName} in slot {count}");
}
private Vector2 CalculateSecondaryMarkerPosition(int slotIndex)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
return _secondaryStartPosition + new Vector2(0f, (float)(-slotIndex) * _secondaryVerticalSpacing);
}
private HitMarkerBehaviour GetSecondaryMarkerFromPool()
{
//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)
if (_inactiveSecondaryMarkersPool.Count > 0)
{
return _inactiveSecondaryMarkersPool.Dequeue();
}
GameObject val = new GameObject("SecondaryHitMarker");
val.transform.SetParent(_canvas.transform, false);
return val.AddComponent<HitMarkerBehaviour>();
}
private void ReturnSecondaryMarkerToPool(HitMarkerBehaviour marker)
{
((Component)marker).gameObject.SetActive(false);
_inactiveSecondaryMarkersPool.Enqueue(marker);
}
private void OnSecondaryMarkerComplete(string weaponName)
{
int num = _activeSecondaryMarkers.FindIndex((SecondaryMarkersSlot slot) => slot.WeaponName == weaponName);
if (num >= 0)
{
SecondaryMarkersSlot secondaryMarkersSlot = _activeSecondaryMarkers[num];
_activeSecondaryMarkers.RemoveAt(num);
ReturnSecondaryMarkerToPool(secondaryMarkersSlot.Marker);
RepositionActiveSecondaryMarkers();
LoggerUtils.LogDebug("ModularHitMarkerManager", "Secondary marker completed and removed: " + weaponName);
}
}
private void RepositionActiveSecondaryMarkers()
{
//IL_001b: 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_0027: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < _activeSecondaryMarkers.Count; i++)
{
SecondaryMarkersSlot secondaryMarkersSlot = _activeSecondaryMarkers[i];
secondaryMarkersSlot.SlotIndex = i;
Vector2 newPosition = CalculateSecondaryMarkerPosition(i);
secondaryMarkersSlot.Marker.UpdatePosition(newPosition);
}
}
[IteratorStateMachine(typeof(<InitializeHitmarkerCoroutine>d__30))]
public IEnumerator InitializeHitmarkerCoroutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <InitializeHitmarkerCoroutine>d__30(0)
{
<>4__this = this
};
}
private void CreatePrimaryMarker(GameObject canvas)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
try
{
GameObject val = new GameObject("HitMarker");
val.transform.SetParent(canvas.transform, false);
_primaryMarker = val.AddComponent<HitMarkerBehaviour>();
_primaryMarker.Initialize(_primaryConfig, _weaponPrimarySprite, _primaryPosition);
LoggerUtils.LogInfo("HitMarkerManager", "Hitmarker system ready");
}
catch (Exception ex)
{
LoggerUtils.LogCriticalError("HitMarkerManager", "Failed to create hitmarker on canvas", ex);
}
}
}
public class HitMarkerBehaviour : MonoBehaviour
{
[CompilerGenerated]
private sealed class <HitmarkerAnimationCoroutine>d__13 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public HitMarkerBehaviour <>4__this;
private float <timer>5__2;
private float <timer>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <HitmarkerAnimationCoroutine>d__13(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0040: 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_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Expected O, but got Unknown
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: 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_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
HitMarkerBehaviour hitMarkerBehaviour = <>4__this;
switch (num)
{
default:
return false;
case 0:
{
<>1__state = -1;
hitMarkerBehaviour._isAnimating = true;
((Graphic)hitMarkerBehaviour._hitmarkerImage).color = hitMarkerBehaviour._config.Color;
((Transform)hitMarkerBehaviour._rectTransform).localScale = new Vector3(hitMarkerBehaviour._config.ScaleStart, hitMarkerBehaviour._config.ScaleStart, 1f);
if (hitMarkerBehaviour._config.Type == HitMarkerType.Primary)
{
<timer>5__2 = 0f;
goto IL_0139;
}
<timer>5__2 = hitMarkerBehaviour._config.Duration * 0.25f;
float num6 = hitMarkerBehaviour._config.Duration * 0.75f;
<>2__current = (object)new WaitForSeconds(num6);
<>1__state = 2;
return true;
}
case 1:
<>1__state = -1;
goto IL_0139;
case 2:
<>1__state = -1;
<timer>5__3 = 0f;
goto IL_024d;
case 3:
{
<>1__state = -1;
goto IL_024d;
}
IL_024d:
if (<timer>5__3 < <timer>5__2)
{
float num2 = <timer>5__3 / <timer>5__2;
Color color = ((Graphic)hitMarkerBehaviour._hitmarkerImage).color;
color.a = Mathf.Lerp(1f, 0f, num2);
((Graphic)hitMarkerBehaviour._hitmarkerImage).color = color;
float num3 = Mathf.Lerp(hitMarkerBehaviour._config.ScaleStart, hitMarkerBehaviour._config.ScaleEnd, num2);
((Transform)hitMarkerBehaviour._rectTransform).localScale = new Vector3(num3, num3, 1f);
<timer>5__3 += Time.deltaTime;
<>2__current = null;
<>1__state = 3;
return true;
}
break;
IL_0139:
if (<timer>5__2 < hitMarkerBehaviour._config.Duration)
{
float num4 = <timer>5__2 / hitMarkerBehaviour._config.Duration;
float num5 = Mathf.Lerp(hitMarkerBehaviour._config.ScaleStart, hitMarkerBehaviour._config.ScaleEnd, num4);
((Transform)hitMarkerBehaviour._rectTransform).localScale = new Vector3(num5, num5, 1f);
Color color2 = ((Graphic)hitMarkerBehaviour._hitmarkerImage).color;
color2.a = Mathf.Lerp(1f, 0f, num4);
((Graphic)hitMarkerBehaviour._hitmarkerImage).color = color2;
<timer>5__2 += Time.deltaTime;
<>2__current = null;
<>1__state = 1;
return true;
}
break;
}
((Transform)hitMarkerBehaviour._rectTransform).localScale = Vector3.one;
Color color3 = ((Graphic)hitMarkerBehaviour._hitmarkerImage).color;
color3.a = 0f;
((Graphic)hitMarkerBehaviour._hitmarkerImage).color = color3;
((Component)hitMarkerBehaviour).gameObject.SetActive(false);
hitMarkerBehaviour._isAnimating = false;
LoggerUtils.LogDebug("HitMarkerBehaviour", "Animation completed");
hitMarkerBehaviour._onAnimationComplete?.Invoke();
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private HitMarkerConfig _config;
private Image _hitmarkerImage;
private RectTransform _rectTransform;
private bool _isAnimating;
private Action _onAnimationComplete;
public bool IsAnimating => _isAnimating;
public HitMarkerType MarkerType => _config?.Type ?? HitMarkerType.Primary;
public void Initialize(HitMarkerConfig config, Sprite sprite, Vector2 position, Action onComplete = null)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
_config = config;
_onAnimationComplete = onComplete;
LoggerUtils.LogDebug("HitMarkerBehaviour", "Initializing HitMarkerBehaviour");
try
{
SetupImageComponent(sprite);
SetupRectTransform(position);
((Component)this).gameObject.SetActive(false);
LoggerUtils.LogDebug("HitMarkerBehaviour", "HitMarkerBehaviour initialized successfully");
}
catch (Exception ex)
{
LoggerUtils.LogCriticalError("HitMarkerBehaviour", "Failed to initialize", ex);
throw;
}
}
private void SetupImageComponent(Sprite sprite)
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)sprite == (Object)null)
{
LoggerUtils.LogError("HitMarkerBehaviour", "Cannot setup image with null sprite");
return;
}
LoggerUtils.LogDebug("HitMarkerBehaviour", "Setting up Image component");
_hitmarkerImage = ((Component)this).GetComponent<Image>();
if ((Object)(object)_hitmarkerImage == (Object)null)
{
_hitmarkerImage = ((Component)this).gameObject.AddComponent<Image>();
}
_hitmarkerImage.sprite = sprite;
((Graphic)_hitmarkerImage).color = _config.Color;
}
private void SetupRectTransform(Vector2 position)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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_009f: Unknown result type (might be due to invalid IL or missing references)
LoggerUtils.LogDebug("HitMarkerBehaviour", "Setting up RectTransform");
_rectTransform = ((Component)this).GetComponent<RectTransform>();
if ((Object)(object)_rectTransform == (Object)null)
{
LoggerUtils.LogError("HitMarkerBehaviour", "RectTransform not found");
return;
}
_rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
_rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
_rectTransform.pivot = new Vector2(0.5f, 0.5f);
_rectTransform.anchoredPosition = position;
_rectTransform.sizeDelta = _config.Size;
}
public void ShowHitMark()
{
if (_config == null || (Object)(object)_hitmarkerImage == (Object)null)
{
LoggerUtils.LogWarning("HitMarkerBehaviour", "Cannot show hitmarker: not properly initialized");
return;
}
LoggerUtils.LogDebug("HitMarkerBehaviour", "Showing hitmarker");
((Component)this).gameObject.SetActive(true);
if (_isAnimating)
{
((MonoBehaviour)this).StopAllCoroutines();
}
((MonoBehaviour)this).StartCoroutine(HitmarkerAnimationCoroutine());
}
[IteratorStateMachine(typeof(<HitmarkerAnimationCoroutine>d__13))]
private IEnumerator HitmarkerAnimationCoroutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <HitmarkerAnimationCoroutine>d__13(0)
{
<>4__this = this
};
}
public void UpdatePosition(Vector2 newPosition)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_rectTransform != (Object)null)
{
_rectTransform.anchoredPosition = newPosition;
}
}
}
}
namespace HitMarker.Core
{
public static class ModConstants
{
public const string MOD_GUID = "HitMarker.Mod";
public const string MOD_NAME = "HitMarker";
public const string MOD_VERSION = "0.1.4";
public const string HITMARKER_PRIMARY_TEXTURE_PATH = "HitMarker.Resources.hitmarker.png";
public const string HITMARKER_SECONDARY_SPIKE_TEXTURE_PATH = "HitMarker.Resources.spike.png";
public static readonly string[] SPECIAL_NAMES = new string[1] { "duende" };
public const int WALL_LAYER = 3;
public const float CANVAS_WAIT_TIME = 2f;
public const float HITMARKER_PRIMARY_DURATION = 0.7f;
public const float HITMARKER_PRIMARY_SCALE_START = 1.5f;
public const float HITMARKER_PRIMARY_SCALE_END = 1f;
public const int HITMARKER_PRIMARY_SIZE = 50;
public static readonly Color HITMARKER_PRIMARY_COLOR = new Color(1f, 0f, 0f, 1f);
public const float HITMARKER_SECONDARY_DURATION = 1.5f;
public const float HITMARKER_SECONDARY_SCALE_START = 1f;
public const float HITMARKER_SECONDARY_SCALE_END = 0.7f;
public const int HITMARKER_SECONDARY_SIZE = 70;
public static readonly Color HITMARKER_SECONDARY_COLOR = new Color(1f, 1f, 1f, 1f);
public const string LOG_PREFIX = "[HITMARKER]";
public const string PATCH_LOG_PREFIX = "[HITMARKER] [PATCH]";
public const string HITMARKER_LOG_PREFIX = "[HITMARKER] [HITMARKER]";
public const string RESOURCE_LOG_PREFIX = "[HITMARKER] [RESOURCE]";
}
public static class ResourceLoader
{
public static Texture2D LoadTextureFromResources(string resourcePath)
{
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Expected O, but got Unknown
LoggerUtils.LogDebug("ResourceLoader", "Loading texture: " + resourcePath);
Assembly executingAssembly = Assembly.GetExecutingAssembly();
try
{
using Stream stream = executingAssembly.GetManifestResourceStream(resourcePath);
if (stream == null)
{
LoggerUtils.LogError("ResourceLoader", "Resource not found: " + resourcePath);
LogAvailableResources();
return null;
}
byte[] array = new byte[stream.Length];
int num = stream.Read(array, 0, array.Length);
if (num != array.Length)
{
LoggerUtils.LogError("ResourceLoader", $"Incomplete stream read. Expected: {array.Length}, Read: {num}");
return null;
}
Texture2D val = new Texture2D(2, 2);
if (ImageConversion.LoadImage(val, array))
{
LoggerUtils.LogInfo("ResourceLoader", $"Texture loaded successfully ({((Texture)val).width}x{((Texture)val).height})");
return val;
}
LoggerUtils.LogError("ResourceLoader", "Failed to convert bytes to image");
Object.Destroy((Object)(object)val);
return null;
}
catch (Exception ex)
{
LoggerUtils.LogCriticalError("ResourceLoader", "Exception loading resource " + resourcePath, ex);
return null;
}
}
public static Sprite CreateSpriteFromTexture(Texture2D texture)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)texture == (Object)null)
{
LoggerUtils.LogError("ResourceLoader", "Cannot create sprite from null texture");
return null;
}
try
{
Sprite result = Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0.5f, 0.5f));
LoggerUtils.LogDebug("ResourceLoader", $"Sprite created ({((Texture)texture).width}x{((Texture)texture).height})");
return result;
}
catch (Exception ex)
{
LoggerUtils.LogError("ResourceLoader", "Failed to create sprite: " + ex.Message);
return null;
}
}
private static void LogAvailableResources()
{
if (LoggerUtils.MinLogLevel > LogLevel.Debug)
{
return;
}
try
{
string[] manifestResourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
LoggerUtils.LogDebug("ResourceLoader", $"Available embedded resources ({manifestResourceNames.Length}):");
string[] array = manifestResourceNames;
foreach (string text in array)
{
LoggerUtils.LogDebug("ResourceLoader", " - " + text);
}
}
catch (Exception ex)
{
LoggerUtils.LogError("ResourceLoader", "Failed to list resources: " + ex.Message);
}
}
}
}
namespace HitMarker.Console
{
public class CommandManager : MonoBehaviour
{
private readonly Dictionary<string, ICommand> _commands = new Dictionary<string, ICommand>();
private int index;
private void Awake()
{
LoggerUtils.LogDebug("CommandManager", "Awake called. Initializing CommandManager...");
RegisterCommand(new GiveCommand());
}
private void Update()
{
if (Input.GetKeyDown((KeyCode)107) && index <= 15)
{
ExecuteCommand("give", index.ToString());
index++;
}
if (Input.GetKeyDown((KeyCode)108) && index <= 15)
{
((MonoBehaviour)this).StartCoroutine(Mod.Instance.TestHitMarker());
}
}
public void RegisterCommand(ICommand command)
{
if (command == null || string.IsNullOrEmpty(command.Name))
{
throw new ArgumentException("Command or command name cannot be null or empty.");
}
if (_commands.ContainsKey(command.Name))
{
throw new InvalidOperationException("Command '" + command.Name + "' is already registered.");
}
_commands[command.Name] = command;
}
public void ExecuteCommand(string commandName, string args)
{
if (_commands.TryGetValue(commandName, out var value))
{
value.Execute(args);
return;
}
throw new KeyNotFoundException("Command '" + commandName + "' not found.");
}
}
public interface ICommand
{
string Name { get; }
void Execute(string args);
}
}
namespace HitMarker.Console.Commands.Give
{
public class GiveCommand : ICommand
{
public string Name => "give";
public string Description => "Spawns a craftable item by its index. Usage: givecraftable <index>";
public void Execute(string args)
{
if (args == null || args.Equals(""))
{
LoggerUtils.LogDebug("GiveCraftableCommand", "Usage: givecraftable <index>");
return;
}
ModSpawnHelper.SpawnItem(args);
LoggerUtils.LogDebug("GiveCraftableCommand", $"Item with index {args[0]} spawned successfully.");
}
}
public static class ModSpawnHelper
{
public static void SpawnItem(string itemId)
{
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
NetworkManager val = NetworkManager.Instances.FirstOrDefault();
if ((Object)(object)val == (Object)null || !val.IsHostStarted)
{
LoggerUtils.LogError("SpawnItem", "Failed to spawn item: Not running as host.");
return;
}
CraftingForge[] array = Object.FindObjectsOfType<CraftingForge>();
GameObject val2 = null;
CraftingForge val3 = null;
if (!int.TryParse(itemId, out var result))
{
LoggerUtils.LogError("SpawnItem", "Item id '" + itemId + "' non valido.");
return;
}
CraftingForge[] array2 = array;
foreach (CraftingForge val4 in array2)
{
if (result >= 0 && result < val4.CraftablePrefabs.Length)
{
val2 = val4.CraftablePrefabs[result];
if ((Object)(object)val2 != (Object)null)
{
val3 = val4;
break;
}
}
}
if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null)
{
LoggerUtils.LogError("SpawnItem", "Item '" + itemId + "' non trovato.");
return;
}
GameObject val5 = GameObject.FindWithTag("Player");
Vector3 val6 = (((Object)(object)val5 != (Object)null) ? (val5.transform.position + val5.transform.forward * 2f) : (((Object)(object)val3.itemSpawnPoint != (Object)null) ? val3.itemSpawnPoint.position : Vector3.zero));
GameObject val7 = Object.Instantiate<GameObject>(val2, val6, Quaternion.identity);
((NetworkBehaviour)val3).ServerManager.Spawn(val7, (NetworkConnection)null, default(Scene));
LoggerUtils.LogDebug("SpawnItem", "Item '" + itemId + "' spawnato con successo.");
}
}
}
namespace HitMarker.API
{
public static class HitMarkerAPI
{
private static bool _isInitialized;
public static bool IsAvailable
{
get
{
if ((Object)(object)Mod.Instance != (Object)null)
{
return Mod.Instance.HitMarkerManager?.IsInitialized ?? false;
}
return false;
}
}
public static string Version => "0.1.4";
public static bool ShowHitmarker()
{
if (!IsAvailable)
{
LoggerUtils.LogDebug("HitMarkerAPI", "Hitmarker system not available");
return false;
}
try
{
Mod.Instance.ShowHitmarkerInstance();
return true;
}
catch (Exception ex)
{
LoggerUtils.LogError("HitMarkerAPI", "Failed to show hitmarker: " + ex.Message);
return false;
}
}
public static bool IsLocalPlayerOwner(GameObject gameObject)
{
return NetworkUtils.IsLocalPlayerOwner(gameObject);
}
}
}