Skip to main content

SpawnHelper

A static class in Root.Township, the global namespace.

Static shortcuts for spawning network prefabs on the server, placing them in a chunk or under a chunking parent. See the Spawning guide.

Properties​

MemberWhat it is
static SpawnManager Manager { get; set; }The SpawnManager used for spawning. Set by the spawn manager when it starts.

Methods​

MemberWhat it is
static NetworkEntity Spawn(NetworkPrefab prefab, SpawnData spawnData, NetworkEntity chunkingParent, SaveMode saveMode, SpawnHelper.SpawningCallback position = null, SpawnHelper.SpawningCallback preChunking = null)Server: spawns a prefab (by prefab or hash), places it, initializes it and puts it in a chunk or under a chunking parent.
static NetworkEntity Spawn(uint prefabHash, SpawnData spawnData, NetworkEntity chunkingParent, SaveMode saveMode, SpawnHelper.SpawningCallback position = null, SpawnHelper.SpawningCallback preChunking = null)Server: spawns a prefab (by prefab or hash), places it, initializes it and puts it in a chunk or under a chunking parent.
static NetworkEntity Spawn(uint prefabHash, SpawnData spawnData, Chunk chunk, SpawnHelper.SpawningCallback position = null, SpawnHelper.SpawningCallback preChunking = null)Server: spawns a prefab (by prefab or hash), places it, initializes it and puts it in a chunk or under a chunking parent.
static NetworkEntity Spawn(NetworkPrefab prefab, SpawnData spawnData, Chunk chunk, SpawnHelper.SpawningCallback position = null, SpawnHelper.SpawningCallback preChunking = null)Server: spawns a prefab (by prefab or hash), places it, initializes it and puts it in a chunk or under a chunking parent.
static NetworkEntity Spawn(NetworkPrefab prefab, SpawnData spawnData, NetworkEntity chunkingParent, SaveMode saveMode, Vector3 position, Quaternion rotation, SpawnHelper.SpawningCallback preChunking = null)Server: spawns a prefab (by prefab or hash), places it, initializes it and puts it in a chunk or under a chunking parent.
static NetworkEntity Spawn(uint prefabHash, SpawnData spawnData, Chunk chunk, Vector3 position, Quaternion rotation = null, SpawnHelper.SpawningCallback preChunking = null)Server: spawns a prefab (by prefab or hash), places it, initializes it and puts it in a chunk or under a chunking parent.
static NetworkEntity Spawn(NetworkPrefab prefab, SpawnData spawnData, Chunk chunk, Vector3 position, Quaternion rotation = null, SpawnHelper.SpawningCallback preChunking = null)Server: spawns a prefab (by prefab or hash), places it, initializes it and puts it in a chunk or under a chunking parent.
static NetworkEntity Spawn(NetworkPrefab prefab, SpawnData spawnData, NetworkEntity chunkingParent, SaveMode saveMode, Transform parent, Vector3 localPosition = null, Quaternion localRotation = null, SpawnHelper.SpawningCallback preChunking = null)Server: spawns a prefab (by prefab or hash), places it, initializes it and puts it in a chunk or under a chunking parent.
static NetworkEntity Spawn(uint prefabHash, SpawnData spawnData, NetworkEntity chunkingParent, SaveMode saveMode, Transform parent, Vector3 localPosition = null, Quaternion localRotation = null, SpawnHelper.SpawningCallback preChunking = null)Server: spawns a prefab (by prefab or hash), places it, initializes it and puts it in a chunk or under a chunking parent.
static NetworkEntity Spawn(NetworkPrefab prefab, SpawnData spawnData, Chunk chunk, Transform parent, Vector3 localPosition = null, Quaternion localRotation = null, SpawnHelper.SpawningCallback preChunking = null)Server: spawns a prefab (by prefab or hash), places it, initializes it and puts it in a chunk or under a chunking parent.
static bool SpawnDocked(uint prefabHash, int count, SpawnData spawnData, PickupDock dock, Chunk fallbackChunk = null, Action<Pickup> preDockModify = null)Server: spawns an item and docks the count into a dock. On failure it drops it nearby or destroys it, and returns false.
static bool SpawnDocked(Item item, int count, SpawnData spawnData, PickupDock dock, Chunk fallbackChunk = null, Action<Pickup> preDockModify = null)Server: spawns an item and docks the count into a dock. On failure it drops it nearby or destroys it, and returns false.
static NetworkEntity SpawnPouchOrPickup(Item item, int count, SpawnData spawnData, Chunk chunk, Vector3 position, Quaternion rotation = null)Server: spawns a pouch holding the items when there are several stackable ones, otherwise a single item.
static NetworkEntity SpawnUnchunked(NetworkPrefab prefab, SpawnData spawnData)Server: spawns and initializes a prefab without giving it a chunk. You must set one, dock it, or destroy it.
static NetworkEntity SpawnUnchunked(uint prefabHash, SpawnData spawnData)Server: spawns and initializes a prefab without giving it a chunk. You must set one, dock it, or destroy it.
2 private and internal methods
MemberWhat it is
private static bool SpawnDockedPickup(Pickup pickup, int count, PickupDock dock, Chunk fallbackChunk, Action<Pickup> preDockModify)Docks a freshly spawned pickup into a dock. If that fails, it drops the pickup at the dock in the fallback (or dock's) chunk, or destroys it.
private static NetworkEntity SpawnPouch(Item item, int count, SpawnData spawnData, Chunk chunk, Vector3 position, Quaternion rotation = null)Spawns a pouch at a position (random yaw by default) and fills it with a stack of the item; destroys the pouch if docking fails.