TilePlus Version 5
Unity3D Tilemap Extension
Loading...
Searching...
No Matches
TilePlus.TileFabLib Class Reference

Utilities for Tilefab loading. More...

Static Public Member Functions

static async Awaitable< bool > LoadTileFabsAsync (List< TileFabLoadParams > loadParams, List< TilefabLoadResults > loadResultsList, float intervalBetweenTileFabs=0, float intervalBetweenBundles=0, TpZoneManager? zoneManager=null)
 Async-Awaitable: Load several tilefabs at once from a list of specifications.
static async Awaitable< TilefabLoadResults?> LoadTileFabAsync (Tilemap? tileParent, TpTileFab? tileFab, Vector3Int offset, TpTileBundle.TilemapRotation rotation=TpTileBundle.TilemapRotation.Zero, FabOrBundleLoadFlags fabOrBundleLoadFlags=FabOrBundleLoadFlags.NormalWithFilter, Func< FabOrBundleFilterType, BoundsInt, object, bool >? filter=null, Dictionary< string, Tilemap >? targetMap=null, TpZoneManager? zoneManagerInstance=null, float intervalBetweenBundles=0)
 Async Awaitable version - Load one or more tilemaps and associated prefabs, if any. ONLY difference is intervalBetweenBundles parameter, used to delay between bundle loads. IF a TileFab has only one bundle there's no need to use this. IF you set intervalBetweenBundles < .10 then there's no need to use this.
static ? TilefabLoadResults LoadTileFab (Tilemap? tileParent, TpTileFab? tileFab, Vector3Int offset, TpTileBundle.TilemapRotation rotation=TpTileBundle.TilemapRotation.Zero, FabOrBundleLoadFlags fabOrBundleLoadFlags=FabOrBundleLoadFlags.NormalWithFilter, Func< FabOrBundleFilterType, BoundsInt, object, bool >? filter=null, Dictionary< string, Tilemap >? targetMap=null, TpZoneManager? zoneManagerInstance=null)
 Non- async-Awaitable version: Load one or more tilemaps and associated prefabs, if any.
static Dictionary< Vector3Int, string >? List< GameObject > loadedPrefabs LoadBundle (TpTileBundle tileBundleAsset, Tilemap map, Vector3Int offset, TpTileBundle.TilemapRotation rotation=TpTileBundle.TilemapRotation.Zero, FabOrBundleLoadFlags fabOrBundleLoadFlags=FabOrBundleLoadFlags.NormalWithFilter, Func< FabOrBundleFilterType, BoundsInt, object, bool >? filter=null, RectInt? zoneLocator=null)
static ? Tilemap FindTilemap (TpTileFab.AssetSpec spec)
static bool GetTileFabFromGuid (string guid, out TpTileFab? fab)
 Get a TileFab instance from a GUID string.
static bool EnableZoneManagers (bool enable=true, int initialNumManagers=1, int guidTableSize=128, Dictionary< string, TpTileFab >? stringToFabMap=null)
 Enable/Disable the Zone Manager subsystem.
static bool CreateZoneManagerInstance (out TpZoneManager? instance, string iName, Dictionary< string, Tilemap > targetMap)
 Create a ZM instance or get an existing one.
static bool HasNamedInstance (string iName)
 Does the named ZoneLayout controller instance exist?
static bool DeleteNamedInstance (string iName, bool disableWhenNone=true)
 Delete a named ZoneLayout controller instance.
static bool GetNamedInstance (string iName, out TpZoneManager? instance)
 Get a named ZoneLayout controller instance.
static bool RemapTileGuid (Guid oldGuid, out Guid newGuid)
 Attempt to remap a GUID.
static bool RemoveFromGuidLookup (Guid alias)
 Delete from the loadedGuidLookup when you are not using the built-in system. It's important to remove these when you are deleting a TileFab or you'll have a memory leak;.
static void UpdateGuidLookup (ZoneReg oldReg, ZoneReg newReg)
 Update the GUID lookup. Used to alias previously-used TPT tile GUIDs to new TPT tile GUIDs.
static bool AddGuidLookup (Guid original, Guid alias)
 Add to the loadedGuidLookup so that TpLib's Guid-to-tile lookup works. This is only for use if you aren't using the built-in system.
static bool RemoveGuidLookup (BundleGuidMap bundleGuidMap)
 Remove a GUID lookup. Used when deleting a ZoneReg.
