TilePlus Version 5
Unity3D Tilemap Extension
Loading...
Searching...
No Matches
TilePlus.TpSpawner Class Referencesealed

Pooled spawner for TilePlus system. More...

Inheritance diagram for TilePlus.TpSpawner:
Collaboration diagram for TilePlus.TpSpawner:

Public Types

enum  PositioningMode { UseAssetSetting , AtTilePosition , AtContactPosition , RandomInZone }
 Enum PositioningMode. More...
enum  TileParentingMode { SameParentAsTile , ParentByReference , ParentByTag , ParentByName }
 How to parent painted tiles. More...

Public Member Functions

override string Status ()
 The TilePlus SysInfo window will show all SRS 'Status' strings when playing in-editor (if the 'show' checkbox is checked). This is totally optional.
override bool CanPollForDetails ()
 Used by SRS inspector. If the contents of an SRS change frequently then this should be overridden to return true.
Returns
T/F
accessed via reflection (editor only) don't change this to a prop or change the name
override string Details (int limit=-1)
 Get a string with the pool status.
override void OnEnable ()
 OnEnable.
override void OnDisable ()
 Unity event method.
void ResetPools ()
 Reset all prefab pools. V3.1 and later: also clears collidableGO hashset.
bool IsPreloaded (GameObject prefab)
 has this prefab already been preloaded?
void Preload (GameObject? prefab, int quantity)
 Preload a pool.
void DespawnPrefab (int sourcePrefabId, GameObject? target)
 Despawn a prefab into the pool.
GameObject? SpawnPrefabFromTile (TilePlusPrefabSpawnerItem spawnerItem, TilePlusBase tile, Transform? altParent, bool keepWorldPosition)
 Spawn a single prefab from a tile that implements the ISpawner interface.
GameObject? SpawnPrefab (GameObject? prefab, Vector3 position, Transform? parentTransform=null, string parentNameOrTag="", bool searchForTag=false, bool keepWorldPosition=true)
 Spawn a single prefab. Always uses pooling.
TilePlusBasePaintTile (PaintingSpec? item, TilePlusBase sourceTile, Tilemap? paintTarget, TilePaintPosition paintPos=TilePaintPosition.None)
 Paint a tile from the TpTileList asset by index. Note that null is returned if the position is occupied. Also, you can change the tilemap to use for painting with the m_PaintingTilemap field in-editor or via code.
bool IsCollidable (GameObject go)
 Returns true if a spawned GO is a collidable.
bool TestCollidable (GameObject go)
 Test for colliders.
Tilemap? GetPaintingTilemap (TileParentingMode parentingMode, string mapNameOrTag, string info)
 Get the tilemap for painting.
Public Member Functions inherited from TilePlus.ScriptableRuntimeService< T >
override string ToString ()
 Customize ToString in overrides.
Public Member Functions inherited from TilePlus.IScriptableService
void Update (float deltaTime)
 Update implementation: Must override with explicit implementation.
void MessageTarget (ObjectPacket packet)
 If Accepts messages is true, reimplement this to get messaged.

Properties

string PoolHostName [get]
 Gets the name of the pool host.
string CleanPoolHostName [get]
 Get the pool host name with no advice.
int NumPooledPrefabs [get]
 total Number of pooled prefabs
int NumCollidables [get]
 Total number of Collidables.
GameObject[] AllCollidableSpawnedPrefabs [get]
 Get an array of all Collidables. Note: uses LINQ and may generate some GC.
Properties inherited from TilePlus.ScriptableRuntimeService< T >
string ServiceName [get]
 A name for this service: used for profiling. Ordinarily just returns the 'name' property of the Service S.O. instance.
Properties inherited from TilePlus.IScriptableService
bool PeristThruReload [get]
 If true, this will not be deleted when the Unity scene changes.
bool WantsUpdate [get]
 Does this SRS want an update tick? MUST override if you're providing an Update method. MUST override with explicit implementation.
bool ReadyForUpdate [get]
 Is this SRS ready for an update? MUST Override if your SRS doesn't always need an update. MUST override with explicit implementation.
string[] AcceptableMessages [get]
 If true, can accept ObjectPacket messages from the Service Manager with command-strings matching those returned here.

Events

Action< GameObject, GameObject >? OnCollidableObjectSpawned
 This event fires when a GO is spawned AND it has a collider. First GO is what was spawned. Second GO is the source prefab To be deemed Collidable it needs to have a TpSpawnlink component on the main (root) GO, the IgnoreCollider flag must be false, and either a Collider or Collider2D component.
