42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
using System.Linq;
|
|
using System.Reflection;
|
|
using Aki.Reflection.Patching;
|
|
using EFT;
|
|
using EFT.Animations;
|
|
using UnityEngine;
|
|
|
|
namespace SamSWAT.ReflexSightsRework
|
|
{
|
|
public class Patch : ModulePatch
|
|
{
|
|
public static float TotalErgonomics;
|
|
public static float Overweight;
|
|
private static Transform _currentWeapon;
|
|
private static SightSwitch[] _instances;
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
{
|
|
return typeof(ProceduralWeaponAnimation).GetMethod("set_IsAiming");
|
|
}
|
|
|
|
[PatchPostfix]
|
|
private static void PatchPostfix(bool value, ProceduralWeaponAnimation __instance,
|
|
Player.FirearmController ___firearmController_0)
|
|
{
|
|
if (___firearmController_0 == null) return;
|
|
|
|
if (_currentWeapon != ___firearmController_0.WeaponRoot || _instances.Any(x => x.gameObject.activeSelf == false))
|
|
{
|
|
_currentWeapon = ___firearmController_0.WeaponRoot;
|
|
_instances = _currentWeapon.GetComponentsInChildren<SightSwitch>();
|
|
}
|
|
|
|
if (_instances.Length == 0) return;
|
|
|
|
TotalErgonomics = ___firearmController_0.TotalErgonomics;
|
|
Overweight = __instance.Overweight;
|
|
|
|
foreach (var instance in _instances) instance.enabled = value;
|
|
}
|
|
}
|
|
} |