Skip to main content

RandomSpawnRectangle

A class in Root.Township, the global namespace.

Server: spawns a random number of items from a distribution at random points in a box, then removes itself. Saved so it can be placed in saves.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private Distribution distributionDistribution the spawned prefabs are picked from.
private int maximumExclusive upper bound on the item count.
private int minimumInclusive lower bound on the item count.
private float minimumUpSmallest up component of a spawned item's up vector, limiting tilt.
private Vector3 sizeSize of the spawn box in local space, from the object's origin.

Methods​

MemberWhat it is
override void InitializeAsServer(SpawnData spawnData)Spawns the items now if the entity is in a chunk, or once it's added to one.
2 private and internal methods
MemberWhat it is
private void OnDrawGizmos()Editor: draws the spawn box in translucent blue.
private void SpawnItems(Chunk chunk)Spawns a random count of prefabs from the distribution in the box, tilted no further than minimumUp, then destroys this entity (or clears the distribution if it has no prefab).