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.
- Listed in World generation
- Inherits or implements
NetworkEntityBehaviour,ISavable<LootModuleSaveData>,ISavableSave<LootModuleSaveData>,ISavableSaveBase - Derived types
LootModuleSaveData - Documented in Loot
Constructors
| Member | What it is |
|---|---|
LootModule() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
10 private and internal fields
| Member | What it is |
|---|---|
private PickupDockGroup group | Backing field for Group. |
private float incrementingFailChance | Fail chance passed to LootHelper.Spawn (default 0.05), probably added per item spawned. |
private bool isOneOff | Spawn once after a short delay, then destroy this entity. |
private static Logger logger | Logger for this class. |
private Biome overrideBiome | Biome to generate loot from instead of the chunk's. |
private float prosperity | Prosperity attribute set on the spawn data, which affects loot quality (default 1). |
private bool respawn | Editor button that calls Respawn. |
private float respawnFrequency | Seconds between refills (default 172800, 48 hours); saved values under 60 are ignored. |
private SpawnData spawnData | Spawn data reused for every refill, made on the first one. |
private Timeline.IEntry waitToRefill | Timeline entry for the repeating refill; saved so the countdown survives restarts. |
Properties
| Member | What 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
| Member | What 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
| Member | What 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. |