|
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.
|
Photon Fusion 2.x INetworkObjectProvider that provisions objects from a project-wide pool via IPoolAdapter, instead of allocating with Instantiate/Destroy.
More...
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. | |
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).
| MegaCrush.Spawner.FusionAdapter.FusionPoolProvider.FusionPoolProvider | ( | IPoolAdapter | pool | ) |
Creates a provider that bridges Fusion provisioning to the project pool.
| pool | Project-wide pool adapter used to get/return instances. |
| NetworkObjectAcquireResult MegaCrush.Spawner.FusionAdapter.FusionPoolProvider.AcquirePrefabInstance | ( | NetworkRunner | runner, |
| in NetworkPrefabAcquireContext | context, | ||
| out NetworkObject | instance ) |
| NetworkPrefabId MegaCrush.Spawner.FusionAdapter.FusionPoolProvider.GetPrefabId | ( | NetworkRunner | runner, |
| NetworkObjectGuid | prefabGuid ) |
| void MegaCrush.Spawner.FusionAdapter.FusionPoolProvider.Prewarm | ( | GameObject | prefab, |
| int | count ) |
Prewarms the underlying pool with instances of prefab .
| prefab | Prefab to prime in the pool. |
| count | Number 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.
| 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.
| runner | Active Fusion runner. |
| prefabId | Prefab identifier used by Fusion for spawning. |
| prefab | Prefab GameObject associated with prefabId . |
| prewarm | Number of instances to precreate in the pool (0 = none). |
Optional. The cache will auto-populate on first acquisition if not registered.
| void MegaCrush.Spawner.FusionAdapter.FusionPoolProvider.ReleaseInstance | ( | NetworkRunner | runner, |
| in NetworkObjectReleaseContext | context ) |
|
private |
|
private |
Local cache of prefab lookups keyed by NetworkPrefabId to reduce repeated calls into NetworkRunner.Prefabs.
| 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.