Beispiel #1
0
        /// <summary>
        /// Note: If the target <paramref name="cell"/> has any free subcell, the value of <paramref name="subCell"/> is ignored.
        /// </summary>
        public bool CanEnterCell(World world, Actor self, CPos cell, SubCell subCell = SubCell.FullCell, Actor ignoreActor = null, BlockedByActor check = BlockedByActor.All)
        {
            // PERF: Avoid repeated trait queries on the hot path
            if (locomotor == null)
            {
                locomotor = world.WorldActor.TraitsImplementing <Locomotor>()
                            .SingleOrDefault(l => l.Info.Name == Locomotor);
            }

            if (locomotor.MovementCostForCell(cell) == PathGraph.MovementCostForUnreachableCell)
            {
                return(false);
            }

            return(locomotor.CanMoveFreelyInto(self, cell, subCell, check, ignoreActor));
        }
        public bool CanEnterCell(World world, Actor self, CPos cell, Actor ignoreActor = null, bool checkTransientActors = true)
        {
            // PERF: Avoid repeated trait queries on the hot path
            if (locomotor == null)
            {
                locomotor = world.WorldActor.TraitsImplementing <Locomotor>()
                            .SingleOrDefault(l => l.Info.Name == Locomotor);
            }

            if (locomotor.MovementCostForCell(cell) == short.MaxValue)
            {
                return(false);
            }

            var check = checkTransientActors ? CellConditions.All : CellConditions.BlockedByMovers;

            return(locomotor.CanMoveFreelyInto(self, cell, ignoreActor, check));
        }
 public bool CanExistInCell(CPos cell)
 {
     return(Locomotor.MovementCostForCell(cell) != short.MaxValue);
 }