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

A Scene Manager component for Tilemaps when used with the templating system (TileFabLib/TpZoneManager/TpZoneLayout). More...

Inheritance diagram for TilePlus.TpChunkedSceneManager:
Collaboration diagram for TilePlus.TpChunkedSceneManager:

Public Member Functions

bool Initialize (int initialSceneIndex=0, string initialSceneName="", bool sceneNameIsGuid=false)
 Init this component.
bool SetSceneFromSceneNameOrGuid (string tileSceneNameOrGuid, bool isGuid)
 Set Scene using name of 'TScene' or its GUID.
bool SetScene (int tileSceneIndex, bool clearPrevious=true, Func< TSceneList.TSceneSpec, TpZoneLayout, object?, object >? callback=null)
 Set Scene using index of 'Scene'.
bool ClearScene (bool clearCaches=true)
 Use before changing a Unity scene: deletes all zones placed via Layout.
HashSet< string?> GetUsedSceneLayoutNames (TSceneList.TScene tScene)
 Get all ZoneLayout names with no duplicates. Note all names changed to lowercase.
TpZoneLayoutGetNamedZoneLayout (string zoneLayoutName)
 Get a ZoneLayout for a given ZoneLayout name as found in a TSceneSpec.
TSceneList.? TSceneSpec GetSceneSpecWithLayoutName (string layoutName)
 Get the SceneSpec for a named layout in the current TScene.

Public Attributes

TSceneListm_TSceneList
 A reference to a Project asset that contains a list of TileScenes. Each Tile Scene is an instance of a TScene class. Each TScene class has a list of TSceneSpec class instances. Each TSceneSpec instance has a ChunkTemplateSelector (the content to load) and a ZoneLayout component name. The name is used to lookup the ZoneLayout component REFERENCE, which is the connection to the TpZoneLayout component and its underlying TpZoneManager. When a new scene is loaded, one or more TpZoneLayout has their ChunkSelector references set to the ChunkTemplateSelector from the TSceneSpec specifically connected to the TpZoneLayout. What a mouthful.
List< TpZoneLayoutm_ZoneLayouts = new()
 This list can have any non-local (ie not on the same GO) ZoneLayouts. Optional.

Properties

TSceneList.? TScene CurrentScene [get]
 Current Scene.
TSceneList.? TScene LastScene [get]
 The previous TScene (or null).
int CurrentSceneIndex [get]
 Current Scene Index.
int PreviousSceneIndex [get]
 Previous Scene Index.
BoundsInt LargestSelectorBounds [get]
 BoundsInt representing the largest BoundsInt of a Selector.
bool SceneChangeInProgress [get]
 Indicates if a scene change is in progress. Note: static property.
HashSet< TpZoneLayoutCurrentActiveLayouts = new() [get]
 Get the currently-active TpZoneLayouts. Valid when OnNewTsceneChosen callback.
int TotalNumLayouts [get]
 The total number of TpZoneLayouts found during init.

Events

Action< TpChunkedSceneManager, TSceneList.TScene?>? OnBeforeTSceneChange
 Invoked when SetScene is entered. TileScene passed to Action is the CURRENT TileScene (the one active before SetScene is called). NOTE that on first use the TileScene will be NULL since there isn't an active one at that point in time.
Action< TpChunkedSceneManager, TSceneList.TScene >? OnAfterTSceneChange
 Invoked when SetScene is complete. TileScene passed to Action is the NEW TileScene.
Action< TpChunkedSceneManager, TSceneList.TScene >? OnNewTSceneChosen
 Invoked when a new TileScene has been sucessfully selected. Subsriber should save this somewhere.
Action< TpChunkedSceneManager, TSceneList.TScene?, TpZoneManager, ZoneReg >? OnZoneRegAddedForLayout
 Invoked when an active ZoneManager for a TSceneLyout issues OnZoneRegAdded. Note that one can get the ZoneManager's controlling TpZoneLayout from a property in the ZoneManager.
Action< TpChunkedSceneManager, TSceneList.TScene?, TpZoneManager, ZoneReg >? OnZoneRegDeletedForLayout
 Invoked when an active ZoneManager for a TSceneLyout issues OnZoneRegDeleted. Note that one can get the ZoneManager's controlling TpZoneLayout from a property in the ZoneManager.