Action< GameObject >? OnCollidableObjectDespawned
 This event fires when a GO is despawned AND it has or had a collider. GameObject is what's being despawned To be deemed Collidable it needs to have a TpSpawnlink component on the main (root) GO, the IgnoreCollider flag must be false, and either a Collider or Collider2D component.

Additional Inherited Members

Static Protected Member Functions inherited from TilePlus.ScriptableRuntimeService< T >
static void Create ()
 Create and initialize method.

Detailed Description

Pooled spawner for TilePlus system.

Member Enumeration Documentation

◆ PositioningMode

Enum PositioningMode.

Enumerator
UseAssetSetting 

Use the setting from the asset.

AtTilePosition 

At the tile's grid position.

AtContactPosition 

At the contact position sent to MessageTarget.

RandomInZone 

Randomly in the Zone.

◆ TileParentingMode

How to parent painted tiles.

Enumerator
SameParentAsTile 

Use the same parent as the Tile.

ParentByReference 

Use a provided tilemap reference.

ParentByTag 

Use a Tag.

ParentByName 

Use a Name.

Member Function Documentation

◆ CanPollForDetails()

override bool TilePlus.TpSpawner.CanPollForDetails ( )
virtual

Used by SRS inspector. If the contents of an SRS change frequently then this should be overridden to return true.

Returns
T/F
accessed via reflection (editor only) don't change this to a prop or change the name

Reimplemented from TilePlus.ScriptableRuntimeService< T >.

◆ DespawnPrefab()

void TilePlus.TpSpawner.DespawnPrefab ( int sourcePrefabId,
GameObject? target )

Despawn a prefab into the pool.

Parameters
sourcePrefabIdInstance Id of source prefab
targetthe instantiated prefab

If the sourcePrefabId isn't found in m_Pools then the target is Destroyed.

◆ Details()

override string TilePlus.TpSpawner.Details ( int limit = -1)
virtual

Get a string with the pool status.

Parameters
limitLimit the number of pools shown

returns>A string with the Pools' status

Reimplemented from TilePlus.ScriptableRuntimeService< T >.

◆ GetPaintingTilemap()

Tilemap? TilePlus.TpSpawner.GetPaintingTilemap ( TileParentingMode parentingMode,
string mapNameOrTag,
string info )

Get the tilemap for painting.

Parameters
parentingModesearch by tag,name,etc
mapNameOrTagsearch string
infowill print this if an error/warning/log
Returns
Tilemap to use for painting or null for not found.

◆ IsCollidable()

bool TilePlus.TpSpawner.IsCollidable ( GameObject go)

Returns true if a spawned GO is a collidable.

Parameters
goGameObj to test
Returns
true if this GO is in the collidables HashSet

If the prefab adds or removes a collider AFTER it is spawned then using this test is useless.

◆ IsPreloaded()

bool TilePlus.TpSpawner.IsPreloaded ( GameObject prefab)

has this prefab already been preloaded?

Parameters
prefabprefab to test
Returns
true if preloaded already

◆ OnDisable()

override void TilePlus.TpSpawner.OnDisable ( )
virtual

Unity event method.

Reimplemented from TilePlus.ScriptableRuntimeService< T >.

◆ OnEnable()

override void TilePlus.TpSpawner.OnEnable ( )
virtual

OnEnable.

Reimplemented from TilePlus.ScriptableRuntimeService< T >.

◆ PaintTile()

TilePlusBase? TilePlus.TpSpawner.PaintTile ( PaintingSpec? item,
TilePlusBase sourceTile,
Tilemap? paintTarget,
TilePaintPosition paintPos = TilePaintPosition::None )

Paint a tile from the TpTileList asset by index. Note that null is returned if the position is occupied. Also, you can change the tilemap to use for painting with the m_PaintingTilemap field in-editor or via code.

Parameters
itemPainting spec for the tile to paint
sourceTileA tile instance that implements the ISpawner interface.
paintTargetTarget tilemap. If it's the same as the sourceTile's map and paint position ends up being the same as the sourceTile position then nothing is painted.
paintPosNone, use paintPos from tile asset, else overrides tile spec.
Returns
tile that was painted or null if error
Exceptions
System.ArgumentOutOfRangeException

If paintPos from asset is None then use a random position, if paintPos from asset is Top then if the target tilemap is different than this tile's parent then use the same grid position as this tile.

