diff --git a/UOP1_Project/Assets/Prefabs/Characters/SlimeCritter_Base.prefab b/UOP1_Project/Assets/Prefabs/Characters/SlimeCritter_Base.prefab index 31f549ae2e..73763014da 100644 --- a/UOP1_Project/Assets/Prefabs/Characters/SlimeCritter_Base.prefab +++ b/UOP1_Project/Assets/Prefabs/Characters/SlimeCritter_Base.prefab @@ -96,7 +96,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 1eeda163c70b3cb4ebb88ba92f608fd8, type: 3} m_Name: m_EditorClassIdentifier: - _transitionTableSO: {fileID: 11400000, guid: c106e88137c90384bb4b18ba46869b64, type: 2} + _transitionTableSO: {fileID: 11400000, guid: 97384f5b5a9cc0e47aaff3a52d666851, type: 2} _debugger: debugTransitions: 0 appendConditionsInfo: 1 diff --git a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/Actions/RoamingStateMachine.asset b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/Actions/RoamingStateMachine.asset new file mode 100644 index 0000000000..e9e2903045 --- /dev/null +++ b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/Actions/RoamingStateMachine.asset @@ -0,0 +1,15 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3f0633ea79d4a789da71a1872f069ec5, type: 3} + m_Name: RoamingStateMachine + m_EditorClassIdentifier: + _transitionTableSO: {fileID: 11400000, guid: 78d9b7ea1925a748c89267477d971b09, type: 2} diff --git a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/Actions/RoamingStateMachine.asset.meta b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/Actions/RoamingStateMachine.asset.meta new file mode 100644 index 0000000000..77b8eeebf9 --- /dev/null +++ b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/Actions/RoamingStateMachine.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c7c61620b878156d0be2d17161a60f6d +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/RoamingTable.asset b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/RoamingTable.asset new file mode 100644 index 0000000000..cdc3d9b4b5 --- /dev/null +++ b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/RoamingTable.asset @@ -0,0 +1,27 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 872cbaa965d1f6e4e98365d74e2060df, type: 3} + m_Name: RoamingTable + m_EditorClassIdentifier: + _transitions: + - FromState: {fileID: 11400000, guid: 0fe0dc68c0fc2604ca06ad36d16b1117, type: 2} + ToState: {fileID: 11400000, guid: 4b41f0e0e0982384b8f7a718509ea3a9, type: 2} + Conditions: + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: 6519cfc02b3c6c34d8607ac0645ef287, type: 2} + Operator: 0 + - FromState: {fileID: 11400000, guid: 4b41f0e0e0982384b8f7a718509ea3a9, type: 2} + ToState: {fileID: 11400000, guid: 0fe0dc68c0fc2604ca06ad36d16b1117, type: 2} + Conditions: + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: 822af955c346ff5429598d4280c5ba73, type: 2} + Operator: 0 diff --git a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/RoamingTable.asset.meta b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/RoamingTable.asset.meta new file mode 100644 index 0000000000..6cbd2cd820 --- /dev/null +++ b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/RoamingTable.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 78d9b7ea1925a748c89267477d971b09 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/SlimeRockCritter_Simplified_TransitionTable.asset b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/SlimeRockCritter_Simplified_TransitionTable.asset new file mode 100644 index 0000000000..b6be9a6b50 --- /dev/null +++ b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/SlimeRockCritter_Simplified_TransitionTable.asset @@ -0,0 +1,129 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 872cbaa965d1f6e4e98365d74e2060df, type: 3} + m_Name: SlimeRockCritter_Simplified_TransitionTable + m_EditorClassIdentifier: + _transitions: + - FromState: {fileID: 11400000, guid: 58ed5fdf35d804093aa322bf33a82f30, type: 2} + ToState: {fileID: 11400000, guid: ea7a8e48b1a87c241bb721da98d1d812, type: 2} + Conditions: + - ExpectedResult: 1 + Condition: {fileID: 11400000, guid: 72dd7a9972bd3614ead2fd62cebc6144, type: 2} + Operator: 0 + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: 27c06ead5f7a1ed4d89197fe9a61d0c2, type: 2} + Operator: 0 + - FromState: {fileID: 11400000, guid: ea7a8e48b1a87c241bb721da98d1d812, type: 2} + ToState: {fileID: 11400000, guid: 5b0e38103a74c054cb968153b3227b71, type: 2} + Conditions: + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: 1ff6d66c9ad367543beb3f2455a1d06c, type: 2} + Operator: 0 + - FromState: {fileID: 11400000, guid: ea7a8e48b1a87c241bb721da98d1d812, type: 2} + ToState: {fileID: 11400000, guid: 05826b0374eccc245b9b1da390ab7d04, type: 2} + Conditions: + - ExpectedResult: 1 + Condition: {fileID: 11400000, guid: 72dd7a9972bd3614ead2fd62cebc6144, type: 2} + Operator: 0 + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: 3d30788033cfd9d4fa24fa5112d9430c, type: 2} + Operator: 0 + - FromState: {fileID: 11400000, guid: 05826b0374eccc245b9b1da390ab7d04, type: 2} + ToState: {fileID: 11400000, guid: ea7a8e48b1a87c241bb721da98d1d812, type: 2} + Conditions: + - ExpectedResult: 1 + Condition: {fileID: 11400000, guid: 3d30788033cfd9d4fa24fa5112d9430c, type: 2} + Operator: 0 + - FromState: {fileID: 11400000, guid: 05826b0374eccc245b9b1da390ab7d04, type: 2} + ToState: {fileID: 11400000, guid: 0fe9688a46e58a24d8a88cd363a8e472, type: 2} + Conditions: + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: 5d0cf556c54f5154a9edc595f1958590, type: 2} + Operator: 0 + - FromState: {fileID: 11400000, guid: 0fe9688a46e58a24d8a88cd363a8e472, type: 2} + ToState: {fileID: 11400000, guid: 5b0e38103a74c054cb968153b3227b71, type: 2} + Conditions: + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: 1ff6d66c9ad367543beb3f2455a1d06c, type: 2} + Operator: 0 + - FromState: {fileID: 11400000, guid: 0fe9688a46e58a24d8a88cd363a8e472, type: 2} + ToState: {fileID: 11400000, guid: 658f06f54a3654c498a26d9714beaff0, type: 2} + Conditions: + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: 8d78c6cbad5610342b28e8f66a8a9d11, type: 2} + Operator: 0 + - FromState: {fileID: 11400000, guid: 628073f665cfda9468013b5ecbc7e6c3, type: 2} + ToState: {fileID: 11400000, guid: f4a07080dd036db4392317bdcd3c20b4, type: 2} + Conditions: + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: c06b3d79b9eb00344825524cd0f6091a, type: 2} + Operator: 0 + - FromState: {fileID: 11400000, guid: 5b0e38103a74c054cb968153b3227b71, type: 2} + ToState: {fileID: 11400000, guid: ea7a8e48b1a87c241bb721da98d1d812, type: 2} + Conditions: + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: b5098991df6fea14294cbd13e586cfd8, type: 2} + Operator: 0 + - FromState: {fileID: 11400000, guid: 05826b0374eccc245b9b1da390ab7d04, type: 2} + ToState: {fileID: 11400000, guid: 5b0e38103a74c054cb968153b3227b71, type: 2} + Conditions: + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: 1ff6d66c9ad367543beb3f2455a1d06c, type: 2} + Operator: 0 + - FromState: {fileID: 11400000, guid: 5b0e38103a74c054cb968153b3227b71, type: 2} + ToState: {fileID: 11400000, guid: 05826b0374eccc245b9b1da390ab7d04, type: 2} + Conditions: + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: b5098991df6fea14294cbd13e586cfd8, type: 2} + Operator: 0 + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: 3d30788033cfd9d4fa24fa5112d9430c, type: 2} + Operator: 0 + - FromState: {fileID: 11400000, guid: 05826b0374eccc245b9b1da390ab7d04, type: 2} + ToState: {fileID: 11400000, guid: 628073f665cfda9468013b5ecbc7e6c3, type: 2} + Conditions: + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: fa8a674126a68004888ee6cef86cb5f5, type: 2} + Operator: 0 + - FromState: {fileID: 11400000, guid: 5b0e38103a74c054cb968153b3227b71, type: 2} + ToState: {fileID: 11400000, guid: 628073f665cfda9468013b5ecbc7e6c3, type: 2} + Conditions: + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: fa8a674126a68004888ee6cef86cb5f5, type: 2} + Operator: 0 + - FromState: {fileID: 11400000, guid: 658f06f54a3654c498a26d9714beaff0, type: 2} + ToState: {fileID: 11400000, guid: 05826b0374eccc245b9b1da390ab7d04, type: 2} + Conditions: + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: 8f1dae963c547274b808dd5db78a28e3, type: 2} + Operator: 0 + - FromState: {fileID: 11400000, guid: 658f06f54a3654c498a26d9714beaff0, type: 2} + ToState: {fileID: 11400000, guid: 5b0e38103a74c054cb968153b3227b71, type: 2} + Conditions: + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: 1ff6d66c9ad367543beb3f2455a1d06c, type: 2} + Operator: 0 + - FromState: {fileID: 11400000, guid: 658f06f54a3654c498a26d9714beaff0, type: 2} + ToState: {fileID: 11400000, guid: 628073f665cfda9468013b5ecbc7e6c3, type: 2} + Conditions: + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: fa8a674126a68004888ee6cef86cb5f5, type: 2} + Operator: 0 + - FromState: {fileID: 11400000, guid: ea7a8e48b1a87c241bb721da98d1d812, type: 2} + ToState: {fileID: 11400000, guid: 58ed5fdf35d804093aa322bf33a82f30, type: 2} + Conditions: + - ExpectedResult: 0 + Condition: {fileID: 11400000, guid: 72dd7a9972bd3614ead2fd62cebc6144, type: 2} + Operator: 1 + - ExpectedResult: 1 + Condition: {fileID: 11400000, guid: 27c06ead5f7a1ed4d89197fe9a61d0c2, type: 2} + Operator: 0 diff --git a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/SlimeRockCritter_Simplified_TransitionTable.asset.meta b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/SlimeRockCritter_Simplified_TransitionTable.asset.meta new file mode 100644 index 0000000000..5ccc9ee37c --- /dev/null +++ b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/SlimeRockCritter_Simplified_TransitionTable.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 97384f5b5a9cc0e47aaff3a52d666851 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/SlimeRockCritter_TransitionTable.asset b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/SlimeRockCritter_TransitionTable.asset index 417d0efe51..fb5486875b 100644 --- a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/SlimeRockCritter_TransitionTable.asset +++ b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/SlimeRockCritter_TransitionTable.asset @@ -130,6 +130,9 @@ MonoBehaviour: - FromState: {fileID: 11400000, guid: 4b41f0e0e0982384b8f7a718509ea3a9, type: 2} ToState: {fileID: 11400000, guid: ea7a8e48b1a87c241bb721da98d1d812, type: 2} Conditions: + - ExpectedResult: 1 + Condition: {fileID: 11400000, guid: 72dd7a9972bd3614ead2fd62cebc6144, type: 2} + Operator: 0 - ExpectedResult: 0 Condition: {fileID: 11400000, guid: 27c06ead5f7a1ed4d89197fe9a61d0c2, type: 2} Operator: 0 diff --git a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/States/Roaming.asset b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/States/RoamingMove.asset similarity index 96% rename from UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/States/Roaming.asset rename to UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/States/RoamingMove.asset index 566836f90d..669570c837 100644 --- a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/States/Roaming.asset +++ b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/States/RoamingMove.asset @@ -10,7 +10,7 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 35432205b9a6a374bbbfe6b7cac92179, type: 3} - m_Name: Roaming + m_Name: RoamingMove m_EditorClassIdentifier: _actions: - {fileID: 11400000, guid: 46af8bb2ed6efed4ab26d05dfc1b560f, type: 2} diff --git a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/States/Roaming.asset.meta b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/States/RoamingMove.asset.meta similarity index 100% rename from UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/States/Roaming.asset.meta rename to UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/States/RoamingMove.asset.meta diff --git a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/States/RoamingState.asset b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/States/RoamingState.asset new file mode 100644 index 0000000000..ae4ac34ca4 --- /dev/null +++ b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/States/RoamingState.asset @@ -0,0 +1,16 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 35432205b9a6a374bbbfe6b7cac92179, type: 3} + m_Name: RoamingState + m_EditorClassIdentifier: + _actions: + - {fileID: 11400000, guid: c7c61620b878156d0be2d17161a60f6d, type: 2} diff --git a/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/States/RoamingState.asset.meta b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/States/RoamingState.asset.meta new file mode 100644 index 0000000000..942769223c --- /dev/null +++ b/UOP1_Project/Assets/ScriptableObjects/StateMachine/Critters/SlimeRockCritter/States/RoamingState.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 58ed5fdf35d804093aa322bf33a82f30 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateMachineActionSO.cs b/UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateMachineActionSO.cs new file mode 100644 index 0000000000..b2a4262d90 --- /dev/null +++ b/UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateMachineActionSO.cs @@ -0,0 +1,56 @@ +namespace UOP1.StateMachine.ScriptableObjects +{ + using UnityEngine; + using UOP1.StateMachine; + using System; + using System.Collections.Generic; + + [CreateAssetMenu(fileName = "StateMachineAction", menuName = "State Machines/Actions/StateMachine")] + public class StateMachineActionSO : StateActionSO + { + [Tooltip("Set the initial state of this StateMachine")] + public TransitionTableSO _transitionTableSO = default; + } + + public class StateMachineAction : StateAction + { + private new StateMachineActionSO _originSO => (StateMachineActionSO)base.OriginSO; // The SO this StateAction spawned from + private readonly Dictionary _cachedComponents = new Dictionary(); + internal State _currentState; + + private StateMachine _parentStateMachine = default; + private State _initialState = default; + + public override void Awake(StateMachine stateMachine) + { + _parentStateMachine = stateMachine; + _initialState = _originSO._transitionTableSO.GetInitialState(stateMachine); + } + + public override void OnStateEnter() + { + _currentState = _initialState; + _currentState.OnStateEnter(); + } + + public override void OnUpdate() + { + if (_currentState.TryGetTransition(out var transitionState)) + Transition(transitionState); + + _currentState.OnUpdate(); + } + + public override void OnStateExit() + { + _currentState.OnStateExit(); + } + + private void Transition(State transitionState) + { + _currentState.OnStateExit(); + _currentState = transitionState; + _currentState.OnStateEnter(); + } + } +} diff --git a/UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateMachineActionSO.cs.meta b/UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateMachineActionSO.cs.meta new file mode 100644 index 0000000000..0de779f17a --- /dev/null +++ b/UOP1_Project/Assets/Scripts/StateMachine/ScriptableObjects/StateMachineActionSO.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3f0633ea79d4a789da71a1872f069ec5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: