Roseinspectableuser
Overview
The RoseInspectableUser component allows an entity (e.g., a player character) to use Rose Glasses to interact with "rose-inspectable" objects or locations. It manages the spawning of Charlie Residue for visual feedback, handles the cooldown state of the glasses, triggers inspect actions, and plays appropriate quips (dialogue or sound effects) based on success or cooldown status. It integrates tightly with the roseinspectable component on target entities and supports both targeted and point-based inspection.
Dependencies & Tags
- Component Dependencies: Requires the host entity to have
components.talkerfor quips andcomponents.player_classifiedfor UI cooldown state updates.components.roseinspectablemust be present on target entities during targeted inspection. - Invalid Tags:
{"lunar_aligned", "notroseinspectable"}— entities possessing either tag are rejected as inspection targets. - Residue Interaction: Spawns a
"charlieresidue"prefab for each inspection attempt and tracks its lifecycle (e.g., removes listeners on entity destruction). - No tags added/removed to the host entity itself.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | (passed) | Reference to the host entity (e.g., player). |
cooldowntime | number | TUNING.SKILLS.WINONA.ROSEGLASSES_COOLDOWNTIME | Duration (in seconds) of the cooldown after a successful inspection. |
target | Entity? | nil | The inspected entity (if inspecting a target). |
point | Vector3? | nil | The inspected world position (if inspecting a point). |
residue | PrefabInstance? | nil | The currently active Charlie Residue instance spawned for inspection feedback. |
quipcooldowntime | number? | nil | Timestamp used to throttle quip repetition (4–5 second interval). |
cooldowntask | Task? | nil | Task handle tracking active cooldown; nil when not in cooldown. |
Note:
cooldowntaskis initialized asnilbut managed dynamically. Properties liketarget,point, andresidueare set per inspection request and reset afterward.
Main Functions
SetCooldownTime(cooldowntime)
- Description: Updates the duration used for cooldowns (used for dynamic tuning, e.g., skill upgrades).
- Parameters:
cooldowntime(number): New cooldown duration in seconds.
GoOnCooldown()
- Description: Cancels any existing cooldown task and starts a new one using the current
cooldowntime. Also sets theroseglasses_cooldownstate in the player’s classified UI. - Parameters: None.
OnCharlieResidueActivated(residue)
- Description: Triggered when a spawned residue is activated (e.g., by player interaction). Performs actual inspection logic: inspects the current
target(if set) or the storedpoint, applies cooldown if needed, and handles cooldown quips. - Parameters:
residue(PrefabInstance): The residue instance being activated. Must matchself.residuefor processing.
SetRoseInpectionOnTarget(target)
- Description: Prepares the component to inspect a specific entity: sets
target, clearspoint, spawns/resets residue, and links the residue to the target viaroseinspectable:HookupResidue. - Parameters:
target(Entity): Entity to inspect.
SetRoseInpectionOnPoint(point)
- Description: Prepares inspection of a world point: clears
target, setspoint, and spawns/resets residue. - Parameters:
point(Vector3or similar): World position to inspect.
ForceDecayResidue()
- Description: Immediately triggers decay of the current
residue, cleaning up listeners first. - Parameters: None.
SpawnResidue()
- Description: Destroys any existing residue and spawns a new
"charlieresidue"prefab at the appropriate location (ontargetor atpoint). Attaches listeners for residue removal. - Parameters: None.
DoRoseInspectionOnPoint()
- Description: Iterates through
ROSEPOINT_CONFIGURATIONSto find and execute an inspection match at the currentpoint. Returnstrueif a match triggered a cooldown (caller should callGoOnCooldown()). - Parameters: None.
- Returns:
boolean—trueif a successful match induce a cooldown.
DoQuip(reason, failed)
- Description: Plays a localized string/audio quip (e.g., cooldown message or announcement) via
talker. Enforces per-quip cooldowns to avoid spam. - Parameters:
reason(string): Key for localized string (e.g.,"ROSEGLASSES_COOLDOWN").failed(boolean): Iftrue, plays a failure quip immediately; otherwise, enforces quip cooldown before playing.
TryToDoRoseInspectionOnTarget(target)
- Description: Validates and initiates inspection of a target entity. Performs pre-flight checks (tags, presence of
roseinspectable, cooldown, residue eligibility). If valid, callsSetRoseInpectionOnTarget()and plays an announcement. - Parameters:
target(Entity): Entity to inspect.
- Returns:
boolean, string—true, ""on success;false, reasonon failure (e.g.,"ROSEGLASSES_INVALID","ROSEGLASSES_COOLDOWN").
TryToDoRoseInspectionOnPoint(pt)
- Description: Initiates point-based inspection: sets
pointand spawns residue, then announces inspection. - Parameters:
pt(Vector3): Point in the world to inspect.
- Returns:
boolean— Alwaystrue.
ApplyCooldown(duration)
- Description: Creates a delayed task to end the cooldown after
duration, updates UI state, and cancels any previous cooldown task. - Parameters:
duration(number): Cooldown duration in seconds.
OnCooldown()
- Description: Ends the cooldown state by clearing
cooldowntaskand updating UI state. - Parameters: None.
IsInCooldown()
- Description: Returns whether the component is currently in cooldown.
- Returns:
boolean.
OnSave()
- Description: Saves remaining cooldown time for persistence.
- Returns:
table— Containscooldownkey with remaining seconds if active.
OnLoad(data)
- Description: Restores active cooldown from saved data.
- Parameters:
data(table?): Saved component data.
LongUpdate(dt)
- Description: Adjusts the cooldown task for time scaling (e.g., during slow-mo or season transitions) by rescheduling.
- Parameters:
dt(number): Delta time to apply.
GetDebugString()
- Description: Returns a debug-friendly string summarizing current state (target/point and remaining cooldown).
- Returns:
string.
Events & Listeners
- Listens for
"onremove"on host entity: Cancels active cooldown and callsOnCooldown()viaOnRemoveFromEntity. - Listens for
"onremove"onself.residue: Clearsself.residueviaself.residue._onresidueremoved. - Triggers:
"silentcloseinspect"— Sent during quip spam prevention.- Passively via
DoQuip: Usestalker:Sayto trigger speech/quips. - Via
residue._onresidueremoved: Automatically callsself.residue = nil.