@@ -47,6 +47,9 @@ public Command(CommandType commandType, STATE_ID stateID)
47
47
48
48
public event System . Action < STATE_ID , TSTATE > OnChangeState ;
49
49
50
+ [ SerializeField ]
51
+ private bool _debug ;
52
+
50
53
public STATE_ID currentStateID => _currentStateID ;
51
54
[ SerializeField ]
52
55
private STATE_ID _currentStateID ;
@@ -91,6 +94,9 @@ public void Start(MonoBehaviour owner, STATE_ID startState, params STATE_ID[] ne
91
94
/// <param name="state">변경할 스테이트</param>
92
95
public void ChangeState ( STATE_ID state )
93
96
{
97
+ if ( _debug )
98
+ Debug . Log ( $ "{ _owner . name } .FSM.ChangeState changeState:{ state } , wait:{ _waitQueue . ToStringCollection ( ) } ", _owner ) ;
99
+
94
100
_commandQueue . Add ( new Command ( CommandType . Change , state ) ) ;
95
101
}
96
102
@@ -108,10 +114,8 @@ public void FinishState()
108
114
/// <param name="nextStates"></param>
109
115
public void EnqueueToWaitQueue ( params STATE_ID [ ] nextStates )
110
116
{
111
- // List version
112
- // _waitQueue.AddRange(nextStates.Select(item => new StateWithParam(item)));
113
117
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 ) ;
115
119
nextStates . Foreach ( state => _waitQueue . Add ( state ) ) ;
116
120
}
117
121
@@ -165,18 +169,20 @@ private void ProcessCommand(Command command)
165
169
166
170
private void OnStartState ( STATE_ID stateID )
167
171
{
172
+ if ( _debug )
173
+ Debug . Log ( $ "{ _owner . name } .FSM.OnStartState.Entry current:{ currentStateID } , new:{ stateID } , wait:{ _waitQueue . ToStringCollection ( ) } ", _owner ) ;
174
+
168
175
if ( _stateInstance . TryGetValue ( stateID , out TSTATE state ) == false )
169
176
{
170
177
Debug . LogError ( $ "{ _owner . name } .FSM.OnStartState(StateWithParam:'{ stateID } ') state is not found", _owner ) ;
171
178
return ;
172
179
}
173
180
174
181
if ( state . Equals ( currentState ) )
175
- {
176
182
return ;
177
- }
178
183
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 ) ;
180
186
181
187
currentState ? . OnChangeState ( state ) ;
182
188
state . OnAwake ( ) ;
@@ -188,7 +194,8 @@ private void OnStartState(STATE_ID stateID)
188
194
189
195
private void OnFinishState ( )
190
196
{
191
- // Debug.Log($"OnFinishState current:{currentState?.GetType().Name}");
197
+ if ( _debug )
198
+ Debug . Log ( $ "{ _owner . name } .FSM.OnFinishState current:{ currentStateID } , wait:{ _waitQueue . ToStringCollection ( ) } ") ;
192
199
193
200
if ( _currentCoroutine != null )
194
201
_owner . StopCoroutine ( _currentCoroutine ) ;
0 commit comments