r2mods/ilspy_dump/ror2_csproj/EntityStates.VagrantNovaItem/ReadyState.cs

40 lines
849 B
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using RoR2;
namespace EntityStates.VagrantNovaItem;
public class ReadyState : BaseVagrantNovaItemState
{
private HealthComponent attachedHealthComponent;
public override void OnEnter()
{
base.OnEnter();
attachedHealthComponent = base.attachedBody?.healthComponent;
SetChargeSparkEmissionRateMultiplier(1f);
GlobalEventManager.onServerDamageDealt += OnDamaged;
}
public override void OnExit()
{
base.OnExit();
GlobalEventManager.onServerDamageDealt -= OnDamaged;
}
public override void FixedUpdate()
{
base.FixedUpdate();
if (base.isAuthority && attachedHealthComponent.isHealthLow)
{
outer.SetNextState(new ChargeState());
}
}
private void OnDamaged(DamageReport report)
{
if (report.hitLowHealth && (object)report?.victim?.body == base.attachedBody)
{
outer.SetNextState(new ChargeState());
}
}
}