static void AddChunkedBundle (TpTileBundle chunkedBundle)
 Add a chunked Bundle to an internal list.
static void RemoveChunkedBundle (TpTileBundle unchunkedBundle)
 Remove a chunked Bundle from the internal list.

Static Public Attributes

static Dictionary< Vector3Int, string > posToGuidMap
 Load the contents of a Bundle asset to a tilemap. Note: assumes tilemap is at 0,0,0. If not, adjust offset prior to call.

Properties

static ulong RegistrationIndex [get]
 Gets the current, unused registration index.
static bool AnyActiveZoneManagers [get]
 Any Zone Manager instances?
static int NumZoneManagerInstances [get]
 how many active zone managers
static bool ZoneManagerCreationEnabled [get]
 Is the creation of Zone Manager instances enabled?
static int NumZoneManagerChunks [get]
 how many chunks are being managed by ALL zone managers.

Detailed Description

Utilities for Tilefab loading.

Member Function Documentation

◆ AddChunkedBundle()

void TilePlus.TileFabLib.AddChunkedBundle ( TpTileBundle chunkedBundle)
static

Add a chunked Bundle to an internal list.

Parameters
chunkedBundle

◆ AddGuidLookup()

bool TilePlus.TileFabLib.AddGuidLookup ( Guid original,
Guid alias )
static

Add to the loadedGuidLookup so that TpLib's Guid-to-tile lookup works. This is only for use if you aren't using the built-in system.

Parameters
originalPrevious Guid from when the game state was saved
aliasalias Guid from TileFab loading's guid change operation or elsewhere
Returns
true unless there was an existing and matching Guid key in either dictionary. Treat that as a fatal error.

◆ CreateZoneManagerInstance()

bool TilePlus.TileFabLib.CreateZoneManagerInstance ( out TpZoneManager? instance,
string iName,
Dictionary< string, Tilemap > targetMap )
static

Create a ZM instance or get an existing one.

Parameters
instanceout param gets the instance
iNameunique name. If already used, fetches existing ZM instance
targetMapTilemaps to be controlled by this ZM
Returns

◆ DeleteNamedInstance()

bool TilePlus.TileFabLib.DeleteNamedInstance ( string iName,
bool disableWhenNone = true )
static

Delete a named ZoneLayout controller instance.

Parameters
iNamethe unique name for the ZoneLayout
disableWhenNoneAuto-shutoff zone management when there are no more ZMs
Returns
true if the deletion was successful. False if name not found or ZoneManagement is not active

◆ EnableZoneManagers()

bool TilePlus.TileFabLib.EnableZoneManagers ( bool enable = true,
int initialNumManagers = 1,
int guidTableSize = 128,
Dictionary< string, TpTileFab >? stringToFabMap = null )
static

Enable/Disable the Zone Manager subsystem.

Parameters
enableon/off
initialNumManagersbest guess at # of managers required
guidTableSizebest guess at GUID translation table size
stringToFabMapOptional map from string to TpTileFab. If omitted, it's created here.
Returns
true for success

Note that TileFabs might have to be in Resource Folders to be found since they're only referred to by GUIDs - unless you create a ScriptableObject parented to some GameObject component so that the TileFabs are included in a build.

The bundle data cache can be used when reusing the same TileFabs and Bundles repeatedly AND new GUIDs are NOT required. Useful for the 'chunk streaming' mode of operation when using Zone Managers and Zone Layout when the GUIDs of the tiles aren't modified. NOTE that GUID remapping is ignored when using this feature.

◆ FindTilemap()

? Tilemap TilePlus.TileFabLib.FindTilemap ( TpTileFab.AssetSpec spec)
static

Find a tilemap given an asset spec from a TileFab

Parameters
specThe Asset Spec from a TileFab
Returns
Found Tilemap or null

◆ GetNamedInstance()

bool TilePlus.TileFabLib.GetNamedInstance ( string iName,
out TpZoneManager? instance )
static

Get a named ZoneLayout controller instance.

Parameters
iNamethe unique name for the ZoneLayout
instancean out param for the instance
Returns
true if found, false if not. If not found, instance is set to null.

◆ GetTileFabFromGuid()

bool TilePlus.TileFabLib.GetTileFabFromGuid ( string guid,
out TpTileFab? fab )
static

Get a TileFab instance from a GUID string.

Parameters
guidGUID string
fabTileFab instance. Null if not found
Returns
true if found