◆ Preload()

void TilePlus.TpSpawner.Preload ( GameObject? prefab,
int quantity )

Preload a pool.

Parameters
prefabPrefab to preload
quantityhow many instances to preload

◆ ResetPools()

void TilePlus.TpSpawner.ResetPools ( )

Reset all prefab pools. V3.1 and later: also clears collidableGO hashset.

Pools are cleared, which Destroys the pooled prefabs. Any prefabs that have been taken from the pool BUT are NOT released to the pool will NOT be destroyed.

◆ SpawnPrefab()

GameObject? TilePlus.TpSpawner.SpawnPrefab ( GameObject? prefab,
Vector3 position,
Transform? parentTransform = null,
string parentNameOrTag = "",
bool searchForTag = false,
bool keepWorldPosition = true )

Spawn a single prefab. Always uses pooling.

Parameters
prefabthe prefab asset reference
positionworld position to spawn at
parentTransformParent transform - can be null
parentNameOrTagName or tag of parent if Transform is null
searchForTagIf transform is null AND parentNameOrTag isn't empty, search for tag if this is true, otherwise search for name
keepWorldPositionKeep world position relative to parent if one is provided or located via name or tag. See Transform.SetParent
Returns
Spawned GameObj or null for error

If parent is NULL and parentNameOrTag is not an empty string then a parent is searched for by tag or name depending on value of searchForTag. If no parent is found then spawned item is not parented or remains parented to TppPoolHost. If that's what you want, leave parent=null and parentNameOrTag=string.Empty

◆ SpawnPrefabFromTile()

GameObject? TilePlus.TpSpawner.SpawnPrefabFromTile ( TilePlusPrefabSpawnerItem spawnerItem,
TilePlusBase tile,
Transform? altParent,
bool keepWorldPosition )

Spawn a single prefab from a tile that implements the ISpawner interface.

Parameters
spawnerItemitem from the prefab list
tileA tile instance that implements the ISpawner interface
altParentif null, uses info from asset
keepWorldPositionKeep world position relative to parent if using altParent. See Transform.SetParent
Returns
Spawned GameObj or null for error
Exceptions
System.ArgumentOutOfRangeException

Will log an error if tile does not implement ITpSpawnUtilClient

◆ Status()

override string TilePlus.TpSpawner.Status ( )
virtual

The TilePlus SysInfo window will show all SRS 'Status' strings when playing in-editor (if the 'show' checkbox is checked). This is totally optional.

Reimplemented from TilePlus.ScriptableRuntimeService< T >.

◆ TestCollidable()

bool TilePlus.TpSpawner.TestCollidable ( GameObject go)

Test for colliders.

Parameters
goGameObject
Returns
true if GO or children has a collider or collider2d and top level of GO needs TpSpawnlink w IgnoreCollider flag=false

Property Documentation

◆ AllCollidableSpawnedPrefabs

GameObject [] TilePlus.TpSpawner.AllCollidableSpawnedPrefabs
get

Get an array of all Collidables. Note: uses LINQ and may generate some GC.

◆ CleanPoolHostName

string TilePlus.TpSpawner.CleanPoolHostName
get

Get the pool host name with no advice.

◆ NumCollidables

int TilePlus.TpSpawner.NumCollidables
get

Total number of Collidables.

◆ NumPooledPrefabs

int TilePlus.TpSpawner.NumPooledPrefabs
get

total Number of pooled prefabs

The number of pooled prefabs.

◆ PoolHostName

string TilePlus.TpSpawner.PoolHostName
get

Gets the name of the pool host.

The name of the pool host.

Event Documentation

◆ OnCollidableObjectDespawned

Action<GameObject>? TilePlus.TpSpawner.OnCollidableObjectDespawned

This event fires when a GO is despawned AND it has or had a collider. GameObject is what's being despawned To be deemed Collidable it needs to have a TpSpawnlink component on the main (root) GO, the IgnoreCollider flag must be false, and either a Collider or Collider2D component.

◆ OnCollidableObjectSpawned

Action<GameObject, GameObject>? TilePlus.TpSpawner.OnCollidableObjectSpawned

This event fires when a GO is spawned AND it has a collider. First GO is what was spawned. Second GO is the source prefab To be deemed Collidable it needs to have a TpSpawnlink component on the main (root) GO, the IgnoreCollider flag must be false, and either a Collider or Collider2D component.


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