/** * Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile. */ RailType GetTileRailType(TileIndex tile) { switch (TileMap.GetTileType(tile)) { case TileType.MP_RAILWAY: return(GetRailType(tile)); case TileType.MP_ROAD: /* rail/road crossing */ if (IsLevelCrossing(tile)) { return(GetRailType(tile)); } break; case TileType.MP_STATION: if (HasStationRail(tile)) { return(GetRailType(tile)); } break; case TileType.MP_TUNNELBRIDGE: if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) { return(GetRailType(tile)); } break; default: break; } return(RailType.INVALID_RAILTYPE); }
/** * Get the type of vehicles that can use a depot * @param t The tile * @pre IsDepotTile(t) * @return the type of vehicles that can use the depot */ public static VehicleType GetDepotVehicleType(TileIndex t) { switch (TileMap.GetTileType(t)) { default: throw new NotReachedException(); case TileType.MP_RAILWAY: return(VehicleType.VEH_TRAIN); case TileType.MP_ROAD: return(VehicleType.VEH_ROAD); case TileType.MP_WATER: return(VehicleType.VEH_SHIP); case TileType.MP_STATION: return(VehicleType.VEH_AIRCRAFT); } }
/** * Returns the RoadBits on an arbitrary tile * Special behaviour: * - road depots: entrance is treated as road piece * - road tunnels: entrance is treated as road piece * - bridge ramps: start of the ramp is treated as road piece * - bridge middle parts: bridge itself is ignored * * If straight_tunnel_bridge_entrance is set a ROAD_X or ROAD_Y * for bridge ramps and tunnel entrances is returned depending * on the orientation of the tunnel or bridge. * @param tile the tile to get the road bits for * @param rt the road type to get the road bits form * @param straight_tunnel_bridge_entrance whether to return straight road bits for tunnels/bridges. * @return the road bits of the given tile */ public static RoadBits GetAnyRoadBits(this TileIndex tile, RoadType rt, bool straight_tunnel_bridge_entrance) { if (!HasTileRoadType(tile, rt)) { return(RoadBits.ROAD_NONE); } switch (TileMap.GetTileType(tile)) { case TileType.MP_ROAD: switch (GetRoadTileType(tile)) { default: case RoadTileType.ROAD_TILE_NORMAL: return(GetRoadBits(tile, rt)); case RoadTileType.ROAD_TILE_CROSSING: return(GetCrossingRoadBits(tile)); case RoadTileType.ROAD_TILE_DEPOT: return(DiagDirToRoadBits(GetRoadDepotDirection(tile))); } case TileType.MP_STATION: if (!IsRoadStopTile(tile)) { return(RoadBits.ROAD_NONE); } if (IsDriveThroughStopTile(tile)) { return((GetRoadStopDir(tile) == DiagDirection.DIAGDIR_NE) ? RoadBits.ROAD_X : RoadBits.ROAD_Y); } return(DiagDirToRoadBits(GetRoadStopDir(tile))); case TileType.MP_TUNNELBRIDGE: if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) { return(RoadBits.ROAD_NONE); } return(straight_tunnel_bridge_entrance ? AxisToRoadBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) : DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile)))); default: return(RoadBits.ROAD_NONE); } }
/** * Clean up unnecessary RoadBits of a planed tile. * @param tile current tile * @param org_rb planed RoadBits * @return optimised RoadBits */ RoadBits CleanUpRoadBits(TileIndex tile, RoadBits org_rb) { if (!TileMap.IsValidTile(tile)) { return(RoadBits.ROAD_NONE); } for (DiagDirection dir = DiagDirection.DIAGDIR_BEGIN; dir < DiagDirection.DIAGDIR_END; dir++) { TileIndex neighbor_tile = TileAddByDiagDir(tile, dir); /* Get the Roadbit pointing to the neighbor_tile */ RoadBits target_rb = DiagDirToRoadBits(dir); /* If the roadbit is in the current plan */ if (org_rb & target_rb) { bool connective = false; const RoadBits mirrored_rb = MirrorRoadBits(target_rb); if (TileMap.IsValidTile(neighbor_tile)) { switch (TileMap.GetTileType(neighbor_tile)) { /* Always connective ones */ case TileType.MP_CLEAR: case TileType.MP_TREES: connective = true; break; /* The conditionally connective ones */ case TileType.MP_TUNNELBRIDGE: case TileType.MP_STATION: case TileType.MP_ROAD: if (IsNormalRoadTile(neighbor_tile)) { /* Always connective */ connective = true; } else { const RoadBits neighbor_rb = GetAnyRoadBits(neighbor_tile, RoadType.ROADTYPE_ROAD) | GetAnyRoadBits(neighbor_tile, RoadType.ROADTYPE_TRAM); /* Accept only connective tiles */ connective = (neighbor_rb & mirrored_rb) != RoadBits.ROAD_NONE; } break; case TileType.MP_RAILWAY: connective = IsPossibleCrossing(neighbor_tile, DiagDirToAxis(dir)); break; case TileType.MP_WATER: /* Check for real water tile */ connective = !WaterMap.IsWater(neighbor_tile); break; /* The definitely not connective ones */ default: break; } } /* If the neighbor tile is inconnective, remove the planed road connection to it */ if (!connective) { org_rb ^= target_rb; } } } return(org_rb); }