|
|
|
|
|
|
using UnityEngine; |
|
|
|
using UOP1.StateMachine.ScriptableObjects; |
|
|
|
using UOP1.StateMachine.ScriptableObjects; |
|
|
|
|
|
|
|
namespace UOP1.StateMachine |
|
|
|
{ |
|
|
|
|
|
|
/// </summary>
|
|
|
|
internal bool GetStatement() |
|
|
|
{ |
|
|
|
bool returnValue; |
|
|
|
if (!_originSO.cacheResult) |
|
|
|
return Statement(); |
|
|
|
if (_originSO.cacheResult && _isCached) |
|
|
|
returnValue = _cachedStatement; |
|
|
|
else |
|
|
|
if (!_isCached) |
|
|
|
returnValue = Statement(); |
|
|
|
|
|
|
|
if (_originSO.cacheResult) |
|
|
|
{ |
|
|
|
_isCached = true; |
|
|
|
_cachedStatement = returnValue; |
|
|
|
} |
|
|
|
_isCached = true; |
|
|
|
_cachedStatement = Statement(); |
|
|
|
return returnValue; |
|
|
|
return _cachedStatement; |
|
|
|
} |
|
|
|
|
|
|
|
internal void ClearStatementCache() |
|
|
|
|
|
|
/// </summary>
|
|
|
|
public readonly struct StateCondition |
|
|
|
{ |
|
|
|
internal readonly StateConditionSO _originSO; |
|
|
|
public StateCondition(StateConditionSO originSO, StateMachine stateMachine, Condition condition, bool expectedResult) |
|
|
|
public StateCondition(StateMachine stateMachine, Condition condition, bool expectedResult) |
|
|
|
_originSO = originSO; |
|
|
|
_condition._originSO = originSO; |
|
|
|
_expectedResult = expectedResult; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
bool isMet = statement == _expectedResult; |
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
_stateMachine._debugger.TransitionConditionResult(_originSO.name, statement, isMet); |
|
|
|
_stateMachine._debugger.TransitionConditionResult(_condition._originSO.name, statement, isMet); |
|
|
|
#endif
|
|
|
|
return isMet; |
|
|
|
} |