Exemple #1
0
 internal WorldMovementInfo(World world, MobileInfo info)
 {
     // PERF: This struct allows us to cache the terrain info for the tileset used by the world.
     // This allows us to speed up some performance-sensitive pathfinding calculations.
     World        = world;
     TerrainInfos = info.TilesetTerrainInfo[world.Map.Rules.TileSet];
 }
Exemple #2
0
        public Mobile(ActorInitializer init, MobileInfo info)
        {
            self = init.Self;
            Info = info;

            speedModifiers = Exts.Lazy(() => self.TraitsImplementing <ISpeedModifier>().ToArray());

            ToSubCell = FromSubCell = info.SharesCell ? init.World.Map.DefaultSubCell : SubCell.FullCell;
            if (init.Contains <SubCellInit>())
            {
                FromSubCell = ToSubCell = init.Get <SubCellInit, SubCell>();
            }

            if (init.Contains <LocationInit>())
            {
                fromCell = toCell = init.Get <LocationInit, CPos>();
                SetVisualPosition(self, init.World.Map.CenterOfSubCell(FromCell, FromSubCell));
            }

            this.Facing = init.Contains <FacingInit>() ? init.Get <FacingInit, int>() : info.InitialFacing;

            // Sets the visual position to WPos accuracy
            // Use LocationInit if you want to insert the actor into the ActorMap!
            if (init.Contains <CenterPositionInit>())
            {
                SetVisualPosition(self, init.Get <CenterPositionInit, WPos>());
            }
        }
Exemple #3
0
        public bool IsPassable(CPos p1, CPos p2, MobileInfo mi, uint movementClass)
        {
            // HACK: Work around units in other movement layers from being blocked
            // when the point in the main layer is not pathable
            if (p1.Layer != 0 || p2.Layer != 0)
            {
                return(true);
            }

            // HACK: Workaround until we can generalize movement classes
            if (mi.Subterranean || mi.Jumpjet)
            {
                return(true);
            }

            return(domainIndexes[movementClass].IsPassable(p1, p2));
        }
        bool ValidTransitionCell(CPos cell, MobileInfo mi)
        {
            var terrainType = map.GetTerrainInfo(cell).Type;

            if (!mi.SubterraneanTransitionTerrainTypes.Contains(terrainType) && mi.SubterraneanTransitionTerrainTypes.Any())
            {
                return(false);
            }

            if (mi.SubterraneanTransitionOnRamps)
            {
                return(true);
            }

            var tile = map.Tiles[cell];
            var ti   = map.Rules.TileSet.GetTileInfo(tile);

            return(ti == null || ti.RampType == 0);
        }
 int ICustomMovementLayer.ExitMovementCost(ActorInfo a, MobileInfo mi, CPos cell)
 {
     return(ends.Contains(cell) ? 0 : int.MaxValue);
 }
 bool ICustomMovementLayer.EnabledForActor(ActorInfo a, MobileInfo mi)
 {
     return(enabled);
 }
Exemple #7
0
 public MoveOrderTargeter(Actor self, MobileInfo unitType)
 {
     this.unitType = unitType;
     rejectMove    = !self.AcceptsOrder("Move");
 }
 bool ICustomMovementLayer.EnabledForActor(ActorInfo a, MobileInfo mi)
 {
     return(mi.Subterranean);
 }
 int ICustomMovementLayer.ExitMovementCost(ActorInfo a, MobileInfo mi, CPos cell)
 {
     return(ValidTransitionCell(cell, mi) ? mi.SubterraneanTransitionCost : int.MaxValue);
 }
Exemple #10
0
 int ICustomMovementLayer.EntryMovementCost(ActorInfo a, MobileInfo mi, CPos cell)
 {
     return(portals.Contains(cell) ? 0 : int.MaxValue);
 }
Exemple #11
0
 public MoveOrderTargeter(Actor self, MobileInfo unitType)
 {
     this.unitType = unitType;
     rejectMove    = !self.AcceptsOrder("Move");
     moveDisablers = self.TraitsImplementing <IDisableMove>().ToArray();
 }
Exemple #12
0
 internal WorldMovementInfo(World world, MobileInfo info)
 {
     World        = world;
     TerrainInfos = info.TilesetTerrainInfo[world.TileSet];
 }
Exemple #13
0
 bool ICustomMovementLayer.EnabledForActor(ActorInfo a, MobileInfo mi)
 {
     return(mi.Jumpjet);
 }
Exemple #14
0
 int ICustomMovementLayer.EntryMovementCost(ActorInfo a, MobileInfo mi, CPos cell)
 {
     return(ValidTransitionCell(cell, mi) ? mi.JumpjetTransitionCost : int.MaxValue);
 }