67 lines
852 B
C#
67 lines
852 B
C#
|
|
|
|
using System;
|
|
|
|
|
|
|
|
namespace net;
|
|
|
|
|
|
|
|
public class Context
|
|
{
|
|
|
|
}
|
|
|
|
public class State<T, CTX>
|
|
where T : State<T, CTX>
|
|
where CTX : Context
|
|
{
|
|
virtual public void onEnter( CTX ctx, State<T, CTX> oldState )
|
|
{
|
|
}
|
|
|
|
virtual public void onExit( CTX ctx, State<T, CTX> newState )
|
|
{
|
|
}
|
|
}
|
|
|
|
/*
|
|
public class PotentialState<T, CTX> : State<T, CTX>
|
|
where T : State<T, CTX>
|
|
where CTX : Context
|
|
{
|
|
virtual public void onEnter(CTX ctx, State<T, CTX> oldState)
|
|
{
|
|
}
|
|
|
|
virtual public void onExit(CTX ctx, State<T, CTX> newState)
|
|
{
|
|
}
|
|
}
|
|
*/
|
|
|
|
|
|
public class FSM<T, CTX, ST>
|
|
where T : FSM<T, CTX, ST>
|
|
where CTX : Context
|
|
where ST : State<ST, CTX>
|
|
{
|
|
public CTX Context { get; private set; }
|
|
public ST State { get; private set; }
|
|
|
|
public FSM( CTX context, ST state )
|
|
{
|
|
Context = context;
|
|
State = state;
|
|
}
|
|
|
|
public void Transition( ST newState )
|
|
{
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|