Loading...
Searching...
No Matches
CityBuilderCore.IStructureManager Interface Reference

Detailed Description

tracks all the IStructures on the map
used to check and retrieve structures at any point on the map

Inheritance diagram for CityBuilderCore.IStructureManager:
CityBuilderCore.ISaveData CityBuilderCore.DefaultStructureManager

Public Member Functions

IEnumerable< IStructureGetStructures (int mask)
 retrieves all the structures on the map that have any of the levels in the mask
 
IEnumerable< IStructureGetStructures (Vector2Int point, int mask=0, bool? isWalkable=null, bool? isUnderlying=null, bool? isDecorator=null)
 retrieves all the structures at a point on the map that fit some criteria
 
IStructure GetStructure (string key)
 retrieves a structure by its unique key
 
int Remove (IEnumerable< Vector2Int > points, int mask, bool decoratorsOnly, Action< IStructure > removing=null)
 removes points from any structure that occupies that point
for some structures that will remove the entire thing(buildings)
 
void RegisterStructure (IStructure structure, bool isUnderlying=false)
 adds a structure into the managers care, others will now be able to retrieve it from the manager
structures on the map should always be registered with the manager,
 
void DeregisterStructure (IStructure structure, bool isUnderlying=false)
 removes a previously registered structure from the manager
 
- Public Member Functions inherited from CityBuilderCore.ISaveData
string SaveData ()
 serializes the objects state(usually to json) and returns it
 
void LoadData (string json)
 deserializes the serialized json data and loads the data as its new state
 

Events

Action Changed
 fired whenever the points occupied by structures change
 

Member Function Documentation

◆ DeregisterStructure()

void CityBuilderCore.IStructureManager.DeregisterStructure ( IStructure structure,
bool isUnderlying = false )

removes a previously registered structure from the manager

Parameters
structurethe structure that will be added to the manager
isUnderlyingshould be the same as when RegisterStructure(IStructure, bool) was called

Implemented in CityBuilderCore.DefaultStructureManager.

◆ GetStructure()

IStructure CityBuilderCore.IStructureManager.GetStructure ( string key)

retrieves a structure by its unique key

Parameters
keykey of the structure, often set in the inspector
Returns
the structure if any was found

Implemented in CityBuilderCore.DefaultStructureManager.

◆ GetStructures() [1/2]

IEnumerable< IStructure > CityBuilderCore.IStructureManager.GetStructures ( int mask)

retrieves all the structures on the map that have any of the levels in the mask

Parameters
maskthe structure level to check, 0 for all
Returns
all the structures on the map that collide with the mask

Implemented in CityBuilderCore.DefaultStructureManager.

◆ GetStructures() [2/2]

IEnumerable< IStructure > CityBuilderCore.IStructureManager.GetStructures ( Vector2Int point,
int mask = 0,
bool? isWalkable = null,
bool? isUnderlying = null,
bool? isDecorator = null )

retrieves all the structures at a point on the map that fit some criteria

Parameters
pointa point on the map
maskstructure level to check, o for all
isWalkableif you only want to check for structures that are walkable or non walkable
isUnderlyingwhether to check for underlying structures
isDecoratorif you only want to check for decorators or non decorators
Returns

Implemented in CityBuilderCore.DefaultStructureManager.

◆ RegisterStructure()

void CityBuilderCore.IStructureManager.RegisterStructure ( IStructure structure,
bool isUnderlying = false )

adds a structure into the managers care, others will now be able to retrieve it from the manager
structures on the map should always be registered with the manager,

Parameters
structurethe structure that will be added to the manager
isUnderlyingwhether the structure shold be stored in a special collection instead of a point dictionary, recommended for structures with low number but many points like road networks

Implemented in CityBuilderCore.DefaultStructureManager.

◆ Remove()

int CityBuilderCore.IStructureManager.Remove ( IEnumerable< Vector2Int > points,
int mask,
bool decoratorsOnly,
Action< IStructure > removing = null )

removes points from any structure that occupies that point
for some structures that will remove the entire thing(buildings)

Parameters
pointsthe points on the map from which to remove structures
maskstructure levels to remove, 0 for all
decoratorsOnlywhether to only remove decorators, for example when building on top of them
removingaction invoked for any structure that will have points removed, can be used to create dust or place demolishing animations instead of the structure
Returns
how many structures were affected

Implemented in CityBuilderCore.DefaultStructureManager.