From 959b9aac05fc1fbb5ff9be10a5249576d7abb645 Mon Sep 17 00:00:00 2001 From: Marc Hernandez Date: Fri, 19 Apr 2024 02:13:27 -0700 Subject: [PATCH] FSM logging --- fsm/FSM.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/fsm/FSM.cs b/fsm/FSM.cs index 15fc7ce..93e1828 100644 --- a/fsm/FSM.cs +++ b/fsm/FSM.cs @@ -1,6 +1,7 @@  using System; +using System.Runtime.CompilerServices; @@ -41,14 +42,22 @@ public class FSM 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. + +*/ \ No newline at end of file