64 lines
2.5 KiB
C#
64 lines
2.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Invector;
|
|
using Invector.vMelee;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace Beyond
|
|
{
|
|
public class bMeleeManager : vMeleeManager
|
|
{
|
|
/// <summary>
|
|
/// Listener of Damage Event
|
|
/// </summary>
|
|
/// <param name="hitInfo"></param>
|
|
public override void OnDamageHit(ref vHitInfo hitInfo)
|
|
{
|
|
//+1 because of Random.Range extrem value exclusion
|
|
vDamage damage = new vDamage(Random.Range(hitInfo.attackObject.minDamage.damageValue, hitInfo.attackObject.maxDamage.damageValue + 1));
|
|
damage.sender = transform;
|
|
damage.reaction_id = currentReactionID;
|
|
damage.recoil_id = currentRecoilID;
|
|
damage.damageType = hitInfo.attackObject.damage.damageType;
|
|
if (this.activeRagdoll) damage.activeRagdoll = this.activeRagdoll;
|
|
if (this.attackName != string.Empty) damage.damageType = this.attackName;
|
|
if (this.ignoreDefense) damage.ignoreDefense = this.ignoreDefense;
|
|
if (this.senselessTime != 0) damage.senselessTime = this.senselessTime;
|
|
/// Calc damage with multiplier
|
|
/// and Call ApplyDamage of attackObject
|
|
|
|
damage.damageValue *= damageMultiplier > 1 ? damageMultiplier : 1;
|
|
float modifier = GameStateManager.Instance.EnemyDamageModifier;
|
|
if (modifier != 1f)
|
|
{
|
|
damage.damageValue = (int)((float) damage.damageValue * modifier);
|
|
}
|
|
|
|
hitInfo.targetIsBlocking = !hitInfo.attackObject.ApplyDamage(hitInfo.hitBox, hitInfo.targetCollider, damage);
|
|
|
|
onDamageHit.Invoke(hitInfo);
|
|
}
|
|
|
|
[Button]
|
|
public void CopyMembers()
|
|
{
|
|
var managers = GetComponents<vMeleeManager>();
|
|
foreach (var m in managers)
|
|
{
|
|
if (m != this)
|
|
{
|
|
// This copies EVERY Serialized field from 'm' to 'this'
|
|
// It works perfectly because bMeleeManager inherits vMeleeManager
|
|
JsonUtility.FromJsonOverwrite(JsonUtility.ToJson(m), this);
|
|
|
|
// Re-run init to apply the copied data
|
|
this.Init();
|
|
|
|
// Stop after finding the first match so we don't copy ourselves if checking later
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |