Runtime Spawner 1.5.1
Generic Runtime spawn and instance pooling system for spawning random AI agents around a map. Works with ANY AI system easily.
Loading...
Searching...
No Matches
MegaCrush.Spawner.BasicSpawnHandle Class Reference

Minimal, reusable implementation of ISpawnHandle used by the core RuntimeSpawner system. More...

Inheritance diagram for MegaCrush.Spawner.BasicSpawnHandle:
MegaCrush.Spawner.ISpawnHandle

Public Member Functions

 BasicSpawnHandle (GameObject instance, bool isNetworked, Component netIdentity, Action< GameObject > despawnAction)
 Creates a new BasicSpawnHandle.
 
virtual bool TryGetNetworkComponent< T > (out T component)
 Attempts to retrieve a component of type T from the spawned instance.
 
virtual void Despawn ()
 Executes the configured despawn action, if any, and clears the Instance reference.
 

Protected Member Functions

Component GetRawIdentity ()
 Provides direct access to the raw network identity component, if present.
 

Protected Attributes

readonly Action< GameObject > _despawnAction
 Action invoked when Despawn is called.
 
readonly Component _netIdentity
 Optional network identity or backend component associated with the instance.
 

Properties

GameObject Instance [get, protected set]
 The spawned GameObject instance.
 
bool IsNetworked [get, protected set]
 Indicates whether the instance represents a networked object.
 
- Properties inherited from MegaCrush.Spawner.ISpawnHandle

Detailed Description

Minimal, reusable implementation of ISpawnHandle used by the core RuntimeSpawner system.

This handle tracks a spawned GameObject and an optional network identity component, and delegates despawn behavior to a user-supplied Action<T>.

Integration adapters (e.g., Photon Fusion, PUN, or custom pooling systems) can either:

  • Use this class directly when no engine-specific logic is needed, or
  • Subclass it to add engine-specific behavior (e.g., networked despawn, ownership transfer, etc.).

The core package never assumes a specific networking backend, keeping this type Unity-only.

Constructor & Destructor Documentation

◆ BasicSpawnHandle()

MegaCrush.Spawner.BasicSpawnHandle.BasicSpawnHandle ( GameObject instance,
bool isNetworked,
Component netIdentity,
Action< GameObject > despawnAction )

Creates a new BasicSpawnHandle.

Parameters
instanceThe spawned GameObject instance.
isNetworkedWhether the instance represents a networked object. Purely informational in core.
netIdentityOptional backend identity component (e.g., NetworkObject, PhotonView). Used only by derived adapters.
despawnActionAction invoked when Despawn is called. May be null for manual cleanup.

Member Function Documentation

◆ Despawn()

virtual void MegaCrush.Spawner.BasicSpawnHandle.Despawn ( )
virtual

Executes the configured despawn action, if any, and clears the Instance reference.

This method is safe to call multiple times; subsequent calls will no-op once Instance is null.

Implements MegaCrush.Spawner.ISpawnHandle.

◆ GetRawIdentity()

Component MegaCrush.Spawner.BasicSpawnHandle.GetRawIdentity ( )
protected

Provides direct access to the raw network identity component, if present.

Returns
The identity component associated with the instance, or null if none.

This helper exists primarily for adapter subclasses to expose backend-specific identifiers without polluting the core interface.

◆ TryGetNetworkComponent< T >()

virtual bool MegaCrush.Spawner.BasicSpawnHandle.TryGetNetworkComponent< T > ( out T component)
virtual

Attempts to retrieve a component of type T from the spawned instance.

Template Parameters
TThe component type to query.
Parameters
componentWhen this method returns, contains the requested component or null.
Returns
true if the component exists; otherwise false.

Implements MegaCrush.Spawner.ISpawnHandle.

Type Constraints
T :Component 

Member Data Documentation

◆ _despawnAction

readonly Action<GameObject> MegaCrush.Spawner.BasicSpawnHandle._despawnAction
protected

Action invoked when Despawn is called.

◆ _netIdentity

readonly Component MegaCrush.Spawner.BasicSpawnHandle._netIdentity
protected

Optional network identity or backend component associated with the instance.

Property Documentation

◆ Instance

GameObject MegaCrush.Spawner.BasicSpawnHandle.Instance
getprotected set

The spawned GameObject instance.

Implements MegaCrush.Spawner.ISpawnHandle.

◆ IsNetworked

bool MegaCrush.Spawner.BasicSpawnHandle.IsNetworked
getprotected set

Indicates whether the instance represents a networked object.

Implements MegaCrush.Spawner.ISpawnHandle.


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