Skip to content

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 ​

boolauto_close_enabledtrue
floatauto_close_distance4.0
boolis_loot_openfalse
Playerlooting_playernull
booltracking_distancefalse
Timerdistance_check_timernull

Methods ​

boolcan_interact( player: Player )
voidstart_interaction( player: Player )
voidend_interaction()
voidforce_close_loot()
boolis_open()
Playerget_looting_player()
boolhas_loot()
voidcleanup()

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