Пример #1
0
        private static Pawn BestPawnToHuntForPredator(Pawn predator)
        {
            if (predator.meleeVerbs.TryGetMeleeVerb() == null)
            {
                return(null);
            }
            bool  flag = false;
            float summaryHealthPercent = predator.health.summaryHealth.SummaryHealthPercent;

            if (summaryHealthPercent < 0.25)
            {
                flag = true;
            }
            List <Pawn> allPawnsSpawned = predator.Map.mapPawns.AllPawnsSpawned;
            Pawn        pawn            = null;
            float       num             = 0f;
            bool        tutorialMode    = TutorSystem.TutorialMode;

            for (int i = 0; i < allPawnsSpawned.Count; i++)
            {
                Pawn pawn2 = allPawnsSpawned[i];
                if (predator.GetRoom(RegionType.Set_Passable) == pawn2.GetRoom(RegionType.Set_Passable) && predator != pawn2 && (!flag || pawn2.Downed) && FoodUtility.IsAcceptablePreyFor(predator, pawn2) && predator.CanReach(pawn2, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn) && !pawn2.IsForbidden(predator) && (!tutorialMode || pawn2.Faction != Faction.OfPlayer))
                {
                    float preyScoreFor = FoodUtility.GetPreyScoreFor(predator, pawn2);
                    if (preyScoreFor > num || pawn == null)
                    {
                        num  = preyScoreFor;
                        pawn = pawn2;
                    }
                }
            }
            return(pawn);
        }