Skip to main content

LootModule

A class in Root.Township, Alta.Loot.

Server: fills the parent PickupDockGroup with generated loot on first spawn and again every respawnFrequency (default 48 hours), using the chunk's biome or an override. A one-off module spawns once and then destroys itself.

Constructors​

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

Fields​

10 private and internal fields
MemberWhat it is
private PickupDockGroup groupBacking field for Group.
private float incrementingFailChanceFail chance passed to LootHelper.Spawn (default 0.05), probably added per item spawned.
private bool isOneOffSpawn once after a short delay, then destroy this entity.
private static Logger loggerLogger for this class.
private Biome overrideBiomeBiome to generate loot from instead of the chunk's.
private float prosperityProsperity attribute set on the spawn data, which affects loot quality (default 1).
private bool respawnEditor button that calls Respawn.
private float respawnFrequencySeconds between refills (default 172800, 48 hours); saved values under 60 are ignored.
private SpawnData spawnDataSpawn data reused for every refill, made on the first one.
private Timeline.IEntry waitToRefillTimeline entry for the repeating refill; saved so the countdown survives restarts.

Properties​

MemberWhat it is
PickupDockGroup Group { get; }The PickupDockGroup in a parent that loot is spawned into, found on first use.
bool IsGenerationValueUsed { get; }Always true.

Methods​

MemberWhat it is
override void InitializeAsServer(SpawnData spawnData)Server: spawns loot if the entity is being generated (or is one-off) and starts the repeating refill timer.
4 private and internal methods
MemberWhat it is
private void OnDestroy()Cancels the refill timer.
private void OnValidate()Editor: sets the prefab's save mode to Child.
private void Respawn()Spawns loot into the group with LootHelper.Spawn, building spawn data from the chunk or override biome with this module's prosperity. Destroys the entity if one-off.
private void Respawn(int count)Spawns loot into the group with LootHelper.Spawn, building spawn data from the chunk or override biome with this module's prosperity. Destroys the entity if one-off.