Decompiled source of ExtraWeaponCustomization v4.2.1
ExtraWeaponCustomization.dll
Decompiled a week ago
            The result has been truncated due to the large size, download it to view full contents!
        
        
        using System; using System.Collections; using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Numerics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using System.Text.Json.Serialization; using AIGraph; using AK; using AccurateCrosshair.API; using Agents; using AmorLib.Utils; using AssetShards; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP.Hook; using BepInEx.Unity.IL2CPP.Utils.Collections; using CharacterDestruction; using CullingSystem; using DamSync; using EWC.API; using EWC.Attributes; using EWC.CustomWeapon; using EWC.CustomWeapon.ComponentWrapper; using EWC.CustomWeapon.ComponentWrapper.OwnerComps; using EWC.CustomWeapon.ComponentWrapper.WeaponComps; using EWC.CustomWeapon.CustomShot; using EWC.CustomWeapon.Enums; using EWC.CustomWeapon.HitTracker; using EWC.CustomWeapon.ObjectWrappers; using EWC.CustomWeapon.Properties; using EWC.CustomWeapon.Properties.Effects; using EWC.CustomWeapon.Properties.Effects.Debuff; using EWC.CustomWeapon.Properties.Effects.Heal; using EWC.CustomWeapon.Properties.Effects.Hit.CustomFoam; using EWC.CustomWeapon.Properties.Effects.Hit.DOT; using EWC.CustomWeapon.Properties.Effects.Hit.DOT.DOTGlowFX; using EWC.CustomWeapon.Properties.Effects.Hit.Explosion; using EWC.CustomWeapon.Properties.Effects.Hit.Explosion.EEC_ExplosionFX; using EWC.CustomWeapon.Properties.Effects.Hit.Explosion.EEC_ExplosionFX.Handlers; using EWC.CustomWeapon.Properties.Effects.ShrapnelHit; using EWC.CustomWeapon.Properties.Effects.Spread; using EWC.CustomWeapon.Properties.Effects.Triggers; using EWC.CustomWeapon.Properties.Traits; using EWC.CustomWeapon.Properties.Traits.CustomProjectile; using EWC.CustomWeapon.Properties.Traits.CustomProjectile.Components; using EWC.CustomWeapon.Properties.Traits.CustomProjectile.Managers; using EWC.CustomWeapon.Structs; using EWC.CustomWeapon.WeaponContext; using EWC.CustomWeapon.WeaponContext.Attributes; using EWC.CustomWeapon.WeaponContext.Contexts; using EWC.CustomWeapon.WeaponContext.Contexts.Base; using EWC.Dependencies; using EWC.JSON; using EWC.JSON.Converters; using EWC.Networking; using EWC.Patches.Enemy; using EWC.Patches.Gun; using EWC.Patches.Melee; using EWC.Patches.SNet; using EWC.Utils; using EWC.Utils.Extensions; using EWC.Utils.Structs; using EndskApi.Api; using EndskApi.Enums.EnemyKill; using EndskApi.Information.EnemyKill; using Enemies; using ExtraRecoilData.API; using ExtraToolCustomization.ToolData; using FX_EffectSystem; using FirstPersonItem; using GTFO.API; using GTFO.API.JSON.Converters; using GTFO.API.Utilities; using GTFuckingXP.Extensions; using GTFuckingXP.Information.Level; using GameData; using GameEvent; using Gear; using Globals; using HarmonyLib; using Il2CppInterop.Runtime.Attributes; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppInterop.Runtime.Runtime; using Il2CppSystem; using Il2CppSystem.Collections; using Il2CppSystem.Collections.Generic; using KillIndicatorFix; using LevelGeneration; using MSC.CustomMeleeData; using MTFO.API; using Microsoft.CodeAnalysis; using MovementSpeedAPI; using Player; using SNetwork; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("ExtraWeaponCustomization")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+f592ec929de2074dedaf4c86ac020479114afc74")] [assembly: AssemblyProduct("ExtraWeaponCustomization")] [assembly: AssemblyTitle("ExtraWeaponCustomization")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace EWC { internal static class Configuration { private static readonly ConfigEntry<bool> _showExplosionEffect; private static readonly ConfigEntry<bool> _playExplosionSFX; private static readonly ConfigEntry<float> _explosionSFXCooldown; private static readonly ConfigEntry<int> _explosionSFXShotOverride; private static readonly ConfigEntry<bool> _playExplosionShake; private static readonly ConfigEntry<float> _autoAimTickDelay; private static readonly ConfigEntry<float> _homingTickDelay; private static readonly ConfigFile configFile; private static ConfigEntry<bool> ForceCreateTemplate { get; set; } public static bool ShowExplosionEffect => _showExplosionEffect.Value; public static bool PlayExplosionSFX => _playExplosionSFX.Value; public static float ExplosionSFXCooldown => _explosionSFXCooldown.Value; public static int ExplosionSFXShotOverride => _explosionSFXShotOverride.Value; public static bool PlayExplosionShake => _playExplosionShake.Value; public static float AutoAimTickDelay => _autoAimTickDelay.Value; public static float HomingTickDelay => _homingTickDelay.Value; static Configuration() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "ExtraWeaponCustomization.cfg"), true); string text = "Auto Aim Settings"; _autoAimTickDelay = configFile.Bind<float>(text, "Search Cooldown", 0.1f, "Time between attempted searches to acquire targets."); text = "Explosion Settings"; _showExplosionEffect = configFile.Bind<bool>(text, "Show Effect", true, "Enables explosion visual FX."); _playExplosionSFX = configFile.Bind<bool>(text, "Play Sound", true, "Enables explosion sound FX."); _explosionSFXCooldown = configFile.Bind<float>(text, "SFX Cooldown", 0.08f, "Minimum time between explosion sound effects, to prevent obnoxiously loud sounds."); _explosionSFXShotOverride = configFile.Bind<int>(text, "Shots to Override SFX Cooldown", 8, "Amount of shots fired before another explosion sound effect is forced, regardless of cooldown.\nSmaller numbers let fast-firing weapons and shotguns make more sounds in a short span of time."); _playExplosionShake = configFile.Bind<bool>(text, "Play Screen Shake", true, "Enables explosion screen shake. Doesn't bypass the global screen shake settings modifier."); text = "Projectile Settings"; _homingTickDelay = configFile.Bind<float>(text, "Homing Search Cooldown", 0.1f, "Minimum time between attempted searches to acquire a new target."); text = "Tools"; ForceCreateTemplate = configFile.Bind<bool>(text, "Force Create Template", false, "Creates the template file again."); CheckAndRefreshTemplate(); } [InvokeOnLoad] private static void Init() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown LiveEdit.CreateListener(Paths.ConfigPath, "ExtraWeaponCustomization.cfg", false).FileChanged += new LiveEditEventHandler(OnFileChanged); } private static void OnFileChanged(LiveEditEventArgs _) { configFile.Reload(); CheckAndRefreshTemplate(); } private static void CheckAndRefreshTemplate() { if (ForceCreateTemplate.Value) { ForceCreateTemplate.Value = false; CustomDataManager.Current.CreateTemplate(); configFile.Save(); } } } [BepInPlugin("Dinorush.ExtraWeaponCustomization", "ExtraWeaponCustomization", "4.2.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal sealed class EntryPoint : BasePlugin { public const string MODNAME = "ExtraWeaponCustomization"; private IEnumerable<MethodInfo> _cleanupCallbacks; private IEnumerable<MethodInfo> _checkpointCleanupCallbacks; private IEnumerable<MethodInfo> _checkpointCallbacks; private IEnumerable<MethodInfo> _enterCallbacks; private IEnumerable<MethodInfo> _buildDoneCallbacks; public static bool Loaded { get; private set; } public override void Load() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (!MTFOAPIWrapper.HasCustomContent) { EWCLogger.Error("No MTFO datablocks detected. Not loading EWC..."); return; } Loaded = true; new Harmony("ExtraWeaponCustomization").PatchAll(); CacheFrequentCallbacks(); InvokeCallbacks<InvokeOnLoadAttribute>(); SyncManagerPatches.OnCheckpointReload += RunFrequentCallback(_checkpointCleanupCallbacks); SyncManagerPatches.OnCheckpointReload += RunFrequentCallback(_checkpointCallbacks); LevelAPI.OnLevelCleanup += RunFrequentCallback(_cleanupCallbacks); LevelAPI.OnEnterLevel += RunFrequentCallback(_enterCallbacks); LevelAPI.OnBuildDone += RunFrequentCallback(_buildDoneCallbacks); AssetAPI.OnStartupAssetsLoaded += AssetAPI_OnStartupAssetsLoaded; EWCLogger.Log("Loaded ExtraWeaponCustomization"); } private static Action RunFrequentCallback(IEnumerable<MethodInfo> callbacks) { IEnumerable<MethodInfo> callbacks2 = callbacks; return delegate { foreach (MethodInfo item in callbacks2) { item.Invoke(null, null); } }; } private void AssetAPI_OnStartupAssetsLoaded() { InvokeCallbacks<InvokeOnAssetLoadAttribute>(); RuntimeHelpers.RunClassConstructor(typeof(CustomDataManager).TypeHandle); } private void CacheFrequentCallbacks() { IEnumerable<MethodInfo> source = from method in ((IEnumerable<Type>)AccessTools.GetTypesFromAssembly(((object)this).GetType().Assembly)).SelectMany((Func<Type, IEnumerable<MethodInfo>>)AccessTools.GetDeclaredMethods) where method.IsStatic select method; var source2 = from method in source let attr = method.GetCustomAttribute<InvokeOnCleanupAttribute>() where attr != null select new { Method = method, Attribute = attr }; _cleanupCallbacks = source2.Select(pair => pair.Method); _checkpointCleanupCallbacks = from pair in source2 where pair.Attribute.OnCheckpoint select pair.Method; _checkpointCallbacks = source.Where((MethodInfo method) => method.GetCustomAttribute<InvokeOnCheckpointAttribute>() != null); _enterCallbacks = source.Where((MethodInfo method) => method.GetCustomAttribute<InvokeOnEnterAttribute>() != null); _buildDoneCallbacks = source.Where((MethodInfo method) => method.GetCustomAttribute<InvokeOnBuildDoneAttribute>() != null); } private void InvokeCallbacks<T>() where T : Attribute { foreach (MethodInfo item in from method in ((IEnumerable<Type>)AccessTools.GetTypesFromAssembly(((object)this).GetType().Assembly)).SelectMany((Func<Type, IEnumerable<MethodInfo>>)AccessTools.GetDeclaredMethods) where method.GetCustomAttribute<T>() != null where method.IsStatic select method) { item.Invoke(null, null); } } } internal static class EWCLogger { private static ManualLogSource logger = Logger.CreateLogSource("ExtraWeaponCustomization"); public static void Log(string format, params object[] args) { Log(string.Format(format, args)); } public static void Log(string str) { if (logger != null) { logger.Log((LogLevel)8, (object)str); } } public static void Warning(string format, params object[] args) { Warning(string.Format(format, args)); } public static void Warning(string str) { if (logger != null) { logger.Log((LogLevel)4, (object)str); } } public static void Error(string format, params object[] args) { Error(string.Format(format, args)); } public static void Error(string str) { if (logger != null) { logger.Log((LogLevel)2, (object)str); } } public static void Debug(string format, params object[] args) { Debug(string.Format(format, args)); } public static void Debug(string str) { if (logger != null) { logger.Log((LogLevel)32, (object)str); } } } } namespace EWC.Utils { public static class CopyUtil<T> where T : notnull { private static readonly Dictionary<Type, List<PropertyInfo>> _classProperties = new Dictionary<Type, List<PropertyInfo>>(); public static T Clone(T obj, params object?[]? args) { Type type = obj.GetType(); if (!_classProperties.ContainsKey(type)) { List<PropertyInfo> list = new List<PropertyInfo>(); _classProperties.Add(type, list); Type type2 = type; while (type2.BaseType != null) { PropertyInfo[] properties = type2.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo propertyInfo in properties) { MethodInfo? getMethod = propertyInfo.GetGetMethod(nonPublic: false); MethodInfo setMethod = propertyInfo.GetSetMethod(nonPublic: true); if (!(getMethod == null) && !(setMethod == null) && !setMethod.IsPublic && propertyInfo.CanWrite) { list.Add(propertyInfo); } } type2 = type2.BaseType; } if (type.IsAssignableTo(typeof(ISyncProperty))) { list.Add(type.GetProperty("SyncPropertyID")); } } T val = (T)Activator.CreateInstance(type, args); foreach (PropertyInfo item in _classProperties[type]) { item.SetValue(val, item.GetValue(obj)); } return val; } } internal static class CoroutineUtil { public static bool Stop(ref Coroutine? routine, MonoBehaviour? parent = null) { if (routine != null) { if ((Object)(object)parent == (Object)null) { CoroutineManager.StopCoroutine(routine); } else { parent.StopCoroutine(routine); } routine = null; return true; } return false; } } internal static class DamageableUtil { private static IntPtr _cachedExpedition = default(IntPtr); private static float _cachedHealth = 15f; public static float LockHealth { get { if (RundownManager.ActiveExpedition != null && ((Il2CppObjectBase)RundownManager.ActiveExpedition).Pointer != _cachedExpedition) { _cachedExpedition = ((Il2CppObjectBase)RundownManager.ActiveExpedition).Pointer; _cachedHealth = RundownManager.ActiveExpeditionBalanceData.WeakDoorLockHealth; } return _cachedHealth; } } public static IDamageable? GetDamageableFromRayHit(RaycastHit rayHit) { if (!((Object)(object)((RaycastHit)(ref rayHit)).collider == (Object)null)) { return GetDamageableFromCollider(((RaycastHit)(ref rayHit)).collider); } return null; } public static IDamageable? GetDamageableFromCollider(Collider? collider) { if (!((Object)(object)collider == (Object)null)) { return GetDamageableFromGO(((Component)collider).gameObject); } return null; } public static IDamageable? GetDamageableFromGO(GameObject? go) { if ((Object)(object)go == (Object)null) { return null; } ColliderMaterial component = go.GetComponent<ColliderMaterial>(); IDamageable val = ((component != null) ? component.Damageable : null); if (val != null) { return val; } return go.GetComponent<IDamageable>(); } public static bool IsValid([NotNullWhen(true)] this IDamageable? damageable) { if (damageable == null) { return false; } if (!((Object)(object)damageable.GetBaseAgent() != (Object)null)) { return (Object)(object)((Il2CppObjectBase)damageable).TryCast<LG_WeakLockDamage>() != (Object)null; } return true; } public static bool IsEnemy([NotNullWhen(true)] this IDamageable? damageable) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 if (damageable == null) { return false; } Agent baseAgent = damageable.GetBaseAgent(); if ((Object)(object)baseAgent != (Object)null && baseAgent.Alive) { return (int)baseAgent.Type == 1; } return false; } } public sealed class DelayedCallback { [CompilerGenerated] private sealed class <Update>d__16 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public DelayedCallback <>4__this; object? IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object? IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Update>d__16(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown int num = <>1__state; DelayedCallback delayedCallback = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; delayedCallback._onStart?.Invoke(); break; case 1: <>1__state = -1; break; } if (delayedCallback._endTime > Clock.Time) { <>2__current = (object)new WaitForSeconds(delayedCallback._endTime - Clock.Time); <>1__state = 1; return true; } delayedCallback._routine = null; delayedCallback._onEnd?.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 readonly float _delay; private readonly Func<float>? _getDelay; private readonly Action? _onStart; private readonly Action? _onRefresh; private readonly Action? _onEnd; private float _endTime; private Coroutine? _routine; public bool Active { get { if (_endTime > Clock.Time) { return _routine != null; } return false; } } public DelayedCallback(Func<float> getDelay, Action? onEnd) : this(getDelay, null, null, onEnd) { } public DelayedCallback(Func<float> getDelay, Action? onStart, Action? onEnd) : this(getDelay, onStart, null, onEnd) { } public DelayedCallback(Func<float> getDelay, Action? onStart, Action? onRefresh, Action? onEnd) { _getDelay = getDelay; _onStart = onStart; _onRefresh = onRefresh; _onEnd = onEnd; } public DelayedCallback(float delay, Action? onEnd) : this(delay, null, null, onEnd) { } public DelayedCallback(float delay, Action? onStart, Action? onEnd) : this(delay, onStart, null, onEnd) { } public DelayedCallback(float delay, Action? onStart, Action? onRefresh, Action? onEnd) { _delay = delay; _onStart = onStart; _onRefresh = onRefresh; _onEnd = onEnd; } public void Start(bool checkEnd = false, bool refresh = true) { bool active = Active; if (!(!refresh && active)) { _endTime = Clock.Time + (_getDelay?.Invoke() ?? _delay); if (checkEnd && !active && _routine != null) { _onEnd?.Invoke(); _onStart?.Invoke(); } else if (_routine == null) { _routine = CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(Update()), (Action)null); } else { _onRefresh?.Invoke(); } } } [IteratorStateMachine(typeof(<Update>d__16))] public IEnumerator Update() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Update>d__16(0) { <>4__this = this }; } public void Stop() { if (CoroutineUtil.Stop(ref _routine)) { _onEnd?.Invoke(); } } public void Cancel() { CoroutineUtil.Stop(ref _routine); } public bool CheckEnd() { if (_routine == null) { return true; } if (!Active && CoroutineUtil.Stop(ref _routine)) { _onEnd?.Invoke(); return true; } return false; } } public sealed class HitData { public float damage; public Vector2 damageFalloff; public float falloff = 1f; public float precisionMulti; public float staggerMulti; public float maxRayDist; public float randomSpread; public float angOffsetX; public float angOffsetY; public PlayerAgent owner; public Vector3 fireDir; public Vector3 hitPos; public IDamageable? damageable; public GameObject? gameObject; private RaycastHit _rayHit; public ShotInfo shotInfo; private readonly DamageType _baseDamageType; public DamageType damageType; private WeaponHitData? _weaponHitData; private MeleeWeaponFirstPerson? _meleeWeapon; public RaycastHit RayHit { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _rayHit; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) _rayHit = value; hitPos = ((RaycastHit)(ref _rayHit)).point; gameObject = (((Object)(object)((RaycastHit)(ref _rayHit)).collider != (Object)null) ? ((Component)((RaycastHit)(ref _rayHit)).collider).gameObject : null); damageable = DamageableUtil.GetDamageableFromRayHit(_rayHit); UpdateDamageType(); } } public HitData(WeaponHitData hitData, float additionalDist = 0f) : this(DamageType.Bullet) { Setup(hitData, additionalDist); } public HitData(MeleeWeaponFirstPerson melee, MeleeWeaponDamageData hitData) : this(DamageType.Bullet) { Setup(melee, hitData); } public HitData(HitData data) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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) _weaponHitData = data._weaponHitData; _meleeWeapon = data._meleeWeapon; shotInfo = data.shotInfo; damage = data.damage; falloff = data.falloff; damageFalloff = data.damageFalloff; precisionMulti = data.precisionMulti; staggerMulti = data.staggerMulti; randomSpread = data.randomSpread; angOffsetX = data.angOffsetX; angOffsetY = data.angOffsetY; owner = data.owner; fireDir = data.fireDir; maxRayDist = data.maxRayDist; _rayHit = data._rayHit; hitPos = data.hitPos; damageable = data.damageable; gameObject = data.gameObject; damageType = data.damageType; _baseDamageType = data._baseDamageType; } public HitData(DamageType baseDamageType) { _baseDamageType = baseDamageType; shotInfo = new ShotInfo(); } public void Setup(WeaponHitData hitData, float additionalDist = 0f) { //IL_0022: 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_005e: 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_0076: Unknown result type (might be due to invalid IL or missing references) _weaponHitData = hitData; _meleeWeapon = null; shotInfo = ShotManager.GetVanillaShotInfo(hitData); ResetDamage(); damageFalloff = hitData.damageFalloff; randomSpread = hitData.randomSpread; angOffsetX = hitData.angOffsetX; angOffsetY = hitData.angOffsetY; owner = hitData.owner; fireDir = hitData.fireDir; maxRayDist = hitData.maxRayDist; RayHit = hitData.rayHit; falloff = CalcFalloff(additionalDist); } public void Setup(MeleeWeaponFirstPerson melee, MeleeWeaponDamageData hitData) { //IL_0021: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) _weaponHitData = null; _meleeWeapon = melee; ResetDamage(); falloff = 1f; Vector3 val = hitData.hitPos - hitData.sourcePos; fireDir = ((Vector3)(ref val)).normalized; hitPos = hitData.hitPos; damageable = hitData.damageComp ?? hitData.damageGO.GetComponent<IDamageable>(); gameObject = hitData.damageGO; UpdateDamageType(); } public void Apply() { if (_weaponHitData != null) { Apply(_weaponHitData); } else if ((Object)(object)_meleeWeapon != (Object)null) { Apply(_meleeWeapon); } } public WeaponHitData Apply(WeaponHitData hitData) { //IL_001a: 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_006e: Unknown result type (might be due to invalid IL or missing references) hitData.owner = owner; hitData.damage = damage; hitData.damageFalloff = damageFalloff; hitData.precisionMulti = precisionMulti; hitData.staggerMulti = staggerMulti; hitData.randomSpread = randomSpread; hitData.angOffsetX = angOffsetX; hitData.angOffsetY = angOffsetY; hitData.rayHit = RayHit; hitData.fireDir = fireDir; hitData.maxRayDist = maxRayDist; return hitData; } public MeleeWeaponFirstPerson Apply(MeleeWeaponFirstPerson melee) { melee.m_damageToDeal = damage; melee.m_precisionMultiToDeal = precisionMulti; melee.m_staggerMultiToDeal = staggerMulti; return melee; } public void ResetDamage() { damage = shotInfo.OrigDamage; precisionMulti = shotInfo.OrigPrecision; staggerMulti = shotInfo.OrigStagger; } public float CalcRawFalloff(float distance) { return Math.Max(distance.Map(damageFalloff.x, damageFalloff.y, 1f, 0f), BulletWeapon.s_falloffMin); } public float CalcFalloff(float additionalDist = 0f) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) RaycastHit rayHit = RayHit; return CalcRawFalloff(((RaycastHit)(ref rayHit)).distance + additionalDist); } private void UpdateDamageType() { if ((Object)(object)gameObject != (Object)null) { damageType = ((damageable != null) ? _baseDamageType.WithSubTypes(damageable) : (_baseDamageType | DamageType.Terrain)); } else { damageType = _baseDamageType | DamageType.Dead; } } public WeaponHitData ToWeaponHitData() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0073: 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_008a: Expected O, but got Unknown return new WeaponHitData { damage = damage, damageFalloff = damageFalloff, precisionMulti = precisionMulti, staggerMulti = staggerMulti, randomSpread = randomSpread, angOffsetX = angOffsetX, angOffsetY = angOffsetY, owner = owner, rayHit = RayHit, fireDir = fireDir, maxRayDist = maxRayDist }; } } public static class LayerUtil { public static int MaskDynamic { get; private set; } public static int MaskEntityAndWorld { get; private set; } public static int MaskEntityAndWorld3P { get; private set; } public static int MaskWorld { get; private set; } public static int MaskWorldExcProj { get; private set; } public static int MaskDecalValid { get; private set; } public static int MaskEntityDynamic3P { get; private set; } public static int MaskEntity { get; private set; } public static int MaskEntity3P { get; private set; } public static int MaskOwner { get; private set; } public static int MaskFriendly { get; private set; } public static int MaskEnemy { get; private set; } public static int MaskEnemyDynamic { get; private set; } [InvokeOnAssetLoad] private static void Init() { MaskOwner = LayerMask.GetMask(new string[1] { "PlayerMover" }); MaskFriendly = LayerMask.GetMask(new string[1] { "PlayerSynced" }); MaskEnemy = LayerMask.GetMask(new string[1] { "EnemyDamagable" }); MaskDynamic = LayerMask.GetMask(new string[1] { "Dynamic" }); MaskEnemyDynamic = MaskEnemy | MaskDynamic; MaskEntity3P = MaskFriendly | MaskEnemy; MaskEntity = MaskOwner | MaskEntity3P; MaskDecalValid = LayerMask.GetMask(new string[3] { "Default", "Default_NoGraph", "Default_BlockGraph" }); MaskWorldExcProj = MaskDecalValid | MaskDynamic; MaskWorld = MaskWorldExcProj | LayerMask.GetMask(new string[1] { "ProjectileBlocker" }); MaskEntityAndWorld = MaskEntity | MaskWorld; MaskEntityDynamic3P = MaskEntity3P | MaskDynamic; MaskEntityAndWorld3P = MaskEntity3P | MaskWorld; } } [Flags] internal enum SearchSetting { None = 0, Alloc = 1, ClosestHit = 2, CheckLOS = 4, CheckDoors = 8, CheckOwner = 0x10, CheckFriendly = 0x20, IgnoreDupes = 0x40 } internal static class SearchUtil { private static readonly List<EnemyAgent> s_enemyCache = new List<EnemyAgent>(); private static readonly List<(EnemyAgent, RaycastHit)> s_combinedCache = new List<(EnemyAgent, RaycastHit)>(); private static readonly List<(PlayerAgent, RaycastHit)> s_combinedCachePlayer = new List<(PlayerAgent, RaycastHit)>(); private static readonly Queue<AIG_CourseNode> s_nodeQueue = new Queue<AIG_CourseNode>(); private static readonly List<RaycastHit> s_rayHitCache = new List<RaycastHit>(); public static HashSet<IntPtr>? DupeCheckSet; public static int SightBlockLayer = 0; public const float WeakspotBufferDist = 0.1f; private static Ray s_ray; private static RaycastHit s_rayHit; private const float Epsilon = 1E-05f; private static Vector3 ClosestPointOnBounds(Bounds bounds, Vector3 point) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) return new Vector3(Math.Clamp(point.x, ((Bounds)(ref bounds)).min.x, ((Bounds)(ref bounds)).max.x), Math.Clamp(point.y, ((Bounds)(ref bounds)).min.y, ((Bounds)(ref bounds)).max.y), Math.Clamp(point.z, ((Bounds)(ref bounds)).min.z, ((Bounds)(ref bounds)).max.z)); } private static int GetMaxSteps(float dist) { if (!(dist <= 0.5f)) { return (int)Math.Ceiling(Math.Max(3.0, 2.0 * Math.Log2(dist))); } return 1; } private static float GetStepDist(float dist, int step, int maxSteps) { if (maxSteps != 1) { return dist * (float)step / (float)(maxSteps - 1); } return dist / 2f; } private static bool BoundsInRange(Ray il2Ray, float range, float angle, Bounds il2Bounds) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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) float num = range * range; Vector3 vector = new Vector3(((Ray)(ref il2Ray)).origin.x, ((Ray)(ref il2Ray)).origin.y, ((Ray)(ref il2Ray)).origin.z); Vector3 vector2 = new Vector3(((Ray)(ref il2Ray)).direction.x, ((Ray)(ref il2Ray)).direction.y, ((Ray)(ref il2Ray)).direction.z); SBounds sBounds = il2Bounds; Vector3 vector3 = sBounds.ClosestPoint(vector) - vector; if (vector3.LengthSquared() >= num) { return false; } if (angle >= 180f || sBounds.Contains(vector)) { return true; } if (angle <= 90f) { vector3 = sBounds.center - vector; float num2 = Vector3.Dot(vector2, vector3); if (num2 < 0f) { float num3 = sBounds.extents.X * Math.Abs(vector2.X) + sBounds.extents.Y * Math.Abs(vector2.Y) + sBounds.extents.Z * Math.Abs(vector2.Z); if (num2 + num3 < 0f) { return false; } } } float num4 = default(float); if (((Bounds)(ref il2Bounds)).IntersectRay(il2Ray, ref num4) && num4 < range) { return true; } float num5 = (float)Math.Cos((double)angle * Math.PI / 180.0); Span<float> span = stackalloc float[3] { sBounds.min.X, sBounds.min.Y, sBounds.min.Z }; Span<float> span2 = stackalloc float[3] { sBounds.size.X, sBounds.size.Y, sBounds.size.Z }; Span<int> span3 = stackalloc int[3] { GetMaxSteps(span2[0]), GetMaxSteps(span2[1]), GetMaxSteps(span2[2]) }; Span<int> span4 = stackalloc int[3] { Math.Min(span3[0], 2), Math.Min(span3[1], 2), Math.Min(span3[2], 2) }; Span<float> span5 = stackalloc float[3]; for (int i = 0; i < span4[0]; i++) { span5[0] = span[0] + GetStepDist(span2[0], i, span4[0]); for (int j = 0; j < span4[1]; j++) { span5[1] = span[1] + GetStepDist(span2[1], j, span4[1]); for (int k = 0; k < span4[2]; k++) { span5[2] = span[2] + GetStepDist(span2[2], k, span4[2]); vector3.X = span5[0] - vector.X; vector3.Y = span5[1] - vector.Y; vector3.Z = span5[2] - vector.Z; if (vector3.LengthSquared() < num && Vector3.Dot(vector2, Vector3.Normalize(vector3)) >= num5) { return true; } } } } for (int l = 0; l < 3; l++) { int index = (l + 1) % 3; int index2 = (l + 2) % 3; for (int m = 1; m < span3[l] - 1; m++) { span5[l] = span[l] + GetStepDist(span2[l], m, span3[l]); for (int n = 0; n < span4[index]; n++) { span5[index] = span[index] + GetStepDist(span2[index], n, span4[index]); for (int num6 = 0; num6 < span4[index2]; num6++) { span5[index2] = span[index2] + GetStepDist(span2[index2], num6, span4[index2]); vector3.X = span5[0] - vector.X; vector3.Y = span5[1] - vector.Y; vector3.Z = span5[2] - vector.Z; if (vector3.LengthSquared() < num && Vector3.Dot(vector2, Vector3.Normalize(vector3)) >= num5) { return true; } } } } } return false; } private static bool RaycastEnsured(Collider collider, float range, out RaycastHit hit) { //IL_0001: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_0113: Unknown result type (might be due to invalid IL or missing references) if (collider.Raycast(s_ray, ref hit, range)) { return true; } ((Ray)(ref s_ray)).origin = ((Ray)(ref s_ray)).GetPoint(-5f); if (collider.Raycast(s_ray, ref hit, 5f)) { return true; } Vector3 direction = ((Ray)(ref s_ray)).direction; Bounds bounds = collider.bounds; ((Ray)(ref s_ray)).direction = ((Bounds)(ref bounds)).center - ((Ray)(ref s_ray)).origin; if (collider.Raycast(s_ray, ref hit, 10f)) { return true; } DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(101, 5); defaultInterpolatedStringHandler.AppendLiteral("Attempted to get a raycast to "); defaultInterpolatedStringHandler.AppendFormatted(((Object)collider).name); defaultInterpolatedStringHandler.AppendLiteral(" but failed! Pos: "); defaultInterpolatedStringHandler.AppendFormatted<Vector3>(((Ray)(ref s_ray)).origin); defaultInterpolatedStringHandler.AppendLiteral(", Dir: "); defaultInterpolatedStringHandler.AppendFormatted(CustomExtensions.ToDetailedString(direction)); defaultInterpolatedStringHandler.AppendLiteral(", Collider center: "); bounds = collider.bounds; defaultInterpolatedStringHandler.AppendFormatted<Vector3>(((Bounds)(ref bounds)).center); defaultInterpolatedStringHandler.AppendLiteral(", Diff to collider center: "); defaultInterpolatedStringHandler.AppendFormatted(CustomExtensions.ToDetailedString(((Ray)(ref s_ray)).direction)); EWCLogger.Warning(defaultInterpolatedStringHandler.ToStringAndClear()); return false; } private static List<Collider> GetValidColliders(Ray ray, float range, float angle, Agent agent) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Il2CppArrayBase<Collider> componentsInChildren = ((Component)agent).GetComponentsInChildren<Collider>(); List<Collider> list = new List<Collider>(componentsInChildren.Length); foreach (Collider item in componentsInChildren) { if (((Component)item).GetComponent<IDamageable>() != null && item.enabled && BoundsInRange(ray, range, angle, item.bounds)) { list.Add(item); } } return list; } public static bool IsAgentInCone(Ray ray, float range, float angle, Agent agent, out RaycastHit hit, SearchSetting settings = SearchSetting.None) { //IL_0002: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Invalid comparison between Unknown and I4 //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Invalid comparison between Unknown and I4 //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) hit = default(RaycastHit); if ((Object)(object)agent == (Object)null || !agent.Alive) { return false; } if (settings.HasFlag(SearchSetting.IgnoreDupes)) { if ((int)agent.Type == 1) { HashSet<IntPtr>? dupeCheckSet = DupeCheckSet; if (dupeCheckSet != null && dupeCheckSet.Contains(((Il2CppObjectBase)((Il2CppObjectBase)agent).Cast<EnemyAgent>().Damage).Pointer)) { return false; } } if ((int)agent.Type == 0) { HashSet<IntPtr>? dupeCheckSet2 = DupeCheckSet; if (dupeCheckSet2 != null && dupeCheckSet2.Contains(((Il2CppObjectBase)((Il2CppObjectBase)agent).Cast<PlayerAgent>().Damage).Pointer)) { return false; } } } List<Collider> validColliders = GetValidColliders(ray, range, angle, agent); if (validColliders.Count == 0) { return false; } ((Ray)(ref s_ray)).origin = ((Ray)(ref ray)).origin; float num = range * range; float num2 = num; Collider val = null; bool flag = false; AgentType type = agent.Type; foreach (Collider item in validColliders) { Vector3 val2 = item.ClosestPoint(((Ray)(ref ray)).origin); Vector3 direction = val2 - ((Ray)(ref ray)).origin; float num3 = ((Vector3)(ref direction)).sqrMagnitude; float num4 = num3; if (settings.HasFlag(SearchSetting.ClosestHit) && (int)type == 1 && num3 < num && (int)((Component)item).GetComponent<Dam_EnemyDamageLimb>().m_type == 1) { float num5 = Math.Max(((Vector3)(ref direction)).magnitude - 0.1f, 0f); num3 = num5 * num5; } if (!(num3 < num2) || (settings.HasFlag(SearchSetting.CheckLOS) && Physics.Linecast(((Ray)(ref ray)).origin, val2, SightBlockLayer))) { continue; } num2 = num3; val = item; if (!settings.HasFlag(SearchSetting.ClosestHit)) { break; } ((Ray)(ref s_ray)).direction = direction; if (!(num2 < 1E-05f)) { continue; } if (!(num4 > 1E-05f)) { ((Ray)(ref s_ray)).origin = ((Ray)(ref s_ray)).origin - ((Ray)(ref ray)).direction * Math.Min(0.1f, range / 2f); ((Ray)(ref s_ray)).direction = val2 - ((Ray)(ref s_ray)).origin; if (RaycastEnsured(item, range, out hit)) { ((RaycastHit)(ref hit)).point = val2; ((RaycastHit)(ref hit)).distance = 0f; flag = true; } else { val = null; } } break; } if ((Object)(object)val == (Object)null) { return false; } if (settings.HasFlag(SearchSetting.ClosestHit) && !flag && !RaycastEnsured(val, range, out hit)) { return false; } return true; } private static void CacheEnemiesInRange(Ray ray, float range, float angle, AIG_CourseNode origin, SearchSetting settings) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) AIG_SearchID.IncrementSearchID(); ushort searchID = AIG_SearchID.SearchID; s_nodeQueue.Enqueue(origin); ((AIG_CourseGraphMember)origin).m_searchID = searchID; CacheEnemiesInRangeFromQueue(ray, range, angle, settings); } private static void CacheEnemiesInRangeFromQueue(Ray ray, float range, float angle, SearchSetting settings) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_00f1: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) ushort searchID = AIG_SearchID.SearchID; float num = range * range; s_combinedCache.Clear(); AIG_CourseNode result; while (s_nodeQueue.TryDequeue(out result)) { Enumerator<AIG_CoursePortal> enumerator = result.m_portals.GetEnumerator(); while (enumerator.MoveNext()) { AIG_CoursePortal current = enumerator.Current; AIG_CourseNode oppositeNode = current.GetOppositeNode(result); if ((!settings.HasFlag(SearchSetting.CheckDoors) || current.IsTraversable) && ((AIG_CourseGraphMember)oppositeNode).m_searchID != searchID && BoundsInRange(ray, range, angle, current.m_cullPortal.m_portalBounds)) { ((AIG_CourseGraphMember)oppositeNode).m_searchID = searchID; s_nodeQueue.Enqueue(oppositeNode); } } Enumerator<EnemyAgent> enumerator2 = result.m_enemiesInNode.GetEnumerator(); while (enumerator2.MoveNext()) { EnemyAgent current2 = enumerator2.Current; if (!((Object)(object)current2 == (Object)null) && ((Agent)current2).Alive && !(((Dam_SyncedDamageBase)current2.Damage).Health <= 0f)) { Vector3 val = ClosestPointOnBounds(((C_Cullable)current2.MovingCuller.Culler).Bounds, ((Ray)(ref ray)).origin) - ((Ray)(ref ray)).origin; if (!(((Vector3)(ref val)).sqrMagnitude > num) && IsAgentInCone(ray, range, angle, (Agent)(object)current2, out s_rayHit, settings)) { s_combinedCache.Add((current2, s_rayHit)); } } } } } public static List<EnemyAgent> GetEnemiesInRange(Ray ray, float range, float angle, AIG_CourseNode origin, SearchSetting settings = SearchSetting.None) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) s_enemyCache.Clear(); if (range == 0f || angle == 0f) { if (!settings.HasFlag(SearchSetting.Alloc)) { return s_enemyCache; } return new List<EnemyAgent>(); } CacheEnemiesInRange(ray, range, angle, origin, settings); if (settings.HasFlag(SearchSetting.Alloc)) { return s_combinedCache.ConvertAll(((EnemyAgent, RaycastHit) pair) => pair.Item1); } foreach (var item2 in s_combinedCache) { EnemyAgent item = item2.Item1; s_enemyCache.Add(item); } return s_enemyCache; } public static List<(EnemyAgent enemy, RaycastHit hit)> GetEnemyHitsInRange(Ray ray, float range, float angle, AIG_CourseNode origin, SearchSetting settings = SearchSetting.ClosestHit) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (range == 0f || angle == 0f) { s_combinedCache.Clear(); if (!settings.HasFlag(SearchSetting.Alloc)) { return s_combinedCache; } return new List<(EnemyAgent, RaycastHit)>(); } settings |= SearchSetting.ClosestHit; CacheEnemiesInRange(ray, range, angle, origin, settings); if (settings.HasFlag(SearchSetting.Alloc)) { return new List<(EnemyAgent, RaycastHit)>(s_combinedCache); } return s_combinedCache; } public static List<RaycastHit> GetLockHitsInRange(Ray ray, float range, float angle, SearchSetting settings = SearchSetting.None) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) s_rayHitCache.Clear(); if (range == 0f || angle == 0f) { if (!settings.HasFlag(SearchSetting.Alloc)) { return s_rayHitCache; } return new List<RaycastHit>(); } Collider[] array = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(((Ray)(ref ray)).origin, range, LayerUtil.MaskDynamic)); Vector3 direction = ((Ray)(ref ray)).direction; Collider[] array2 = array; foreach (Collider val in array2) { IDamageable damageableFromCollider = DamageableUtil.GetDamageableFromCollider(val); if (damageableFromCollider == null) { continue; } if (settings.HasFlag(SearchSetting.IgnoreDupes)) { HashSet<IntPtr>? dupeCheckSet = DupeCheckSet; if (dupeCheckSet != null && dupeCheckSet.Contains(((Il2CppObjectBase)damageableFromCollider.GetBaseDamagable()).Pointer)) { continue; } } if (!settings.HasFlag(SearchSetting.CheckLOS) || !Physics.Linecast(((Ray)(ref ray)).origin, damageableFromCollider.DamageTargetPos, ref s_rayHit, SightBlockLayer) || !(((Il2CppObjectBase)((Component)((RaycastHit)(ref s_rayHit)).collider).gameObject).Pointer != ((Il2CppObjectBase)((Component)val).gameObject).Pointer)) { ((Ray)(ref ray)).direction = damageableFromCollider.DamageTargetPos - ((Ray)(ref ray)).origin; if (val.Raycast(ray, ref s_rayHit, range) && Vector3.Angle(((Ray)(ref ray)).direction, direction) < angle) { s_rayHitCache.Add(s_rayHit); } } } if (settings.HasFlag(SearchSetting.Alloc)) { return new List<RaycastHit>(s_rayHitCache); } return s_rayHitCache; } public static List<(PlayerAgent player, RaycastHit hit)> GetPlayerHitsInRange(Ray ray, float range, float angle, SearchSetting settings = SearchSetting.CheckOwner | SearchSetting.CheckFriendly) { //IL_0076: 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_0082: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00e6: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) s_combinedCachePlayer.Clear(); if (range == 0f || angle == 0f) { if (!settings.HasFlag(SearchSetting.Alloc)) { return s_combinedCachePlayer; } return new List<(PlayerAgent, RaycastHit)>(); } float num = range * range; Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator(); while (enumerator.MoveNext()) { PlayerAgent current = enumerator.Current; if ((Object)(object)current == (Object)null || !((Agent)current).Alive) { continue; } Vector3 val = ClosestPointOnBounds(((C_Cullable)current.m_movingCuller.Culler).Bounds, ((Ray)(ref ray)).origin) - ((Ray)(ref ray)).origin; if (((Vector3)(ref val)).sqrMagnitude > num) { continue; } if (((Agent)current).IsLocallyOwned) { if (!settings.HasFlag(SearchSetting.CheckOwner)) { continue; } ((Ray)(ref s_ray)).origin = ((Ray)(ref ray)).origin; ((Ray)(ref s_ray)).direction = ((Dam_SyncedDamageBase)current.Damage).DamageTargetPos - ((Ray)(ref ray)).origin; if (!((Component)current).GetComponent<Collider>().Raycast(s_ray, ref s_rayHit, range) || (settings.HasFlag(SearchSetting.CheckLOS) && Physics.Linecast(((Ray)(ref ray)).origin, ((RaycastHit)(ref s_rayHit)).point, SightBlockLayer))) { continue; } } else if (!settings.HasFlag(SearchSetting.CheckFriendly) || !IsAgentInCone(ray, range, angle, (Agent)(object)current, out s_rayHit, settings)) { continue; } s_combinedCachePlayer.Add((current, s_rayHit)); } if (settings.HasFlag(SearchSetting.Alloc)) { return new List<(PlayerAgent, RaycastHit)>(s_combinedCachePlayer); } return s_combinedCachePlayer; } public static List<RaycastHit> RaycastAll(Ray ray, float maxDist, int layerMask, SearchSetting settings = SearchSetting.None) { //IL_0013: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) if (settings.HasFlag(SearchSetting.CheckLOS) && Physics.Raycast(ray, ref s_rayHit, maxDist, SightBlockLayer)) { maxDist = ((RaycastHit)(ref s_rayHit)).distance; } s_rayHitCache.Clear(); DamageUtil.IncrementSearchID(); uint searchID = DamageUtil.SearchID; float num2; for (float num = 0f; Physics.Raycast(ray, ref s_rayHit, maxDist, layerMask); num += num2, ((Ray)(ref ray)).origin = ((Ray)(ref ray)).origin + ((Ray)(ref ray)).direction * num2, maxDist -= num2) { num2 = ((RaycastHit)(ref s_rayHit)).distance + 0.1f; IDamageable component = ((Component)((RaycastHit)(ref s_rayHit)).collider).GetComponent<IDamageable>(); if (component == null) { continue; } IDamageable baseDamagable = component.GetBaseDamagable(); if (baseDamagable.TempSearchID == searchID) { continue; } if (settings.HasFlag(SearchSetting.IgnoreDupes)) { HashSet<IntPtr>? dupeCheckSet = DupeCheckSet; if (dupeCheckSet != null && dupeCheckSet.Contains(((Il2CppObjectBase)baseDamagable).Pointer)) { continue; } } ((RaycastHit)(ref s_rayHit)).distance = ((RaycastHit)(ref s_rayHit)).distance + num; s_rayHitCache.Add(s_rayHit); baseDamagable.TempSearchID = searchID; } if (settings.HasFlag(SearchSetting.Alloc)) { return new List<RaycastHit>(s_rayHitCache); } return s_rayHitCache; } public static bool RaycastFirst(Ray ray, out RaycastHit hit, float maxDist, int layerMask, Func<IDamageable, bool> filter, SearchSetting settings = SearchSetting.None) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) if (settings.HasFlag(SearchSetting.CheckLOS) && Physics.Raycast(ray, ref s_rayHit, maxDist, SightBlockLayer)) { maxDist = ((RaycastHit)(ref s_rayHit)).distance; } DamageUtil.IncrementSearchID(); uint searchID = DamageUtil.SearchID; float num2; for (float num = 0f; Physics.Raycast(ray, ref hit, maxDist, layerMask); num += num2, ((Ray)(ref ray)).origin = ((Ray)(ref ray)).origin + ((Ray)(ref ray)).direction * num2, maxDist -= num2) { num2 = ((RaycastHit)(ref s_rayHit)).distance + 0.1f; IDamageable component = ((Component)((RaycastHit)(ref hit)).collider).GetComponent<IDamageable>(); if (component == null) { continue; } IDamageable baseDamagable = component.GetBaseDamagable(); if (baseDamagable.TempSearchID == searchID) { continue; } if (settings.HasFlag(SearchSetting.IgnoreDupes)) { HashSet<IntPtr>? dupeCheckSet = DupeCheckSet; if (dupeCheckSet != null && dupeCheckSet.Contains(((Il2CppObjectBase)baseDamagable).Pointer)) { continue; } } ((RaycastHit)(ref hit)).distance = ((RaycastHit)(ref hit)).distance + num; baseDamagable.TempSearchID = searchID; if (filter(component)) { return true; } } return false; } } internal static class SortUtil { private static List<(RaycastHit hit, float distance)> s_limbCache = new List<(RaycastHit, float)>(); private static List<((IDamageable damageable, RaycastHit hit), float distance)> s_damageableLimbCache = new List<((IDamageable, RaycastHit), float)>(); public static int Rayhit(RaycastHit x, RaycastHit y) { if (((RaycastHit)(ref x)).distance == ((RaycastHit)(ref y)).distance) { return 0; } if (!(((RaycastHit)(ref x)).distance < ((RaycastHit)(ref y)).distance)) { return 1; } return -1; } public static int RayhitTuple<T>((T, RaycastHit hit) x, (T, RaycastHit hit) y) { if (((RaycastHit)(ref x.hit)).distance == ((RaycastHit)(ref y.hit)).distance) { return 0; } if (!(((RaycastHit)(ref x.hit)).distance < ((RaycastHit)(ref y.hit)).distance)) { return 1; } return -1; } public static void SortWithWeakspotBuffer(IList<RaycastHit> list) { //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_0021: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 s_limbCache.EnsureCapacity(list.Count); foreach (RaycastHit item in list) { RaycastHit current = item; IDamageable? damageableFromRayHit = DamageableUtil.GetDamageableFromRayHit(current); int num; if (damageableFromRayHit == null) { num = 0; } else { Dam_EnemyDamageLimb obj = ((Il2CppObjectBase)damageableFromRayHit).TryCast<Dam_EnemyDamageLimb>(); num = (((int)((obj != null) ? new eLimbDamageType?(obj.m_type) : null).GetValueOrDefault() == 1) ? 1 : 0); } bool flag = (byte)num != 0; s_limbCache.Add((current, flag ? Math.Max(((RaycastHit)(ref current)).distance - 0.1f, 0f) : ((RaycastHit)(ref current)).distance)); } s_limbCache.Sort(FloatTuple); CopySortedList(s_limbCache, list); s_limbCache.Clear(); } public static void SortWithWeakspotBuffer(IList<(IDamageable, RaycastHit)> list) { //IL_0027: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Invalid comparison between Unknown and I4 //IL_0049: Unknown result type (might be due to invalid IL or missing references) s_damageableLimbCache.EnsureCapacity(list.Count); foreach (var item3 in list) { IDamageable item = item3.Item1; RaycastHit item2 = item3.Item2; Dam_EnemyDamageLimb obj = ((Il2CppObjectBase)item).TryCast<Dam_EnemyDamageLimb>(); bool flag = obj != null && (int)obj.m_type == 1; s_damageableLimbCache.Add(((item, item2), flag ? Math.Max(((RaycastHit)(ref item2)).distance - 0.1f, 0f) : ((RaycastHit)(ref item2)).distance)); } s_damageableLimbCache.Sort(FloatTuple); CopySortedList<(IDamageable, RaycastHit)>(s_damageableLimbCache, list); s_damageableLimbCache.Clear(); } public static void CopySortedList<T>(IList<(T, float)> sortedList, IList<T> list) { for (int i = 0; i < list.Count; i++) { list[i] = sortedList[i].Item1; } } public static void CopySortedList<T>(IList<(T, float, float)> sortedList, IList<T> list) { for (int i = 0; i < list.Count; i++) { list[i] = sortedList[i].Item1; } } public static int FloatTuple<T>((T, float val) x, (T, float val) y) { if (x.val == y.val) { return 0; } if (!(x.val < y.val)) { return 1; } return -1; } public static int FloatTuple<T>((T, float val1, float val2) x, (T, float val1, float val2) y) { if (x.val1 == y.val1) { if (x.val2 == y.val2) { return 0; } if (!(x.val2 < y.val2)) { return 1; } return -1; } if (!(x.val1 < y.val1)) { return 1; } return -1; } } } namespace EWC.Utils.Structs { public struct SBounds { public Vector3 center; public Vector3 extents; public Vector3 max; public Vector3 min; public Vector3 size; public SBounds(Bounds bounds) { //IL_0003: 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_001b: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) center = new Vector3(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).center.y, ((Bounds)(ref bounds)).center.z); size = new Vector3(((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.y, ((Bounds)(ref bounds)).size.z); extents = size * 0.5f; max = center + extents; min = center - extents; } public readonly Vector3 ClosestPoint(Vector3 point) { return new Vector3(Math.Clamp(point.X, min.X, max.X), Math.Clamp(point.Y, min.Y, max.Y), Math.Clamp(point.Z, min.Z, max.Z)); } public readonly bool Contains(Vector3 point) { if (point.X >= min.X && point.X <= max.X && point.Y >= min.Y && point.Y <= max.Y && point.Z >= min.Z) { return point.Z <= max.Z; } return false; } public static implicit operator SBounds(Bounds bounds) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return new SBounds(bounds); } } } namespace EWC.Utils.Extensions { internal static class ArchetypeExtensions { public static int PierceLimit(this ArchetypeDataBlock dataBlock) { if (!dataBlock.PiercingBullets) { return 1; } return dataBlock.PiercingDamageCountLimit; } } internal static class CollectionExtensions { public static bool TryGetValueAs<Key, Value, ValueAs>(this IDictionary<Key, Value> dict, Key key, [MaybeNullWhen(false)] out ValueAs valueAs) where Key : notnull where ValueAs : Value { if (dict.TryGetValue(key, out Value value)) { valueAs = (ValueAs)(object)value; return true; } valueAs = default(ValueAs); return false; } public static IReadOnlyDictionary<Key, Value> OrEmptyIfNull<Key, Value>(this IReadOnlyDictionary<Key, Value>? dict) where Key : notnull { return dict ?? ImmutableDictionary<Key, Value>.Empty; } public static IReadOnlyList<T> OrEmptyIfNull<T>(this IReadOnlyList<T>? list) { return list ?? ImmutableList<T>.Empty; } public static T[] Extend<T>(this T[] array, params T[] newArray) { T[] array2 = new T[array.Length + newArray.Length]; array.CopyTo(array2, 0); newArray.CopyTo(array2, array.Length); return array2; } public static T[] Remove<T>(this T[] array, params T[] removeValues) { T[] array2 = new T[array.Length - removeValues.Length]; int num = 0; for (int i = 0; i < array.Length; i++) { bool flag = false; for (int j = 0; j < removeValues.Length; j++) { T val = removeValues[j]; ref T reference = ref val; T val2 = default(T); if (val2 == null) { val2 = reference; reference = ref val2; } if (reference.Equals(array[i])) { flag = true; break; } } if (!flag) { array2[num++] = array[i]; } } return array2; } } internal static class EnumExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasAnyFlag<T>(this T value, T flag) where T : Enum { int num = Convert.ToInt32(value); int num2 = Convert.ToInt32(flag); if (num2 != 0) { return (num & num2) != 0; } return true; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool HasFlagIn(this Enum type, Enum[] flagSet) { foreach (Enum flag in flagSet) { if (type.HasFlag(flag)) { return true; } } return false; } } internal static class Il2ObjectExtensions { public static bool TryCastOut<T>(this Object obj, [MaybeNullWhen(false)] out T result) where T : Object { result = ((Il2CppObjectBase)obj).TryCast<T>(); return result != null; } public static bool TryGetComp<T>(this GameObject obj, [MaybeNullWhen(false)] out T result) { result = obj.GetComponent<T>(); return result != null; } public static bool TryGetComp<T>(this Component obj, [MaybeNullWhen(false)] out T result) { result = obj.GetComponent<T>(); return result != null; } } internal static class NumExtensions { public static float Map(this float orig, float fromMin, float fromMax, float toMin, float toMax, float exponent = 1f) { if (fromMin == fromMax) { if (!(orig < fromMin)) { return toMax; } return toMin; } orig = Math.Clamp(orig, fromMin, fromMax); if (exponent != 1f) { return (float)Math.Pow((orig - fromMin) / (fromMax - fromMin), exponent) * (toMax - toMin) + toMin; } return (orig - fromMin) / (fromMax - fromMin) * (toMax - toMin) + toMin; } public static float MapInverted(this float orig, float fromMin, float fromMax, float toMax, float toMin, float exponent = 1f) { if (fromMin == fromMax) { if (!(orig < fromMin)) { return toMin; } return toMax; } orig = Math.Clamp(orig, fromMin, fromMax); if (exponent != 1f) { return (float)Math.Pow((fromMax - orig) / (fromMax - fromMin), exponent) * (toMax - toMin) + toMin; } return (fromMax - orig) / (fromMax - fromMin) * (toMax - toMin) + toMin; } public static float Lerp(this float t, float min, float max) { return (max - min) * Math.Clamp(t, 0f, 1f) + min; } public static float Lerp(this double t, float min, float max) { return (max - min) * (float)Math.Clamp(t, 0.0, 1.0) + min; } } internal static class SlotExtensions { public static InventorySlot ToInventorySlot(this AmmoType ammo) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected I4, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0029: Unknown result type (might be due to invalid IL or missing references) return (InventorySlot)((int)ammo switch { 0 => 1, 1 => 2, 2 => 3, 3 => 4, _ => 0, }); } public static AmmoType ToAmmoType(this InventorySlot slot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected I4, but got Unknown //IL_001b: 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_0023: 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_002c: 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) return (AmmoType)((slot - 1) switch { 0 => 0, 1 => 1, 2 => 2, 3 => 3, _ => 4, }); } } internal static class StringExtensions { public static T ToEnum<T>(this string? value, T defaultValue) where T : struct { if (string.IsNullOrEmpty(value)) { return defaultValue; } if (!Enum.TryParse<T>(value.Replace(" ", null), ignoreCase: true, out var result)) { return defaultValue; } return result; } } internal static class VectorExtensions { private static Vector3 _cacheDir = Vector3.zero; private static Vector3 _cacheUp = Vector3.zero; private static Vector3 _cacheRight = Vector3.zero; public static Vector3 RotateBy(this Vector3 dir, float x, float y) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0076: 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_001f: 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_0082: 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_008c: 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_0092: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (_cacheDir != dir) { Vector3 val = Vector3.Cross((Math.Abs(dir.y) < 0.99f) ? Vector3.up : Vector3.forward, dir); _cacheRight = ((Vector3)(ref val)).normalized; val = Vector3.Cross(_cacheRight, dir); _cacheUp = ((Vector3)(ref val)).normalized; _cacheDir = dir; } if (x != 0f) { dir = Quaternion.AngleAxis(0f - x, _cacheUp) * dir; } if (y != 0f) { dir = Quaternion.AngleAxis(0f - y, _cacheRight) * dir; } return dir; } } } namespace EWC.Patches.SNet { [HarmonyPatch] internal static class SyncManagerPatches { public static event Action? OnCheckpointReload; [HarmonyPatch(typeof(SNet_SyncManager), "OnRecallDone")] [HarmonyWrapSafe] [HarmonyPostfix] private static void Pre_Reload() { SyncManagerPatches.OnCheckpointReload?.Invoke(); } } } namespace EWC.Patches.Sentry { [HarmonyPatch] internal static class SentryPatches { [HarmonyPatch(typeof(SentryGunFirstPerson), "OnGearSpawnComplete")] [HarmonyWrapSafe] [HarmonyPostfix] private static void OnGearSpawn(SentryGunFirstPerson __instance) { CustomWeaponManager.AddSpawnedItem((ItemEquippable)(object)__instance); } [HarmonyPatch(typeof(SentryGunInstance), "OnGearSpawnComplete")] [HarmonyWrapSafe] [HarmonyPostfix] private static void PostSpawnCallback(SentryGunInstance __instance) { CustomWeaponManager.ActivateSentry(__instance); } [HarmonyPatch(typeof(SentryGunInstance), "SyncedPickup")] [HarmonyWrapSafe] [HarmonyPrefix] private static void PrePickupCallback(SentryGunInstance __instance) { CustomWeaponManager.RemoveSentry(__instance); } [HarmonyPatch(typeof(SentryGunInstance), "StartFiring")] [HarmonyWrapSafe] [HarmonyPostfix] private static void PostStartFiring(SentryGunInstance __instance) { if (((Component)(object)__instance).TryGetComp<CustomGunComponent>(out var result)) { ((SentryGunComp)result.Gun).IsFirstShot = true; } } [HarmonyPatch(typeof(SentryGunInstance), "StopFiring")] [HarmonyWrapSafe] [HarmonyPostfix] private static void PostStopFiring(SentryGunInstance __instance) { if (((Component)(object)__instance).TryGetComp<CustomGunComponent>(out var result) && !((SentryGunComp)result.Gun).IsFirstShot) { result.Invoke(StaticContext<WeaponPostStopFiringContext>.Instance); } } [HarmonyPatch(typeof(SentryGunInstance_Firing_Bullets), "UpdateFireMaster")] [HarmonyWrapSafe] [HarmonyPrefix] private static void PreFireCallback(SentryGunInstance_Firing_Bullets __instance, bool targetIsTagged, out (CustomGunComponent? cgc, bool fired) __state) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Invalid comparison between Unknown and I4 float time = Clock.Time; if (!((Component)(object)__instance).TryGetComp<CustomGunComponent>(out var result)) { if (__instance.m_fireBulletTimer < time && __instance.m_burstTimer < time) { ShotManager.CacheFiringSentry(((Il2CppObjectBase)__instance.m_core).Cast<SentryGunInstance>(), targetIsTagged); __state = (null, true); } else { __state = (null, false); } return; } SentryGunComp sentryGunComp = (SentryGunComp)result.Gun; bool num = (int)sentryGunComp.FireMode == 1; bool flag = !num || __instance.m_burstTimer < time; bool flag2 = num && __instance.m_burstClipCurr == 0; if (!flag2 && flag && __instance.m_fireBulletTimer < time) { ShotManager.CacheFiringSentry(sentryGunComp.Value, targetIsTagged); if (sentryGunComp.IsFirstShot) { result.Invoke(StaticContext<WeaponPreStartFireContext>.Instance); } result.UpdateStoredFireRate(targetIsTagged); if (sentryGunComp.IsFirstShot) { result.Invoke(StaticContext<WeaponPostStartFireContext>.Instance); } result.Invoke(StaticContext<WeaponPreFireContext>.Instance); ShotManager.AdvanceGroupMod(result, targetIsTagged); __state = (result, true); } else if (flag2 && flag) { __state = (result, false); } else { __state = (null, false); } } [HarmonyPatch(typeof(SentryGunInstance_Firing_Bullets), "UpdateFireMaster")] [HarmonyWrapSafe] [HarmonyPostfix] private static void PostFireCallback(SentryGunInstance_Firing_Bullets __instance, (CustomGunComponent? cgc, bool fired) __state) { var (customGunComponent, _) = __state; if ((Object)(object)customGunComponent == (Object)null) { if (__state.fired) { ShotManager.ClearFiringInfo(); } } else if (__state.fired) { customGunComponent.NotifyShotFired(); ShotManager.CancelTracerFX(customGunComponent); iSentrygunInstanceCore core = __instance.m_core; float costOfBullet = core.CostOfBullet; customGunComponent.Invoke(new WeaponAmmoContext((int)(core.Ammo / costOfBullet), (int)(core.AmmoMaxCap / costOfBullet))); customGunComponent.Invoke(StaticContext<WeaponPostFireContext>.Instance); customGunComponent.ModifyFireRate(); ShotManager.ClearFiringInfo(); } else { customGunComponent.Invoke(StaticContext<WeaponPostStopFiringContext>.Instance); ((SentryGunComp)customGunComponent.Gun).IsFirstShot = true; customGunComponent.ModifyFireRate(); } } [HarmonyPatch(typeof(SentryGunInstance_Firing_Bullets), "UpdateFireClient")] [HarmonyWrapSafe] [HarmonyPrefix] private static void PreFireClientCallback(SentryGunInstance_Firing_Bullets __instance, out (CustomGunComponent? cgc, bool fired) __state) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 float time = Clock.Time; if (!((Component)(object)__instance).TryGetComp<CustomGunComponent>(out var result)) { if (__instance.m_fireBulletTimer < time && __instance.m_burstTimer < time) { ShotManager.CacheFiringSentry(((Il2CppObjectBase)__instance.m_core).Cast<SentryGunInstance>(), isTagged: false); __state = (null, true); } else { __state = (null, false); } return; } bool num = (int)result.Gun.FireMode == 1; bool flag = !num || __instance.m_burstTimer < time; bool flag2 = num && __instance.m_burstClipCurr == 0; if (!flag2 && flag && __instance.m_fireBulletTimer < time) { ShotManager.CacheFiringSentry(((SentryGunComp)result.Gun).Value, isTagged: false); result.Invoke(StaticContext<WeaponPreFireContextSync>.Instance); result.UpdateStoredFireRate(); __state = (result, true); } else if (flag2 && flag) { __state = (result, false); } else { __state = (null, false); } } [HarmonyPatch(typeof(SentryGunInstance_Firing_Bullets), "UpdateFireClient")] [HarmonyWrapSafe] [HarmonyPostfix] private static void PostFireClientCallback(SentryGunInstance_Firing_Bullets __instance, (CustomGunComponent? cgc, bool fired) __state) { var (customGunComponent, _) = __state; if ((Object)(object)customGunComponent == (Object)null) { ShotManager.ClearFiringInfo(); } else if (__state.fired) { customGunComponent.NotifyShotFired(); ShotManager.CancelTracerFX(customGunComponent); customGunComponent.Invoke(StaticContext<WeaponPostFireContextSync>.Instance); customGunComponent.ModifyFireRate(); ShotManager.ClearFiringInfo(); } else { customGunComponent.ModifyFireRate(); } } [HarmonyPatch(typeof(SentryGunInstance), "GiveAmmoRel")] [HarmonyWrapSafe] [HarmonyPrefix] private static void UpdateClip(SentryGunInstance __instance, ref float ammoClassRel, out CustomGunComponent? __state) { if ((int)(__instance.Ammo / __instance.CostOfBullet) != (int)(__instance.AmmoMaxCap / __instance.CostOfBullet) && ((Component)(object)__instance).TryGetComp<CustomGunComponent>(out __state)) { ammoClassRel = __state.Invoke(new WeaponPreAmmoPackContext(ammoClassRel)).AmmoAmount; } else { __state = null; } } [HarmonyPatch(typeof(SentryGunInstance), "GiveAmmoRel")] [HarmonyWrapSafe] [HarmonyPostfix] private static void UpdateAmmo(SentryGunInstance __instance, CustomGunComponent? __state) { if (!((Object)(object)__state == (Object)null)) { float costOfBullet = __instance.CostOfBullet; __state.Invoke(new WeaponAmmoContext((int)(__instance.Ammo / costOfBullet), (int)(__instance.AmmoMaxCap / costOfBullet))); } } } } namespace EWC.Patches.Player { [HarmonyPatch] internal static class PlayerBackpackPatches { [HarmonyPatch(typeof(PlayerBackpack), "SpawnAndEquipGearAsync")] [HarmonyWrapSafe] [HarmonyPostfix] private static void SpawnGearCallback(PlayerBackpack __instance, InventorySlot slot) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) PlayerAgent val = (__instance.Owner.HasPlayerAgent ? ((Il2CppObjectBase)__instance.Owner.PlayerAgent).Cast<PlayerAgent>() : null); BackpackItem val2 = default(BackpackItem); if (!((Object)(object)val == (Object)null) && __instance.TryGetBackpackItem(slot, ref val2)) { CustomWeaponManager.AddEquippedItem(val, ((Il2CppObjectBase)val2.Instance).Cast<ItemEquippable>()); } } [HarmonyPatch(typeof(PlayerSync), "OnSpawn")] [HarmonyWrapSafe] [HarmonyPostfix] private static void SpawnPlayerCallback(PlayerSync __instance) { //IL_0024: 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) PlayerAgent agent = __instance.m_agent; PlayerBackpack val = default(PlayerBackpack); if (!PlayerBackpackManager.TryGetBackpack(agent.Owner, ref val)) { return; } InventorySlot[] validSlots = CustomDataManager.ValidSlots; BackpackItem val3 = default(BackpackItem); foreach (InventorySlot val2 in validSlots) { if (val.TryGetBackpackItem(val2, ref val3)) { CustomWeaponManager.AddEquippedItem(agent, ((Il2CppObjectBase)val3.Instance).Cast<ItemEquippable>()); } } } } [HarmonyPatch] internal static class PlayerDamagePatches { [HarmonyPatch(typeof(Dam_PlayerDamageBase), "OnIncomingDamage")] [HarmonyWrapSafe] [HarmonyPrefix] private static void Pre_TakeDamage(Dam_PlayerDamageBase __instance, float damage, ref bool __state) { SNet_Player owner = __instance.Owner.Owner; __state = damage > 0f && ((Dam_SyncedDamageBase)__instance).Health > 0f && (owner.IsLocal || (owner.IsBot && SNet.IsMaster)); } [HarmonyPatch(typeof(Dam_PlayerDamageBase), "OnIncomingDamage")] [HarmonyWrapSafe] [HarmonyPostfix] private static void Post_TakeDamage(Dam_PlayerDamageBase __instance, float damage, bool __state) { if (__state) { CustomWeaponManager.InvokeOnGear(__instance.Owner.Owner, new WeaponDamageTakenContext(damage)); } } [HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveSetHealth")] [HarmonyPrefix] private static void Pre_ReceiveHealth(Dam_PlayerDamageBase __instance, ref float __state) { __state = ((Dam_SyncedDamageBase)__instance).Health; } [HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveSetHealth")] [HarmonyWrapSafe] [HarmonyPostfix] private static void Post_ReceiveHealth(Dam_PlayerDamageBase __instance, float __state) { if (__state != ((Dam_SyncedDamageBase)__instance).Health) { CustomWeaponManager.InvokeOnGear(__instance.Owner.Owner, new WeaponHealthContext(__instance)); } } } [HarmonyPatch] internal static class PlayerInventoryPatches { private static bool _allowReload = true; [HarmonyPatch(typeof(PUI_Inventory), "SetSlotAmmo")] [HarmonyWrapSafe] [HarmonyPrefix] private static void SetAmmoUICallback(PUI_Inventory __instance, InventorySlot slot, ref int clipAbs, ref int inPackAbs, ref float inPackRel) { //IL_0000: 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) if ((int)slot == 0) { return; } SNet_Player owner = __instance.m_owner; object obj; if (owner == null) { obj = null; } else { SNet_IPlayerAgent playerAgent = owner.PlayerAgent; if (playerAgent == null) { obj = null; } else { PlayerAgent obj2 = ((Il2CppObjectBase)playerAgent).TryCast<PlayerAgent>(); if (obj2 == null) { obj = null; } else { FirstPersonItemHolder fPItemHolder = obj2.FPItemHolder; if (fPItemHolder == null) { obj = null; } else { ItemEquippable wieldedItem = fPItemHolder.WieldedItem; if (wieldedItem == null) { obj = null; } else { BulletWeapon obj3 = ((Il2CppObjectBase)wieldedItem).TryCast<BulletWeapon>(); obj = ((obj3 != null) ? ((Component)obj3).GetComponent<CustomWeaponComponent>() : null); } } } } } CustomWeaponComponent customWeaponComponent = (CustomWeaponComponent)obj; if (!((Object)(object)customWeaponComponent == (Object)null)) { PUI_InventoryItem val = __instance.m_inventorySlots[slot]; WeaponPreAmmoUIContext weaponPreAmmoUIContext = new WeaponPreAmmoUIContext(clipAbs, inPackAbs, inPackRel, val.ShowAmmoClip, val.ShowAmmoPack, val.ShowAmmoTotalRel, val.ShowAmmoInfinite); customWeaponComponent.Invoke(weaponPreAmmoUIContext); clipAbs = weaponPreAmmoUIContext.Clip; inPackAbs = weaponPreAmmoUIContext.Reserve; inPackRel = weaponPreAmmoUIContext.TotalRel; val.ShowAmmoClip = weaponPreAmmoUIContext.ShowClip; val.ShowAmmoPack = weaponPreAmmoUIContext.ShowReserve; val.ShowAmmoTotalRel = weaponPreAmmoUIContext.ShowRel; val.ShowAmmoInfinite = weaponPreAmmoUIContext.ShowInfinite; } } [HarmonyPatch(typeof(PlayerAmmoStorage), "PickupAmmo")] [HarmonyWrapSafe] [HarmonyPrefix] private static void AmmoPackCallback(PlayerAmmoStorage __instance, AmmoType ammoType, ref float ammoAmount) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) BackpackItem val = default(BackpackItem); if (__instance.m_playerBackpack.TryGetBackpackItem(ammoType.ToInventorySlot(), ref val)) { Item instance = val.Instance; CustomWeaponComponent customWeaponComponent = ((instance != null) ? ((Component)instance).GetComponent<CustomWeaponComponent>() : null); if ((Object)(object)customWeaponComponent != (Object)null) { ammoAmount = customWeaponComponent.Invoke(new WeaponPreAmmoPackContext(ammoAmount)).AmmoAmount; } } } [HarmonyPatch(typeof(PlayerAmmoStorage), "PickupAmmo")] [HarmonyWrapSafe] [HarmonyPostfix] private static void PostAmmoPackCallback(PlayerAmmoStorage __instance, AmmoType ammoType) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) BackpackItem val = default(BackpackItem); if (__instance.m_playerBackpack.TryGetBackpackItem(ammoType.ToInventorySlot(), ref val)) { Item instance = val.Instance; ((instance != null) ? ((Component)instance).GetComponent<CustomWeaponComponent>() : null)?.Invoke(new WeaponPostAmmoPackContext(__instance)); } } [HarmonyPatch(typeof(PlayerInventoryLocal), "DoReload")] [HarmonyPatch(typeof(PlayerInventoryBase), "DoReload")] [HarmonyWrapSafe] [HarmonyPostfix] private static void ReloadCallback(PlayerInventoryBase __instance) { ItemEquippable wieldedItem = __instance.m_wieldedItem; CustomWeaponComponent customWeaponComponent = ((wieldedItem != null) ? ((Component)wieldedItem).GetComponent<CustomWeaponComponent>() : null); if (!((Object)(object)customWeaponComponent == (Object)null)) { customWeaponComponent.Invoke(StaticContext<WeaponPostReloadContext>.Instance); } } [HarmonyPatch(typeof(PlayerInventoryLocal), "TriggerReload")] [HarmonyWrapSafe] [HarmonyPrefix] private static bool ReloadPreStartCallback(PlayerInventoryLocal __instance) { _allowReload = true; ItemEquippable wieldedItem = ((PlayerInventoryBase)__instance).m_wieldedItem; CustomWeaponComponent customWeaponComponent = ((wieldedItem != null) ? ((Component)wieldedItem).GetComponent<CustomWeaponComponent>() : null); if ((Object)(object)customWeaponComponent == (Object)null) { return true; } _allowReload = customWeaponComponent.Invoke(new WeaponPreReloadContext()).Allow; return _allowReload; } [HarmonyPatch(typeof(PlayerInventoryLocal), "TriggerReload")] [HarmonyWrapSafe] [HarmonyPostfix] private static void ReloadStartCallback(PlayerInventoryLocal __instance) { if (_allowReload) { ItemEquippable wieldedItem = ((PlayerInventoryBase)__instance).m_wieldedItem; CustomWeaponComponent customWeaponComponent = ((wieldedItem != null) ? ((Component)wieldedItem).GetComponent<CustomWeaponComponent>() : null); if (!((Object)(object)customWeaponComponent == (Object)null) && ((PlayerInventoryBase)__instance).m_wieldedItem.IsReloading) { customWeaponComponent.Invoke(StaticContext<WeaponReloadStartContext>.Instance); } } } [HarmonyPatch(typeof(PlayerInventoryBase), "TriggerReload")] [HarmonyWrapSafe] [HarmonyPostfix] private static void ReloadStartBotsCallback(PlayerInventoryBase __instance) { ItemEquippable wieldedItem = __instance.m_wieldedItem; CustomWeaponComponent customWeaponComponent = ((wieldedItem != null) ? ((Component)wieldedItem).GetComponent<CustomWeaponComponent>() : null); if (!((Object)(object)customWeaponComponent == (Object)null) && __instance.m_wieldedItem.IsReloading) { customWeaponComponent.Invoke(StaticContext<WeaponReloadStartContext>.Instance); } } [HarmonyPatch(typeof(PlayerAmmoStorage), "FillAllClips")] [HarmonyWrapSafe] [HarmonyPostfix] private static void PostFillAllClipsCallback(PlayerAmmoStorage __instance) { BackpackItem val = default(BackpackItem); if (__instance.m_playerBackpack.TryGetBackpackItem((InventorySlot)1, ref val)) { Item instance = val.Instance; ((instance != null) ? ((Component)instance).GetComponent<CustomWeaponComponent>() : null)?.Invoke(new WeaponPostAmmoInitContext(__instance, __instance.StandardAmmo)); } BackpackItem val2 = default(BackpackItem); if (__instance.m_playerBackpack.TryGetBackpackItem((InventorySlot)2, ref val2)) { Item instance2 = val2.Instance; ((instance2 != null) ? ((Component)instance2).GetComponent<CustomWeaponComponent>() : null)?.Invoke(new WeaponPostAmmoInitContext(__instance, __instance.SpecialAmmo)); } BackpackItem val3 = default(BackpackItem); if (__instance.m_playerBackpack.TryGetBackpackItem((InventorySlot)3, ref val3)) { Item instance3 = val3.Instance; ((instance3 != null) ? ((Component)instance3).GetComponent<CustomWeaponComponent>() : null)?.Invoke(new WeaponPostAmmoInitContext(__instance, __instance.SpecialAmmo)); } } } [HarmonyPatch] internal static class PlayerLocalPatches { [HarmonyPatch(typeof(PUI_LocalPlayerStatus), "UpdateHealth")] [HarmonyWrapSafe] [HarmonyPrefix] private static void UpdateHealth(PUI_LocalPlayerStatus __instance, float health) { if (__instance.m_lastHealthVal <= 0.14f && health > 0.14f && __instance.m_warningRoutine != null) { __instance.m_healthWarningLooping = true; } } } [HarmonyPatch] internal static class PlayerLocomotionPatches { private static bool _inJump; [HarmonyPatch(typeof(PLOC_Crouch), "Enter")] [HarmonyWrapSafe] [HarmonyPostfix] private static void EnterCrouch(PLOC_Crouch __instance) { CustomWeaponManager.InvokeOnGear(((PLOC_Base)__instance).m_owner.Owner, StaticContext<WeaponCrouchContext>.Instance); } [HarmonyPatch(typeof(PLOC_Crouch), "Exit")] [HarmonyWrapSafe] [HarmonyPostfix] private static void ExitCrouch(PLOC_Crouch __instance) { CustomWeaponManager.InvokeOnGear(((PLOC_Base)__instance).m_owner.Owner, StaticContext<WeaponCrouchEndContext>.Instance); } [HarmonyPatch(typeof(PLOC_Run), "Enter")] [HarmonyWrapSafe] [HarmonyPostfix] private static void EnterSprint(PLOC_Run __instance) { CustomWeaponManager.InvokeOnGear(((PLOC_Base)__instance).m_owner.Owner, StaticContext<WeaponSprintContext>.Instance); } [HarmonyPatch(typeof(PLOC_Run), "Exit")] [HarmonyWrapSafe] [HarmonyPostfix] private static void ExitSprint(PLOC_Run __instance) { CustomWeaponManager.InvokeOnGear(((PLOC_Base)__instance).m_owner.Owner, StaticContext<WeaponSprintEndContext>.Instance); } [HarmonyPatch(typeof(PLOC_Jump), "Enter")] [HarmonyWrapSafe] [HarmonyPostfix] private static void EnterJump(PLOC_Jump __instance) { _inJump = true; CustomWeaponManager.InvokeOnGear(((PLOC_Base)__instance).m_owner.Owner, StaticContext<WeaponJumpContext>.Instance); } [HarmonyPatch(typeof(PLOC_Jump), "CommonExit")] [HarmonyWrapSafe] [HarmonyPostfix] private static void ExitJump(PLOC_Jump __instance) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 PlayerAgent owner = ((PLOC_Base)__instance).m_owner; if (((Agent)owner).IsLocallyOwned && (int)owner.Locomotion.m_currentStateEnum != 4) { CustomWeaponManager.InvokeOnGear(owner.Owner, StaticContext<WeaponJumpEndContext>.Instance); _inJump = false; } } [HarmonyPatch(typeof(PLOC_Fall), "Enter")] [HarmonyWrapSafe] [HarmonyPostfix] private static void EnterFall(PLOC_Fall __instance) { if (!_inJump) { CustomWeaponManager.InvokeOnGear(((PLOC_Base)__instance).m_owner.Owner, StaticContext<WeaponJumpContext>.Instance); _inJump = true; } } [HarmonyPatch(typeof(PLOC_Fall), "Exit")] [HarmonyWrapSafe] [HarmonyPostfix] private static void ExitFall(PLOC_Fall __instance) { CustomWeaponManager.InvokeOnGear(((PLOC_Base)__instance).m_owner.Owner, StaticContext<WeaponJumpEndContext>.Instance); _inJump = false; } } } namespace EWC.Patches.Native { internal static class EnemyDetectionPatches { private unsafe delegate void d_DetectOnNoise(IntPtr _this, IntPtr agentTarget, float movementDetectionDistance, float shootDetectionDistance, float delta, out float output, Il2CppMethodInfo* methodInfo); private static INativeDetour? DetectOnNoiseDetour; private static d_DetectOnNoise? orig_DetectOnNoise; private static readonly Dictionary<int, List<CustomWeaponComponent>> s_cachedCWCs = new Dictionary<int, List<CustomWeaponComponent>>(); private static readonly InventorySlot[] GunSlots; [InvokeOnLoad] private unsafe static void ApplyNativePatch() { DetectOnNoiseDetour = INativeDetour.CreateAndApply<d_DetectOnNoise>((IntPtr)(nint)Il2CppAPI.GetIl2CppMethod<EnemyDetection>("DetectOnNoiseDistance_Conditional_AnimatedWindow", typeof(void).Name, false, new string[5] { "AgentTarget", typeof(float).Name, typeof(float).Name, typeof(float).Name, typeof(float).MakeByRefType().Name }), (d_DetectOnNoise)DetectOnNoisePatch, ref orig_DetectOnNoise); NativePatchAPI.AddDetectPostfix(Post_DetectAgentNoise); } private unsafe static void DetectOnNoisePatch(IntPtr _this, IntPtr agentTarget, float movementDetectionDistance, float shootDetectionDistance, float delta, out float output, Il2CppMethodInfo* methodInfo) { //IL_0009: 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_0015: Expected O, but got Unknown //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0044: Expected O, but got Unknown output = 0f; EnemyDetection val = new EnemyDetection(_this); AgentTarget agentTarget2 = new AgentTarget(agentTarget); if (NativePatchAPI.RunDetectPrefix(val, agentTarget2, movementDetectionDistance, shootDetectionDistance, delta, ref output)) { orig_DetectOnNoise(_this, agentTarget, movementDetectionDistance, shootDetectionDistance, delta, out output, methodInfo); } NativePatchAPI.RunDetectPostfix(val, agentTarget2, movementDetectionDistance, shootDetectionDistance, delta, ref output