Table of Contents

Class Map

Namespace
TinyLife.World
Assembly
Tiny Life.dll

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
JsonTypeSafeGenericDataHolder
Map
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 Point

The size, in sections, of this map

Fields

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

List<Mail>

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

float

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

float

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

int

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

List<Person>

Info

This map's PerSaveOptions.MapInfo, which includes its name and whether it is custom.

public PerSaveOptions.MapInfo Info { get; }

Property Value

PerSaveOptions.MapInfo

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

bool

IsCurrent

Whether this map is current. This returns whether this map is the same as CurrentMap.

public bool IsCurrent { get; }

Property Value

bool

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

Dictionary<string, Map>

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

int

Time

This map's current in-game time, including the full day and time.

public TimeSpan Time { get; }

Property Value

TimeSpan

Methods

AddHousehold(Lot)

Adds a new household to this map by calling the Household constructor.

public Household AddHousehold(Lot lot)

Parameters

lot Lot

The lot that the household should live on

Returns

Household

The newly created household

AddLight(Light)

Adds the given light to the world at its Position

public void AddLight(Light light)

Parameters

light Light

The light to add

AddLot(Rectangle)

Adds a new lot with the given area to this map's lots

public Lot AddLot(Rectangle area)

Parameters

area Rectangle

The 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 Lot

The lot to add.

AddNewRoomsAndValidateExisting(Point[], UndoableAction, bool)

Adds new Room objects to the given positions if there are valid rooms present, and validates additional rooms, checking for whether they should still exists.

public void AddNewRoomsAndValidateExisting(Point[] positions, UndoableAction action, bool editWorld = false)

Parameters

positions Point[]

The positions that should be inspected for possible rooms.

action UndoableAction

The undoable action that this method should add its actions to. If this method should be executed immediately, use the UndoableAction immediate constructor.

editWorld bool

Whether the world should be edited when adding new rooms, which involves adding concrete floors and a roof to new rooms.

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 void AddObject(MapObject obj)

Parameters

obj MapObject

The object to add to this map

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 Point

The position to add a road to

AddRoof(Roof)

Adds the given roof to this map

public void AddRoof(Roof roof)

Parameters

roof Roof

The roof to add

AddWall(Point, Point)

Adds the given wall to the given position.

public bool AddWall(Point pos, Point secondPos)

Parameters

pos Point

The position that the new wall should have

secondPos Point

The second position that the new wall should have

Returns

bool

Whether the wall could be added

AddWall(Wall)

Adds the given wall to the given position. Optionally, the Room related to that wall is re-calculated.

public bool AddWall(Wall wall)

Parameters

wall Wall

The 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 Vector2

The position, in world space

borderOffset bool

Whether 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 Vector2

The 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(Person, Point, Point)

Returns whether the given person can walk between the two given positions. Internally, this method only queries whether GetPathCost(Person, Point, Point) 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(Person person, Point currPos, Point nextPos)

Parameters

person Person

The person to get the path cost for

currPos Point

The current position

nextPos Point

The next, neighboring position

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 GameTime

The game's time

batch SpriteBatch

The sprite batch to use for drawing

selectionMode bool

Whether 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 RenderTarget2D

The light map to draw lighting data onto, or null to use the default light map

ignoreObjectVisibility bool

Whether object visibility (Visibility) should be ignored

~Map()

protected ~Map()

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 Lot)> GetAllLotEmployments()

Returns

IEnumerable<(LotEmployment Employment, Lot Lot)>

All lot employments on this map

GetClosestEmptyTile(Vector2, int, bool, bool, bool)

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, int radius = 2, bool ignorePeople = true, bool hasToBeOnLot = false, bool sameRoom = false)

Parameters

pos Vector2

The position to be close to

radius int

The radius to search for empty tiles in

ignorePeople bool

Whether or not people should be ignored. If this is true, the returned empty tile might currently be occupied by a Person.

hasToBeOnLot bool

Whether or not the returned tile position has to be part of a Lot

sameRoom bool

Whether or not the returned tile position has to be in the same room as pos

Returns

Point?

The closest empty tile, or null if there isn't one

GetClosestFreeExitPoint(Vector2)

Returns the closest point to the given position that the map can be exited from. An exit point is a sidewalk next to a road, which additionally doesn't have any objects in the way.

public Point GetClosestFreeExitPoint(Vector2 position)

Parameters

position Vector2

The position.

Returns

Point

The closest free exit point, which is expected to exist on every map.

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 Point

The position to find the closest roads to

radius int

