straightforward IStructureManager implementation
holds collections, decorators and tiles in seperate lists similar to underlying structures
https://citybuilder.softleitner.com/manual/structures
|
IEnumerable< IStructure > | GetStructures (int mask) |
| retrieves all the structures on the map that have any of the levels in the mask
|
|
IEnumerable< IStructure > | GetStructures (Vector2Int point, int mask, 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
|
|
StructureCollection | GetStructureCollection (string key) |
|
StructureDecorators | GetStructureDecorators (string key) |
|
StructureTiles | GetStructureTiles (string 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
|
|
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
|
|
|
const int | LEVEL_COUNT = 8 |
|
|
virtual void | Awake () |
|
virtual void | Start () |
|
virtual void | Update () |
|
virtual void | OnDestroy () |
|
|
Action | Changed |
|
Action | Changed |
| fired whenever the points occupied by structures change
|
|
◆ DeregisterStructure()
void CityBuilderCore.DefaultStructureManager.DeregisterStructure |
( |
IStructure | structure, |
|
|
bool | isUnderlying = false ) |
|
inline |
◆ GetStructure()
IStructure CityBuilderCore.DefaultStructureManager.GetStructure |
( |
string | key | ) |
|
|
inline |
retrieves a structure by its unique key
- Parameters
-
key | key of the structure, often set in the inspector |
- Returns
- the structure if any was found
Implements CityBuilderCore.IStructureManager.
◆ GetStructures() [1/2]
IEnumerable< IStructure > CityBuilderCore.DefaultStructureManager.GetStructures |
( |
int | mask | ) |
|
|
inline |
retrieves all the structures on the map that have any of the levels in the mask
- Parameters
-
mask | the structure level to check, 0 for all |
- Returns
- all the structures on the map that collide with the mask
Implements CityBuilderCore.IStructureManager.
◆ GetStructures() [2/2]
IEnumerable< IStructure > CityBuilderCore.DefaultStructureManager.GetStructures |
( |
Vector2Int | point, |
|
|
int | mask, |
|
|
bool? | isWalkable = null, |
|
|
bool? | isUnderlying = null, |
|
|
bool? | isDecorator = null ) |
|
inline |
retrieves all the structures at a point on the map that fit some criteria
- Parameters
-
point | a point on the map |
mask | structure level to check, o for all |
isWalkable | if you only want to check for structures that are walkable or non walkable |
isUnderlying | whether to check for underlying structures |
isDecorator | if you only want to check for decorators or non decorators |
- Returns
Implements CityBuilderCore.IStructureManager.
◆ LoadData()
void CityBuilderCore.DefaultStructureManager.LoadData |
( |
string | json | ) |
|
|
inline |
◆ RegisterStructure()
void CityBuilderCore.DefaultStructureManager.RegisterStructure |
( |
IStructure | structure, |
|
|
bool | isUnderlying = false ) |
|
inline |
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
-
structure | the structure that will be added to the manager |
isUnderlying | whether 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 |
Implements CityBuilderCore.IStructureManager.
◆ Remove()
int CityBuilderCore.DefaultStructureManager.Remove |
( |
IEnumerable< Vector2Int > | points, |
|
|
int | mask, |
|
|
bool | decoratorsOnly, |
|
|
Action< IStructure > | removing = null ) |
|
inline |
removes points from any structure that occupies that point
for some structures that will remove the entire thing(buildings)
- Parameters
-
points | the points on the map from which to remove structures |
mask | structure levels to remove, 0 for all |
decoratorsOnly | whether to only remove decorators, for example when building on top of them |
removing | action 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
Implements CityBuilderCore.IStructureManager.
◆ SaveData()
string CityBuilderCore.DefaultStructureManager.SaveData |
( |
| ) |
|
|
inline |
serializes the objects state(usually to json) and returns it
- Returns
- serialized save data
Implements CityBuilderCore.ISaveData.