Fixes to issues in v4.0.1

This commit is contained in:
Adam Ramberg 2020-03-22 01:22:08 +01:00
parent 342d5331e2
commit cb5f702df6
6 changed files with 54 additions and 18 deletions

View File

@ -12,6 +12,6 @@ namespace UnityAtoms
public List<T> List { get => _list; } public List<T> List { get => _list; }
[SerializeField] [SerializeField]
private List<T> _list; private List<T> _list = default;
} }
} }

8
Packages/FSM.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6a5572b146e6849ee995630d0f3991f5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -37,18 +37,18 @@ namespace UnityAtoms.FSM
public bool IsTransitioning { get => _currentTransition != null; } public bool IsTransitioning { get => _currentTransition != null; }
[SerializeField] [SerializeField]
private FSMTransitionDataEvent _transitionStarted = default(FSMTransitionDataEvent); private FSMTransitionDataEvent _transitionStarted = default;
[SerializeField] [SerializeField]
private BoolEvent _completeCurrentTransition = default(BoolEvent); private BoolEvent _completeCurrentTransition = default;
[SerializeField] [SerializeField]
[AtomList] [AtomList]
private FSMStateListWrapper _states; private FSMStateListWrapper _states = default;
[SerializeField] [SerializeField]
[AtomList] [AtomList]
private TransitionListWrapper _transitions; private TransitionListWrapper _transitions = default;
private bool _isUpdatingState = false; private bool _isUpdatingState = false;
private Transition _currentTransition = null; private Transition _currentTransition = null;
@ -220,7 +220,7 @@ namespace UnityAtoms.FSM
Validate(); Validate();
// Set all timers to the same as the cooldown // Set all timers to the same as the cooldown
for (var i = 0; i < _states.List.Count; ++i) for (var i = 0; _states != null && _states.List != null && i < _states.List.Count; ++i)
{ {
_states.List[i].Timer = _states.List[i].Cooldown; _states.List[i].Timer = _states.List[i].Cooldown;
} }
@ -289,14 +289,14 @@ namespace UnityAtoms.FSM
private void Validate() private void Validate()
{ {
for (var i = 0; i < _transitions.List.Count; ++i) for (var i = 0; _transitions != null && _transitions.List != null && i < _transitions.List.Count; ++i)
{ {
var transition = _transitions.List[i]; var transition = _transitions.List[i];
if (!_states.List.Exists((s) => s.Id == transition.FromState)) if (_states == null || _states.List == null || !_states.List.Exists((s) => s.Id == transition.FromState))
{ {
Debug.LogError($"Transition with From State {transition.FromState} can't be found in the defined states."); Debug.LogError($"Transition with From State {transition.FromState} can't be found in the defined states.");
} }
if (!_states.List.Exists((s) => s.Id == transition.ToState)) if (_states == null || _states.List == null || !_states.List.Exists((s) => s.Id == transition.ToState))
{ {
Debug.LogError($"Transition with To State {transition.ToState} can't be found in the defined states."); Debug.LogError($"Transition with To State {transition.ToState} can't be found in the defined states.");
} }
@ -333,7 +333,7 @@ namespace UnityAtoms.FSM
private void ResetAllSubMachines() private void ResetAllSubMachines()
{ {
for (var i = 0; i < _states.List.Count; ++i) for (var i = 0; _states != null && _states.List != null && i < _states.List.Count; ++i)
{ {
if (_states.List[i].SubMachine != null) if (_states.List[i].SubMachine != null)
{ {
@ -351,7 +351,7 @@ namespace UnityAtoms.FSM
{ {
// Update timers and call OnStateCooldown handlers if applicable // Update timers and call OnStateCooldown handlers if applicable
var currentValue = Value; var currentValue = Value;
for (var i = 0; i < _states.List.Count; ++i) for (var i = 0; _states != null && _states.List != null && i < _states.List.Count; ++i)
{ {
var state = _states.List[i]; var state = _states.List[i];
if (state.Cooldown > 0f) if (state.Cooldown > 0f)
@ -401,7 +401,7 @@ namespace UnityAtoms.FSM
{ {
Transition ret = null; Transition ret = null;
for (var i = 0; i < _transitions.List.Count; ++i) for (var i = 0; _transitions != null && _transitions.List != null && i < _transitions.List.Count; ++i)
{ {
var transition = _transitions.List[i]; var transition = _transitions.List[i];
if (command == transition.Command && _currentFlatValue == transition.FromState) if (command == transition.Command && _currentFlatValue == transition.FromState)
@ -415,7 +415,7 @@ namespace UnityAtoms.FSM
private FSMState GetState(string id) private FSMState GetState(string id)
{ {
for (var i = 0; i < _states.List.Count; ++i) for (var i = 0; _states != null && _states.List != null && i < _states.List.Count; ++i)
{ {
if (_states.List[i].Id == id) if (_states.List[i].Id == id)
{ {

View File

@ -15,19 +15,19 @@ namespace UnityAtoms.FSM
public string Command { get => _command.Value; } public string Command { get => _command.Value; }
[SerializeField] [SerializeField]
private StringReference _fromState; private StringReference _fromState = default;
[SerializeField] [SerializeField]
private StringReference _toState; private StringReference _toState = default;
[SerializeField] [SerializeField]
private StringReference _command; private StringReference _command = default;
[SerializeField] [SerializeField]
private BoolVariable _testCondition; private BoolVariable _testCondition = default;
[SerializeField] [SerializeField]
private bool _raiseEventToCompleteTransition; private bool _raiseEventToCompleteTransition = default;
private FiniteStateMachine _fsmReference; private FiniteStateMachine _fsmReference;
private Action _onComplete; private Action _onComplete;

View File

@ -0,0 +1,21 @@
{
"name": "MamboJamboStudios.UnityAtomsMonoHooks.Editor",
"references": [
"GUID:14165214884ae4a619bfb290f28194a7",
"GUID:87264ae76e36244ae9adf5b5fbf7ca19",
"GUID:29492541a59d04a81b47a7f225e8a22d",
"GUID:598750ec792e4472396f5fbc092caa65",
"GUID:39d90d64ded314c27a72b2586cd86439"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9bc48b3aaac2247dbad05ace2c2d11d7
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: