//--------------------------------------------------------------------- // executes the behavior after a given amount of time in miliseconds has passed // <param name="elapsedTimeFunction">function that returns elapsed time</param> // <param name="timeToWait">maximum time to wait before executing behavior</param> // <param name="behavior">behavior to run</param> public DecoratorTimer(BehaviorTree bt, Func<int> func_elapsedtm, int wait_tm, BehaviorComponent behavior) : base(bt) { mFuncElapsedTm = func_elapsedtm; mBehavior = behavior; mWaitTime = wait_tm; }
//--------------------------------------------------------------------- // randomly executes the behavior // <param name="probability">probability of execution</param> // <param name="randomFunction">function that determines probability to execute</param> // <param name="behavior">behavior to execute</param> public DecoratorRandom(BehaviorTree bt, float probability, Func<float> func_random, BehaviorComponent behavior) : base(bt) { mProbability = probability; mRandomFunction = func_random; mBehavior = behavior; }
//------------------------------------------------------------------------- public Bt(Entity self) { // 建立行为树 mSelf = self; mBehaviorTree = new BehaviorTree(); mBehaviorTree.Blackboard.setData("Entity", mSelf); Blackboard = mBehaviorTree.Blackboard; }
//--------------------------------------------------------------------- // inverts the given behavior // -Returns Success on Failure or Error // -Returns Failure on Success // -Returns Running on Running public DecoratorInverter(BehaviorTree bt, BehaviorComponent behavior) : base(bt) { mBehavior = behavior; }
//--------------------------------------------------------------------- // executes the behavior based on a counter // -each time Counter is called the counter increments by 1 // -Counter executes the behavior when it reaches the supplied maxCount public DecoratorCounter(BehaviorTree bt, int max_count, BehaviorComponent behavior) : base(bt) { mMaxCount = max_count; mBehavior = behavior; }
//--------------------------------------------------------------------- // attempts to run the behaviors all in one cycle (stateful on running) // -Returns Success when all are successful // -Returns Failure if one behavior fails or an error occurs // -Does not Return Running public StatefulSequence(BehaviorTree bt, params BehaviorComponent[] behaviors) : base(bt) { this._Behaviors = behaviors; }
//--------------------------------------------------------------------- public Action2(BehaviorTree bt) : base(bt) { }
//--------------------------------------------------------------------- // Performs the given behavior components sequentially (one evaluation per Behave call) // Performs an AND-Like behavior and will perform each successive component // -Returns Success if all behavior components return Success // -Returns Running if an individual behavior component returns Success or Running // -Returns Failure if a behavior components returns Failure or an error is encountered public PartialSequence(BehaviorTree bt, params BehaviorComponent[] behaviors) : base(bt) { _Behaviors = behaviors; _seqLength = (short) _Behaviors.Length; }
//--------------------------------------------------------------------- public BehaviorComponent(BehaviorTree bt) { mBehaviorTree = bt; }
//--------------------------------------------------------------------- // executes the behavior based on a counter // -each time Counter is called the counter increments by 1 // -Counter executes the behavior when it reaches the supplied maxCount public DecoratorCounter(BehaviorTree bt, int max_count, BehaviorComponent behavior) : base(bt) { mMaxCount = max_count; mBehavior = behavior; }
//--------------------------------------------------------------------- // The selector for the root node of the behavior tree // <param name="index">an index representing which of the behavior branches to perform</param> // <param name="behaviors">the behavior branches to be selected from</param> public RootSelector(BehaviorTree bt, Func<int> func_index, params BehaviorComponent[] behaviors) : base(bt, behaviors) { mFuncIndex = func_index; //mBehaviors = behaviors; }
//--------------------------------------------------------------------- // attempts to run the behaviors all in one cycle // -Returns Success when all are successful // -Returns Failure if one behavior fails or an error occurs // -Returns Running if any are running public Sequence(BehaviorTree bt, params BehaviorComponent[] behaviors) : base(bt) { _behaviors = behaviors; }
//------------------------------------------------------------------------- public BtChild(IComponent co_actorai, Blackboard blackboard, BehaviorTree bt) { CoActorAi = (CellActorMirrorAi<DefActorMirrorAi>)co_actorai; Blackboard = blackboard; BehaviorTree = bt; }
//--------------------------------------------------------------------- public Action1(BehaviorTree bt, Func<BehaviorTree, object[], BehaviorReturnCode> action, params object[] list_param) : base(bt) { mAction = action; mListParam = list_param; }
//--------------------------------------------------------------------- // Selects among the given behavior components (stateful on running) // Performs an OR-Like behavior and will "fail-over" to each successive component until Success is reached or Failure is certain // -Returns Success if a behavior component returns Success // -Returns Running if a behavior component returns Running // -Returns Failure if all behavior components returned Failure public StatefulSelector(BehaviorTree bt, params BehaviorComponent[] behaviors) : base(bt) { this._Behaviors = behaviors; }
//--------------------------------------------------------------------- // Selects among the given behavior components // Performs an OR-Like behavior and will "fail-over" to each successive component until Success is reached or Failure is certain // -Returns Success if a behavior component returns Success // -Returns Running if a behavior component returns Running // -Returns Failure if all behavior components returned Failure public Selector(BehaviorTree bt, params BehaviorComponent[] behaviors) : base(bt) { _Behaviors = behaviors; }
//--------------------------------------------------------------------- // Selects among the given behavior components (one evaluation per Behave call) // Performs an OR-Like behavior and will "fail-over" to each successive component until Success is reached or Failure is certain // -Returns Success if a behavior component returns Success // -Returns Running if a behavior component returns Failure or Running // -Returns Failure if all behavior components returned Failure or an error has occured public PartialSelector(BehaviorTree bt, params BehaviorComponent[] behaviors) : base(bt) { mBehaviors = behaviors; _selLength = (short)mBehaviors.Length; }
//------------------------------------------------------------------------- public BehaviorReturnCode actionDummy(BehaviorTree bt, params object[] list_param) { return BehaviorReturnCode.Success; }
//--------------------------------------------------------------------- // Returns a return code equivalent to the test // -Returns Success if true // -Returns Failure if false // <param name="test">the value to be tested</param> public Conditional(BehaviorTree bt, Func<BehaviorTree, object[], Boolean> func_bool, params object[] list_param) : base(bt) { mFuncBool = func_bool; mListParam = list_param; }
//------------------------------------------------------------------------- public bool conditionPlayerManual(BehaviorTree bt, params object[] list_param) { return true; }
//--------------------------------------------------------------------- // Selects among the given behavior components // Performs an OR-Like behavior and will "fail-over" to each successive component until Success is reached or Failure is certain // -Returns Success if a behavior component returns Success // -Returns Running if a behavior component returns Running // -Returns Failure if all behavior components returned Failure public Selector(BehaviorTree bt, params BehaviorComponent[] behaviors) : base(bt) { _Behaviors = behaviors; }
//------------------------------------------------------------------------- //------------------------------------------------------------------------- public BtChildPlayerManual(IComponent co_actorai, Blackboard blackboard, BehaviorTree bt) : base(co_actorai, blackboard, bt) { }