kotcity4 / kotcity.data / CityMap

CityMap

data class CityMap

A map representing the city. The map hangs on to Buildings and Locations. The map is set up as a grid of BlockCoordinate and various layers hanging onto various values (desirability, crime, etc).

Constructors

<init>

CityMap(width: Int = 512, height: Int = 512)

A map representing the city. The map hangs on to Buildings and Locations. The map is set up as a grid of BlockCoordinate and various layers hanging onto various values (desirability, crime, etc).

Properties

bulldozedCounts

var bulldozedCounts: MutableMap<Zone, Int>

Every time the Liquidator runs it will drop a count of bulldozed zones in here so we know how many get demolished.

cachedLocationsIn

val cachedLocationsIn: (block: BlockCoordinate) -> List<Location>

a cached version of locationsIn. This can be used when you want to do a fast lookup on a building but don't really care if you are wrong or not

censusTaker

val censusTaker: CensusTaker

cityName

var cityName: String?

Name of the city

crimeLayer

val crimeLayer: MutableMap<BlockCoordinate, Double>

debug

var debug: Boolean

Should we print debug output or not?

desirabilityLayers

val desirabilityLayers: List<DesirabilityLayer>

fileName

var fileName: String?

where we loaded OR saved this city to... used to determine save vs. save as...

fireCoverageLayer

val fireCoverageLayer: MutableMap<BlockCoordinate, Double>

groundLayer

val groundLayer: MutableMap<BlockCoordinate, MapTile>

height

var height: Int

height in blocks of the city

nationalTradeEntity

val nationalTradeEntity: NationalTradeEntity

policePresenceLayer

val policePresenceLayer: MutableMap<BlockCoordinate, Double>

pollutionLayer

val pollutionLayer: MutableMap<BlockCoordinate, Double>

powerLineLayer

val powerLineLayer: MutableMap<BlockCoordinate, Building>

resourceLayers

val resourceLayers: MutableMap<String, QuantizedMap<Double>>

time

var time: Date

Current time in the simulation

trafficLayer

var trafficLayer: MutableMap<BlockCoordinate, Double>

width

var width: Int

width in blocks of the city

zoneLayer

val zoneLayer: MutableMap<BlockCoordinate, Zone>

Functions

build

fun build(building: Building, block: BlockCoordinate, updateBuildingIndex: Boolean = true): Unit

Plops the given Building at the given BlockCoordinate. Note the coordinate is the top-left of the building. We do check for collisions, hopefully preventing overlaps.

buildPowerline

fun buildPowerline(firstBlock: BlockCoordinate, lastBlock: BlockCoordinate): Unit

Builds a line of powerlines from firstBlock to lastBlock

buildRailroad

fun buildRailroad(from: BlockCoordinate, to: BlockCoordinate): Unit

Builds Railroad between the two supplied BlockCoordinate. Railroad can currently be built in an "L" shape.

buildRoad

fun buildRoad(from: BlockCoordinate, to: BlockCoordinate, isOneWay: Boolean = false): Unit

Builds a (possibly) one-way road or standard road

buildingBlocks

fun buildingBlocks(coordinate: BlockCoordinate, building: Building): List<BlockCoordinate>

Takes a coordinate and a building and returns the "footprint" of the building. In other words, each block the building sits in.

bulldoze

fun bulldoze(from: BlockCoordinate, to: BlockCoordinate): Unit

Bulldozes from the top left to the bottom right

canBuildBuildingAt

fun canBuildBuildingAt(newBuilding: Building, coordinate: BlockCoordinate, waterCheck: Boolean = true): Boolean

See if we can plop a new building on the map at the given coordinate

coordinatesForBuilding

fun coordinatesForBuilding(building: Building): BlockCoordinate?

For a given Building, runs through it and finds the coordinate

debug

fun debug(message: String): Unit

desirabilityLayer

fun desirabilityLayer(type: Zone, level: Int): DesirabilityLayer?

We will probably end up having a desirabilty layer for each zone and each level... but I am not 100% sure yet

dezone

fun dezone(firstBlock: BlockCoordinate, lastBlock: BlockCoordinate): Unit

Removes zoning designation from a rectangle of BlockCoordinate

eachLocation

fun eachLocation(callback: (Location) -> Unit): Unit

elevations

fun elevations(): Pair<Double, Double>

Returns the minimum and maximum heights on this map

hasTrafficNearby

fun hasTrafficNearby(coordinate: BlockCoordinate, radius: Int, quantity: Int): Boolean

Used to check traffic at a given coordinate with a certain radius

hourlyTick

suspend fun hourlyTick(hour: Int): Unit

Things that we want done each game hour

locations

fun locations(): List<Location>

Returns a massive list of all locations

locationsAt

fun locationsAt(coordinate: BlockCoordinate): List<Location>

Returns a list of Locations that we found at the current coordinate

locationsInRectangle

fun locationsInRectangle(topLeft: BlockCoordinate, bottomRight: BlockCoordinate): List<Location>

Returns a list of Locations in the provided rectangle of coordinates

nearestBuildings

fun nearestBuildings(coordinate: BlockCoordinate, distance: Int = 10): List<Location>

Does a spatial lookup at coordinate for a list of Locations

pollutionNearby

fun pollutionNearby(coordinate: BlockCoordinate, radius: Int): Double

Returns a count of pollution at the given BlockCoordinate

purgeRTree

fun purgeRTree(): Unit

Purges spatial index of buildings...

setResourceValue

fun setResourceValue(resourceName: String, blockCoordinate: BlockCoordinate, resourceValue: Double): Unit

Used to store where oil, gold, etc are underneath the map. Not currently used.

suggestedFilename

fun suggestedFilename(): String

Suggests a filename to save the city as... it's based off the name of the city but made safe for filenames

tick

fun tick(): Unit

Main game loop. The engine calls this every X milliseconds and various functions are run from here.

trafficNearby

fun trafficNearby(coordinate: BlockCoordinate, radius: Int): Int

Returns a count of traffic at the given coordinate and radius

updateBuildingIndex

fun updateBuildingIndex(): Unit

Updates the spatial index, enabling quick building lookups...

zone

fun zone(type: Zone, from: BlockCoordinate, to: BlockCoordinate): Unit

Designates a given area as a certain Zone

Companion Object Functions

flatMap

fun flatMap(width: Int = 512, height: Int = 512): CityMap

Returns a totally flat map of the given size.