Skip to content

Commit

Permalink
Update StateMachine.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Haijie HJ2 Pan committed Apr 28, 2023
1 parent c86a7c5 commit 8a6d326
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions FSM/StateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,16 @@ public State<TState, TParam> NewState(TState stateName)
public StateMachine<TState, TParam> Any(Func<TParam, bool> valid, Action<TParam> transfer,TState to)
{
foreach (State<TState, TParam> state in m_States)
{
if (to.GetHashCode() != state.GetStateInt())
{
Transition<TState, TParam> transition = new Transition<TState, TParam>(state, valid).Transfer(transfer);
transition.To(to);
state.Transitions.Add(transition);
}
}
state.Translate(valid).Transfer(transfer).To(to);
return this;
}

public StateMachine<TState, TParam> Where(TState from, Func<TParam, bool> valid, Action<TParam> transfer, TState to)
{
foreach(State<TState,TParam> state in m_States)
{
if ((from.GetHashCode() & state.GetStateInt()) == state.GetStateInt())
{
Transition<TState, TParam> transition = new Transition<TState, TParam>(state, valid).Transfer(transfer);
transition.To(to);
state.Transitions.Add(transition);
}
}
state.Translate(valid).Transfer(transfer).To(to);
return this;
}
public StateMachine<TState, TParam> Initialize()
Expand Down

0 comments on commit 8a6d326

Please sign in to comment.