@@ -47,6 +47,9 @@ public Command(CommandType commandType, STATE_ID stateID)
4747
4848 public event System . Action < STATE_ID , TSTATE > OnChangeState ;
4949
50+ [ SerializeField ]
51+ private bool _debug ;
52+
5053 public STATE_ID currentStateID => _currentStateID ;
5154 [ SerializeField ]
5255 private STATE_ID _currentStateID ;
@@ -91,6 +94,9 @@ public void Start(MonoBehaviour owner, STATE_ID startState, params STATE_ID[] ne
9194 /// <param name="state">변경할 스테이트</param>
9295 public void ChangeState ( STATE_ID state )
9396 {
97+ if ( _debug )
98+ Debug . Log ( $ "{ _owner . name } .FSM.ChangeState changeState:{ state } , wait:{ _waitQueue . ToStringCollection ( ) } ", _owner ) ;
99+
94100 _commandQueue . Add ( new Command ( CommandType . Change , state ) ) ;
95101 }
96102
@@ -108,10 +114,8 @@ public void FinishState()
108114 /// <param name="nextStates"></param>
109115 public void EnqueueToWaitQueue ( params STATE_ID [ ] nextStates )
110116 {
111- // List version
112- // _waitQueue.AddRange(nextStates.Select(item => new StateWithParam(item)));
113117 if ( _waitQueue . Count > 10 )
114- Debug . LogWarning ( $ "{ _owner . name } _waitQueue.Count > 10", _owner ) ;
118+ Debug . LogWarning ( $ "{ _owner . name } _waitQueue.Count > 10, wait: { _waitQueue . ToStringCollection ( ) } ", _owner ) ;
115119 nextStates . Foreach ( state => _waitQueue . Add ( state ) ) ;
116120 }
117121
@@ -165,18 +169,20 @@ private void ProcessCommand(Command command)
165169
166170 private void OnStartState ( STATE_ID stateID )
167171 {
172+ if ( _debug )
173+ Debug . Log ( $ "{ _owner . name } .FSM.OnStartState.Entry current:{ currentStateID } , new:{ stateID } , wait:{ _waitQueue . ToStringCollection ( ) } ", _owner ) ;
174+
168175 if ( _stateInstance . TryGetValue ( stateID , out TSTATE state ) == false )
169176 {
170177 Debug . LogError ( $ "{ _owner . name } .FSM.OnStartState(StateWithParam:'{ stateID } ') state is not found", _owner ) ;
171178 return ;
172179 }
173180
174181 if ( state . Equals ( currentState ) )
175- {
176182 return ;
177- }
178183
179- // Debug.Log($"OnStartState current:{currentState?.GetType().Name}, new:{state.GetType().Name}");
184+ if ( _debug )
185+ Debug . Log ( $ "{ _owner . name } .FSM.OnStartState.Execute current:{ currentStateID } , new:{ stateID } , wait:{ _waitQueue . ToStringCollection ( ) } ", _owner ) ;
180186
181187 currentState ? . OnChangeState ( state ) ;
182188 state . OnAwake ( ) ;
@@ -188,7 +194,8 @@ private void OnStartState(STATE_ID stateID)
188194
189195 private void OnFinishState ( )
190196 {
191- // Debug.Log($"OnFinishState current:{currentState?.GetType().Name}");
197+ if ( _debug )
198+ Debug . Log ( $ "{ _owner . name } .FSM.OnFinishState current:{ currentStateID } , wait:{ _waitQueue . ToStringCollection ( ) } ") ;
192199
193200 if ( _currentCoroutine != null )
194201 _owner . StopCoroutine ( _currentCoroutine ) ;
0 commit comments