Files
BoneSync/BoneSync/Patching/CallPatchedMethod.cs

64 lines
2.0 KiB
C#

using StressLevelZero.Combat;
using StressLevelZero.Pool;
using StressLevelZero.Props;
using StressLevelZero.Props.Weapons;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Events;
namespace BoneSync.Patching
{
public static class CallPatchedMethods
{
public static bool allowPatchedMethodCall
{
private set;
get;
}
public static void TakeDamage(ObjectDestructable __instance, Vector3 normal, float damage, bool crit, AttackType attackType)
{
allowPatchedMethodCall = true;
__instance.TakeDamage(normal, damage, crit, attackType);
allowPatchedMethodCall = false;
}
public static void TakeDamage(Prop_Health __instance, float damage, bool crit, AttackType attackType)
{
allowPatchedMethodCall = true;
__instance.TAKEDAMAGE(damage, crit, attackType);
allowPatchedMethodCall = false;
}
public static void FireGun(Gun __instance)
{
allowPatchedMethodCall = true;
__instance.Fire();
allowPatchedMethodCall = false;
}
public static void BypassPatchInvoke(this UnityEvent e)
{
allowPatchedMethodCall = true;
e.Invoke();
allowPatchedMethodCall = false;
}
public static Poolee InstantiatePoolee(Pool pool, Vector3 position, Quaternion rotation, Vector3 scale)
{
allowPatchedMethodCall = true;
Poolee poolee = pool.InstantiatePoolee(position, rotation);
poolee.transform.position = position;
poolee.transform.rotation = rotation;
poolee.transform.localScale = scale;
poolee.transform.parent = null;
poolee.gameObject.SetActive(true);
allowPatchedMethodCall = false;
return poolee;
}
}
}