The 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 Point

The road position.

pos Vector2

The (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.

GetDeadPerson(Guid)

Returns a dead Person with the given Guid id

public Person GetDeadPerson(Guid id)

Parameters

id Guid

The id to get a dead person by

Returns

Person

The dead person instance, or null if there is none

GetDepth(Vector2, float, bool, bool, bool)

Gets the depth that should be used for drawing a Wall or Tile at the given position

public float GetDepth(Vector2 worldPos, float offset = 0, bool center = true, bool borderOffset = false, bool applyCameraRotation = true)

Parameters

worldPos Vector2

The position to get depth for, in tile coordinates

offset float

An offset added to the depth value

center bool

Whether the position should be centered on the x axis

borderOffset bool

Whether 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 true

applyCameraRotation bool

Whether the game's current CameraRotation should be applied using ApplyCameraRotation(Vector2, bool, Direction2?)

Returns

float

The depth to pass to the draw call

GetExitRoads()

Returns the positions of all of the roads that are at the borders of this map and the MLEM.Misc.Direction2 that the map border is in

public IEnumerable<(Point Road, Direction2 Dir)> GetExitRoads()

Returns

IEnumerable<(Point Road, Direction2 Dir)>

All of the exit roads out of this map

GetHousehold(Person)

Returns the household that the given Person lives in

public Household GetHousehold(Person person)

Parameters

person Person

The 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 Lot

The 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 Point

The 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 Guid

The 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 Guid

The 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 RectangleF

The 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(Person, Point, Point)

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(Person person, Point currPos, Point nextPos)

Parameters

person Person

The person to get the path cost for

currPos Point

The current position

nextPos Point

The next, neighboring position

Returns

float

The cost to path to this location

GetPeople()

Returns all of the Person objects that are on this map. Note that no TinyLife.World.Map.DeadPeople are returned.

public IEnumerable<Person> GetPeople()

Returns

IEnumerable<Person>

This map's people

GetRandomTile(Random, Vector2, int, 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 radius = 32, bool hasToBeOnLot = false, bool sameRoom = false, Predicate<Point> valid = null)

Parameters

random Random

The random to use

pos Vector2

The position that the radius should be centered on

radius int

The radius

hasToBeOnLot bool

Whether the position returned has to be on a lot

sameRoom bool

Whether the position returned has to be in the same room as the pos passed

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 Person 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<Person> GetRegularVisitors()

Returns

IEnumerable<Person>

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)

Gets a Roof whose area contains the given position

public Roof GetRoof(Point pos)

Parameters

pos Point

The position 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 RectangleF

The area to search for roofs in.

Returns

IEnumerable<Roof>

The roofs in the given area.

GetRoom(Point)

Returns the room that the given position is contained in

public Room GetRoom(Point pos)

Parameters

pos Point

The position to query

Returns

Room

The room at that location, or null if there is none

GetSection(Point)

Returns the MapSection at the given tile position

public MapSection GetSection(Point pos)

Parameters

pos Point

The tile position

Returns

MapSection

The section at that position

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)

Parameters

point Point

The position to find the section for, in tile coordinates

radiusIncrease int

The radius, in sections, that the search area should be extended by

Returns

IEnumerable<MapSection>

A set of sections covered by this area

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)

Parameters

area RectangleF

The area to find sections in, in tile coordinates

radiusIncrease int

The radius, in sections, that the search area should be extended by

Returns

IEnumerable<MapSection>

A set of sections covered by this area

GetTile(Point)

Returns the tile at the given position on this map

public Tile GetTile(Point pos)

Parameters

pos Point

The position to query

Returns

Tile

The tile at that position

GetTilesAround(Vector2, int, bool, bool, Predicate<Point>)

Returns a set of tiles around the given position that match the given conditions

public IEnumerable<Point> GetTilesAround(Vector2 pos, int radius, bool hasToBeOnLot = false, bool sameRoom = false, Predicate<Point> valid = null)

Parameters

pos Vector2

The position

radius int

The radius, in tiles

hasToBeOnLot bool

Whether the returned positions have to be on a lot

sameRoom bool

Whether the returned positions have to be in the same room as the pos passed

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 RectangleF

The camera area, in camera space.

Returns

RectangleF

The visible area, in world space.

GetWallBetween(Point, Point)

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 Wall GetWallBetween(Point pos, Point secondPos)

Parameters

pos Point

The first position

secondPos Point

The second position

Returns

Wall

The wall between the two positions, or null if there is none

GetWalls(RectangleF)

