FSM logging

This commit is contained in:
Marc Hernandez 2024-04-19 02:13:27 -07:00
parent 1a05f3b2b9
commit 959b9aac05

View File

@ -1,6 +1,7 @@

using System;
using System.Runtime.CompilerServices;
@ -41,14 +42,22 @@ public class FSM<T, CTX, ST>
State.onEnter( Context, state );
}
public void Transition(ST newState)
public void transition(ST newState, string reason = "",
[CallerMemberName] string member = "",
[CallerFilePath] string path = "",
[CallerLineNumber] int line = 0 )
{
log.debug( $"{GetType().Name} switching to {newState.GetType().Name}from {State.GetType().Name} bcs {reason} Code {log.relativePath(path)}:({line}): {member}" );
State.onExit( Context, newState );
newState.onEnter( Context, State );
State = newState;
}
}
/*
Im going to preface this with, I use FSMs everywhere for quite a few things.
*/