r2mods/ilspy_dump/ror2_csproj/EntityStates/IdleSkillOverrideHandoff.cs

52 lines
1.1 KiB
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
namespace EntityStates;
public class IdleSkillOverrideHandoff : EntityState, ISkillOverrideHandoff
{
public static float skillOverrideTimeout = 0.05f;
private bool shouldProcess;
private SkillStateOverrideData skillOverrideData;
public void TransferSkillOverride(SkillStateOverrideData skillOverrideData)
{
this.skillOverrideData = skillOverrideData;
shouldProcess = this.skillOverrideData != null;
}
public override void Update()
{
if (shouldProcess)
{
base.Update();
skillOverrideData.StepRestock();
if (base.age > skillOverrideTimeout)
{
skillOverrideData.ClearOverrides();
skillOverrideData = null;
shouldProcess = false;
}
}
}
public override void ModifyNextState(EntityState nextState)
{
base.ModifyNextState(nextState);
if (skillOverrideData != null && nextState is ISkillOverrideHandoff skillOverrideHandoff)
{
skillOverrideHandoff.TransferSkillOverride(skillOverrideData);
skillOverrideData = null;
shouldProcess = false;
}
}
public override void OnExit()
{
base.OnExit();
if (shouldProcess)
{
skillOverrideData?.ClearOverrides();
}
}
}