◆ HasNamedInstance()

bool TilePlus.TileFabLib.HasNamedInstance ( string iName)
static

Does the named ZoneLayout controller instance exist?

Parameters
iNamethe unique name for the ZoneLayout
Returns
True if it exists

◆ LoadBundle()

Dictionary< Vector3Int, string >? List< GameObject > loadedPrefabs TilePlus.TileFabLib.LoadBundle ( TpTileBundle tileBundleAsset,
Tilemap map,
Vector3Int offset,
TpTileBundle.TilemapRotation rotation = TpTileBundle::TilemapRotation::Zero,
FabOrBundleLoadFlags fabOrBundleLoadFlags = FabOrBundleLoadFlags::NormalWithFilter,
Func< FabOrBundleFilterType, BoundsInt, object, bool >? filter = null,
RectInt? zoneLocator = null )
static

◆ LoadTileFab()

? TilefabLoadResults TilePlus.TileFabLib.LoadTileFab ( Tilemap? tileParent,
TpTileFab? tileFab,
Vector3Int offset,
TpTileBundle.TilemapRotation rotation = TpTileBundle::TilemapRotation::Zero,
FabOrBundleLoadFlags fabOrBundleLoadFlags = FabOrBundleLoadFlags::NormalWithFilter,
Func< FabOrBundleFilterType, BoundsInt, object, bool >? filter = null,
Dictionary< string, Tilemap >? targetMap = null,
TpZoneManager? zoneManagerInstance = null )
static

Non- async-Awaitable version: Load one or more tilemaps and associated prefabs, if any.

Parameters
tileParentthe parent of the calling tile (if any, can be null if not a tile)
tileFaba TpTileFab asset
offsetoptional offset from tiles' stored positions
rotationoptional rotation (not implemented)
fabOrBundleLoadFlagsFlags from the LoadFlags enum.
filtera Func of returning a bool. See also LoadBundle.
targetMapA dictionary mapping tilemap names as found in the TileFab to actual Tilemap instances. Used to override the names from the Tilefab. Case-sensitive. It's also much faster than a name lookup as done without a provided mapping.
zoneManagerInstanceIf using TpZoneManager, pass its instance.
Returns
Instance of TilefabLoadResults record. If null is returned then there was an error of some kind.

Does not support chunkify flag in the fabOrBundleLoadFlags

◆ LoadTileFabAsync()

async Awaitable< TilefabLoadResults?> TilePlus.TileFabLib.LoadTileFabAsync ( Tilemap? tileParent,
TpTileFab? tileFab,
Vector3Int offset,
TpTileBundle.TilemapRotation rotation = TpTileBundle::TilemapRotation::Zero,
FabOrBundleLoadFlags fabOrBundleLoadFlags = FabOrBundleLoadFlags::NormalWithFilter,
Func< FabOrBundleFilterType, BoundsInt, object, bool >? filter = null,
Dictionary< string, Tilemap >? targetMap = null,
TpZoneManager? zoneManagerInstance = null,
float intervalBetweenBundles = 0 )
static

Async Awaitable version - Load one or more tilemaps and associated prefabs, if any. ONLY difference is intervalBetweenBundles parameter, used to delay between bundle loads. IF a TileFab has only one bundle there's no need to use this. IF you set intervalBetweenBundles < .10 then there's no need to use this.

Parameters
tileParentthe parent of the calling tile (if any, can be null if not a tile)
tileFaba TpTileFab asset
offsetoptional offset from tiles' stored positions
rotationoptional rotation (not implemented)
fabOrBundleLoadFlagsFlags from the LoadFlags enum.
filtera Func of returning a bool. See also LoadBundle.
targetMapA dictionary mapping tilemap names as found in the TileFab to actual Tilemap instances. Used to override the names from the Tilefab. Case-sensitive. It's also much faster than a name lookup as done without a provided mapping.
zoneManagerInstanceIf using TpZoneManager, pass its instance.
intervalBetweenBundleswait time between each Bundle of a TileFab. Range is 0.01f - 0.1f (seconds). If 0 (default value) then there are no delays between Bundle loads.
Returns
Instance of TilefabLoadResults record. If null is returned then there was an error of some kind.

◆ LoadTileFabsAsync()

async Awaitable< bool > TilePlus.TileFabLib.LoadTileFabsAsync ( List< TileFabLoadParams > loadParams,
List< TilefabLoadResults > loadResultsList,
float intervalBetweenTileFabs = 0,
float intervalBetweenBundles = 0,
TpZoneManager? zoneManager = null )
static

