![]() |
TilePlus Version 5
Unity3D Tilemap Extension
|
TpZoneManager is used to manage square areas of tilemaps called Zones. More...


Public Member Functions | |
| void | ResetInstance (bool resetEvents=true) |
| Reset all registrations, reset registrationIndex. | |
| bool | AddRegistration (ZoneReg reg, AssetGuidPositionHash hash) |
| Add a registration. Only use if you're not using AddZone and creating your own ZoneRegs. | |
| bool | HasZone (ZoneReg reg) |
| Is there a registration for this ZoneReg? | |
| bool | UnloadZones (List< ZoneReg > regs, bool destroyTiles=true, bool destroyPrefabs=true) |
| Unload a list of Zones. | |
| async Awaitable< bool > | UnloadZonesAsync (List< ZoneReg > regs, bool destroyTiles=true, bool destroyPrefabs=true) |
| Unload a list of Zones, Async Does one reg per frame. | |
| bool | UnloadAllZones () |
| Unload ALL zones, including all parented prefabs. | |
| bool | UnloadZone (ZoneReg? reg, bool destroyTiles=true, bool destroyPrefabs=true) |
| Unload a chunk. | |
| void | Initialize (int size, Vector3Int? origin=null, int initialMaxNumChunks=64) |
| Required if you want to use chunking. No chunking data is accumulated and chunking will not work if this isn't used. Note that you should use this again for every new scene. WIPES OUT ANY EXISTING TILEFAB REGISTRATION DATA WHEN USED!! | |
| List< ZoneReg > | GetZoneRegsForRegion (RectInt? locator) |
| Get the ZoneRegs for a Zone locator RectInt. | |
| bool | FindRegionalZoneRegs (RectInt? locator, ref HashSet< RectInt > inside, ref List< ZoneReg > outside) |
| Obtain two datasets: one is a List of ZoneRegs that are outside of an area and another is a HashSet of ZoneRegs that are inside the area. | |
| List< ZoneReg > | GetZoneRegsForGridPosition (Vector3Int gridPosition, Vector2Int? dimensions=null, bool align=true) |
| Get the ZoneRegs for a chunk located at a Grid position. | |
| List< ZoneReg > | GetZoneRegsForWorldPosition (Vector3 worldPosition, Tilemap? map, Vector2Int? dimensions=null, bool align=true) |
| Get the Zone registration for a chunk located at a World position. | |
| RectInt | GetLocatorForGridPosition (Vector3Int gridPosition, Vector2Int ?dimensions=null, bool align=true) |
| Create an Zone registration locator from a grid position. | |
| RectInt | GetLocatorForWorldPosition (Vector3 position, Tilemap? map, Vector2Int? dimensions=null, bool align=true) |
| Create an Zone registration locator from a world position. | |
| bool | HasZoneRegForLocator (RectInt locator) |
| Is there a Zone registration associated with a RectInt locator? | |
| bool | GetZoneRegForLocator (RectInt locator, out ZoneReg? reg) |
| Get a Zone Reg for a locator RectInt. | |
| RectInt | GetLocatorForSgridPosition (Vector2Int sGridPosition, Vector2Int? dimensions=null) |
| Convert a super-grid position to a locator. | |
| Vector3Int | GetGridPositionForSgridPosition (Vector2Int sGridPosition) |
| Get a Tilemap grid position from a sGrid position. | |
| string | GetZoneRegJson (bool prettyPrint=true) |
| Get a JSON version of the Zone registrations. | |
| List< TilefabLoadResults >? | RestoreFromZoneRegJson (string jsonString, Dictionary< string, Tilemap >? targetMap=null, Func< FabOrBundleFilterType, BoundsInt, object, bool >? filter=null, bool filterOnlyTilePlusTiles=true) |
| Restore all Tilefabs or Bundles based on a json-archived dataset. | |
| bool | DeleteZoneRegistration (ZoneReg reg) |
| Remove an Zone registration given an instance of one. | |
| IEnumerable< ZoneReg > | GetLastRegistrations (int numResults=1) |
| Get the last N Zone registrations. | |
| ZoneReg? | GetLastRegistration () |
| Get the very last Zone Reg. Handy when you know there is only one. | |
| IEnumerable< ZoneReg > | GetAllZoneRegistrationsFiltered (bool orderByIndex=false, Func< ZoneReg, bool >? filter=null) |
| Get all zone registrations with optional filtering and ordering. | |
| bool | IsAlignedToGrid (Vector3Int position) |
| Is this grid position aligned to the super-grid? | |
| Vector3Int | AlignToGrid (Vector3Int position) |
| Align a position to the super-grid. Note: positions are aligned to the lower-left corner of a rectint. | |
Properties | |
| IEnumerable< ZoneReg > | GetAllZoneRegistrations [get] |
| Get the all loading results. | |
| bool | ChunkingConfigured [get] |
| Is chunking configured? | |
| int | ChunkSize [get] |
| Size of a chunk as set during initialization. | |
| int | NumChunksInUse [get] |
| The number of chunks in the chunkmap. | |
| Dictionary< string, Tilemap >.ValueCollection | MonitoredTilemaps [get] |
| Get a collection of the MonitoredTilemaps dictionary values: Tilemap instances. These are the only ones that clients of this instance should be using. | |
| Dictionary< string, Tilemap > | MonitoredTilemapDict [get] |
| Access to the Monitored Tilemaps for this instance. DO NOT ALTER THIS DICTIONARY. DON'T SAVE A REFERENCE. | |
| RectInt | DefaultLocator [get] |
| Get the default locator. This is the value used when you don't specify a dimensions value when GetZoneReg or GetLocator with dimensions = null. | |
| Vector2Int | WorldOrigin [get] |
| Get the ChunkMapAnchorPosition. This is the base or startingPosition from where all Chunks begin. You can find the center of a chunk by adding multiples of ChunkMapAnchorSize to ChunkMapAnchorPosition. | |
| string | InstanceName [get] |
| The name of this instance. Read only. | |
| TpZoneLayout? | ZoneLayoutComponent [get, set] |
| A ref to the ZoneLayout, if used with chunking system. Null otherwise. | |
Events | |
| Action< ZoneReg, TpZoneManager >? | OnZoneRegAdded |
| Notify me when a Zone Reg is added. | |
| Action< ZoneReg, TpZoneManager >? | OnZoneRegDeleted |
| Notify me when a Zone Reg is deleted. | |
| Action< Tilemap, List< TilePlusBase > >? | OnTptTilesWillBeDeleted |
| Notify me that a list of TPT tiles will be deleted. | |
TpZoneManager is used to manage square areas of tilemaps called Zones.
| bool TilePlus.TpZoneManager.AddRegistration | ( | ZoneReg | reg, |
| AssetGuidPositionHash | hash ) |
Add a registration. Only use if you're not using AddZone and creating your own ZoneRegs.
| reg | The ZoneReg |
| hash | An AssetGuidPositionHash instance |
| Vector3Int TilePlus.TpZoneManager.AlignToGrid | ( | Vector3Int | position | ) |
Align a position to the super-grid. Note: positions are aligned to the lower-left corner of a rectint.
| position | position to adjust |
| bool TilePlus.TpZoneManager.DeleteZoneRegistration | ( | ZoneReg | reg | ) |
Remove an Zone registration given an instance of one.
| reg | ZoneReg instance |
| bool TilePlus.TpZoneManager.FindRegionalZoneRegs | ( | RectInt? | locator, |
| ref HashSet< RectInt > | inside, | ||
| ref List< ZoneReg > | outside ) |
Obtain two datasets: one is a List of ZoneRegs that are outside of an area and another is a HashSet of ZoneRegs that are inside the area.
| locator | the RectInt Locator describing the area. |
| inside | ref HashSet for inside |
| outside | ref List for outside |
| IEnumerable< ZoneReg > TilePlus.TpZoneManager.GetAllZoneRegistrationsFiltered | ( | bool | orderByIndex = false, |
| Func< ZoneReg, bool >? | filter = null ) |
Get all zone registrations with optional filtering and ordering.
| orderByIndex | order by ZoneReg index if true |
| filter | Func of ZoneReg returning bool. If ret val true then zm returned else it is skipped. |
| Vector3Int TilePlus.TpZoneManager.GetGridPositionForSgridPosition | ( | Vector2Int | sGridPosition | ) |
Get a Tilemap grid position from a sGrid position.
| sGridPosition | a sGrid position |
| ZoneReg? TilePlus.TpZoneManager.GetLastRegistration | ( | ) |
Get the very last Zone Reg. Handy when you know there is only one.
| IEnumerable< ZoneReg > TilePlus.TpZoneManager.GetLastRegistrations | ( | int | numResults = 1 | ) |
Get the last N Zone registrations.
| numResults | # of results desired. For a tilefab that should be 1 |
| RectInt TilePlus.TpZoneManager.GetLocatorForGridPosition | ( | Vector3Int | gridPosition, |
| Vector2Int ? | dimensions = null, | ||
| bool | align = true ) |
Create an Zone registration locator from a grid position.
| gridPosition | position on a Tilemap |
| dimensions | [Nullable] optional size of locator. If null, ChunkMapAnchorPosition as set by Initialize |
| align | Align to grid. Default=true |
| RectInt TilePlus.TpZoneManager.GetLocatorForSgridPosition | ( | Vector2Int | sGridPosition, |
| Vector2Int? | dimensions = null ) |
Convert a super-grid position to a locator.
| sGridPosition | s sGrid postion |
| dimensions | dimensions of locator or null for default |
| RectInt TilePlus.TpZoneManager.GetLocatorForWorldPosition | ( | Vector3 | position, |
| Tilemap? | map, | ||
| Vector2Int? | dimensions = null, | ||
| bool | align = true ) |
Create an Zone registration locator from a world position.
| position | world position |
| map | Tilemap to use for translating world to grid positions. If null, new RectInt() is returned. |
| dimensions | [Nullable] optional size of locator. If null, ChunkMapAnchorPosition as set by Initialize |
| align | Align to grid. Default=true |
| bool TilePlus.TpZoneManager.GetZoneRegForLocator | ( | RectInt | locator, |
| out ZoneReg? | reg ) |
Get a Zone Reg for a locator RectInt.
| locator | a locator |
| reg | a registration |
| string TilePlus.TpZoneManager.GetZoneRegJson | ( | bool | prettyPrint = true | ) |
Get a JSON version of the Zone registrations.
| prettyPrint |
| List< ZoneReg > TilePlus.TpZoneManager.GetZoneRegsForGridPosition | ( | Vector3Int | gridPosition, |
| Vector2Int? | dimensions = null, | ||
| bool | align = true ) |
Get the ZoneRegs for a chunk located at a Grid position.
| gridPosition | The position to use when searching for Zone registrations |
| dimensions | [Nullable] if not null, this is the search area. If null, ChunkMapAnchorPosition as set by Initialize |
| align | Align to grid. Default=true |
| List< ZoneReg > TilePlus.TpZoneManager.GetZoneRegsForRegion | ( | RectInt? | locator | ) |
Get the ZoneRegs for a Zone locator RectInt.
| locator | the RectInt chunk locator |
return empty list if chunking not enabled or chunklocator is null. Note that the same list is cleared and re-used every time that this is called.
| List< ZoneReg > TilePlus.TpZoneManager.GetZoneRegsForWorldPosition | ( | Vector3 | worldPosition, |
| Tilemap? | map, | ||
| Vector2Int? | dimensions = null, | ||
| bool | align = true ) |
Get the Zone registration for a chunk located at a World position.
| worldPosition | The position to use when searching for Zone registrations |
| map | Tilemap to use for translating world to grid positions. If null, an empty list is returned. |
| dimensions | [Nullable] if not null, this is the search area. If null, ChunkMapAnchorPosition as set by Initialize |
| align | Align to grid. Default=true |
| bool TilePlus.TpZoneManager.HasZone | ( | ZoneReg | reg | ) |
| bool TilePlus.TpZoneManager.HasZoneRegForLocator | ( | RectInt | locator | ) |
Is there a Zone registration associated with a RectInt locator?
| locator | the RectInt to check |
| void TilePlus.TpZoneManager.Initialize | ( | int | size, |
| Vector3Int? | origin = null, | ||
| int | initialMaxNumChunks = 64 ) |
Required if you want to use chunking. No chunking data is accumulated and chunking will not work if this isn't used. Note that you should use this again for every new scene. WIPES OUT ANY EXISTING TILEFAB REGISTRATION DATA WHEN USED!!
| size | Size of a chunk. Must be even, rounded up if not. Min=4. 4x4, 6x6, 8x8 ... 16x16 chunks etc |
| origin | The origin position, the base position, such as Vector3Int.zero, where the chunk numbers should be centered. If null then Vector3Int.zero is used. |
| initialMaxNumChunks | sets certain data structures' initial size. Base this on the total number of chunks of 'size' that would be in your camera's FOV at one time (for example). There's no problem if the max num chunks is exceeded, this just allocates memory early on given your best estimate of what's required as set in this method. |
| bool TilePlus.TpZoneManager.IsAlignedToGrid | ( | Vector3Int | position | ) |
Is this grid position aligned to the super-grid?
| position | position to test |
| void TilePlus.TpZoneManager.ResetInstance | ( | bool | resetEvents = true | ) |
Reset all registrations, reset registrationIndex.
| resetEvents | Reset event descriptions (default=true) |
| List< TilefabLoadResults >? TilePlus.TpZoneManager.RestoreFromZoneRegJson | ( | string | jsonString, |
| Dictionary< string, Tilemap >? | targetMap = null, | ||
| Func< FabOrBundleFilterType, BoundsInt, object, bool >? | filter = null, | ||
| bool | filterOnlyTilePlusTiles = true ) |
Restore all Tilefabs or Bundles based on a json-archived dataset.
| jsonString | data string to decode |
| targetMap | optional mapping from tilemap name to Tilemap instance. Speeds tilemap lookups greatly |
| filter | a Func of [(enum)FilterDataSource, object] returning a bool. See also LoadTileFab. |
| filterOnlyTilePlusTiles | if true (default) only applies filters to TilePLus tiles, which is usually sufficient and saves much time. |
The list of TilefabLoadResults is cleared the next time that this method is used.
| bool TilePlus.TpZoneManager.UnloadAllZones | ( | ) |
Unload ALL zones, including all parented prefabs.
| bool TilePlus.TpZoneManager.UnloadZone | ( | ZoneReg? | reg, |
| bool | destroyTiles = true, | ||
| bool | destroyPrefabs = true ) |
Unload a chunk.
| reg | corresponding ZoneReg for the chunk you want to delete. |
| destroyTiles | destroy tiles if true (default) |
| destroyPrefabs | destroy prefabs if true (default) |
runtime use ONLY
| bool TilePlus.TpZoneManager.UnloadZones | ( | List< ZoneReg > | regs, |
| bool | destroyTiles = true, | ||
| bool | destroyPrefabs = true ) |
Unload a list of Zones.
| regs | List of ZoneRegs to delete |
| destroyTiles | destroy tiles (default) |
| destroyPrefabs | destroy prefabs (default) |
| async Awaitable< bool > TilePlus.TpZoneManager.UnloadZonesAsync | ( | List< ZoneReg > | regs, |
| bool | destroyTiles = true, | ||
| bool | destroyPrefabs = true ) |
Unload a list of Zones, Async Does one reg per frame.
| regs | List of ZoneRegs to delete |
| destroyTiles | destroy tiles (default) |
| destroyPrefabs | destroy prefabs (default) |
|
get |
Is chunking configured?
|
get |
Size of a chunk as set during initialization.
|
get |
Get the default locator. This is the value used when you don't specify a dimensions value when GetZoneReg or GetLocator with dimensions = null.
|
get |
Get the all loading results.
|
get |
The name of this instance. Read only.
|
get |
Access to the Monitored Tilemaps for this instance. DO NOT ALTER THIS DICTIONARY. DON'T SAVE A REFERENCE.
|
get |
Get a collection of the MonitoredTilemaps dictionary values: Tilemap instances. These are the only ones that clients of this instance should be using.
|
get |
The number of chunks in the chunkmap.
|
get |
Get the ChunkMapAnchorPosition. This is the base or startingPosition from where all Chunks begin. You can find the center of a chunk by adding multiples of ChunkMapAnchorSize to ChunkMapAnchorPosition.
|
getset |
A ref to the ZoneLayout, if used with chunking system. Null otherwise.
| Action<Tilemap,List<TilePlusBase> >? TilePlus.TpZoneManager.OnTptTilesWillBeDeleted |
Notify me that a list of TPT tiles will be deleted.
Be aware that when the ZoneManager instance is deleted this subscription expires
| Action<ZoneReg, TpZoneManager>? TilePlus.TpZoneManager.OnZoneRegAdded |
Notify me when a Zone Reg is added.
Be aware that when the ZoneManager instance is deleted this subscription expires
| Action<ZoneReg,TpZoneManager>? TilePlus.TpZoneManager.OnZoneRegDeleted |
Notify me when a Zone Reg is deleted.
Be aware that when the ZoneManager instance is deleted this subscription expires