Lunarriftmutationsmanager
Overview
This component tracks which lunar rift mutations (mutated warg, bearger, and deerclops) have been defeated by the player, manages the optional quest progression tied to these defeats (including Wagstaff's appearance and dialogue), and handles reward state for the associated questline. It exists only on the master simulation and is attached to the world entity, not individual players or entities.
Dependencies & Tags
- Requires:
TheWorld.ismastersim(asserted in constructor). - Interacts with:
TheWorld.components.wagboss_tracker(checks Wagboss defeat status).ent.components.health.destroytime(temporarily extended upon mutation defeat if Wagstaff not spawned).
- No tags added or removed.
- No components explicitly added to
inst.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | — | Reference to the world entity the component is attached to. |
task_completed | boolean | false | Indicates whether the full mutation quest reward has been given. |
_MUTATIONS_NAMES | table (array) | {"mutatedwarg", "mutatedbearger", "mutateddeerclops"} | List of mutation prefab names (for mods compatibility). |
_MUTATIONS | table (map) | inverted _MUTATIONS_NAMES | Maps prefab names to numeric indices (e.g., "mutatedwarg" → 1). |
defeated_mutations | table (array) | {} | List of mutation indices (from _MUTATIONS) corresponding to defeated bosses. |
num_mutations | number | 3 | Total number of tracked mutations (#_MUTATIONS_NAMES). |
wagstaff | Entity? | nil | Reference to the currently spawned wagstaff_npc_mutations NPC. |
Main Functions
RefreshDefeatedMutationsTable()
- Description: Resets internal tracking: clears
defeated_mutations, setswagstafftonil, and refreshesnum_mutations. - Parameters: None.
IsWagstaffSpawned()
- Description: Returns
trueifwagstaffis non-nil, currently valid, and not in the process of eroding out (erodingoutfalse). - Parameters: None.
GetNumDefeatedMutations()
- Description: Returns the count of defeated mutations (length of
defeated_mutationsarray). - Parameters: None.
HasDefeatedAllMutations()
- Description: Returns
trueif the number of defeated mutations equalsnum_mutations. - Parameters: None.
HasDefeatedThisMutation(prefab)
- Description: Returns
trueif the givenprefabname (e.g.,"mutatedwarg") corresponds to a defeated mutation. - Parameters:
prefab(string) — The prefab name to check.
SetMutationDefeated(ent)
- Description: Records a new defeat when a tracked mutation boss (
mutatedwarg,mutatedbearger, ormutateddeerclops) dies. Triggers Wagstaff appearance or reward logic. - Parameters:
ent(Entity) — The defeated mutation entity.
TriggerWagstaffAppearance(ent)
- Description: Spawns
wagstaff_npc_mutationsnear the defeated entity (ent) if not already spawned, faces him toward the corpse, and has him comment on the kill. - Parameters:
ent(Entity) — The defeated mutation entity to reference in placement and dialogue.
ShouldGiveReward()
- Description: Returns
trueif either the task is completed or all mutations have been defeated. - Parameters: None.
OnRewardGiven()
- Description: Marks the quest task as completed, broadcasts
"ms_lunarriftmutationsmanager_taskcompleted"event, and resetsdefeated_mutationsif all mutations were defeated. - Parameters: None.
OnSave()
- Description: Serializes
defeated_mutationsandtask_completedstate for networked or save-game persistence. - Parameters: None.
- Returns:
table?— Non-nilonly if data exists to save.
OnLoad(data)
- Description: Restores saved state:
defeated_mutationsandtask_completed, re-broadcasting"ms_lunarriftmutationsmanager_taskcompleted"if needed. - Parameters:
data(table?) — Save data fromOnSave().
GetDebugString()
- Description: Returns a formatted string for debug logs showing defeated mutation names, count, and task completion status.
- Parameters: None.
- Returns:
string
Events & Listeners
- Listens for: None (explicit event listeners not found).
- Triggers/Pushes:
"ms_lunarriftmutationsmanager_taskcompleted"— Pushed on world when reward is given viaOnRewardGiven()(either on first reward or task reset).