TpLib
TpLib itself is a large class divided into eight partial classes:
- TpLib
- TpLibData
- TpLibDataAccess
- TpLibPools
- TpLibScene
- TpLibTasks
- TpLibTiming
And in an Editor folder
- TpLibEditorUtils
If you're coding to the TpLib API, the parts you'd most likely be interested in are TpLibDataAccess and TpLibTasks. Complete information can be found in the API reference (a zip file in the TilePlusExtras folder).
TpLibDataAccess
The methods in TpLibDataAccess have pre-built 'queries' that allow you to extract information from the TMDB, which are data loaded into various structures in the TpLibData section of TpLib such as Types, Interfaces, Tags, GUIDs, etc.
There is also functionality for complex operations:
- Cut And Paste: Move a TPT tile from one positionn to another.
- Copy And Paste: Copy a TPT tile and place the copy elsewhere.
- This should always be used for this sort of operation so that the cloned tiles are copied correctly.
Queries
Please consult the API reference for complete information. Not every variation is shown below.
-
GetAllTilesInRegionForMap: load all TPT tiles on a specified Tilemap and within a RectInt region into a provided List.
-
GetAllTiles<T>: load all TPT tiles of Type T in all Tilemaps into a provided
list,List, with filtering callback. -
GetAllTilesOfTypeGetAllTilesOfType: load all TPT tiles of a particular Type from a specified Tilemap into a provided List, with filtering callback and a RectInt region. If the specified Tilemap is null, uses all Tilemaps. -
GetAllTilesWithInterface<T>: load all TPT tiles from a specified Tilemap into a provided List, with filtering. If the Tilemap is null, uses all Tilemaps.
- An overload uses a provided list of Type T (saves casting later) and queries all Tilemaps. This includes a filter and a RectInt region.
-
GetTilesWithTag: Get all tiles on a specified Tilemap with a particular tag into a provided List with filtering and a RectInt region. If the specified Tilemap is null then all Tilemaps are used.
-
GetFirstTileWithTag: Convenience method, returns the first tile found from GetTilesWithTag.
-
GetTilePlusBaseFromGuid: Find a TPT tile on any Tilemap that has a specified GUID.
- Overloads allow use of a GUID string or byte array.
-
GetTilePlusBaseOfTypeFromGuid<T>: Similar to GetTilePlusBaseFromGuid but returns null if the tile is not of Type T.
The methods that don't take a Tilemap reference or allow reference to be null provide a Tilemap- and position-independent way to locate tiles without having any idea where they are actually located.
GetTilesWithTagThis is extremely useful!
GetFirstTileWithTagWhen used with the TileFab loading and the Layout systems you can easily locate TPT tiles as they're loaded and you won't get null ref errors after the tiles are unloaded.
GetTilePlusBaseFromGuidWhen used with the Messaging Service, you can send messages to tiles based on their Type, Interface, tags, etc., without having to prebuild a list of targets. It happens auto-magically.