/// <summary> /// Add behaviour to data. /// </summary> /// <param name="hBehaviour">Behaviour want to add to data.</param> public virtual void AddBehaviour(BaseActorBehaviour hBehaviour) { if (hBehaviour == null) { return; } if (listBehaviour == null) { listBehaviour = new List <BaseActorBehaviour>(); } listBehaviour.Add(hBehaviour); CreateBehaviour(hBehaviour); }
/// <summary> /// Call stop function in this behaviour. /// </summary> /// <param name="hBehaviour">Behaviour want to call stop.</param> protected virtual void StopBehaviour(BaseActorBehaviour hBehaviour) { if (listBehaviourRunning == null) { listBehaviourRunning = new List <BaseActorBehaviour>(); } if (hBehaviour == null || !listBehaviourRunning.Contains(hBehaviour)) { return; } listBehaviourRunning.Remove(hBehaviour); hBehaviour.OnStopBehaviour(this); }
public static void RunEvent(this BaseActorBehaviourEvent[] arrayEvent, BaseActorController hBaseController, BaseActorBehaviour hBaseBehaviour) { if (arrayEvent == null || arrayEvent.Length <= 0) { return; } for (int i = 0; i < arrayEvent.Length; i++) { var hEvent = arrayEvent[i]; if (hEvent != null) { hEvent.RunEvent(hBaseController, hBaseBehaviour); } } }
public static void RunEvent(this List <BaseActorBehaviourEvent> listEvent, BaseActorController hBaseController, BaseActorBehaviour hBaseBehaviour) { if (listEvent == null || listEvent.Count <= 0) { return; } for (int i = 0; i < listEvent.Count; i++) { var hEvent = listEvent[i]; if (hEvent != null) { hEvent.RunEvent(hBaseController, hBaseBehaviour); } } }
/// <summary> /// Call late update function in this behaviour. /// </summary> /// <param name="behaviour">Behaviour want to call late update.</param> protected virtual void LateUpdateBehaviour(BaseActorBehaviour behaviour) { behaviour?.OnLateUpdateBehaviour(this); }
/// <summary> /// Call fix update function in this behaviour. /// </summary> /// <param name="behaviour">Behaviour want to call fixed update.</param> protected virtual void FixedUpdateBehaviour(BaseActorBehaviour behaviour) { behaviour?.OnFixedUpdateBehaviour(this); }
/// <summary> /// Call destroy function in this behaviour. /// </summary> /// <param name="hBehaviour">Behaviour want to call destroy.</param> protected virtual void DestroyBehaviour(BaseActorBehaviour hBehaviour) { hBehaviour?.OnDestroyBehaviour(this); }
/// <summary> /// Call create function in this behaviour. /// </summary> /// <param name="hBehaviour">Behaviour want to call create.</param> protected virtual void CreateBehaviour(BaseActorBehaviour hBehaviour) { hBehaviour?.OnCreateBehaviour(this); }
/// <summary> /// Remove this behaviour type ID in data and add new one to data instead. /// </summary> /// <param name="hNewBehaviour">New behaviour for replace old one.</param> public virtual void ChangeBehaviour(BaseActorBehaviour hNewBehaviour) { RemoveBehaviour(hNewBehaviour.behaviourTypeID); AddBehaviour(hNewBehaviour); }
/// <summary> /// Remove this behaviour type in data and add new one to data instead. /// </summary> /// <typeparam name="T">Behaviour type that want to change.(Remove first one that found.)</typeparam> /// <param name="hNewBehaviour">>New behaviour for replace old one.</param> public virtual void ChangeBehaviour <T>(BaseActorBehaviour hNewBehaviour) where T : BaseActorBehaviour { RemoveBehaviour <T>(); AddBehaviour(hNewBehaviour); }
public abstract void RunEvent(BaseActorController hBaseController, BaseActorBehaviour hBaseBehaviour);