TinyLifeExampleMod/Api/TinyLife/World/Map.md

13 KiB

Map

Namespace: TinyLife > World

Assembly: Tiny Life.dll

Implements IGenericDataHolder

Summary

A map holds all of the data about a city, like its tiles, its objects and its roads. A map is split into TinyLife.World.MapSection objects which allows faster retrieval of objects in an area.

Constructors

Name Summary
Map ( String, Point ) Creates a new map with the given name and size

Fields

Type Name Summary
String Name The name of this map

Properties

Type Name Summary
Point Size The size in tiles that this map has. This is always TinyLife.World.Map.SizeInSections multiplied by TinyLife.World.MapSection.Size.
Point SizeInSections The size, in sections (not tiles) that this map has
Int32 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.

Methods

Return Name Summary
Household AddHousehold ( Lot, Person[] ) Adds a new household to this map by calling the TinyLife.World.Household constructor.
Lot AddLot ( Rectangle ) Adds a new lot with the given area to this map's lots
void AddObject ( MapObject ) Adds the given object to this map. Note that, if the object's TinyLife.Objects.MapObject.Id is already present on this map, this method will cause an exception.
void 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.
void AddRoof ( Roof ) Adds the given roof to this map
Boolean AddWall ( Point, Point ) Adds the given wall to the given position.
Boolean AddWall ( Wall, Boolean ) Adds the given wall to the given position. Optionally, the TinyLife.World.Room related to that wall is re-calculated.
void Draw ( GameTime, SpriteBatch, 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.
Nullable<Point> 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 TinyLife.Objects.MapObject instances on it.
Point GetClosestRoad ( Point, Int32 ) Returns the clost road marker to the given position, keeping the given radius in mind.
Point GetClosestSidewalk ( Point, Vector2 ) Returns the closest sidewalk position to the given road position. A sidewalk is a tile whose name starts with "Concrete" that is TinyLife.World.Map.RoadRadius+1 tiles away from the road marker. Note that the road position must have TinyLife.World.Map.IsRoad(Microsoft.Xna.Framework.Point) return true for it.
Person GetDeadPerson ( Guid ) Returns a dead TinyLife.Objects.Person with the given System.Guid id
Single GetDepth ( Vector2, Single, Boolean ) Gets the depth that should be used for drawing an object at the given tile position
Household GetHousehold ( Person ) Returns the household that the given TinyLife.Objects.Person lives in
Household GetHousehold ( Lot ) Returns the household that lives on the given TinyLife.World.Lot
IEnumerable<Household> GetHouseholds ( ) Returns a set of all of the TinyLife.World.Household instances that live on this map
Lot GetLot ( Guid ) Returns the lot with the given id on this map. The returned lot's TinyLife.World.Lot.Id will equal the given id.
Lot GetLot ( Point ) Returns the lot that is present at the given position. The lot returned will always have its TinyLife.World.Lot.Area contain the passed position.
IEnumerable<Lot> GetLots ( ) Returns a set of all of the TinyLife.World.Lot objects on this map
T GetObject ( 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.
IEnumerable<T> GetObjects ( RectangleF ) Returns a set of objects that are present in the given area.
Single GetPathCost ( 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, has to be directly or diagonally adjacent to.
IEnumerable<Person> GetPeople ( ) Returns all of the TinyLife.Objects.Person objects that are on this map
IEnumerable<Point> GetRoads ( ) Returns a set of all of the road markers on this map
Roof GetRoof ( Point ) Gets a TinyLife.World.Roof whose area contains the given position
Room GetRoom ( Point ) Returns the room that the given position is contained in
MapSection GetSection ( Point ) Returns the TinyLife.World.MapSection at the given tile position
IEnumerable<MapSection> GetSections ( Point, Int32 ) Returns a set of sections that are contained in (or intersect with) the given area
IEnumerable<MapSection> GetSections ( RectangleF, Int32 ) Returns a set of sections that are contained in (or intersect with) the given area
Tile GetTile ( Point ) Returns the tile at the given position on this map
Wall GetWallBetween ( Point, Point ) Returns the wall between the and. A wall is between two positions if its TinyLife.World.Wall.Positions are exactly those two positions, ignoring their order.
Boolean IsFreeSpot ( Point ) Returns whether or not the given position on the given map is free for a TinyLife.Objects.Person to stand in
Boolean IsInBounds ( Point ) Returns whether the given position is in bounds of this map's TinyLife.World.Map.Size
Boolean IsInSectionBounds ( Point ) Returns whether the given section position is in bounds of this map's TinyLife.World.Map.SizeInSections.
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 TinyLife.World.Map.AddRoad(Microsoft.Xna.Framework.Point).
void MarkDirtyForPathfinding ( Point ) Marks the given position dirty for pathfinding purposes. When a path is found again close to this position, its cost (TinyLife.World.Map.GetPathCost(Microsoft.Xna.Framework.Point,Microsoft.Xna.Framework.Point)) will be re-calculated. This method is called by TinyLife.Objects.Furniture when it is placed for removed.
SoundEffectInstance PlaySound ( SoundEffect, Vector2, Single, Single, Boolean ) Plays a sound at the given location (in world space) statically. If the sound should move while being played, use TinyLife.World.Map.PlaySound(Microsoft.Xna.Framework.Audio.SoundEffect,Microsoft.Xna.Framework.Audio.AudioEmitter,System.Single,System.Single,System.Boolean) instead. Note that the returned Microsoft.Xna.Framework.Audio.SoundEffectInstance does not need to be disposed when it is finished playing.
SoundEffectInstance PlaySound ( SoundEffect, AudioEmitter, Single, Single, Boolean ) Plays a sound at the given location (in world space) with the given Microsoft.Xna.Framework.Audio.AudioEmitter, whose Microsoft.Xna.Framework.Audio.AudioEmitter.Position can be updated by the caller (in screen space). If the sound should move in a static locatdion, use TinyLife.World.Map.PlaySound(Microsoft.Xna.Framework.Audio.SoundEffect,Microsoft.Xna.Framework.Vector2,System.Single,System.Single,System.Boolean) instead. Note that the returned Microsoft.Xna.Framework.Audio.SoundEffectInstance does not need to be disposed when it is finished playing.
void RemoveHousehold ( Household ) Removes the given household from this map
void RemoveLot ( Lot ) Removes the given lot from this map's lots
void RemoveObject ( MapObject ) Removes the given object from this map and its underlying TinyLife.World.MapSection. This also calls TinyLife.Objects.MapObject.OnRemoved.
void RemoveRoof ( Roof ) Removes the given TinyLife.World.Roof from this map
Boolean RemoveWall ( Wall ) Removes the given wall from the map
void SetTile ( Point, Tile ) Sets the tile at the given position to the given tile
void Update ( GameTime, TimeSpan, GameSpeed ) Updates this map, its TinyLife.World.MapSection objects and its TinyLife.World.Households.
void Validate ( ) This method is called when this object is loaded from disk. When called on a map, each TinyLife.World.MapSection is validated, and roads and rooms are generated.

Static Fields

Type Name Summary
Int32 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.

Static Methods

Return Name Summary
Map LoadStaticMap ( String ) Loads a static map with the given name from the game's content directory. Note that the map is not validated (TinyLife.World.Map.Validate).