Exemple #1
0
        public override Activity Tick( Actor self )
        {
            if( IsCanceled || !target.IsValid) return NextActivity;

            var mobile = self.Trait<Mobile>();

            var ps1 = new PathSearch( self.World, mobile.Info, self )
            {
                checkForBlocked = true,
                heuristic = location => 0,
                inReverse = true
            };

            foreach( var cell in Util.AdjacentCells(target) )
                if (cell == self.Location)
                    return NextActivity;
                else
                    ps1.AddInitialCell( cell );

            ps1.heuristic = PathSearch.DefaultEstimator( mobile.toCell );

            var ps2 = PathSearch.FromPoint( self.World, mobile.Info, self, mobile.toCell, target.CenterLocation.ToCPos(), true );
            var ret = self.World.WorldActor.Trait<PathFinder>().FindBidiPath( ps1, ps2 );

            return Util.SequenceActivities( mobile.MoveTo( () => ret ), this );
        }
Exemple #2
0
        public static PathSearch FromPoint(World world, MobileInfo mi, Actor self, CPos from, CPos target, bool checkForBlocked)
        {
            var search = new PathSearch(world, mi, self)
            {
                heuristic = DefaultEstimator(target),
                checkForBlocked = checkForBlocked
            };

            search.AddInitialCell(from);
            return search;
        }
Exemple #3
0
        public static PathSearch FromPoints(World world, MobileInfo mi, Actor self, IEnumerable<CPos> froms, CPos target, bool checkForBlocked)
        {
            var search = new PathSearch(world, mi, self)
            {
                heuristic = DefaultEstimator(target),
                checkForBlocked = checkForBlocked
            };

            foreach (var sl in froms)
                search.AddInitialCell(sl);

            return search;
        }