LootInteraction ​
Inherits: EntityInteraction < Interaction < Resource
Loot Interaction for NPCs Allows players to access a dead entity's inventory Works similarly to InteractableContainer but uses entity.components.inventory()
Description ​
LIFECYCLE:
- Created by NPC when entity dies (if inventory is not empty)
- Removed by NPC when inventory becomes empty
- NPC handles setting/clearing this interaction
Variables ​
bool | auto_close_enabled | true |
float | auto_close_distance | 4.0 |
bool | is_loot_open | false |
Player | looting_player | null |
bool | tracking_distance | false |
Timer | distance_check_timer | null |
Methods ​
bool | can_interact( player: Player ) |
void | start_interaction( player: Player ) |
void | end_interaction() |
void | force_close_loot() |
bool | is_open() |
Player | get_looting_player() |
bool | has_loot() |
void | cleanup() |
Signals ​
loot_opened( entity: Entity, player: Player ) ​
Signal emitted when loot window is opened
loot_closed( entity: Entity, player: Player ) ​
Signal emitted when loot window is closed
Variable descriptions ​
bool auto_close_enabled = true ​
Whether to auto-close loot window when player moves away
float auto_close_distance = 4.0 ​
Distance at which loot auto-closes
bool is_loot_open = false ​
Whether the loot window is currently open
Player looting_player = null ​
The player currently accessing the loot
bool tracking_distance = false ​
Whether we're tracking player distance for auto-close
Timer distance_check_timer = null ​
Distance check timer from ChronoManager
Method descriptions ​
bool can_interact( player: Player ) ​
Check if the player can interact with this loot
void start_interaction( player: Player ) ​
Start the loot interaction
void end_interaction() ​
End the loot interaction
void force_close_loot() ​
Force close the loot window
bool is_open() ​
Check if loot window is currently open
Player get_looting_player() ​
Get the player currently looting
bool has_loot() ​
Check if inventory has any items
void cleanup() ​
Clean up resources when interaction is being removed