Action< TpChunkedSceneManager, Tilemap, List< TilePlusBase > >? OnTptTilesWillBeDeletedForLayout
 Invoked when an active ZoneManager for a TSceneLyout issues OnTptTilesWillBeDeleted.

Detailed Description

A Scene Manager component for Tilemaps when used with the templating system (TileFabLib/TpZoneManager/TpZoneLayout).

Member Function Documentation

◆ ClearScene()

bool TilePlus.TpChunkedSceneManager.ClearScene ( bool clearCaches = true)

Use before changing a Unity scene: deletes all zones placed via Layout.

Parameters
clearCachesClear all bundle caches if true (default)
Returns
false for no current scene or any error

◆ GetNamedZoneLayout()

TpZoneLayout? TilePlus.TpChunkedSceneManager.GetNamedZoneLayout ( string zoneLayoutName)

Get a ZoneLayout for a given ZoneLayout name as found in a TSceneSpec.

Parameters
zoneLayoutNamestring
Returns
null if not found

◆ GetSceneSpecWithLayoutName()

TSceneList.? TSceneSpec TilePlus.TpChunkedSceneManager.GetSceneSpecWithLayoutName ( string layoutName)

Get the SceneSpec for a named layout in the current TScene.

Parameters
layoutNameThe name of a Zone layout in the CURRENT SCENE
Returns
the Scene Spec or NULL if not found. Note that not all Scenes use all layouts!

◆ GetUsedSceneLayoutNames()

HashSet< string?> TilePlus.TpChunkedSceneManager.GetUsedSceneLayoutNames ( TSceneList.TScene tScene)

Get all ZoneLayout names with no duplicates. Note all names changed to lowercase.

Parameters
tScenea tscene
Returns
HashSet of ZoneLayout names

◆ Initialize()

bool TilePlus.TpChunkedSceneManager.Initialize ( int initialSceneIndex = 0,
string initialSceneName = "",
bool sceneNameIsGuid = false )

Init this component.

Parameters
initialSceneIndexInitial Scene index from the list of Scenes. Note: if this is <0 then the initial scene isn't loaded EVEN IF an initial scene name or GUID is provided!
initialSceneNamedefault=empty string. If this isn't empty, the string provided is used to look for a TileScene in the list of TileScenes and the initialSceneIndex value is ignored. Note that this string can be a scene name or the GUID of a scene
sceneNameIsGuidSet this true if the initialSceneName is a GUID
Returns
false for error, eg: the ZoneLayout component LayoutName fields are not unique.

The ZoneLayout components must all be on the same GameObject as this component. Any others not on the same GameObject are ignored unless manually added to the m_ZoneLayout. Also: set up the several SceneChange callbacks before calling this if you want its handler invoked.

◆ SetScene()

bool TilePlus.TpChunkedSceneManager.SetScene ( int tileSceneIndex,
bool clearPrevious = true,
Func< TSceneList.TSceneSpec, TpZoneLayout, object?, object >? callback = null )

Set Scene using index of 'Scene'.

Parameters
tileSceneIndexIndex of selector asset
clearPreviousClear all zones if true (default)
callbackA Func that gets a SceneSpec, a SceneLayout, and an object, returning an object. See remarks
Returns
false for error

Here is where LoadFlag overrides are applied. However, they can be modified in the Layout.Updateick callbacks. The Func is used when any TSceneInitializers are evaluated. It's passed to the Initializer when its Exec method is invoked. It gets the SceneSpec and SceneLayout information for that initializer, and any arbitrary data that's desirable, and returns any arbitrary data that's desirable. The idea is to have most handling of init related to a specific scene be handled by initializers. If that doesn't work then you can handle the various callbacks from ZoneManagers and this component in your own code; and you can certaintly do both as needed to handle special situations.

◆ SetSceneFromSceneNameOrGuid()

bool TilePlus.TpChunkedSceneManager.SetSceneFromSceneNameOrGuid ( string tileSceneNameOrGuid,
bool isGuid )

Set Scene using name of 'TScene' or its GUID.

Parameters
tileSceneNameOrGuidName or GUID of TScene. if isGuid is FALSE, then tries to parse as integer >= 0, if that fails then do a lookup of the scene name.
isGuidset TRUE if the input string is a GUID
Returns
false for error

if isGuid == true the string is tested to see if it really is a guid. If not, we try to parse the string as an integer and use that as a TScene index, ie an index into the list of TScenes in the TSceneList asset.

Member Data Documentation

◆ m_TSceneList

