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.
Inheritance
Implements
Inherited Members
Namespace: TinyLife.World
Assembly: Tiny Life.dll
Syntax
[DataContract]
public class Map : JsonTypeSafeGenericDataHolder, IGenericDataHolder
Constructors
Map(Point)
Creates a new map with the given size
Declaration
public Map(Point sizeInSections)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | sizeInSections | 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.
Declaration
[DataMember]
public readonly List<Mail> MailToSend
Field Value
Type | Description |
---|---|
System.Collections.Generic.List<T><Mail> |
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.
Declaration
public const int RoadRadius = 2
Field Value
Type | Description |
---|---|
System.Int32 |
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.
Declaration
public List<Person> AdoptableChildren { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<T><Person> |
Size
The size in tiles that this map has. This is always SizeInSections multiplied by Size.
Declaration
public Point Size { get; }
Property Value
Type | Description |
---|---|
Microsoft.Xna.Framework.Point |
SizeInSections
The size, in sections (not tiles) that this map has
Declaration
[DataMember]
public Point SizeInSections { get; }
Property Value
Type | Description |
---|---|
Microsoft.Xna.Framework.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.
Declaration
[DataMember]
public int StaticVersion { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Time
This map's current in-game time, including the full day and time.
Declaration
public TimeSpan Time { get; }
Property Value
Type | Description |
---|---|
System.TimeSpan |
Methods
AddHousehold(Lot)
Adds a new household to this map by calling the Household constructor.
Declaration
public Household AddHousehold(Lot lot)
Parameters
Type | Name | Description |
---|---|---|
Lot | lot | The lot that the household should live on |
Returns
Type | Description |
---|---|
Household | The newly created household |
AddLight(Light)
Adds the given light to the world at its Position
Declaration
public void AddLight(Light light)
Parameters
Type | Name | Description |
---|---|---|
Light | light | The light to add |
AddLot(Rectangle)
Adds a new lot with the given area to this map's lots
Declaration
public Lot AddLot(Rectangle area)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Rectangle | area | The area that the new lot should have |
Returns
Type | Description |
---|---|
Lot | The newly created lot |
AddLot(Lot)
Adds the given lot to this map's lots.
Declaration
public void AddLot(Lot lot)
Parameters
Type | Name | Description |
---|---|---|
Lot | lot | The lot to add. |
AddNewRoomsAndValidateExisting(Point[], UndoableAction, Boolean)
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.
Declaration
public void AddNewRoomsAndValidateExisting(Point[] positions, UndoableAction action, bool editWorld = false)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point[] | positions | The positions that should be inspected for possible rooms. |
UndoableAction | action | The undoable action that this method should add its actions to. If this method should be executed immediately, use the UndoableAction immediate constructor. |
System.Boolean | editWorld | 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.
Declaration
public void AddObject(MapObject obj)
Parameters
Type | Name | Description |
---|---|---|
MapObject | obj | 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.
Declaration
public void AddRoad(Point pos)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | pos | The position to add a road to |
AddRoof(Roof)
Adds the given roof to this map
Declaration
public void AddRoof(Roof roof)
Parameters
Type | Name | Description |
---|---|---|
Roof | roof | The roof to add |
AddWall(Point, Point)
Adds the given wall to the given position.
Declaration
public bool AddWall(Point pos, Point secondPos)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | pos | The position that the new wall should have |
Microsoft.Xna.Framework.Point | secondPos | The second position that the new wall should have |
Returns
Type | Description |
---|---|
System.Boolean | 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.
Declaration
public bool AddWall(Wall wall)
Parameters
Type | Name | Description |
---|---|---|
Wall | wall | The wall to add |
Returns
Type | Description |
---|---|
System.Boolean | Whether the wall could be added successfully |
ApplyCameraRotation(Vector2, Boolean, Nullable<Direction2>)
Applies the game's current CameraRotation to the given position in world space
Declaration
public Vector2 ApplyCameraRotation(Vector2 worldPos, bool borderOffset = false, Direction2? cameraRotation = null)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Vector2 | worldPos | The position, in world space |
System.Boolean | borderOffset | 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. |
System.Nullable<T><MLEM.Misc.Direction2> | cameraRotation | An optional override camera rotation which should be used in favor of CameraRotation |
Returns
Type | Description |
---|---|
Microsoft.Xna.Framework.Vector2 | The position in world space, but with camera rotation appplied |
ApplyInverseCameraRotation(Vector2, Nullable<Direction2>)
Applies the game's current CameraRotation to the given position in world space in reverse, undoing the action done by ApplyCameraRotation(Vector2, Boolean, Nullable<Direction2>)
Declaration
public Vector2 ApplyInverseCameraRotation(Vector2 worldPos, Direction2? cameraRotation = null)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Vector2 | worldPos | The position, in world space |
System.Nullable<T><MLEM.Misc.Direction2> | cameraRotation | An optional override camera rotation which should be used in favor of CameraRotation |
Returns
Type | Description |
---|---|
Microsoft.Xna.Framework.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 System.Single.MaxValue or System.Single.PositiveInfinity.
Note that, for this method to return a proper result, nextPos
has to be directly or diagonally adjacent to currPos
.
Declaration
public bool CanWalkBetween(Person person, Point currPos, Point nextPos)
Parameters
Type | Name | Description |
---|---|---|
Person | person | The person to get the path cost for |
Microsoft.Xna.Framework.Point | currPos | The current position |
Microsoft.Xna.Framework.Point | nextPos | The next, neighboring position |
Returns
Type | Description |
---|---|
System.Boolean | Whether the two locations can be walked between |
Draw(GameTime, SpriteBatch, Boolean, Nullable<RectangleF>, Nullable<Matrix>, RenderTarget2D, Boolean)
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.
Declaration
public void Draw(GameTime time, SpriteBatch batch, bool selectionMode, RectangleF? visibleArea = null, Matrix? visibleMatrix = null, RenderTarget2D lightmap = null, bool ignoreObjectVisibility = false)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.GameTime | time | The game's time |
Microsoft.Xna.Framework.Graphics.SpriteBatch | batch | The sprite batch to use for drawing |
System.Boolean | selectionMode | Whether we're drawing in selection mode ("ShowSelectionEffect" cheat displays this mode) |
System.Nullable<T><MLEM.Misc.RectangleF> | visibleArea | The area that is visible to the camera. If this is null, MLEM.Cameras.Camera.GetVisibleRectangle is used instead |
System.Nullable<T><Matrix> | visibleMatrix | A matrix that has a translation and scale that determines the visible area of the screenshot |
Microsoft.Xna.Framework.Graphics.RenderTarget2D | lightmap | The light map to draw lighting data onto, or null to use the default light map |
System.Boolean | ignoreObjectVisibility | Whether object visibility (Visibility) should be ignored |
Finalize()
Declaration
protected void Finalize()
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.
Declaration
public IEnumerable<(LotEmployment Employment, Lot Lot)> GetAllLotEmployments()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><System.ValueTuple<T1, T2><LotEmployment, Lot>> | All lot employments on this map |
GetClosestEmptyTile(Vector2, Int32, Boolean, Boolean, Boolean)
Returns the position of the closest tile that is empty. An empty tile is a tile that has no MapObject instances on it.
Declaration
public Point? GetClosestEmptyTile(Vector2 pos, int radius = 2, bool ignorePeople = true, bool hasToBeOnLot = false, bool sameRoom = false)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Vector2 | pos | The position to be close to |
System.Int32 | radius | The radius to search for empty tiles in |
System.Boolean | ignorePeople | Whether or not people should be ignored. If this is true, the returned empty tile might currently be occupied by a Person. |
System.Boolean | hasToBeOnLot | Whether or not the returned tile position has to be part of a Lot |
System.Boolean | sameRoom | Whether or not the returned tile position has to be in the same room as |
Returns
Type | Description |
---|---|
System.Nullable<T><Microsoft.Xna.Framework.Point> | The closest empty tile, or null if there isn't one |
GetClosestExitRoad(Vector2)
Returns the point of the road that is at the edge of the map and the MLEM.Misc.Direction2 that the map border is in, and is also closest to the given position. Since every map is expected to have at least one exit road, no checking is done to ensure that one exists.
Declaration
public (Point, Direction2) GetClosestExitRoad(Vector2 position)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Vector2 | position |
Returns
Type | Description |
---|---|
System.ValueTuple<T1, T2><Microsoft.Xna.Framework.Point, MLEM.Misc.Direction2> | The closest exit road |
GetClosestRoads(Point, Int32)
Returns all road markers around the given pos
in the given radius
, ordered by their distance to the pos
.
Declaration
public IEnumerable<Point> GetClosestRoads(Point pos, int radius)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | pos | The position to find the closest roads to |
System.Int32 | radius | The radius, in tiles, to search for roads in |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Microsoft.Xna.Framework.Point> | The closest road points |
GetClosestRoadsidePosition(Point, Vector2)
Returns the closest roadside position to the given road
position, as well as the given pos
.
Declaration
public Point? GetClosestRoadsidePosition(Point road, Vector2 pos)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | road | The road position. |
Microsoft.Xna.Framework.Vector2 | pos | The (non-road) position that the returned roadside position should be closest to. |
Returns
Type | Description |
---|---|
System.Nullable<T><Microsoft.Xna.Framework.Point> | The closest roadside position, or null if there is none around. |
GetDeadPerson(Guid)
Returns a dead Person with the given System.Guid id
Declaration
public Person GetDeadPerson(Guid id)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | The id to get a dead person by |
Returns
Type | Description |
---|---|
Person | The dead person instance, or null if there is none |
GetDepth(Vector2, Single, Boolean, Boolean, Boolean)
Declaration
public float GetDepth(Vector2 worldPos, float offset = 0F, bool center = true, bool borderOffset = false, bool applyCameraRotation = true)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Vector2 | worldPos | The position to get depth for, in tile coordinates |
System.Single | offset | An offset added to the depth value |
System.Boolean | center | Whether the position should be centered on the x axis |
System.Boolean | borderOffset | Whether the map border offset should be applied to the camera rotation using ApplyCameraRotation(Vector2, Boolean, Nullable<Direction2>). This value only has an effect if |
System.Boolean | applyCameraRotation | Whether the game's current CameraRotation should be applied using ApplyCameraRotation(Vector2, Boolean, Nullable<Direction2>) |
Returns
Type | Description |
---|---|
System.Single | 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
Declaration
public IEnumerable<(Point, Direction2)> GetExitRoads()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><System.ValueTuple<T1, T2><Microsoft.Xna.Framework.Point, MLEM.Misc.Direction2>> | All of the exit roads out of this map |
GetHousehold(Person)
Returns the household that the given Person lives in
Declaration
public Household GetHousehold(Person person)
Parameters
Type | Name | Description |
---|---|---|
Person | person | The person to query |
Returns
Type | Description |
---|---|
Household | The person's household, or null if there is none |
GetHousehold(Lot)
Returns the household that lives on the given Lot
Declaration
public Household GetHousehold(Lot lot)
Parameters
Type | Name | Description |
---|---|---|
Lot | lot | The lot to query |
Returns
Type | Description |
---|---|
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
Declaration
public IEnumerable<Household> GetHouseholds()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><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.
Declaration
public Lot GetLot(Point pos)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | pos | The position to query |
Returns
Type | Description |
---|---|
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.
Declaration
public Lot GetLot(Guid id)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | The id that the lot should have |
Returns
Type | Description |
---|---|
Lot | The lot with the given id |
GetLots()
Returns a set of all of the Lot objects on this map
Declaration
public IEnumerable<Lot> GetLots()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Lot> | This map's lots |
GetMapSampler()
Declaration
public static SamplerState GetMapSampler()
Returns
Type | Description |
---|---|
Microsoft.Xna.Framework.Graphics.SamplerState |
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.
Declaration
public T GetObject<T>(Guid id)
where T : MapObject
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | The id that the returned object should have |
Returns
Type | Description |
---|---|
T | The object, or null if there is no matching one |
Type Parameters
Name | Description |
---|---|
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.
Declaration
public IEnumerable<T> GetObjects<T>(RectangleF area)
where T : MapObject
Parameters
Type | Name | Description |
---|---|---|
MLEM.Misc.RectangleF | area | The area, in tile coordinates |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><T> | A set of objects that match the criteria |
Type Parameters
Name | Description |
---|---|
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
.
Declaration
public float GetPathCost(Person person, Point currPos, Point nextPos)
Parameters
Type | Name | Description |
---|---|---|
Person | person | The person to get the path cost for |
Microsoft.Xna.Framework.Point | currPos | The current position |
Microsoft.Xna.Framework.Point | nextPos | The next, neighboring position |
Returns
Type | Description |
---|---|
System.Single | 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.
Declaration
public IEnumerable<Person> GetPeople()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Person> | This map's people |
GetRandomTile(Random, Vector2, Int32, Boolean, Boolean, Predicate<Point>)
Returns a random tile in the given radius that matches the given predicate. If no tile is found, an empty System.Nullable<T> is returned.
Declaration
public Point? GetRandomTile(Random random, Vector2 pos, int radius = 32, bool hasToBeOnLot = false, bool sameRoom = false, Predicate<Point> valid = null)
Parameters
Type | Name | Description |
---|---|---|
System.Random | random | The random to use |
Microsoft.Xna.Framework.Vector2 | pos | The position that the radius should be centered on |
System.Int32 | radius | The radius |
System.Boolean | hasToBeOnLot | Whether the position returned has to be on a lot |
System.Boolean | sameRoom | Whether the position returned has to be in the same room as the |
System.Predicate<T><Microsoft.Xna.Framework.Point> | valid | A predicate that determines whether tile should be included |
Returns
Type | Description |
---|---|
System.Nullable<T><Microsoft.Xna.Framework.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.
Declaration
public IEnumerable<Person> GetRegularVisitors()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Person> | This map's regular visitors |
GetRoads()
Returns a set of all of the road markers on this map
Declaration
public IEnumerable<Point> GetRoads()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Microsoft.Xna.Framework.Point> | A set of all road markers on this map |
GetRoof(Point)
Gets a Roof whose area contains the given position
Declaration
public Roof GetRoof(Point pos)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | pos | The position to find a roof at |
Returns
Type | Description |
---|---|
Roof | The roof at that position, or null if there is none |
GetRoofs(RectangleF)
Returns the roofs that intersect the given area
.
Declaration
public IEnumerable<Roof> GetRoofs(RectangleF area)
Parameters
Type | Name | Description |
---|---|---|
MLEM.Misc.RectangleF | area | The area to search for roofs in. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Roof> | The roofs in the given area. |
GetRoom(Point)
Returns the room that the given position is contained in
Declaration
public Room GetRoom(Point pos)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | pos | The position to query |
Returns
Type | Description |
---|---|
Room | The room at that location, or null if there is none |
GetSection(Point)
Returns the MapSection at the given tile position
Declaration
public MapSection GetSection(Point pos)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | pos | The tile position |
Returns
Type | Description |
---|---|
MapSection | The section at that position |
GetSections(Point, Int32)
Returns a set of sections that are contained in (or intersect with) the given area
Declaration
public IEnumerable<MapSection> GetSections(Point point, int radiusIncrease)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | point | The position to find the section for, in tile coordinates |
System.Int32 | radiusIncrease | The radius, in sections, that the search area should be extended by |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><MapSection> | A set of sections covered by this area |
GetSections(RectangleF, Int32)
Returns a set of sections that are contained in (or intersect with) the given area
Declaration
public IEnumerable<MapSection> GetSections(RectangleF area, int radiusIncrease)
Parameters
Type | Name | Description |
---|---|---|
MLEM.Misc.RectangleF | area | The area to find sections in, in tile coordinates |
System.Int32 | radiusIncrease | The radius, in sections, that the search area should be extended by |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><MapSection> | A set of sections covered by this area |
GetTile(Point)
Returns the tile at the given position on this map
Declaration
public Tile GetTile(Point pos)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | pos | The position to query |
Returns
Type | Description |
---|---|
Tile | The tile at that position |
GetTilesAround(Vector2, Int32, Boolean, Boolean, Predicate<Point>)
Returns a set of tiles around the given position that match the given conditions
Declaration
public IEnumerable<Point> GetTilesAround(Vector2 pos, int radius, bool hasToBeOnLot = false, bool sameRoom = false, Predicate<Point> valid = null)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Vector2 | pos | The position |
System.Int32 | radius | The radius, in tiles |
System.Boolean | hasToBeOnLot | Whether the returned positions have to be on a lot |
System.Boolean | sameRoom | Whether the returned positions have to be in the same room as the |
System.Predicate<T><Microsoft.Xna.Framework.Point> | valid | A function that determines whether a position should be returned. If this is null, all valid positions are returned. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><Microsoft.Xna.Framework.Point> | A set of positions that match the given conditions |
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.
Declaration
public Wall GetWallBetween(Point pos, Point secondPos)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | pos | The first position |
Microsoft.Xna.Framework.Point | secondPos | The second position |
Returns
Type | Description |
---|---|
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.
Declaration
public IEnumerable<Wall> GetWalls(RectangleF area)
Parameters
Type | Name | Description |
---|---|---|
MLEM.Misc.RectangleF | area | The area to query for walls |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><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
Declaration
public bool IsFreeSpot(Point pos)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | pos | The position to query |
Returns
Type | Description |
---|---|
System.Boolean | Whether this position is free to stand on |
IsInBounds(Point)
Returns whether the given position is in bounds of this map's Size
Declaration
public bool IsInBounds(Point pos)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | pos | The position to query |
Returns
Type | Description |
---|---|
System.Boolean | 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.
Declaration
public static bool IsLotHidden(Lot lot)
Parameters
Type | Name | Description |
---|---|---|
Lot | lot |
Returns
Type | Description |
---|---|
System.Boolean |
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).
Declaration
public bool IsRoad(Point pos)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | pos |
Returns
Type | Description |
---|---|
System.Boolean |
LoadStaticMap(String, Boolean, Action<String>, Action<Single>, Boolean)
Loads a static map with the given name from the game's content directory. Note that the map is not validated (Validate(Action<String>, Action<Single>, Boolean)).
Declaration
public static Map LoadStaticMap(string name, bool custom, Action<string> setState, Action<float> setProgress, bool validateThoroughly)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the static map to load. |
System.Boolean | custom | Whether the map is in the custom maps directory (or a default map). |
System.Action<T><System.String> | setState | An action that accepts the current state of the loading process. |
System.Action<T><System.Single> | setProgress | An action that accepts the progress of the current state of the loading process. |
System.Boolean | validateThoroughly | Whether the map should be validated thoroughly, which needs to be done if it will be played on. |
Returns
Type | Description |
---|---|
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.
Declaration
public void MarkDirtyForPathfinding(Point pos)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | pos | The position to mark dirty |
MarkObjectDirtyForDrawing(MapObject, MapSection, Boolean)
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.
Declaration
public void MarkObjectDirtyForDrawing(MapObject obj, MapSection section = null, bool removedFromSection = false)
Parameters
Type | Name | Description |
---|---|---|
MapObject | obj | The object to mark dirty. |
MapSection | section | The section that the object is expected to be in, or null to determine the section automatically. |
System.Boolean | removedFromSection | Whether the object was removed, and should not be redrawn in the |
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 GrassyAutoTile.
Declaration
public void MarkTileDirtyForDrawing(Point pos)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | pos | The position to mark dirty. |
MoveEverything(Point, Rectangle, Boolean, Tile)
Moves all of the objects, walls, tiles and roofs in the given area
in the world, optionally moving the lots as well
Declaration
public void MoveEverything(Point offset, Rectangle area, bool moveLots, Tile defaultTile = null)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | offset | The offset to move things by |
Microsoft.Xna.Framework.Rectangle | area | The area to move |
System.Boolean | moveLots | Whether lots should be moved as well. The content of lots will be moved regardless of this parameter |
Tile | defaultTile | 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.
Declaration
public void OnCameraRotationChanged(Direction2 oldRotation, Direction2 newRotation)
Parameters
Type | Name | Description |
---|---|---|
MLEM.Misc.Direction2 | oldRotation | |
MLEM.Misc.Direction2 | newRotation |
PlaySound(SoundEffect, Vector2, Single, Single, Boolean, Boolean)
Plays a sound at the given location (in world space) statically. If the sound should move while being played, use PlaySound(SoundEffect, MapAudioEmitter, Single, Single, Boolean, Boolean) instead. Note that the returned Microsoft.Xna.Framework.Audio.SoundEffectInstance does not need to be disposed when it is finished playing.
Declaration
public SoundEffectInstance PlaySound(SoundEffect sound, Vector2 pos, float volume = 1F, float pitch = 0F, bool loop = false, bool applyWorldSoundVolume = true)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Audio.SoundEffect | sound | The sound effect to play |
Microsoft.Xna.Framework.Vector2 | pos | The position, in world space, to play the sound at |
System.Single | volume | The sound's volume, between 0 and 1 (default) |
System.Single | pitch | The sound's pitch, between -1, 0 (default) and 1 |
System.Boolean | loop | Whether or not the sound should loop |
System.Boolean | applyWorldSoundVolume | Whether the WorldSoundVolume should be applied to the passed |
Returns
Type | Description |
---|---|
Microsoft.Xna.Framework.Audio.SoundEffectInstance | The sound effect instance that is responsible for playing this sound, which can be stopped or paused |
PlaySound(SoundEffect, MapAudioEmitter, Single, Single, Boolean, Boolean)
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, Single, Single, Boolean, Boolean) instead. Note that the returned Microsoft.Xna.Framework.Audio.SoundEffectInstance does not need to be disposed when it is finished playing.
Declaration
public SoundEffectInstance PlaySound(SoundEffect sound, MapAudioEmitter emitter, float volume = 1F, float pitch = 0F, bool loop = false, bool applyWorldSoundVolume = true)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Audio.SoundEffect | sound | The sound effect to play |
MapAudioEmitter | emitter | The audio emitter, whose WorldPosition should be set by the caller |
System.Single | volume | The sound's volume, between 0 and 1 (default) |
System.Single | pitch | The sound's pitch, between -1, 0 (default) and 1 |
System.Boolean | loop | Whether or not the sound should loop |
System.Boolean | applyWorldSoundVolume | Whether the WorldSoundVolume should be applied to the passed |
Returns
Type | Description |
---|---|
Microsoft.Xna.Framework.Audio.SoundEffectInstance | The sound effect instance that is responsible for playing this sound, which can be stopped or paused |
RemoveHousehold(Household)
Removes the given household from this map
Declaration
public void RemoveHousehold(Household household)
Parameters
Type | Name | Description |
---|---|---|
Household | household | The household to remove |
RemoveLight(Light)
Removes the given light from the world
Declaration
public void RemoveLight(Light light)
Parameters
Type | Name | Description |
---|---|---|
Light | light | The light to remove |
RemoveLot(Lot)
Removes the given lot from this map's lots
Declaration
public void RemoveLot(Lot lot)
Parameters
Type | Name | Description |
---|---|---|
Lot | lot | The lot to remove |
RemoveObject(MapObject)
Removes the given object from this map and its underlying MapSection. This also calls OnRemoved().
Declaration
public void RemoveObject(MapObject obj)
Parameters
Type | Name | Description |
---|---|---|
MapObject | obj | The object to remove |
Remarks
When removing a Furniture object from the world entirely, including when putting it into furniture storage or someone's hand, RemoveAndUnlink() should be used instead, or UnlinkParentsAndChildren() should be called in addition to this method. If the furniture item is a child of another furniture item, RemoveChild(Furniture) can also be used instead. 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
Declaration
public void RemoveRoof(Roof roof)
Parameters
Type | Name | Description |
---|---|---|
Roof | roof | The roof to remove |
RemoveWall(Wall)
Removes the given wall from the map
Declaration
public bool RemoveWall(Wall wall)
Parameters
Type | Name | Description |
---|---|---|
Wall | wall | The wall to remove |
Returns
Type | Description |
---|---|
System.Boolean | 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
Declaration
public void SetTile(Point pos, Tile tile)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point | pos | The position |
Tile | tile | The tile |
Update(GameTime, TimeSpan, Single)
Updates this map, its MapSection objects and its Households.
Declaration
public void Update(GameTime time, TimeSpan passedInGame, float speedMultiplier)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.GameTime | time | The game's time |
System.TimeSpan | passedInGame | The amount of time that has passed in game |
System.Single | speedMultiplier | The game speed multiplier, which represents how fast things should happen, which is usually determined by Speed |
UpdateExternalPeople(Action<Single>)
Updates this map's 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 variouos locations.
Declaration
public void UpdateExternalPeople(Action<float> setProgress = null)
Parameters
Type | Name | Description |
---|---|---|
System.Action<T><System.Single> | setProgress |
Validate(Action<String>, Action<Single>, Boolean)
This method is called when this object is loaded from disk. When called on a map, each MapSection is validated, and roads and rooms are generated.
Declaration
public void Validate(Action<string> setState, Action<float> setProgress, bool thorough = true)
Parameters
Type | Name | Description |
---|---|---|
System.Action<T><System.String> | setState | An action that accepts the current state of the loading process. |
System.Action<T><System.Single> | setProgress | An action that accepts the progress of the current state of the loading process. |
System.Boolean | thorough | Whether the map should be validated thoroughly, which needs to be done if it will be played on. |
ValidateExistingRooms(Point[])
Removes all outdated rooms on this map after calling their Validate() methods.
Declaration
public void ValidateExistingRooms(params Point[] positions)
Parameters
Type | Name | Description |
---|---|---|
Microsoft.Xna.Framework.Point[] | positions | The positions around which to validate rooms |
Events
OnObjectAdded
An event that is invoked when a MapObject is added to this map using AddObject(MapObject)
Declaration
public event Action<MapObject> OnObjectAdded
Event Type
Type | Description |
---|---|
System.Action<T><MapObject> |
OnObjectRemoved
An event that is invoked when a MapObject is removed from this map using RemoveObject(MapObject)
Declaration
public event Action<MapObject> OnObjectRemoved
Event Type
Type | Description |
---|---|
System.Action<T><MapObject> |
OnUpdate
An event that is invoked when this map is updated in Update(GameTime, TimeSpan, Single)
Declaration
public event UpdateDelegate OnUpdate
Event Type
Type | Description |
---|---|
UpdateDelegate |