Initial commit
This commit is contained in:
27
Assets/Darkmatter/Code/Domain/StateMachine/StateMachine.cs
Normal file
27
Assets/Darkmatter/Code/Domain/StateMachine/StateMachine.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Darkmatter.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Domain
|
||||
{
|
||||
public abstract class StateMachine
|
||||
{
|
||||
public IState CurrentState { get; private set; }
|
||||
public void ChangeState(IState state)
|
||||
{
|
||||
CurrentState?.Exit();
|
||||
CurrentState = state;
|
||||
CurrentState?.Enter();
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
CurrentState.Update();
|
||||
}
|
||||
|
||||
public void LateUpdate()
|
||||
{
|
||||
CurrentState.LateUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user