Beispiel #1
0
        //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
        }
Beispiel #3
0
        public BehaviourBinarySelector(Func <bool> isConditionMetFunc, BehaviourNode trueNode, BehaviourNode falseNode) : base("Binary Selector", NodeType.COMPOSITE)
        {
            AddChild(trueNode);
            AddChild(falseNode);
            TrueNode.OnStopped.AddListener(TrueActionOnStopped_Listener);
            FalseNode.OnStopped.AddListener(FalseActionOnStopped_Listener);

            _isConditionMetFunc = isConditionMetFunc;

            OnStarted.AddListener(OnStarted_Listener);
            OnStopping.AddListener(OnStopping_Listener);
        }
 public BehaviourStateSelector(T initialState) : base("Enum Selector", NodeType.COMPOSITE)
 {
     NextState     = initialState;
     CurrentState  = initialState;
     States        = Enum.GetValues(typeof(T));
     _stateActions = new Dictionary <T, BehaviourAction>();
     if (States.Length < 1)
     {
         throw new ArgumentException("Enum provided to Initialize must have at least 1 visible definition");
     }
     OnStarted.AddListener(OnStarted_Listener);
     OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener);
 }
        /// <summary>
        /// Delay execution of the child node until the condition is true
        /// </summary>
        /// <param name="isConditionMetFunc">The function used to check the condition</param>
        /// <param name="checkInterval">The interval at which the condition is checked</param>
        /// <param name="randomVariance">The interval variance</param>
        public BehaviourWaitForCondition(Func <bool> isConditionMetFunc, float checkInterval, float randomVariance) : base("WaitForCondition", NodeType.DECORATOR)
        {
            OnStarted.AddListener(OnStarted_Listener);

            OnStopping.AddListener(OnStopping_Listener);
            OnStoppedSilent.AddListener(OnStoppedSilent_Listener);
            OnChildNodeStopped.AddListener(OnChildNodeStopped_Listener);

            m_isConditionMetFunc = isConditionMetFunc;

            m_checkInterval = checkInterval;
            m_checkVariance = randomVariance;


            // this.Label = "" + (checkInterval - randomVariance) + "..." + (checkInterval + randomVariance) + "s";
        }
Beispiel #6
0
        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;
        }
Beispiel #7
0
        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;
            }
        }
Beispiel #8
0
        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;
        }