예제 #1
0
        public override void ExecuteTask(Simulation Sim)
        {
            var pathfindingResult = Pathfinding.Flood(Sim.World.CellAt(AssignedGnome.Location),
                            c => GoalTask.QueryValidLocation(Sim, c.Location),
                            c => 1.0f);

            if (pathfindingResult.GoalFound)
            {
                var path = pathfindingResult.FinalNode.ExtractPath();
                if (path.Count > 1)
                {
                    var blockingGnome = path[1].PresentActor as Gnome;
                    if (blockingGnome != null)
                    {
                        blockingGnome.Mind.PushTask(new NudgedTask(AssignedGnome, path[1].Location));
                    }
                    else
                    {
                        MoveMutation = new WorldMutations.ActorMoveMutation(AssignedGnome.Location, path[1], AssignedGnome);
                        Sim.AddWorldMutation(MoveMutation);
                    }
                }
            }
            else
            {
                FailedToFindPath = true;
            }
        }
예제 #2
0
        public override void ExecuteTask(Simulation Sim)
        {
            var cell = Sim.World.CellAt(Location);
            if (cell.Links.Count == 0)
            {
                FailedToFindPath = true;
                return;
            }

            var retreatLinks = cell.Links.OrderBy(l => l.Neighbor.PresentActor == null ? 0 : 1);
            var link = retreatLinks.First();

            var blockingGnome = link.Neighbor.PresentActor as Gnome;
            if (blockingGnome != null)
                blockingGnome.Mind.PushTask(new NudgedTask(AssignedGnome, link.Neighbor.Location));
            else
            {
                MoveMutation = new WorldMutations.ActorMoveMutation(AssignedGnome.Location, link.Neighbor, AssignedGnome);
                Sim.AddWorldMutation(MoveMutation);
            }
        }