├── Changelog.md ├── Changelog.md.meta ├── LICENSE ├── LICENSE.meta ├── README.md ├── README.md.meta ├── Runtime.meta ├── Runtime ├── Conditions.meta ├── Conditions │ ├── WaitFor.cs │ └── WaitFor.cs.meta ├── Example.meta ├── Example │ ├── TestStateMachine.cs │ └── TestStateMachine.cs.meta ├── HierarchicalStateMachine.cs ├── HierarchicalStateMachine.cs.meta ├── ICondition.cs ├── ICondition.cs.meta ├── IState.cs ├── IState.cs.meta ├── SharedData.cs ├── SharedData.cs.meta ├── State Machines.meta ├── State Machines │ ├── CustomStateMachine.cs │ └── CustomStateMachine.cs.meta ├── StateMachine.cs ├── StateMachine.cs.meta ├── States.meta ├── States │ ├── CustomState.cs │ ├── CustomState.cs.meta │ ├── Empty.cs │ └── Empty.cs.meta ├── com.intothedev.ai.asmdef └── com.intothedev.ai.asmdef.meta ├── package.json └── package.json.meta /Changelog.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Changelog.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a560aca8f58749f4a92858a0299d237f 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Vladislav Kinyashov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c1c232982d224de42ab5c2f19ae3b62c 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Hierarchical State Machine for Unity. Most likely I will rewrite it multiple times in the future but for now it suits my needs. 2 | 3 | ### TODO 4 | - [ ] Rewrite everything 5 | 6 | ## How to Install 7 | ### Git Installation 8 | 9 | If you have Git on your computer, you can open Package Manager indside Unity, select "Add package from Git url...", and paste link ```https://github.com/IntoTheDev/Hierarchical-State-Machine-for-Unity.git``` 10 | 11 | or 12 | 13 | Open the manifest.json file of your Unity project. 14 | Add ```"com.intothedev.ai": "https://github.com/IntoTheDev/Hierarchical-State-Machine-for-Unity.git"``` 15 | 16 | ## Simple Example: 17 | ```csharp 18 | public class TestStateMachine : HierarchicalStateMachine 19 | { 20 | [SerializeField] private float _timeInPatrol = 1f; 21 | [SerializeField] private float _timeInIdle = 3f; 22 | 23 | protected override StateMachine Setup() 24 | { 25 | var patrolState = new PatrolState(transform, speed: 5f, randomizeStartSpeed: true); 26 | var emptyState = new Empty(); 27 | 28 | var stateMachine = new StateMachine() 29 | .Configure(startState: patrolState) 30 | .AddTransition(patrolState, emptyState, new WaitFor(waitFor: 1f), reversed: false) 31 | .AddTransition(emptyState, patrolState, new WaitFor(waitFor: 3f), reversed: false); 32 | 33 | return stateMachine; 34 | } 35 | } 36 | ``` 37 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f11d45a17f0439649ac275aa493d2a8f 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c2b30cc6a011b4647905afb4c4ca6af4 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Conditions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78ebaa11da6866b4fa0de525df053db1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Conditions/WaitFor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace ToolBox.StateMachine 4 | { 5 | [System.Serializable] 6 | public class WaitFor : ICondition 7 | { 8 | [SerializeField, Min(0f)] private float _waitFor = 0f; 9 | private float _timeSpend = 0f; 10 | 11 | public WaitFor(float waitFor) => 12 | _waitFor = waitFor; 13 | 14 | public void OnEnter() => 15 | _timeSpend = 0f; 16 | 17 | public bool Check(float deltaTime) 18 | { 19 | _timeSpend += deltaTime; 20 | return _timeSpend >= _waitFor; 21 | } 22 | 23 | public void OnExit() { } 24 | 25 | public void OnResume() { } 26 | 27 | public void OnPause() { } 28 | } 29 | } -------------------------------------------------------------------------------- /Runtime/Conditions/WaitFor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f627e714efb4324ba7bd8d5d927e0ed 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Example.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 423b3df1e13e0c14b82b1a9836b63336 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Example/TestStateMachine.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace ToolBox.StateMachine.Examples 4 | { 5 | public class TestStateMachine : HierarchicalStateMachine 6 | { 7 | protected override StateMachine Setup() 8 | { 9 | var patrolState = new PatrolState(transform, speed: 5f, randomizeStartSpeed: true); 10 | var emptyState = new Empty(); 11 | 12 | var stateMachine = new CustomStateMachine() 13 | .Configure(patrolState) 14 | .AddTransition(patrolState, emptyState, new WaitFor(waitFor: 1f), reversed: false) 15 | .AddTransition(emptyState, patrolState, new WaitFor(waitFor: 3f), reversed: false); 16 | 17 | return stateMachine; 18 | } 19 | } 20 | 21 | public class PatrolState : IState 22 | { 23 | private Transform _transform = null; 24 | private float _speed = 5f; 25 | private float _currentSpeed = 0f; 26 | 27 | public PatrolState(Transform transform, float speed, bool randomizeStartSpeed) 28 | { 29 | _transform = transform; 30 | _speed = speed; 31 | 32 | if (randomizeStartSpeed) 33 | { 34 | var possibleValues = new float[] { -_speed, _speed }; 35 | _currentSpeed = possibleValues[Random.Range(0, possibleValues.Length)]; 36 | } 37 | } 38 | 39 | public void OnEnter() => 40 | _currentSpeed = _currentSpeed == _speed ? -_speed : _speed; 41 | 42 | public void OnExit() { } 43 | 44 | public void OnPause() { } 45 | 46 | public void OnResume() { } 47 | 48 | public void Tick(float deltaTime) 49 | { 50 | var move = Vector3.right * (_currentSpeed * deltaTime); 51 | _transform.position += move; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Runtime/Example/TestStateMachine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 26f0daad95edebd44a992dfd24d62964 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/HierarchicalStateMachine.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace ToolBox.StateMachine 4 | { 5 | [DisallowMultipleComponent] 6 | public abstract class HierarchicalStateMachine : MonoBehaviour 7 | { 8 | private StateMachine _currentStateMachine = null; 9 | private bool _wasDisabled = false; 10 | 11 | private void Start() 12 | { 13 | _currentStateMachine = Setup(); 14 | _currentStateMachine.OnEnter(); 15 | } 16 | 17 | private void OnEnable() 18 | { 19 | if (_wasDisabled) 20 | _currentStateMachine?.OnResume(); 21 | } 22 | 23 | private void OnDisable() 24 | { 25 | _currentStateMachine?.OnPause(); 26 | _wasDisabled = true; 27 | } 28 | 29 | private void OnDestroy() => 30 | _currentStateMachine?.OnExit(); 31 | 32 | private void Update() => 33 | _currentStateMachine.Tick(Time.deltaTime); 34 | 35 | protected abstract StateMachine Setup(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Runtime/HierarchicalStateMachine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ebc7b0036a318c41a47ad2fb8dd5646 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/ICondition.cs: -------------------------------------------------------------------------------- 1 | namespace ToolBox.StateMachine 2 | { 3 | public interface ICondition 4 | { 5 | void OnEnter(); 6 | 7 | void OnResume(); 8 | 9 | bool Check(float deltaTime); 10 | 11 | void OnPause(); 12 | 13 | void OnExit(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Runtime/ICondition.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a28ce8ef4cbb7cc4ea8c4ad6414b231c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/IState.cs: -------------------------------------------------------------------------------- 1 | namespace ToolBox.StateMachine 2 | { 3 | public interface IState 4 | { 5 | void Tick(float deltaTime); 6 | 7 | void OnEnter(); 8 | 9 | void OnExit(); 10 | 11 | void OnResume(); 12 | 13 | void OnPause(); 14 | } 15 | } -------------------------------------------------------------------------------- /Runtime/IState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ba4bd6ca3cb6bd54aa0ae214a1923ba7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/SharedData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace ToolBox.StateMachine 5 | { 6 | [Serializable] 7 | public class SharedData 8 | { 9 | [SerializeField] private T _value = default; 10 | 11 | public T Value 12 | { 13 | get => _value; 14 | 15 | set 16 | { 17 | _value = value; 18 | OnValueChanged?.Invoke(_value); 19 | } 20 | } 21 | 22 | public event Action OnValueChanged = null; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Runtime/SharedData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3240d4eab9b251a43a8b76d9e0fe757a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/State Machines.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0486ce4bf00ad1b4c880e0e48939eff1 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/State Machines/CustomStateMachine.cs: -------------------------------------------------------------------------------- 1 | namespace ToolBox.StateMachine 2 | { 3 | public class CustomStateMachine : StateMachine { } 4 | } -------------------------------------------------------------------------------- /Runtime/State Machines/CustomStateMachine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce8949978653a9e4d846349212c6be00 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/StateMachine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace ToolBox.StateMachine 6 | { 7 | [Serializable] 8 | public abstract class StateMachine : IState 9 | { 10 | protected IState _startState; 11 | private IState _currentState; 12 | private Dictionary> _transitions = new Dictionary>(); 13 | private List _currentTransitions = new List(); 14 | private List _anyTransitions = new List(); 15 | private List _concurrentStates = new List(); 16 | 17 | private static List _emptyTransitions = new List(0); 18 | 19 | public IState CurrentState => _currentState; 20 | 21 | public void OnResume() 22 | { 23 | _currentState?.OnResume(); 24 | 25 | var count = _concurrentStates.Count; 26 | for (int i = 0; i < count; i++) 27 | _concurrentStates[i].OnResume(); 28 | 29 | OnTransitionsResume(_currentTransitions); 30 | OnTransitionsResume(_anyTransitions); 31 | } 32 | 33 | public void OnPause() 34 | { 35 | _currentState?.OnPause(); 36 | 37 | var count = _concurrentStates.Count; 38 | for (int i = 0; i < count; i++) 39 | _concurrentStates[i].OnPause(); 40 | 41 | OnTransitionsPause(_currentTransitions); 42 | OnTransitionsPause(_anyTransitions); 43 | } 44 | 45 | public void OnEnter() 46 | { 47 | SetState(_startState, true); 48 | 49 | var count = _concurrentStates.Count; 50 | for (int i = 0; i < count; i++) 51 | _concurrentStates[i].OnEnter(); 52 | 53 | OnTransitionsEnter(_anyTransitions); 54 | } 55 | 56 | public void Tick(float deltaTime) 57 | { 58 | var transition = GetTransition(deltaTime); 59 | if (transition != null) 60 | SetState(transition.To, false); 61 | 62 | _currentState?.Tick(deltaTime); 63 | 64 | var count = _concurrentStates.Count; 65 | for (int i = 0; i < count; i++) 66 | _concurrentStates[i].Tick(deltaTime); 67 | } 68 | 69 | public void OnExit() 70 | { 71 | _currentState?.OnExit(); 72 | 73 | var count = _concurrentStates.Count; 74 | for (int i = 0; i < count; i++) 75 | _concurrentStates[i].OnExit(); 76 | 77 | OnTransitionsExit(_currentTransitions); 78 | OnTransitionsExit(_anyTransitions); 79 | } 80 | 81 | public void SetState(IState state, bool force) 82 | { 83 | if (state == _currentState && !force) 84 | return; 85 | 86 | if (_currentState != null) 87 | { 88 | _currentState.OnExit(); 89 | OnTransitionsExit(_currentTransitions); 90 | } 91 | 92 | _currentState = state; 93 | 94 | _transitions.TryGetValue(_currentState.GetHashCode(), out _currentTransitions); 95 | if (_currentTransitions == null) 96 | _currentTransitions = _emptyTransitions; 97 | 98 | _currentState.OnEnter(); 99 | OnTransitionsEnter(_currentTransitions); 100 | } 101 | 102 | public StateMachine AddTransition(IState from, IState to, ICondition predicate, bool reversed) 103 | { 104 | if (_transitions.TryGetValue(from.GetHashCode(), out var transitions) == false) 105 | { 106 | transitions = new List(); 107 | _transitions[from.GetHashCode()] = transitions; 108 | } 109 | 110 | transitions.Add(new Transition(to, predicate, reversed)); 111 | 112 | return this; 113 | } 114 | 115 | public StateMachine AddAnyTransition(IState state, ICondition predicate, bool reversed) 116 | { 117 | _anyTransitions.Add(new Transition(state, predicate, reversed)); 118 | 119 | return this; 120 | } 121 | 122 | public StateMachine AddConcurrentState(IState state) 123 | { 124 | if (!_concurrentStates.Contains(state)) 125 | _concurrentStates.Add(state); 126 | 127 | return this; 128 | } 129 | 130 | public StateMachine Configure() 131 | { 132 | _transitions = new Dictionary>(); 133 | _currentTransitions = new List(); 134 | _anyTransitions = new List(); 135 | _concurrentStates = new List(); 136 | 137 | Postconfigure(); 138 | 139 | return this; 140 | } 141 | 142 | public StateMachine Configure(IState startState) 143 | { 144 | _startState = startState; 145 | 146 | Configure(); 147 | 148 | return this; 149 | } 150 | 151 | protected virtual void Postconfigure() { } 152 | 153 | private Transition GetTransition(float deltaTime) 154 | { 155 | int count = _currentTransitions.Count; 156 | 157 | for (int i = 0; i < count; i++) 158 | { 159 | Transition transition = _currentTransitions[i]; 160 | 161 | var conditionResult = transition.Condition.Check(deltaTime); 162 | var isReversed = transition.Reversed; 163 | 164 | var canTransition = (conditionResult && !isReversed) || (!conditionResult && isReversed); 165 | 166 | if (canTransition) 167 | return transition; 168 | } 169 | 170 | count = _anyTransitions.Count; 171 | 172 | for (int i = 0; i < count; i++) 173 | { 174 | Transition transition = _anyTransitions[i]; 175 | 176 | var conditionResult = transition.Condition.Check(deltaTime); 177 | var isReversed = transition.Reversed; 178 | 179 | var canTransition = (conditionResult && !isReversed) || (!conditionResult && isReversed); 180 | 181 | if (canTransition) 182 | return transition; 183 | } 184 | 185 | return null; 186 | } 187 | 188 | private void OnTransitionsEnter(List transitions) 189 | { 190 | int count = transitions.Count; 191 | 192 | for (int i = 0; i < count; i++) 193 | transitions[i].Condition.OnEnter(); 194 | } 195 | 196 | private void OnTransitionsResume(List transitions) 197 | { 198 | int count = transitions.Count; 199 | 200 | for (int i = 0; i < count; i++) 201 | transitions[i].Condition.OnResume(); 202 | } 203 | 204 | private void OnTransitionsExit(List transitions) 205 | { 206 | int count = transitions.Count; 207 | 208 | for (int i = 0; i < count; i++) 209 | transitions[i].Condition.OnExit(); 210 | } 211 | 212 | private void OnTransitionsPause(List transitions) 213 | { 214 | int count = transitions.Count; 215 | 216 | for (int i = 0; i < count; i++) 217 | transitions[i].Condition.OnPause(); 218 | } 219 | 220 | private class Transition 221 | { 222 | public ICondition Condition { get; } = null; 223 | public IState To { get; } = null; 224 | public bool Reversed { get; } = false; 225 | 226 | public Transition(IState to, ICondition condition, bool reversed) 227 | { 228 | To = to; 229 | Condition = condition; 230 | Reversed = reversed; 231 | } 232 | } 233 | } 234 | } 235 | -------------------------------------------------------------------------------- /Runtime/StateMachine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e9906803959965c489e88375b2f3e2a2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/States.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d2baf0fdfacce4440b228281f514e1a7 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/States/CustomState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ToolBox.StateMachine 4 | { 5 | public class CustomState : IState 6 | { 7 | private event Action _action = null; 8 | 9 | public CustomState(Action action) => 10 | _action += action; 11 | 12 | public void OnEnter() { } 13 | 14 | public void OnExit() { } 15 | 16 | public void OnPause() { } 17 | 18 | public void OnResume() { } 19 | 20 | public void Tick(float deltaTime) => 21 | _action?.Invoke(); 22 | } 23 | } -------------------------------------------------------------------------------- /Runtime/States/CustomState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3900149de6eb53148863bc7f44fec35d 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/States/Empty.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace ToolBox.StateMachine 4 | { 5 | [System.Serializable] 6 | public class Empty : IState 7 | { 8 | public void OnEnter() 9 | { 10 | 11 | } 12 | 13 | public void OnExit() 14 | { 15 | 16 | } 17 | 18 | public void OnPause() 19 | { 20 | 21 | } 22 | 23 | public void OnResume() 24 | { 25 | 26 | } 27 | 28 | public void Tick(float deltaTime) 29 | { 30 | 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Runtime/States/Empty.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 15dbd7984f7e7074b84c5378e8d1c3f6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/com.intothedev.ai.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.intothedev.ai" 3 | } 4 | -------------------------------------------------------------------------------- /Runtime/com.intothedev.ai.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e775100da2eff4f43bfaceca8c8e6835 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.intothedev.ai", 3 | "version": "1.1.0", 4 | "displayName": "Hierarchical State Machine", 5 | "description": "", 6 | "author": { 7 | "name": "IntoTheDev", 8 | "email": "indraayy322@gmail.com", 9 | "url": "https://github.com/IntoTheDev" 10 | }, 11 | "type": "tool" 12 | } 13 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 64ba4d4e9d08c8d4582834bbb774803f 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | --------------------------------------------------------------------------------