コード例 #1
0
        protected override void ReconsiderDecision()
        {
            switch (decision.GoalType)
            {
            case ZombieGoal.Banner:

                if ((!decision.IsValid || decision.PathDistance > MinDistanceToReconsiderBanner) &&
                    (ConsiderPlayerTarget(ref decision) || ConsiderNPCTarget(ref decision)))
                {
                    return;
                }

                if (!BannerTracker.Contains(decision.GoalLocation))
                {
                    var closest = BannerTracker.GetClosest(originalGoal, position);

                    if (closest != null &&
                        AIManager.ZombiePathFinder.TryFindPath(position, closest.KeyLocation, out var path,
                                                               2000000000) == EPathFindingResult.Success)
                    {
                        decision.Clear();
                        decision = new ZombieDecision(this, path);
                        return;
                    }

                    SetCooldown(3.0);
                }

                break;

            case ZombieGoal.NPC:

                if (!decision.IsValid || decision.PathDistance > MinDistanceToReconsiderNPC)
                {
                    if (ConsiderPlayerTarget(ref decision))
                    {
                        return;
                    }

                    NPCBase nPCBase;

                    if (NPCTracker.TryGetNear(position.Vector, MaxRadiusToNPCToConsider, out nPCBase))
                    {
                        if (decision.IsGoingTo(nPCBase) && IsMovingTargetPathOkay(nPCBase.Position))
                        {
                            decision.Reconsidered();
                            return;
                        }

                        if (AIManager.ZombiePathFinder.TryFindPath(position, nPCBase.Position, out var path2,
                                                                   decision.PathDistance / 2) ==
                            EPathFindingResult.Success)
                        {
                            decision.Clear();
                            decision = new ZombieDecision(this, nPCBase, path2);
                        }
                    }

                    if (ConsiderBannerTarget(ref decision))
                    {
                        return;
                    }
                }

                break;

            case ZombieGoal.Player:

                if (Players.FindClosestAlive(position.Vector, out var player, out var num))
                {
                    if (decision.IsGoingTo(player) && IsMovingTargetPathOkay(player.VoxelPosition))
                    {
                        decision.Reconsidered();
                        return;
                    }

                    if (num < MaxSqrdRadiusToPlayerToConsider && AIManager.CanStandAt(player.VoxelPosition) &&
                        AIManager.ZombiePathFinder.TryFindPath(position, player.VoxelPosition, out var path3,
                                                               2000000000) == EPathFindingResult.Success)
                    {
                        decision.Clear();
                        decision = new ZombieDecision(this, player, path3);
                    }
                }

                if (ConsiderNPCTarget(ref decision) || ConsiderBannerTarget(ref decision))
                {
                    return;
                }

                break;


            default:

                if (ConsiderPlayerTarget(ref decision) || ConsiderNPCTarget(ref decision) ||
                    ConsiderBannerTarget(ref decision))
                {
                    return;
                }

                break;
            }

            decision.Reconsidered();
        }