Returns a set of walls in the given area. All Wall objects for which at least one Positions entry is contained in the area are returned.

public IEnumerable<Wall> GetWalls(RectangleF area)

Parameters

area RectangleF

The area to query for walls

Returns

IEnumerable<Wall>

A set of walls in the area

IsFreeSpot(Point)

Returns whether or not the given position on the given map is free for a Person to stand in

public bool IsFreeSpot(Point pos)

Parameters

pos Point

The position 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 Point

The 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

bool

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

bool

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.MapInfo

The PerSaveOptions.MapInfo of the static map to load.

Returns

Map

The static map that was loaded.

MarkDirtyForPathfinding(Point)

Marks the given position dirty for pathfinding purposes. When a path is found again close to this position, its cost (GetPathCost(Person, Point, Point)) will be re-calculated. This method is called by Furniture when it is placed for removed.

public void MarkDirtyForPathfinding(Point pos)

Parameters

pos Point

The 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 MapObject

The object to mark dirty.

section MapSection

The section that the object is expected to be in, or null to determine the section automatically.

removedFromSection bool

Whether the object was removed, and should not be redrawn in the section.

MarkTileDirtyForDrawing(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, Tile) and AutoTile.

public void MarkTileDirtyForDrawing(Point pos)

Parameters

pos Point

The position to mark dirty.

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 Point

The offset to move things by

area Rectangle

The area to move

moveLots bool

Whether lots should be moved as well. The content of lots will be moved regardless of this parameter

defaultTile Tile

The 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 Direction2
newRotation 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

oldMap Map

The previous map.

newMap Map

The new map.

PlaySound(SoundEffect, Vector2, 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 volume = 1, float pitch = 0, bool loop = false, bool applyWorldSoundVolume = true)

Parameters

sound SoundEffect

The sound effect to play

pos Vector2

The position, in world space, to play the sound at

volume float

The sound's volume, between 0 and 1 (default)

pitch float

The sound's pitch, between -1, 0 (default) and 1

loop bool

Whether or not the sound should loop

applyWorldSoundVolume bool

Whether 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, 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 SoundEffect

The sound effect to play

emitter MapAudioEmitter

The audio emitter, whose WorldPosition should be set by the caller

volume float

The sound's volume, between 0 and 1 (default)

pitch float

The sound's pitch, between -1, 0 (default) and 1

loop bool

Whether or not the sound should loop

applyWorldSoundVolume bool

Whether 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

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 Household

The household to remove

RemoveLight(Light)

Removes the given light from the world

public bool RemoveLight(Light light)

Parameters

light Light

The light to remove

Returns

bool

RemoveLot(Lot)

Removes the given lot from this map's lots

public void RemoveLot(Lot lot)

Parameters

lot Lot

The 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 MapObject

The 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 Roof

The roof to remove

RemoveWall(Wall)

Removes the given wall from the map

public bool RemoveWall(Wall wall)

Parameters

wall Wall

The wall to remove

Returns

bool

Whether the wall was present on the map and could be removed

SetTile(Point, Tile)

Sets the tile at the given position to the given tile

public void SetTile(Point pos, Tile tile)

Parameters

pos Point

The position

tile Tile

The tile

Update(GameTime, TimeSpan, float)

Updates this map, its MapSection objects and its Households.

public void Update(GameTime time, TimeSpan passedInGame, float speedMultiplier)

Parameters

time GameTime

The game's time

passedInGame TimeSpan

The amount of time that has passed in game

speedMultiplier float

The 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, and also assigns random people to empty LotEmployment slots. This method does three things: It removes visitors that have been added into the world by the player (through household imports), it removes visitors if the current number of visitors is greater than the maximum, and it attempts to add new visitors if it is lower than the maximum and LotEmployment people in empty slots. This method is called automatically in various locations.

public static void UpdateExternalPeople(ICollection<Map> maps, Action<string> setState = null, Action<float> setProgress = null)

Parameters

maps ICollection<Map>
setState Action<string>
setProgress Action<float>

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 template, Action<string> setState, Action<float> setProgress)

Parameters

template bool

Whether this map should be validated as a template rather than a full 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.

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.MapInfo

The 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.

ValidateExistingRooms(params Point[])

Removes all outdated rooms on this map after calling their Validate() methods.

public void ValidateExistingRooms(params Point[] positions)

Parameters

positions Point[]

The positions around which to validate rooms

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

Action<Map>

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

Action<MapObject>

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

Action<MapObject>

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

Event Type

UpdateDelegate