29 lines
597 B
C#

public class BaseState
{
protected STAGE stage;
protected BaseState nextState;
public BaseState()
{
stage = STAGE.Enter;
}
protected virtual void Enter() => stage = STAGE.Update;
protected virtual void Update() => stage = STAGE.Update;
protected virtual void Exit() => stage = STAGE.Exit;
public BaseState ProcessStates()
{
if (stage == STAGE.Enter) Enter();
if (stage == STAGE.Update) Update();
if (stage == STAGE.Exit)
{
Exit();
return nextState;
}
return this;
}
}