Skip to main content

RandomPooledObjectDefinition

A class in Root.Township, the global namespace.

Pooled object definition asset that picks one of several pooled definitions by weight each time an object is requested.

Constructors​

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

Fields​

2 private and internal fields
MemberWhat it is
private RandomPooledObjectDefinition.PooledObjectElement[] definitionsPooled definitions with their weights.
private int totalWeightSum of all weights, set by InitializePool.

Methods​

MemberWhat it is
override PooledObject Get(Vector3 position, Quaternion rotation)Meant to pick a definition by weight and get an object from it. The roll is cast to int before scaling, so it almost always picks the first entry with weight above 0.
override void InitializePool()Initializes every listed definition's pool and totals their weights.