Shadowthrall Mimics
Based on game build 722832 | Last updated: 2026-04-27
Overview
ShadowThrall_Mimics is a server-only component that manages the spawning of shadow mimic entities. When Shadow Rifts are active in the rift pool and it is Cavenight, this component periodically attempts to spawn mimic copies of eligible entities near players. Mimics are clones of existing items that behave as shadow-affiliated entities. The component tracks active mimics, respects a global cap via TUNING.ITEMMIMIC_CAP, and coordinates spawn attempts per connected player.
Usage example
-- Server-side only - will assert on client
local inst = CreateEntity()
inst:AddComponent("shadowthrall_mimics")
-- Check if a target can be mimicked
if inst.components.shadowthrall_mimics:IsTargetMimicable(some_entity) then
inst.components.shadowthrall_mimics:SpawnMimicFor(some_entity)
end
-- Check if mimics are currently enabled
if inst.components.shadowthrall_mimics:IsEnabled() then
-- Shadow Rifts are active and it is Cavenight
end
Dependencies & tags
External dependencies:
prefabs/itemmimic_data-- providesMUST_TAGSandCANT_TAGSfor entity filtering
Components used:
riftspawner-- checksRiftIsShadowAffinity()to determine if Shadow Rifts are activeitemmimic-- added to spawned mimic entities to mark them as mimicsTransform-- used for position queries and setting mimic spawn locations
Tags:
- None identified (uses tag checks via
itemmimic_data.MUST_TAGSanditemmimic_data.CANT_TAGS)
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | entity | --- | The entity instance that owns this component. |
_activeplayers | table | {} | List of currently connected player entities. |
_activemimics | table | {} | Map of active mimic entities (key = entity, value = true). |
_scheduled_spawn_attempts | table | {} | Map of periodic spawn tasks per player. |
_rift_enabled_modifiers | SourceModifierList | --- | Tracks Shadow Rift modifiers; empty means mimics disabled. |
Main functions
IsTargetMimicable(target)
- Description: Checks whether a target entity is eligible to be mimicked. Returns true if the target has all required tags from
itemmimic_data.MUST_TAGSand none of the excluded tags fromitemmimic_data.CANT_TAGS. - Parameters:
target-- entity instance to check - Returns: boolean -- true if target can be mimicked, false otherwise
- Error states: Errors if
targetis nil or does not haveHasTags/HasOneOfTagsmethods.
SpawnMimicFor(item)
- Description: Attempts to spawn a mimic copy of the given item. First validates the item via
IsTargetMimicable(), then calls internal spawn logic. The mimic is spawned at a random walkable offset near the original item and inherits the original's prefab, skin, and persist data. - Parameters:
item-- entity instance to mimic - Returns:
true, mimicon success;falseon failure (invalid target, no walkable offset, or other spawn failure) - Error states: Errors if
itemis nil or lacks required components for position/prefab queries. Errors if called on client (component asserts master-sim only).
IsEnabled()
- Description: Returns whether shadow mimic spawning is currently enabled. Enabled when at least one Shadow Rift is in the rift pool (tracked via
_rift_enabled_modifiers). - Parameters: None
- Returns: boolean -- true if Shadow Rifts are active, false otherwise
- Error states: None
GetDebugString()
- Description: Returns a debug string showing current active mimic count vs cap and enabled state. Format:
ShadowThrall Mimics: X/Y; ENABLEDorShadowThrall Mimics: X/Y; DISABLED. - Parameters: None
- Returns: string -- debug information
- Error states: None
Debug_PlayerSpawns(player)
- Description: Debug function that immediately triggers a spawn attempt for the specified player. Used for testing spawn logic without waiting for the periodic task.
- Parameters:
player-- player entity to trigger spawn attempt for - Returns: nil
- Error states: Errors if
playeris nil or lacksDoPeriodicTaskmethod.
Events & listeners
- Listens to:
onremove(on mimic entities) -- removes mimic from_activemimicstable when mimic is removedms_playerjoined-- adds player to_activeplayersand starts spawn scheduling if conditions metms_playerleft-- removes player from_activeplayersand cancels their spawn taskms_riftaddedtopool-- enables mimic spawning if the added rift has Shadow affinityms_riftremovedfrompool-- disables mimic spawning if no Shadow Rifts remain in pooliscavenight(world state) -- toggles spawn scheduling based on Cavenight state