TSceneList? TilePlus.TpChunkedSceneManager.m_TSceneList

A reference to a Project asset that contains a list of TileScenes. Each Tile Scene is an instance of a TScene class. Each TScene class has a list of TSceneSpec class instances. Each TSceneSpec instance has a ChunkTemplateSelector (the content to load) and a ZoneLayout component name. The name is used to lookup the ZoneLayout component REFERENCE, which is the connection to the TpZoneLayout component and its underlying TpZoneManager. When a new scene is loaded, one or more TpZoneLayout has their ChunkSelector references set to the ChunkTemplateSelector from the TSceneSpec specifically connected to the TpZoneLayout. What a mouthful.

◆ m_ZoneLayouts

List<TpZoneLayout> TilePlus.TpChunkedSceneManager.m_ZoneLayouts = new()

This list can have any non-local (ie not on the same GO) ZoneLayouts. Optional.

Property Documentation

◆ CurrentActiveLayouts

HashSet<TpZoneLayout> TilePlus.TpChunkedSceneManager.CurrentActiveLayouts = new()
get

Get the currently-active TpZoneLayouts. Valid when OnNewTsceneChosen callback.

◆ CurrentScene

TSceneList.? TScene TilePlus.TpChunkedSceneManager.CurrentScene
get

Current Scene.

◆ CurrentSceneIndex

int TilePlus.TpChunkedSceneManager.CurrentSceneIndex
get

Current Scene Index.

◆ LargestSelectorBounds

BoundsInt TilePlus.TpChunkedSceneManager.LargestSelectorBounds
get

BoundsInt representing the largest BoundsInt of a Selector.

◆ LastScene

TSceneList.? TScene TilePlus.TpChunkedSceneManager.LastScene
get

The previous TScene (or null).

◆ PreviousSceneIndex

int TilePlus.TpChunkedSceneManager.PreviousSceneIndex
get

Previous Scene Index.

◆ SceneChangeInProgress

bool TilePlus.TpChunkedSceneManager.SceneChangeInProgress
get

Indicates if a scene change is in progress. Note: static property.

◆ TotalNumLayouts

int TilePlus.TpChunkedSceneManager.TotalNumLayouts
get

The total number of TpZoneLayouts found during init.

Event Documentation

◆ OnAfterTSceneChange

Action<TpChunkedSceneManager, TSceneList.TScene>? TilePlus.TpChunkedSceneManager.OnAfterTSceneChange

Invoked when SetScene is complete. TileScene passed to Action is the NEW TileScene.

◆ OnBeforeTSceneChange

Action<TpChunkedSceneManager, TSceneList.TScene?>? TilePlus.TpChunkedSceneManager.OnBeforeTSceneChange

Invoked when SetScene is entered. TileScene passed to Action is the CURRENT TileScene (the one active before SetScene is called). NOTE that on first use the TileScene will be NULL since there isn't an active one at that point in time.

◆ OnNewTSceneChosen

Action<TpChunkedSceneManager, TSceneList.TScene>? TilePlus.TpChunkedSceneManager.OnNewTSceneChosen

Invoked when a new TileScene has been sucessfully selected. Subsriber should save this somewhere.

◆ OnTptTilesWillBeDeletedForLayout

Action<TpChunkedSceneManager, Tilemap, List<TilePlusBase> >? TilePlus.TpChunkedSceneManager.OnTptTilesWillBeDeletedForLayout

Invoked when an active ZoneManager for a TSceneLyout issues OnTptTilesWillBeDeleted.

◆ OnZoneRegAddedForLayout

Action<TpChunkedSceneManager, TSceneList.TScene?, TpZoneManager, ZoneReg>? TilePlus.TpChunkedSceneManager.OnZoneRegAddedForLayout

Invoked when an active ZoneManager for a TSceneLyout issues OnZoneRegAdded. Note that one can get the ZoneManager's controlling TpZoneLayout from a property in the ZoneManager.

◆ OnZoneRegDeletedForLayout

Action<TpChunkedSceneManager, TSceneList.TScene?, TpZoneManager, ZoneReg>? TilePlus.TpChunkedSceneManager.OnZoneRegDeletedForLayout

Invoked when an active ZoneManager for a TSceneLyout issues OnZoneRegDeleted. Note that one can get the ZoneManager's controlling TpZoneLayout from a property in the ZoneManager.


The documentation for this class was generated from the following file: