// ------------------------------------------------------ /* * In most real-world instances, you wouldn't want this component to begin processing from Start()! * The owning NPC should really call Restart() when it's ready to being AI processing. This is here * purely to make the demo work quickly :) */ void Start() { if (m_aAIActions.Count > 0) { m_iState = EAIControllerState._RUNNING; } }
// ------------------------------------------------------------------------------------------------------------------- // Interface // ------------------------------------------------------------------------------------------------------------------- /* * OnEnable, search the game object we're attached to and collate all the AIAction scripts that have been added. * These are maintained in a list, that is iterated over each frame... */ void OnEnable() { m_aAIActions.Clear(); foreach (var Action in GetComponents <AIAction>()) { m_aAIActions.Add(Action); } m_iState = EAIControllerState._IDLE; Debug.Log("AIController: Found " + m_aAIActions.Count + " AIActions on this gameObject [" + gameObject.name + "]"); }
// ------------------------------------------------------ public void Restart() { m_iState = EAIControllerState._RUNNING; m_CurrentAction = null; OnRestart?.Invoke(); }
// ------------------------------------------------------ public void Stop() { m_iState = EAIControllerState._STOPPED; m_CurrentAction = null; OnStop?.Invoke(); }