Skip to main content

PooledObject

A class in Root.Township, the global namespace.

Component on a prefab that can be reused through a PooledObjectDefinition pool instead of being destroyed. Used for short-lived local effects.

Constructors​

MemberWhat it is
PooledObject()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Properties​

MemberWhat it is
bool IsReleased { get; private set; }True while the instance sits in the pool unused.
string Name { get; private set; }The GameObject name, captured when the pool created it.
BasicPooledObjectPool Pool { get; private set; }The pool this instance belongs to. Null if it was not made by a pool.

Events​

MemberWhat it is
event PoolChangedHandler ReleasedRaised after the instance goes back to the pool.
event PoolChangedHandler RequestedRaised when the instance is taken from the pool.

Methods​

MemberWhat it is
virtual void FinishRequest()Called by the pool after placing a requested instance. Marks it in use and raises Requested.
void Initialize(BasicPooledObjectPool pool)Called by the pool on a new instance. Links it to the pool and marks it released.
virtual void Release()Returns the instance to its pool (deactivating it, or destroying it if the pool is full). Destroys it if it has no pool.
virtual void ResetRun()Hook for subclasses to restart their effect. Empty in the base class.
protected virtual void OnDestroy()Clears the Released and Requested handlers.
1 private and internal method
MemberWhat it is
private void OnReleased()Called by the pool once the object is back in it; marks it released and raises Released.

Used in​

Members of other types that take, return or hold a PooledObject:

AchievementEffectHandler.MoveQueue, AddonCraftingPart.addon, ForgedModel<TB, TA>.MeshEffectReleased, Smelter.activeOperationSmoke, RecipePlacer.currentPulsator, LiquidChunkVisuals.AddNewChunkVisuals, LiquidChunkVisuals.RemoveChunkVisuals, LiquidChunkVisuals.LiquidChunkData.CurrentVisuals, LiquidVisualChunkDefinition.SpawnVisuals, GenericCraftingNail.DisableTimer, WaterfallEffect.AttachTo, WaterfallEffectGenerator.pooled, HeatPoint.ActiveEffect, HeatSourceBase.activeEffect, ImpactDetectorSettings.LastEffect, PooledFixedImpactor.targetPooledObject, Phantom.activeVisionAttackEffect, SeedSpray.Seed.pooledObject, LiquidParticleMarker.ResetContainer, PouringParticles.StartParticlesAgain, DownedState.respawnOrbObject, EquipmentState.activeName, DevToolsBoard.activeSettings, QuickAccessSettingsBoard.activeSettings, ReturnToMainMenuAction.activeGlyph, ReturnToMainMenuAction.activeOrbObject, TextPopup.PooledObject, RespawnShrineSubscriberMarkController.subscriberMarks, AvailablePointCrystal.FadeOnRequest, BasicPooledObjectPool.pooledObjects, BasicPooledObjectPool.Release, BasicPooledObjectPool.Request, Bellows.particlesObjects, CastToSurfaceEffect.CastToGround, CastToSurfaceEffect.StoreCasted, ColoredExplosive.GetEffect, ColoredPooledParticleSpawner.SpawnedParticles, ColorFadeRelease.ResetSystems, ConglomerateDestroyByTime.CheckNearby, CrystalsAvailablePointManager.activeVisuals, CrystalsAvailablePointManager.temporaryVisuals, DestroyByTime.StartRuning, DurabilityGlobalSettings.GetEffect, DurabilityModule.SetupEffect, DurabilityStateChangeEffect.CleanUp, DurabilityStateChangeEffect.OnRequested, EffectReleaseOnFade.SetupRequest, EmberComposer.activeEffects, EmberComposerFireEffect.RequestedStart, EmissionControl.ResetSystems, EmissionShapeControl.ResetSystems, Explosive.GetEffect, GhostBook.OnRequest, InGameGizmosSettings.DrawLine, InGameGizmosSettings.DrawSphere, InGameLineGizmo.RequestedSetup, InGameSphereGizmo.RequestedSetup, InteractableInspector.OnRequested, LifeTimeEffect.pooledEffect, MaxLimitPooledObjectPool.activeObjects and 56 more.