private Input_t GetInputFromAI(float dt)
        {
            Input_t input = new Input_t();

            input.look = new Vector3(Mathf.Sin(yaw), 0, Mathf.Cos(yaw));

            if (team == gameMode.teams[0])
            {
                return(input);
            }

            UpdateAggro(dt);

            if (curBehavior != null && !curBehavior.IsValid())
            {
                behaviorUpdateTimer = 0;
                curBehavior         = null;
            }

            behaviorUpdateTimer -= dt;
            if (behaviorUpdateTimer <= 0)
            {
                behaviorUpdateTimer += data.behaviorUpdateTime;

                // Evaluate behaviors
                List <CritterBehavior.EvaluationScore> possibleBehaviors = new List <CritterBehavior.EvaluationScore>();
                float totalScore = 0;
                foreach (var b in behaviors)
                {
                    var score = b.Evaluate();
                    if (score.score > 0)
                    {
                        if (b.scoreMultiplier > 0)
                        {
                            score.score *= b.scoreMultiplier;
                        }
                        possibleBehaviors.Add(score);
                        totalScore += score.score;
                    }
                }

                // Choose a behavior
                if (possibleBehaviors.Count > 0)
                {
                    float chooseScore = GameManager.instance.randomNumber * totalScore;
                    foreach (var b in possibleBehaviors)
                    {
                        chooseScore -= b.score;
                        if (chooseScore <= 0)
                        {
                            if (curBehavior != b.behavior)
                            {
                                b.behavior.Start();
                                curBehavior = b.behavior;
                            }
                            break;
                        }
                    }
                }
            }

            // Execute the behavior
            if (curBehavior != null)
            {
                curBehavior.Tick(dt, ref input);
            }

            return(input);
        }
 public EvaluationScore(CritterBehavior b, float score = 0)
 {
     this.behavior = b; this.score = score;
 }