Async-Awaitable: Load several tilefabs at once from a list of specifications.

Parameters
loadParamsA list of TileFabLoadParams
loadResultsListif not null, TileFab LoadResults added to list. Note it is NOT cleared here.
intervalBetweenTileFabswait time between each TileFab. Range is 10-500 MSEC. If 0 (default value) then there are no delays between TileFab loads
intervalBetweenBundleswait time between each Bundle of a TileFab. Range is .01f - 0.1f (Seconds). If 0 (default value) then there are no delays between Bundle loads.
zoneManagerthe ZoneManager instance, if you're using it.
Returns
false if any errors

◆ RemapTileGuid()

bool TilePlus.TileFabLib.RemapTileGuid ( Guid oldGuid,
out Guid newGuid )
static

Attempt to remap a GUID.

Parameters
oldGuidthe old one
newGuidthe remapped one
Returns
true if the remap was successful

◆ RemoveChunkedBundle()

void TilePlus.TileFabLib.RemoveChunkedBundle ( TpTileBundle unchunkedBundle)
static

Remove a chunked Bundle from the internal list.

Parameters
unchunkedBundle

◆ RemoveFromGuidLookup()

bool TilePlus.TileFabLib.RemoveFromGuidLookup ( Guid alias)
static

Delete from the loadedGuidLookup when you are not using the built-in system. It's important to remove these when you are deleting a TileFab or you'll have a memory leak;.

Parameters
aliasThe current Guid for a tile
Returns
false if error: should consider this a fatal error.

◆ RemoveGuidLookup()

bool TilePlus.TileFabLib.RemoveGuidLookup ( BundleGuidMap bundleGuidMap)
static

Remove a GUID lookup. Used when deleting a ZoneReg.

Parameters
bundleGuidMapthe mapping from the active ZoneReg (i.e., one generated after loading a TileFab)
Returns
true if this worked. False if ZoneManagement isn't enabled.

◆ UpdateGuidLookup()

void TilePlus.TileFabLib.UpdateGuidLookup ( ZoneReg oldReg,
ZoneReg newReg )
static

Update the GUID lookup. Used to alias previously-used TPT tile GUIDs to new TPT tile GUIDs.

Parameters
oldRegthe previously-used (saved) reg
newRegthe new reg, with new GUIDs, after loading

Member Data Documentation

◆ posToGuidMap

Dictionary<Vector3Int, string> TilePlus.TileFabLib.posToGuidMap
static

Load the contents of a Bundle asset to a tilemap. Note: assumes tilemap is at 0,0,0. If not, adjust offset prior to call.


NOTE that TpTileBundles do NOT create AssetRegistration entries, ONLY calling LoadTileFab does that.


Parameters
tileBundleAssetthe asset reference
maptarget Tilemap
offsetoffset to position
rotationoptional rotation (unsupported)
fabOrBundleLoadFlagsFlags from the LoadFlags enum.
filterFunc of returning a bool. The filter should return true if the tile/prefab is acceptable or false to omit it.
zoneLocatorIf not null, used instead of Bundle's m_TilemapBoundsInt
Returns
pos-to-GUID map and list of prefabs

map.SetTiles(tileChangeData) is used: flags are not restored. When the tiles are started, the tiles' flags are used. Also, lock flags on the tilemap are ignored.

Property Documentation

◆ AnyActiveZoneManagers

bool TilePlus.TileFabLib.AnyActiveZoneManagers
staticget

Any Zone Manager instances?

◆ NumZoneManagerChunks

int TilePlus.TileFabLib.NumZoneManagerChunks
staticget

how many chunks are being managed by ALL zone managers.

◆ NumZoneManagerInstances

int TilePlus.TileFabLib.NumZoneManagerInstances
staticget

how many active zone managers

◆ RegistrationIndex

ulong TilePlus.TileFabLib.RegistrationIndex
staticget

Gets the current, unused registration index.

◆ ZoneManagerCreationEnabled

bool TilePlus.TileFabLib.ZoneManagerCreationEnabled
staticget

Is the creation of Zone Manager instances enabled?


The documentation for this class was generated from the following file:
  • /Users/jms/Documents/Tpt_55/TPT55/Assets/Plugins/TilePlus/Runtime/FabAndZone/StaticLib/TileFabLib.cs