public void Update() {
     currentAction = currentAction ?? GetDesiredAction();
     if (currentAction != null) {
         if (currentAction.OnUpdate()) {
             currentAction.OnComplete();
             currentAction = null;
         }
     }
 }
Example #2
0
        protected CharacterAction GetDesiredAction()
        {
            DecisionContextPair dcp = ScoreAllDecisions();

            if (dcp.decision == null)
            {
                return(null);
            }
            CharacterAction action = dcp.decision.action;

            action.Setup(dcp.context);
            return(action);
        }
        public override List <Context> Collect(CharacterAction <SingleTargetContext> action, Entity entity)
        {
            float          radius      = SearchRange.Invoke(entity);
            int            factionMask = FactionMask.Invoke(entity);
            List <Entity>  targets     = EntityManager.Instance.FindEntitiesInRange(entity.transform.position, radius, factionMask);
            List <Context> retn        = new List <Context>(targets.Count);

            for (int i = 0; i < retn.Count; i++)
            {
                retn.Add(new SingleTargetContext(entity, targets[i]));
            }
            return(retn);
        }
Example #4
0
 public abstract List <Context> Collect(CharacterAction action, Entity entity);
 public abstract List<Context> Collect(CharacterAction action, Entity entity);