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
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
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
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)
Adds a new household to this map by calling the Household constructor.
public Household AddHousehold(Lot lot)
Parameters
lot
LotThe 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
LightThe 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
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.
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
UndoableActionThe undoable action that this method should add its actions to. If this method should be executed immediately, use the UndoableAction immediate constructor.
editWorld
boolWhether 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
MapObjectThe 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
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
AddWall(Point, Point)
Adds the given wall to the given position.
public bool AddWall(Point pos, Point secondPos)
Parameters
pos
PointThe position that the new wall should have
secondPos
PointThe 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
WallThe 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(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
PersonThe person to get the path cost for
currPos
PointThe current position
nextPos
PointThe 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
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
~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
Vector2The position to be close to
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 Person.
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
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
Vector2The 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
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.
GetDeadPerson(Guid)
public Person GetDeadPerson(Guid id)
Parameters
id
GuidThe 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)
public float GetDepth(Vector2 worldPos, float offset = 0, bool center = true, bool borderOffset = false, bool applyCameraRotation = true)
Parameters
worldPos
Vector2The position to get depth for, in tile coordinates
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
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
PersonThe 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(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
PersonThe person to get the path cost for
currPos
PointThe current position
nextPos
PointThe 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
RandomThe random to use
pos
Vector2The position that the radius should be centered on
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
passedvalid
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
PointThe 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
RectangleFThe 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
PointThe 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
PointThe 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
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
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
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
GetTile(Point)
Returns the tile at the given position on this map
public Tile GetTile(Point pos)
Parameters
pos
PointThe 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
Vector2The position
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
passedvalid
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.
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
PointThe first position
secondPos
PointThe 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
RectangleFThe 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
PointThe 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
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)
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
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
.
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
PointThe 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
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, 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
SoundEffectThe sound effect to play
pos
Vector2The position, in world space, to play the sound at
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, 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
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
RemoveWall(Wall)
Removes the given wall from the map
public bool RemoveWall(Wall wall)
Parameters
wall
WallThe 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
PointThe position
tile
TileThe 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
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, 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
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
boolWhether 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.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.
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
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
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