Skip to content

DoorInteraction ​

Inherits: InteractableObjectInteraction < Interaction < Resource

Door interaction - opens/closes doors with animations Uses available_animations from InteractableDefinition for animation selection

Properties ​

boolis_openfalse
boolcan_open_when_damagedtrue
boolauto_close_enabledfalse
floatauto_close_delay5.0
Stringopen_animation"open"
Stringclose_animation"close"
Stringlocked_animation"locked"
SFXSelectiondoor_open_sound
SFXSelectiondoor_close_sound
SFXSelectiondoor_locked_sound
SFXSelectiondoor_creak_sound

Variables ​

intoriginal_collision_layer
intoriginal_collision_mask
Timerauto_close_timernull

Methods ​

voidsetup_for_interactable_objects( interactable: InteractableObject )
boolcan_interact( player: Player )
voidstart_interaction( player: Player )
voidon_object_destroyed()
voidon_locked_reaction()
boolforce_open()
boolforce_close()
Dictionarysave_state()
voidload_state( state: Dictionary )
voidcleanup()

Signals ​

door_opened( entity: Entity ) ​

Emitted when the door opens.

door_closed( entity: Entity ) ​

Emitted when the door closes.

Property descriptions ​

bool is_open = false ​

True when the door is open.

bool can_open_when_damaged = true ​

True when a damaged door can still be opened.

bool auto_close_enabled = false ​

True when the door closes by itself after a delay.

float auto_close_delay = 5.0 ​

How many seconds an open door waits before it closes by itself.

Animations

String open_animation = "open" ​

Animation to play when door opens Editor will show dropdown of available_animations from InteractableDefinition

String close_animation = "close" ​

Animation to play when door closes

String locked_animation = "locked" ​

Animation to play when locked (optional)

Audio

SFXSelection door_open_sound ​

The sound of the door opening.

SFXSelection door_close_sound ​

The sound of the door closing.

SFXSelection door_locked_sound ​

The sound of trying a locked door.

SFXSelection door_creak_sound ​

A creak played now and then (optional).

Variable descriptions ​

int original_collision_layer ​

The collision layer of the door when it is closed (kept to give it back).

int original_collision_mask ​

The collision mask of the door when it is closed (kept to give it back).

Timer auto_close_timer = null ​

The timer of the automatic closing.

Method descriptions ​

void setup_for_interactable_objects( interactable: InteractableObject ) ​

Sets the door up on its object: finds the nodes it needs and applies its starting state.

bool can_interact( player: Player ) ​

Can the player use the door now (in range, the object is not broken, the requirements are met)?

void start_interaction( player: Player ) ​

The player uses the door.

void on_object_destroyed() ​

Called when the object is destroyed: a destroyed door is forced open and has no collision.

void on_locked_reaction() ​

Called when someone tries the object while it is locked: plays the locked sound and animation.

bool force_open() ​

Opens the door without a player (a script or an event). False when it is destroyed.

bool force_close() ​

Closes the door without a player. False when it is destroyed.

Dictionary save_state() ​

The state of the door for a save.

void load_state( state: Dictionary ) ​

Restores the state of the door from a save.

void cleanup() ​

Gives its timers back and clears what it holds (the object is going away).