Skip to main content

PooledObjectDefinition

A class in Root.Township, the global namespace.

A ScriptableObject asset describing an object pool: which PooledObject prefab to reuse and how many to keep. Call Get to take an instance from the pool.

Constructors​

MemberWhat it is
PooledObjectDefinition()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

7 private and internal fields
MemberWhat it is
private int initializeSizeHow many objects to create up front when the pool is made (capped by maximumPoolSize).
private bool isMaxSizeLimittingWhen true the pool never has more than maximumPoolSize objects active; otherwise it only limits how many it keeps spare.
private bool isMaxSizeLimittingOnAndroidAndroid version of isMaxSizeLimitting. Not read anywhere in this build.
private static Logger loggerNLog logger for this class.
private int maximumPoolSizeMost objects the pool keeps (or allows active, with isMaxSizeLimitting).
private int maximumPoolSizeAndroidAndroid pool size. Not read anywhere in this build.
private PooledObject prefabThe pooled object prefab this definition spawns.

Properties​

MemberWhat it is
int InitializePoolSize { get; }How many instances are created up front, inactive, when the pool is made.
int MaximumPoolSize { get; }How many released instances the pool keeps. With limiting on, also the most that can be active at once (the oldest gets recycled). The Android size field is never read.
BasicPooledObjectPool Pool { get; private set; }The pool, created on first InitializePool or Get. A max-limit pool if the asset has size limiting on, otherwise a plain pool.
PooledObject Prefab { get; }The PooledObject prefab the pool instantiates.

Methods​

MemberWhat it is
override PooledObject Get(Vector3 position, Quaternion rotation)Takes an instance from the pool (or makes a new one), places it at the given position and rotation and activates it.
override void InitializePool()Creates the pool if it doesn't exist yet.

Used in​

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

ActionGlyphsPlacer.actionGlyphPool, AddonCraftingPart.jointAddon, PlayerEffectController.teleportEffect, Smelter.operationalSmoke, RecipePlacer.blowUpPiece, RecipePlacer.pulsatorDefinition, TimberBlock.hittinPiece, TimberBlock.Stage.concludedEffect, TimberBlock.Stage.destroyingEffect, TimberBlock.Stage.DestroyingEffect, TimberPieceBase.hittinEffect, CaveTeleportSettings.arriveAtCaveEffect, CaveTeleportSettings.arriveAtSurfaceEffect, CaveTeleportSettings.departFromCaveEffect, CaveTeleportSettings.departFromSurfaceEffect, PlayerCharacter.teleporterTrail, DeathAnimationSettings.deathVisual, DeathAnimationSettings.DeathVisual, DeathAnimationSettings.deathVisualGroundPosition, DeathAnimationSettings.DeathVisualGroundPosition, DeathAnimationSettings.preDeathVisual, DeathAnimationSettings.PreDeathVisual, Cookable.burntEffect, Cookable.cookedEffect, Cookable.ReplaceWith, CookingPoint.androidBurningEffect, CookingPoint.androidCookingEffect, CookingPoint.burningEffect, CookingPoint.cookingEffect, CookingSettings.androidBoilingParticlesDefinition, CookingSettings.boilingParticlesDefinition, CookingSettings.BoilingParticlesDefinition, CookingSettings.stewIngredientsFilledEffect, CookingSettings.StewIngredientsFilledEffect, CookingSettings.stewRecipeStartedEffect, CookingSettings.StewRecipeStartedEffect, CookingSettings.textPopupDefinition, CookingSettings.TextPopupDefinition, LiquidVisualChunkDefinition.pooledObjectDefinition, StewComponent.stewCreatedEffect, StewComponent.StewCreatedEffect, GenericCraftingSettings.androidDestroyedPieceEffect, GenericCraftingSettings.androidPieceCompletedAnimation, GenericCraftingSettings.destroyedPieceEffect, GenericCraftingSettings.DestroyedPieceEffect, GenericCraftingSettings.genericNailDefaultDefinition, GenericCraftingSettings.GenericNailDefaultDefinition, GenericCraftingSettings.genericPieceDefinition, GenericCraftingSettings.GenericPieceDefinition, GenericCraftingSettings.pieceCompletedAnimation, GenericCraftingSettings.PieceCompletedAnimation, NailSettings.nailDefinition, CustomizationSettings.addedEffect, CustomizationSettings.AddedEffect, CustomizationSettings.disappearEffect, CustomizationSettings.DisappearEffect, WaterfallEffect.AttachTo, WaterfallEffectGenerator.effect, HeatPoint.AddEffect, HeatSourceBase.fireEffect and 209 more.