37 lines
993 B
C#
37 lines
993 B
C#
using UnityEngine;
|
|
|
|
public class TemporaryIncomeModifierInterceptor : BrokerInterceptor
|
|
{
|
|
DamageIncomeModifierEffectInstance incomeModifier;
|
|
|
|
float finalValue;
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
|
|
incomeModifier = GetComponentInParent<DamageIncomeModifierEffectInstance>();
|
|
|
|
broker.OnIncomingDamage.Subscribe(HandleDamageIncomeModifierEffects, GameConstants.BrokerEventPriority.TemporaryMitigationMods);
|
|
}
|
|
|
|
private void HandleDamageIncomeModifierEffects(DamageArgs args)
|
|
{
|
|
finalValue = args.currentValue;
|
|
|
|
if (finalValue >= 0) return;
|
|
|
|
if (incomeModifier.IsActive)
|
|
{
|
|
//Debug.Log("Incoming damage b4 mitigation: " + incomingValue);
|
|
|
|
finalValue = incomeModifier.ModifyDamageIncome(finalValue);
|
|
|
|
if (finalValue > 0) //avoid damage ultra mitigated turning into healing
|
|
finalValue = 0;
|
|
|
|
args.currentValue = finalValue;
|
|
}
|
|
}
|
|
}
|