Class Map
A map holds all of the data about a city, like its tiles, its objects and its roads. A map is split into MapSection objects which allows faster retrieval of objects in an area.
[DataContract]
public class Map : JsonTypeSafeGenericDataHolder, IGenericDataHolder
- Inheritance
-
JsonTypeSafeGenericDataHolderMap
- Implements
-
IGenericDataHolder
- Inherited Members
-
JsonTypeSafeGenericDataHolder.GetDataKeys()
- Extension Methods
Constructors
Map(Point)
Creates a new map with the given size
public Map(Point sizeInSections)
Parameters
sizeInSections
PointThe size, in sections, of this map
Fields
AppliedMigrations
The set of names of the Migration instances that have already been applied to objects on this map. When a new map is created, this collection is initialized with all migrations that exist, as new objects are expected to not need migration.
[JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
public HashSet<string> AppliedMigrations
Field Value
MailToSend
A list of all Mail that needs to be sent by a mail carrier the next morning.
[DataMember]
public readonly List<Mail> MailToSend
Field Value
MaxFloor
The maximum floor, above the ground floor, that objects can be placed on in build mode. It is set to 1 in the demo and 4 in the full version of the game. For querying the maximum floor that the player can currently view, use CurrentMaxFloor.
public const int MaxFloor = 4
Field Value
MinFloor
The minimum floor, below the ground floor, that objects can be placed on in build mode. It is set to 0, but will likely change in the future, when basements are added to the game. For querying the minimum floor that the player can currently view, use CurrentMinFloor.
public const int MinFloor = 0
Field Value
MinorUpdateMinutes
The amount of minutes of in-game time that have to pass before an IUpdatingObject with the Minor is updated.
public const float MinorUpdateMinutes = 15
Field Value
PassiveUpdateMinutes
The amount of minutes of in-game time that have to pass before an IUpdatingObject with the MajorIfActive is updated while this map isn't IsActive.
public const float PassiveUpdateMinutes = 5
Field Value
PathfindingDirtyNeighbors
A collection that is used in MarkDirtyForPathfinding(Point, int) which determines the set of "neighbor" positions that should additionally be marked dirty when a given position is marked as dirty. By default, this collection contains all neighboring positions (MLEM.Maths.Direction2Helper.AllExceptNone), as well as positions two tiles, and one floor, offset in adjacent directions for the purpose of Stairs pathfinding.
public static readonly List<(Point Offset, int FloorOffset)> PathfindingDirtyNeighbors
Field Value
- List<(Point Offset, int FloorOffset)>
PossibleRegularVisitors
Contains a set of information and related functions that determine whether a given PersonLike is a valid visitor for a given map. Each entry contains the Type that extends PersonLike which is valid, a weight function that determines how likely this visitor is to be chosen, a validator function that determines whether a given exported PersonLike is valid for this entry, and a function to create a new PersonLike of the given type if there are none available.
public static readonly List<(Type Type, float Weight, Func<PersonLike, bool> IsValid, Func<Map, Random, PersonLike> CreateNew)> PossibleRegularVisitors
Field Value
- List<(Type Type, float Weight, Func<PersonLike, bool> IsValid, Func<Map, Random, PersonLike> CreateNew)>
RoadRadius
This field holds the radius that roads are required to have (in road tiles) excluding the center dotted line tiles. It is set to 2.
public const int RoadRadius = 2
Field Value
Properties
AdoptableChildren
A set of randomly generated children that can be adopted using AdoptChild. If this collection has children removed from it, it will automatically get repopulated until there are 12 children in it.
public List<Person> AdoptableChildren { get; }
Property Value
Info
This map's PerSaveOptions.MapInfo, which includes its name and whether it is custom.
public PerSaveOptions.MapInfo Info { get; }
Property Value
IsActive
Whether this map is active. An active map is one that is either current (IsCurrent), or that has members of the CurrentHousehold on it.
public bool IsActive { get; }
Property Value
IsCurrent
Whether this map is current. This returns whether this map is the same as CurrentMap.
public bool IsCurrent { get; }
Property Value
Neighborhood
The set of all maps that are loaded together as part of the same save, including this map. During gameplay, this collection is the same as CurrentMaps.
public Dictionary<string, Map> Neighborhood { get; }
Property Value
Size
The size in tiles that this map has. This is always SizeInSections multiplied by Size.
public Point Size { get; }
Property Value
- Point
SizeInSections
The size, in sections (not tiles) that this map has
[DataMember]
public Point SizeInSections { get; }
Property Value
- Point
StaticVersion
The static version of this map. When a new save file is created, a static version of each map is loaded and used as the save file's basis. If the static version of the save file is newer, their save file is updated to the new static map version, which causes all non-lot objects to be copied to the saved map.
[DataMember]
public int StaticVersion { get; }
Property Value
Time
This map's current in-game time, including the full day and time.
public TimeSpan Time { get; }
Property Value
Methods
AddHousehold(Lot, bool)
Adds a new household to this map by calling the Household constructor.
public Household AddHousehold(Lot lot, bool addedThroughPopulating = false)
Parameters
lot
LotThe lot that the household should live on
addedThroughPopulating
boolWhether the household was added through random population rather than by a player.
Returns
- Household
The newly created household
AddLight(Light)
Adds the given light to the world at its Position
public Light AddLight(Light light)
Parameters
light
LightThe light to add
Returns
AddLot(Rectangle)
Adds a new lot with the given area to this map's lots
public Lot AddLot(Rectangle area)
Parameters
area
RectangleThe area that the new lot should have
Returns
- Lot
The newly created lot
AddLot(Lot)
Adds the given lot to this map's lots.
public void AddLot(Lot lot)
Parameters
lot
LotThe lot to add.
AddObject(MapObject)
Adds the given object to this map. Note that, if the object's Id is already present on this map, this method will cause an exception.
public MapObject AddObject(MapObject obj)
Parameters
obj
MapObjectThe object to add to this map
Returns
AddRoad(Point)
Adds a road to the map at the given position. This doesn't actually add the road tiles, but it notifies the pathfinder that there is a road center at this location.
public void AddRoad(Point pos)
Parameters
pos
PointThe position to add a road to
AddRoof(Roof)
Adds the given roof to this map
public void AddRoof(Roof roof)
Parameters
roof
RoofThe roof to add
AddStairs(Stairs)
Adds the given stairs to this map, additionally marking all involved locations dirty for pathfinding.
public void AddStairs(Stairs stairs)
Parameters
stairs
StairsThe stairs to add.
AddWall(WallLike)
Adds the given wall to the given position. Optionally, the Room related to that wall is re-calculated.
public bool AddWall(WallLike wall)
Parameters
wall
WallLikeThe wall to add
Returns
- bool
Whether the wall could be added successfully
ApplyCameraRotation(Vector2, bool, Direction2?)
Applies the game's current CameraRotation to the given position in world space
public Vector2 ApplyCameraRotation(Vector2 worldPos, bool borderOffset = false, Direction2? cameraRotation = null)
Parameters
worldPos
Vector2The position, in world space
borderOffset
boolWhether a border offset should be applied. This is useful for tiles and other objects that aren't centered in the middle of their tiles, but that use the top-left corner of a tile for positioning.
cameraRotation
Direction2?An optional override camera rotation which should be used in favor of CameraRotation
Returns
- Vector2
The position in world space, but with camera rotation appplied
ApplyInverseCameraRotation(Vector2, Direction2?)
Applies the game's current CameraRotation to the given position in world space in reverse, undoing the action done by ApplyCameraRotation(Vector2, bool, Direction2?)
public Vector2 ApplyInverseCameraRotation(Vector2 worldPos, Direction2? cameraRotation = null)
Parameters
worldPos
Vector2The position, in world space
cameraRotation
Direction2?An optional override camera rotation which should be used in favor of CameraRotation
Returns
- Vector2
The position in world space, but without camera rotation appplied
CanWalkBetween(PersonLike, Point, int, Point, int)
Returns whether the given person can walk between the two given positions.
Internally, this method only queries whether GetPathCost(MapObject, Point, int, Point, int) is lower than MaxValue or PositiveInfinity.
Note that, for this method to return a proper result, nextPos
has to be directly or diagonally adjacent to currPos
.
public bool CanWalkBetween(PersonLike person, Point currPos, int currFloor, Point nextPos, int nextFloor)
Parameters
person
PersonLikeThe person to get the path cost for
currPos
PointThe current position
currFloor
intThe current position's floor.
nextPos
PointThe next, neighboring position
nextFloor
intThe next position's floor.
Returns
- bool
Whether the two locations can be walked between
Draw(GameTime, SpriteBatch, bool, RectangleF?, Matrix?, RenderTarget2D, bool)
Draws this map and all of its objects. Note that drawing in this manner uses multiple Microsoft.Xna.Framework.Graphics.RenderTarget2D objects, for things like the ground and the lightmaps.
public void Draw(GameTime time, SpriteBatch batch, bool selectionMode, RectangleF? visibleArea = null, Matrix? visibleMatrix = null, RenderTarget2D lightmap = null, bool ignoreObjectVisibility = false)
Parameters
time
GameTimeThe game's time
batch
SpriteBatchThe sprite batch to use for drawing
selectionMode
boolWhether we're drawing in selection mode ("ShowSelectionEffect" cheat displays this mode)
visibleArea
RectangleF?The area that is visible, in world space. If this is null, MLEM.Cameras.Camera.GetVisibleRectangle() is used to calculate the visible area.
visibleMatrix
Matrix?A matrix that has a translation and scale that determines the visible area of the screenshot
lightmap
RenderTarget2DThe light map to draw lighting data onto, or null to use the default light map
ignoreObjectVisibility
boolWhether object visibility (Visibility) should be ignored
GetAllLotEmployments()
Returns a set of all LotEmployment instances and their Lot on the map. Note that MapWideEmployments are also returned, with their Lot component being set to null.
public IEnumerable<(LotEmployment Employment, Lot EmploymentLot)> GetAllLotEmployments()
Returns
- IEnumerable<(LotEmployment Employment, Lot EmploymentLot)>
All lot employments on this map
GetAllPeople()
Returns all of the PersonLike objects that are on this map, including dead people stored in gravestones.
public IEnumerable<PersonLike> GetAllPeople()
Returns
- IEnumerable<PersonLike>
All people on this map.
GetClosestEmptyTile(Vector2, float, int, bool, bool, bool, bool, Predicate<Point>)
Returns the position of the closest tile that is empty. An empty tile is a tile that has no MapObject instances on it.
public Point? GetClosestEmptyTile(Vector2 pos, float floor, int radius = 2, bool ignorePeople = true, bool hasToBeOnLot = false, bool sameRoom = false, bool hasToBeNonnull = true, Predicate<Point> valid = null)
Parameters
pos
Vector2The position to be close to
floor
floatThe floor to query tiles on.
radius
intThe radius to search for empty tiles in
ignorePeople
boolWhether or not people should be ignored. If this is true, the returned empty tile might currently be occupied by a PersonLike.
hasToBeOnLot
boolWhether or not the returned tile position has to be part of a Lot
sameRoom
boolWhether or not the returned tile position has to be in the same room as
pos
hasToBeNonnull
boolWhether the tile has to be nonnull, ie air tiles on higher levels should not be included.
valid
Predicate<Point>A predicate that can optionally be used to check whether the returned tile matches additional conditions.
Returns
- Point?
The closest empty tile, or null if there isn't one
GetClosestFreeExitPoint(Vector2)
Returns the closest exit point on the map to the given position
, out of all of the points returned by GetExitPoints().
public Point GetClosestFreeExitPoint(Vector2 position)
Parameters
position
Vector2The position that the exit point should be close to.
Returns
- Point
The closest exit point to the given position.
GetClosestRoads(Point, int)
Returns all road markers around the given pos
in the given radius
, ordered by their distance to the pos
.
public IEnumerable<Point> GetClosestRoads(Point pos, int radius)
Parameters
pos
PointThe position to find the closest roads to
radius
intThe radius, in tiles, to search for roads in
Returns
- IEnumerable<Point>
The closest road points
GetClosestRoadsidePosition(Point, Vector2)
Returns the closest roadside position to the given road
position, as well as the given pos
.
public Point? GetClosestRoadsidePosition(Point road, Vector2 pos)
Parameters
road
PointThe road position.
pos
Vector2The (non-road) position that the returned roadside position should be closest to.
Returns
- Point?
The closest roadside position, or null if there is none around.
GetDepth(Vector2, float, float, bool, bool, bool)
Gets the depth that should be used for drawing an object at the given position
public float GetDepth(Vector2 worldPos, float floor, float offset = 0, bool center = true, bool borderOffset = false, bool applyCameraRotation = true)
Parameters
worldPos
Vector2The position to get depth for, in tile coordinates
floor
floatThe floor to get depth for.
offset
floatAn offset added to the depth value
center
boolWhether the position should be centered on the x axis
borderOffset
boolWhether the map border offset should be applied to the camera rotation using ApplyCameraRotation(Vector2, bool, Direction2?). This value only has an effect if
applyCameraRotation
is trueapplyCameraRotation
boolWhether the game's current CameraRotation should be applied using ApplyCameraRotation(Vector2, bool, Direction2?)
Returns
- float
The depth to pass to the draw call
GetExitPoints()
Returns a set of all exit points on the map, which are locations on the map's border that Tinies can exit from either on foot or using their car.
public IEnumerable<(Point Position, Direction2 Dir)> GetExitPoints()
Returns
- IEnumerable<(Point Position, Direction2 Dir)>
All exit points on this map.
GetHousehold(PersonLike)
Returns the household that the given PersonLike lives in
public Household GetHousehold(PersonLike person)
Parameters
person
PersonLikeThe person to query
Returns
- Household
The person's household, or null if there is none
GetHousehold(Lot)
Returns the household that lives on the given Lot
public Household GetHousehold(Lot lot)
Parameters
lot
LotThe lot to query
Returns
- Household
The household that lives on the lot, or null if none lives there
GetHouseholds()
Returns a set of all of the Household instances that live on this map
public IEnumerable<Household> GetHouseholds()
Returns
- IEnumerable<Household>
This map's households
GetLot(Point)
Returns the lot that is present at the given position. The lot returned will always have its Area contain the passed position.
public Lot GetLot(Point pos)
Parameters
pos
PointThe position to query
Returns
- Lot
The lot at that position, or null if there is none
GetLot(Guid)
Returns the lot with the given id on this map. The returned lot's Id will equal the given id.
public Lot GetLot(Guid id)
Parameters
id
GuidThe id that the lot should have
Returns
- Lot
The lot with the given id
GetLots()
Returns a set of all of the Lot objects on this map
public IEnumerable<Lot> GetLots()
Returns
- IEnumerable<Lot>
This map's lots
GetMapSampler()
Returns the Microsoft.Xna.Framework.Graphics.SamplerState to use when rendering the map. This value is determined by BlurZoomedOut, as well as the Camera's scale.
public static SamplerState GetMapSampler()
Returns
- SamplerState
The sampler state to use when rendering the map.
GetObject<T>(Guid)
Returns the object with the given id of the given type. If there is no object with that id, or its type does not match, null is returned.
public T GetObject<T>(Guid id) where T : MapObject
Parameters
id
GuidThe id that the returned object should have
Returns
- T
The object, or null if there is no matching one
Type Parameters
T
The type that the object is expected to have
GetObjects<T>(RectangleF)
Returns a set of objects that are present in the given area.
public IEnumerable<T> GetObjects<T>(RectangleF area) where T : MapObject
Parameters
area
RectangleFThe area, in tile coordinates
Returns
- IEnumerable<T>
A set of objects that match the criteria
Type Parameters
T
The type that the objects need to have
GetPathCost(MapObject, Point, int, Point, int)
Returns the cost to pathfind from the given current position to the given next position.
Note that, for this method to return a proper result, nextPos
has to be directly or diagonally adjacent to currPos
.
public float GetPathCost(MapObject obj, Point currPos, int currFloor, Point nextPos, int nextFloor)
Parameters
obj
MapObjectThe person to get the path cost for
currPos
PointThe current position
currFloor
intThe current position's floor.
nextPos
PointThe next, neighboring position
nextFloor
intThe next position's floor.
Returns
- float
The cost to path to this location
GetPeople()
Returns all of the PersonLike objects that are on this map, excluding dead people stored in gravestones.
public IEnumerable<PersonLike> GetPeople()
Returns
- IEnumerable<PersonLike>
This map's people
GetRandomTile(Random, Vector2, int, int, bool, bool, bool, Predicate<Point>)
Returns a random tile in the given radius that matches the given predicate. If no tile is found, an empty Nullable<T> is returned.
public Point? GetRandomTile(Random random, Vector2 pos, int floor, int radius = 32, bool hasToBeOnLot = false, bool sameRoom = false, bool hasToBeNonnull = true, Predicate<Point> valid = null)
Parameters
random
RandomThe random to use
pos
Vector2The position that the radius should be centered on
floor
intThe floor to query.
radius
intThe radius
hasToBeOnLot
boolWhether the position returned has to be on a lot
sameRoom
boolWhether the position returned has to be in the same room as the
pos
passedhasToBeNonnull
boolWhether the tile has to be nonnull, ie air tiles on higher levels should not be included.
valid
Predicate<Point>A predicate that determines whether tile should be included
Returns
- Point?
A random tile that matches the given conditions
GetRegularVisitors()
Returns the set of PersonLike instances in the world that are regular visitors. This method is a shorthand for GetPeople() and IsRegularVisitor. Note that dead regular visitors are not returned.
public IEnumerable<PersonLike> GetRegularVisitors()
Returns
- IEnumerable<PersonLike>
This map's regular visitors
GetRoads()
Returns a set of all of the road markers on this map
public IEnumerable<Point> GetRoads()
Returns
- IEnumerable<Point>
A set of all road markers on this map
GetRoof(Point, int)
Gets a Roof whose area contains the given position
public Roof GetRoof(Point pos, int floor)
Parameters
pos
PointThe position to find a roof at
floor
intThe floor to find a roof at.
Returns
- Roof
The roof at that position, or null if there is none
GetRoofs(RectangleF)
Returns the roofs that intersect the given area
.
public IEnumerable<Roof> GetRoofs(RectangleF area)
Parameters
area
RectangleFThe area to search for roofs in.
Returns
- IEnumerable<Roof>
The roofs in the given area.
GetRoom(Point, int)
Returns the room that the given pos
is contained in.
If the position is out of bounds (IsInBounds(Point)), null is returned.
public Room GetRoom(Point pos, int floor)
Parameters
pos
PointThe position to query
floor
intThe floor to query.
Returns
- Room
The room at that location, or null if there is none
GetRooms(RectangleF)
Returns all rooms that are contained in, or intersect with, the given area
.
Note that this method performs rather badly on a large scale, and its usage should be avoided if GetRoom(Point, int) is more convenient.
public IEnumerable<Room> GetRooms(RectangleF area)
Parameters
area
RectangleFThe area to search for rooms in.
Returns
- IEnumerable<Room>
The rooms in the area.
GetSection(Point, bool)
Returns the MapSection at the given tile position
public MapSection GetSection(Point pos, bool clamp = false)
Parameters
pos
PointThe tile position
clamp
boolWhether the
pos
should be clamped into the valid Size of the map.
Returns
- MapSection
The section at that position
GetSections(RectangleF, int)
Returns a set of sections that are contained in (or intersect with) the given area
public IEnumerable<MapSection> GetSections(RectangleF area, int radiusIncrease = 0)
Parameters
area
RectangleFThe area to find sections in, in tile coordinates
radiusIncrease
intThe radius, in sections, that the search area should be extended by
Returns
- IEnumerable<MapSection>
A set of sections covered by this area
GetSections(Point, int)
Returns a set of sections that are contained in (or intersect with) the given area
public IEnumerable<MapSection> GetSections(Point point, int radiusIncrease = 0)
Parameters
point
PointThe position to find the section for, in tile coordinates
radiusIncrease
intThe radius, in sections, that the search area should be extended by
Returns
- IEnumerable<MapSection>
A set of sections covered by this area
GetStairs(RectangleF, bool)
Returns all of the stairs in the given area
, including stairs that partly intersect, on all floors.
public IEnumerable<Stairs> GetStairs(RectangleF area, bool includeEntryPositions = false)
Parameters
area
RectangleFThe area.
includeEntryPositions
boolWhether the entry positions of the stairs should be included, rather than just the Area.
Returns
- IEnumerable<Stairs>
The stairs in the area.
GetStaticMaps()
public static IEnumerable<(string Path, string Description, Texture2D Icon, bool Custom, bool Hidden)> GetStaticMaps()
Returns
- IEnumerable<(string Path, string Description, Texture2D Icon, bool Custom, bool Hidden)>
GetStoredDeadPeople()
Returns a set of all of the dead people that are stored in Gravestone furniture, both on this map and in the household storages of any of this map's households.
public IEnumerable<(Gravestone Gravestone, PersonLike Person)> GetStoredDeadPeople()
Returns
- IEnumerable<(Gravestone Gravestone, PersonLike Person)>
The stored dead people on this map.
GetTile(Point, int)
Returns the tile at the given position on this map. Note that, if the floor is not the ground floor 0, this method can return null.
public Tile GetTile(Point pos, int floor)
Parameters
pos
PointThe position to query
floor
intThe floor.
Returns
- Tile
The tile at that position
GetTilesAround(Vector2, float, int, bool, bool, bool, Predicate<Point>)
Returns a set of tiles around the given position that match the given conditions
public IEnumerable<Point> GetTilesAround(Vector2 pos, float floor, int radius, bool hasToBeOnLot = false, bool sameRoom = false, bool hasToBeNonnull = true, Predicate<Point> valid = null)
Parameters
pos
Vector2The position
floor
floatThe floor to query.
radius
intThe radius, in tiles
hasToBeOnLot
boolWhether the returned positions have to be on a lot
sameRoom
boolWhether the returned positions have to be in the same room as the
pos
passedhasToBeNonnull
boolWhether the tile has to be nonnull, ie air tiles on higher levels should not be included.
valid
Predicate<Point>A function that determines whether a position should be returned. If this is null, all valid positions are returned.
Returns
- IEnumerable<Point>
A set of positions that match the given conditions
GetVisibleWorldArea(RectangleF)
Returns a rectangle, in world space, that encompasses all tile positions on a Map that are currently visible, based on the passed cameraArea
, which is expected to be the value of a camera's MLEM.Cameras.Camera.GetVisibleRectangle().
Note that, due to the fact that maps are in isometric perspective, the returned rectangle contains additional tile positions in each corner of the cameraArea
that aren't actually visible.
public static RectangleF GetVisibleWorldArea(RectangleF cameraArea)
Parameters
cameraArea
RectangleFThe camera area, in camera space.
Returns
- RectangleF
The visible area, in world space.
GetVisitPriority(PersonLike)
Returns the visitation priority for this map for the given PersonLike.
The returned value is based on whether the person
is on the same map, and the results of the OnGetVisitPriority event.
public float GetVisitPriority(PersonLike person)
Parameters
person
PersonLikeThe person visiting a lot on this map.
Returns
- float
The priority, as a weight.
GetWallBetween<T>(Point, Point, int)
Returns the wall between the pos
and secondPos
.
A wall is between two positions if its Positions are exactly those two positions, ignoring their order.
public T GetWallBetween<T>(Point pos, Point secondPos, int floor) where T : WallLike
Parameters
pos
PointThe first position
secondPos
PointThe second position
floor
intThe floor.
Returns
- T
The wall between the two positions, or null if there is none
Type Parameters
T
GetWalls<T>(RectangleF)
Returns a set of walls in the given area. All WallLike objects for which at least one Positions entry is contained in the area are returned.
public IEnumerable<T> GetWalls<T>(RectangleF area) where T : WallLike
Parameters
area
RectangleFThe area to query for walls
Returns
- IEnumerable<T>
A set of walls in the area
Type Parameters
T
IsFreeSpot(Point, int)
Returns whether or not the given position on the given map is free for a PersonLike to stand in
public bool IsFreeSpot(Point pos, int floor)
Parameters
pos
PointThe position to query
floor
intThe floor to query.
Returns
- bool
Whether this position is free to stand on
IsInBounds(Point)
Returns whether the given position is in bounds of this map's Size
public bool IsInBounds(Point pos)
Parameters
pos
PointThe position to query
Returns
- bool
true if the position is in bounds, false otherwise
IsLotHidden(Lot)
Whether the given lot is hidden from the camera.
Note that the result of this method will be different from IsLotVisible(Lot), since this method also checks for the ShowAllLots cheat.
For ease of use, this method returns false if lot
is null.
public static bool IsLotHidden(Lot lot)
Parameters
lot
Lot
Returns
IsRoad(Point)
Returns whether the given position contains a road. This doesn't query road tiles, but it queries for road markers added by AddRoad(Point).
public bool IsRoad(Point pos)
Parameters
pos
Point
Returns
LoadStaticMap(MapInfo)
Loads a static map with the given name from the game's content directory. Note that no validation steps (ValidateEarly(MapInfo, Dictionary<string, Map>, Action<string>, Action<float>), Validate(bool, Action<string>, Action<float>), PostValidate(Action<string>, Action<float>)) have taken place when the map is returned.
public static Map LoadStaticMap(PerSaveOptions.MapInfo info)
Parameters
info
PerSaveOptions.MapInfoThe PerSaveOptions.MapInfo of the static map to load.
Returns
- Map
The static map that was loaded.
MarkDirtyForPathfinding(Point, int)
Marks the given position dirty for pathfinding purposes. When a path is found again close to this position, its cost (GetPathCost(MapObject, Point, int, Point, int)) will be re-calculated. This method is called by Furniture when it is placed for removed.
public void MarkDirtyForPathfinding(Point pos, int floor)
Parameters
pos
PointThe position to mark dirty
floor
intThe floor that the position is on.
MarkGroundTileDirtyForDrawing(Point)
Marks the given position dirty for drawing, which causes the underlying MLEM.Graphics.StaticSpriteBatch to re-render the tile. This method is used automatically by SetTile(Point, int, Tile) and AutoTile.
public void MarkGroundTileDirtyForDrawing(Point pos)
Parameters
pos
PointThe position to mark dirty.
MarkObjectDirtyForDrawing(MapObject, MapSection, bool)
Marks the given MapObject dirty for drawing, which causes the underlying MLEM.Graphics.StaticSpriteBatch to re-render the object if its visibility is Static. This method is used automatically by AddObject(MapObject) and RemoveObject(MapObject), as well as when a static object's Position changes.
public void MarkObjectDirtyForDrawing(MapObject obj, MapSection section = null, bool removedFromSection = false)
Parameters
obj
MapObjectThe object to mark dirty.
section
MapSectionThe section that the object is expected to be in, or null to determine the section automatically.
removedFromSection
boolWhether the object was removed, and should not be redrawn in the
section
.
MoveEverything(Point, Rectangle, bool, Tile)
Moves all of the objects, walls, tiles and roofs in the given area
in the world, optionally moving the lots as well
public void MoveEverything(Point offset, Rectangle area, bool moveLots, Tile defaultTile = null)
Parameters
offset
PointThe offset to move things by
area
RectangleThe area to move
moveLots
boolWhether lots should be moved as well. The content of lots will be moved regardless of this parameter
defaultTile
TileThe default tile to replace the moved ground with.
OnCameraRotationChanged(Direction2, Direction2)
A method that is called when CameraRotation is changed. When changing camera rotation manually, this method should be called along with the change.
public void OnCameraRotationChanged(Direction2 oldRotation, Direction2 newRotation)
Parameters
oldRotation
Direction2newRotation
Direction2
OnCurrentGameMapChanged(Map, Map)
This method is invoked when the game's CurrentMap is changed, ie when the camera is moved to a different map.
public void OnCurrentGameMapChanged(Map oldMap, Map newMap)
Parameters
PlaySound(SoundEffect, Vector2, float, float, float, bool, bool)
Plays a sound at the given location (in world space) statically. If the sound should move while being played, use PlaySound(SoundEffect, MapAudioEmitter, float, float, bool, bool) instead. Note that the returned Microsoft.Xna.Framework.Audio.SoundEffectInstance does not need to be disposed when it is finished playing.
public SoundEffectInstance PlaySound(SoundEffect sound, Vector2 pos, float floor, float volume = 1, float pitch = 0, bool loop = false, bool applyWorldSoundVolume = true)
Parameters
sound
SoundEffectThe sound effect to play
pos
Vector2The position, in world space, to play the sound at
floor
floatThe floor to play the sound based on.
volume
floatThe sound's volume, between 0 and 1 (default)
pitch
floatThe sound's pitch, between -1, 0 (default) and 1
loop
boolWhether or not the sound should loop
applyWorldSoundVolume
boolWhether the WorldSoundVolume should be applied to the passed
volume
Returns
- SoundEffectInstance
The sound effect instance that is responsible for playing this sound, which can be stopped or paused
PlaySound(SoundEffect, MapAudioEmitter, float, float, bool, bool)
Plays a sound at the given location (in world space) with the given MapAudioEmitter, whose WorldPosition can be updated by the caller. If the sound should move in a static locatdion, use PlaySound(SoundEffect, Vector2, float, float, float, bool, bool) instead. Note that the returned Microsoft.Xna.Framework.Audio.SoundEffectInstance does not need to be disposed when it is finished playing.
public SoundEffectInstance PlaySound(SoundEffect sound, MapAudioEmitter emitter, float volume = 1, float pitch = 0, bool loop = false, bool applyWorldSoundVolume = true)
Parameters
sound
SoundEffectThe sound effect to play
emitter
MapAudioEmitterThe audio emitter, whose WorldPosition should be set by the caller
volume
floatThe sound's volume, between 0 and 1 (default)
pitch
floatThe sound's pitch, between -1, 0 (default) and 1
loop
boolWhether or not the sound should loop
applyWorldSoundVolume
boolWhether the WorldSoundVolume should be applied to the passed
volume
Returns
- SoundEffectInstance
The sound effect instance that is responsible for playing this sound, which can be stopped or paused
PopulateLots()
Populates a subset of empty residential lots on this map with loaded exported households, or with randomly generated households. This method is automatically invoked every few in-game days if the PopulateLots option is enabled.
public void PopulateLots()
PostValidate(Action<string>, Action<float>)
This method is called when this object is loaded from disk, after Validate(bool, Action<string>, Action<float>) has already been called. When called on a map, post-load preloads like pathfinding pre-generation occurs.
public void PostValidate(Action<string> setState, Action<float> setProgress)
Parameters
setState
Action<string>An action that accepts the current state of the loading process.
setProgress
Action<float>An action that accepts the progress of the current state of the loading process.
PrepareForPermanentRemoval()
Prepares this map for permanent removal, moving all people on this map to their original positions (including their home location if it is on another map and their lot employment map if they have one), and calls PrepareForPermanentRemoval() on all remaining people.
public void PrepareForPermanentRemoval()
RemoveHousehold(Household)
Removes the given household from this map
public void RemoveHousehold(Household household)
Parameters
household
HouseholdThe household to remove
RemoveLight(Light)
Removes the given light from the world
public bool RemoveLight(Light light)
Parameters
light
LightThe light to remove
Returns
RemoveLot(Lot)
Removes the given lot from this map's lots
public void RemoveLot(Lot lot)
Parameters
lot
LotThe lot to remove
RemoveObject(MapObject)
Removes the given object from this map and its underlying MapSection. This also calls OnRemoved().
public void RemoveObject(MapObject obj)
Parameters
obj
MapObjectThe object to remove
Remarks
When removing a Furniture object from the world entirely, including when putting it into furniture storage, RemoveAndUnlink() should be used instead, or UnlinkParentsAndChildren() should be called in addition to this method. As all of those methods also sever the relationships between furniture items and their parents (which is equivalent to calling UnlinkParentsAndChildren()), they are usually preferred over this method, since parent-child relationships should not persist in many cases.
RemoveRoof(Roof)
Removes the given Roof from this map
public void RemoveRoof(Roof roof)
Parameters
roof
RoofThe roof to remove
RemoveStairs(Stairs)
Removes the given stairs from this map entirely, additionally marking all involved locations dirty for pathfinding.
public bool RemoveStairs(Stairs stairs)
Parameters
stairs
StairsThe stairs to remove.
Returns
- bool
Whether the stairs existed on the map, and were successfully removed.
RemoveWall(WallLike)
Removes the given wall from the map
public bool RemoveWall(WallLike wall)
Parameters
wall
WallLikeThe wall to remove
Returns
- bool
Whether the wall was present on the map and could be removed
SetTile(Point, int, Tile)
Sets the tile at the given position to the given tile
public void SetTile(Point pos, int floor, Tile tile)
Parameters
Update(GameTime, TimeSpan, float)
Updates this map, its MapSection objects and its Households.
public void Update(GameTime time, TimeSpan passedInGame, float speedMultiplier)
Parameters
time
GameTimeThe game's time
passedInGame
TimeSpanThe amount of time that has passed in game
speedMultiplier
floatThe game speed multiplier, which represents how fast things should happen, which is usually determined by Speed
UpdateExternalPeople(ICollection<Map>, Action<string>, Action<float>)
Updates the given maps
' regular visitors based on the MaxRegularVisitors value, assigns random people to empty LotEmployment slots, and clears duplicate households that have not been played (HasBeenPlayed).
This method is called automatically in various locations.
public static void UpdateExternalPeople(ICollection<Map> maps, Action<string> setState = null, Action<float> setProgress = null)
Parameters
Validate(bool, Action<string>, Action<float>)
This method is called when this object is loaded from disk, between ValidateEarly(MapInfo, Dictionary<string, Map>, Action<string>, Action<float>) and PostValidate(Action<string>, Action<float>). When called on a map, it causes all objects to be validated, roads to be generated, outdated information to be removed, and more.
public void Validate(bool localize, Action<string> setState, Action<float> setProgress)
Parameters
localize
boolWhether this map's data should be localized upon validation, which is only used for builtin maps and not custom ones.
setState
Action<string>An action that accepts the current state of the loading process.
setProgress
Action<float>An action that accepts the progress of the current state of the loading process.
ValidateEarly(MapInfo, Dictionary<string, Map>, Action<string>, Action<float>)
This method is called when this object is loaded from disk, before Validate(bool, Action<string>, Action<float>) is called. When called on a map, early section and object validation occurs.
public void ValidateEarly(PerSaveOptions.MapInfo info, Dictionary<string, Map> neighborhood, Action<string> setState, Action<float> setProgress)
Parameters
info
PerSaveOptions.MapInfoThe PerSaveOptions.MapInfo to assign to this map.
neighborhood
Dictionary<string, Map>The Neighborhood to assign to this map.
setState
Action<string>An action that accepts the current state of the loading process.
setProgress
Action<float>An action that accepts the progress of the current state of the loading process.
ValidateRooms(Point, int)
Adds new Room objects to the given positions if there are valid rooms present, and validates additional rooms, checking for whether they should still exist.
public Room ValidateRooms(Point position, int floor)
Parameters
position
PointThe position that should be inspected for possible rooms.
floor
intThe floor that should be inspected for possible rooms.
Returns
Events
OnEventsAttachable
An event that is invoked when non-static events for a Map are ready to be attached to. This event is invoked in PostValidate(Action<string>, Action<float>).
public static event Action<Map> OnEventsAttachable
Event Type
OnGetVisitPriority
An event that is invoked when the visitation priority for this map for a PersonLike is evaluated in GetVisitPriority(PersonLike). The visitation priority for any given person can be modified using this event. This event can be subscribed to using OnEventsAttachable.
public event Map.VisitPriorityDelegate OnGetVisitPriority
Event Type
OnObjectAdded
An event that is invoked when a MapObject is added to this map using AddObject(MapObject) This event can be subscribed to using OnEventsAttachable.
public event Action<MapObject> OnObjectAdded
Event Type
OnObjectRemoved
An event that is invoked when a MapObject is removed from this map using RemoveObject(MapObject) This event can be subscribed to using OnEventsAttachable.
public event Action<MapObject> OnObjectRemoved
Event Type
OnPathfindingNodeConstruct
An event that is invoked when a new pathfinding node is constructed after a position was marked as dirty using MarkDirtyForPathfinding(Point, int). This event can be used to make pathfinding for a given position cheaper or more expensive based on mod factors. This event can be subscribed to using OnEventsAttachable.
public event Map.PathfindingNodeConstructDelegate OnPathfindingNodeConstruct
Event Type
OnUpdate
An event that is invoked when this map is updated in Update(GameTime, TimeSpan, float). This event can be subscribed to using OnEventsAttachable.
public event UpdateDelegate OnUpdate