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.FusionAdapter.FusionPoolProvider Class Referencesealed

Photon Fusion 2.x INetworkObjectProvider that provisions objects from a project-wide pool via IPoolAdapter, instead of allocating with Instantiate/Destroy. More...

Inheritance diagram for MegaCrush.Spawner.FusionAdapter.FusionPoolProvider:

Public Member Functions

 FusionPoolProvider (IPoolAdapter pool)
 Creates a provider that bridges Fusion provisioning to the project pool.
 
void RegisterPrefab (NetworkRunner runner, NetworkPrefabId prefabId, GameObject prefab, int prewarm=0)
 Registers a prefab mapping for a known NetworkPrefabId and optionally prewarms the pool.
 
void Prewarm (GameObject prefab, int count)
 Prewarms the underlying pool with instances of prefab .
 
NetworkObjectAcquireResult AcquirePrefabInstance (NetworkRunner runner, in NetworkPrefabAcquireContext context, out NetworkObject instance)
 
void ReleaseInstance (NetworkRunner runner, in NetworkObjectReleaseContext context)
 
NetworkPrefabId GetPrefabId (NetworkRunner runner, NetworkObjectGuid prefabGuid)
 

Public Attributes

bool DelayIfSceneManagerIsBusy = true
 If true, AcquirePrefabInstance returns NetworkObjectAcquireResult.Retry while INetworkSceneManager.IsBusy is true. Mirrors Fusion sample behavior to let scene loads complete before provisioning.
 

Private Attributes

readonly IPoolAdapter _pool
 
readonly Dictionary< NetworkPrefabId, GameObject > _prefabMap = new()
 Local cache of prefab lookups keyed by NetworkPrefabId to reduce repeated calls into NetworkRunner.Prefabs.
 

Detailed Description

Photon Fusion 2.x INetworkObjectProvider that provisions objects from a project-wide pool via IPoolAdapter, instead of allocating with Instantiate/Destroy.

Construct this provider in your Fusion bootstrap and assign it to StartGameArgs.ObjectProvider when starting a NetworkRunner. Fusion will then call AcquirePrefabInstance and ReleaseInstance to obtain/return NetworkObject instances. Prefab resolution is handled through NetworkRunner.Prefabs.

The provider caches a lightweight mapping from NetworkPrefabId to prefab GameObject to avoid repeated registry lookups. Pool sizing/creation is delegated to IPoolAdapter.

This is the non-MonoBehaviour counterpart to FusionPoolObjectProviderBehaviour. Both can be used by FusionObjectFactory for prewarming via Prewarm(GameObject,int).

Constructor & Destructor Documentation

◆ FusionPoolProvider()

MegaCrush.Spawner.FusionAdapter.FusionPoolProvider.FusionPoolProvider ( IPoolAdapter pool)

Creates a provider that bridges Fusion provisioning to the project pool.

Parameters
poolProject-wide pool adapter used to get/return instances.

Member Function Documentation

◆ AcquirePrefabInstance()

NetworkObjectAcquireResult MegaCrush.Spawner.FusionAdapter.FusionPoolProvider.AcquirePrefabInstance ( NetworkRunner runner,
in NetworkPrefabAcquireContext context,
out NetworkObject instance )

◆ GetPrefabId()

NetworkPrefabId MegaCrush.Spawner.FusionAdapter.FusionPoolProvider.GetPrefabId ( NetworkRunner runner,
NetworkObjectGuid prefabGuid )

◆ Prewarm()

void MegaCrush.Spawner.FusionAdapter.FusionPoolProvider.Prewarm ( GameObject prefab,
int count )

Prewarms the underlying pool with instances of prefab .

Parameters
prefabPrefab to prime in the pool.
countNumber of instances to precreate (ignored if <= 0).

Convenience overload when you already have a prefab reference (e.g., from a SpawnEntry), and the provider is used as NetworkRunner.ObjectProvider.

◆ RegisterPrefab()

void MegaCrush.Spawner.FusionAdapter.FusionPoolProvider.RegisterPrefab ( NetworkRunner runner,
NetworkPrefabId prefabId,
GameObject prefab,
int prewarm = 0 )

Registers a prefab mapping for a known NetworkPrefabId and optionally prewarms the pool.

Parameters
runnerActive Fusion runner.
prefabIdPrefab identifier used by Fusion for spawning.
prefabPrefab GameObject associated with prefabId .
prewarmNumber of instances to precreate in the pool (0 = none).

Optional. The cache will auto-populate on first acquisition if not registered.

◆ ReleaseInstance()

void MegaCrush.Spawner.FusionAdapter.FusionPoolProvider.ReleaseInstance ( NetworkRunner runner,
in NetworkObjectReleaseContext context )

Member Data Documentation

◆ _pool

readonly IPoolAdapter MegaCrush.Spawner.FusionAdapter.FusionPoolProvider._pool
private

◆ _prefabMap

readonly Dictionary<NetworkPrefabId, GameObject> MegaCrush.Spawner.FusionAdapter.FusionPoolProvider._prefabMap = new()
private

Local cache of prefab lookups keyed by NetworkPrefabId to reduce repeated calls into NetworkRunner.Prefabs.

◆ DelayIfSceneManagerIsBusy

bool MegaCrush.Spawner.FusionAdapter.FusionPoolProvider.DelayIfSceneManagerIsBusy = true

If true, AcquirePrefabInstance returns NetworkObjectAcquireResult.Retry while INetworkSceneManager.IsBusy is true. Mirrors Fusion sample behavior to let scene loads complete before provisioning.


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