34 lines
760 B
C#
34 lines
760 B
C#
using UnityEngine;
|
|
|
|
public class InvulnerabilityInterceptor : BrokerInterceptor
|
|
{
|
|
Health health;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
|
|
health = GetComponentInParent<Health>();
|
|
|
|
broker.OnIncomingDamage.Subscribe(HandleInvulnerability, GameConstants.BrokerEventPriority.Invulnerability);
|
|
}
|
|
|
|
|
|
private void HandleInvulnerability(DamageArgs args)
|
|
{
|
|
InvulnerabilityArgs invulnerabilityArgs = new InvulnerabilityArgs()
|
|
{
|
|
user = user,
|
|
isImmune = false
|
|
};
|
|
|
|
if(health.Invulnerable)
|
|
{
|
|
args.currentValue = 0;
|
|
invulnerabilityArgs.isImmune = true;
|
|
}
|
|
|
|
broker.OnInvulnerable.Invoke(invulnerabilityArgs);
|
|
}
|
|
}
|