public BehaviourRepeatUntil(Func <bool> isConditionMetFunc) : base(NODE_NAME, NodeType.DECORATOR) { m_isConditionMetFunc = isConditionMetFunc; OnStarted.AddListener(OnStarted_Listener); OnStartedSilent.AddListener(OnStartedSilent_Listener); OnStopping.AddListener(OnStopping_Listener); OnStoppingSilent.AddListener(OnStoppingSilent_Listener); OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener); OnChildNodeStoppedSilent.AddListener(OnChildNodeStoppedSilent_Listener); }
/// <summary> /// Run child nodes in parallel /// </summary> /// <param name="successStopCondition"> /// How many children should return success before parallel stops with success /// </param> /// <param name="failureStopCondition"> /// How many children should return failure before parallel stops with failure /// </param> public BehaviourParallel(StopCondition successStopCondition, StopCondition failureStopCondition) : base("Parallel", NodeType.COMPOSITE) { m_successStopCondition = successStopCondition; m_failureStopCondition = failureStopCondition; OnStarted.AddListener(OnStarted_Listener); OnStartedSilent.AddListener(OnStartedSilent_Listener); OnStopping.AddListener(OnStopping_Listener); OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener); OnChildNodeStoppedSilent.AddListener(OnChildNodeStoppedSilent_Listener); }
/// <summary> /// Repeated runs it's child node /// </summary> /// <param name="totalLoops">The amount of times the child node is looped. If -1 it will loop indefinately unless stopped manually.</param> public BehaviourRepeater(int totalLoops = -1, bool stopOnChildFail = true) : base(NODE_NAME, NodeType.DECORATOR) { TotalLoops = totalLoops; StopOnChildFail = stopOnChildFail; OnStarted.AddListener(OnStarted_Listener); OnStartedSilent.AddListener(OnStartedSilent_Listener); OnStopping.AddListener(OnStopping_Listener); OnStoppingSilent.AddListener(OnStoppingSilent_Listener); OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener); OnChildNodeStoppedSilent.AddListener(OnChildNodeStoppedSilent_Listener); }
//private bool m_initParent = false; public BehaviourObserver(string name, BehaviourNode decoratee, AbortRule abortRule) : base(name, NodeType.DECORATOR) { OnStarted.AddListener(OnStarted_Listener); OnStopping.AddListener(OnStopping_Listener); OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener); OnChildNodeStoppedSilent.AddListener(OnChildNodeStoppedSilent_Listener); m_abortRule = abortRule; m_isObserving = false; AddChild(decoratee); }
private void Init(System.Action serviceAction) { OnStarted.AddListener(OnStarted_Listener); OnStartedSilent.AddListener(OnStartedSilent_Listener); OnStopping.AddListener(OnStopping_Listener); OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener); OnChildNodeStoppedSilent.AddListener(OnChildNodeStoppedSilent_Listener); m_serviceAction = serviceAction; #if UNITY_EDITOR DebugTools.GUIlabel = "every tick"; #endif }
private void Init(float limit, float?randomVariation = null, bool waitOnFailure = false) { OnStarted.AddListener(OnStarted_Listener); OnStartedSilent.AddListener(OnStartedSilent_Listener); OnStopping.AddListener(OnStopping_Listener); OnStoppingSilent.AddListener(OnStoppingSilent_Listener); OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener); OnChildNodeStoppedSilent.AddListener(OnChildNodeStoppedSilent_Listener); m_limit = limit; if (randomVariation != null) { m_randomVariation = randomVariation.Value; } else { m_randomVariation = limit * 0.05f; } m_waitOnFailure = waitOnFailure; }
private void Init(float cooldownTime, float?randomVariation = null, bool startAfterChild = false, bool resetOnFailiure = false, bool failOnCooldown = false) { OnStarted.AddListener(OnStarted_Listener); OnStopping.AddListener(OnStopping_Listener); OnStoppingSilent.AddListener(OnStoppingSilent_Listener); OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener); OnChildNodeStoppedSilent.AddListener(OnChildNodeStoppedSilent_Listener); m_startAfterChild = false; m_cooldownTime = cooldownTime; m_resetOnFailiure = false; if (randomVariation != null) { m_randomVariation = randomVariation.Value; } else { m_randomVariation = cooldownTime * 0.1f; } }
private void Init(float limit, float?randomVariation, bool waitForChildButFailOnLimitReached) { OnStarted.AddListener(OnStarted_Listener); OnStartedSilent.AddListener(OnStartedSilent_Listener); OnStopping.AddListener(OnStopping_Listener); OnStoppingSilent.AddListener(OnStoppingSilent_Listener); OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener); OnChildNodeStoppedSilent.AddListener(OnChildNodeStoppedSilent_Listener); m_limit = limit; if (randomVariation != null) { m_randomVariation = randomVariation.Value; } else { m_randomVariation = m_limit * 0.05f; } m_waitForChildButFailOnLimitReached = waitForChildButFailOnLimitReached; }