PopochiuProp

Inherits: PopochiuClickable

Description

A visual and interactive element in a room, such as backgrounds, foregrounds, tables, or cups.

Props can be clicked, animated, linked to inventory items, and used as navigation obstacles. When selecting a Prop in the scene tree, Popochiu enables three buttons in the Canvas Editor Menu: Baseline, Walk to, and Interaction for adjusting positioning and interaction polygons.


Properties

Type Name Default
float alpha 1.0
Variant current_frame 0
Variant frames 1
Variant link_to_item ""
bool obstacle false
Variant obstacle_polygon []
Variant obstacle_polygon_position Vector2.ZERO
Texture2D texture set_texture
get total_frames get_total_frames
Variant v_frames 1

Methods

Return Type Method
void _on_linked_item_discarded() virtual
void _on_linked_item_removed() virtual
void _on_movement_ended() virtual
void _on_movement_started() virtual
void change_frame(new_frame: int)
void fade_in(duration: float, set_enablement: bool = false, trans = Tween.TransitionType.TRANS_LINEAR, ease = Tween.EaseType.EASE_IN_OUT)
void fade_out(duration: float, set_enablement: bool = false, trans = Tween.TransitionType.TRANS_LINEAR, ease = Tween.EaseType.EASE_IN_OUT)
void fade_to(target_alpha: float, duration: float, set_enablement: bool = false, trans = Tween.TransitionType.TRANS_LINEAR, ease = Tween.EaseType.EASE_IN_OUT)
String get_assigned_animation()
float get_current_animation_position()
NavigationObstacle2D get_navigation_obstacle()
int get_total_frames()
bool is_animation_playing()
void pause_animation()
void play_animation(name: StringName = &"", custom_blend: float = -1, custom_speed: float = 1.0, from_end: bool = false)
void play_animation_backwards(name: StringName = &"", custom_blend: float = -1)
Callable queue_change_frame(new_frame: int)
Callable queue_fade_in(duration: float, set_enablement: bool = false, trans = Tween.TransitionType.TRANS_LINEAR, ease = Tween.EaseType.EASE_IN_OUT)
Callable queue_fade_out(duration: float, set_enablement: bool = false, trans = Tween.TransitionType.TRANS_LINEAR, ease = Tween.EaseType.EASE_IN_OUT)
Callable queue_fade_to(target_alpha: float, duration: float, set_enablement: bool = false)
Callable queue_pause_animation()
Callable queue_play_animation(name: StringName = &"", custom_blend: float = -1, custom_speed: float = 1.0, from_end: bool = false)
Callable queue_play_animation_backwards(name: StringName = &"", custom_blend: float = -1)
Callable queue_stop_animation(keep_state: bool = false)
void set_alpha(value: float)
void set_assigned_animation(name: StringName)
void set_current_frame(value: int)
void set_frames(value: int)
void set_obstacle(value: bool)
void set_texture(value: Texture2D)
void set_v_frames(value: int)
void stop_animation(keep_state: bool = false)

Signals


Signal Descriptions

linked_item_discarded

signal linked_item_discarded(item: PopochiuInventoryItem)

Emitted when the item linked to this object (by link_to_item) is discarded from the inventory. This may happen when the inventory item disappears forever from the game.


linked_item_removed

signal linked_item_removed(item: PopochiuInventoryItem)

Emitted when the item linked to this object (by link_to_item) is removed from the inventory. This may happen when the inventory item disappears forever from the game.


obstacle_state_changed

signal obstacle_state_changed(prop: PopochiuProp)

Emitted when the obstacle flag state is changed.


Property Descriptions

alpha

@export_range(0.0, 1.0) var alpha : float = 1.0
  • Setter: set_alpha

Opacity of the prop. Range: 0.0 (fully transparent) to 1.0 (fully opaque). Setting this value will modulate the alpha channel of the $Sprite2D child.


current_frame

@export var current_frame = 0
  • Setter: set_current_frame

The current frame to use as the texture of this node. Modifying this will change the value of the Sprite2D.frame property in the $Sprite2D child. Trying to assign a value lesser than 0 will roll over the value to the maximum frame (frames * v_frames - 1) or setting the value greater than the number of frames will roll over the value to 0.


frames

@export var frames = 1
  • Setter: set_frames

The number of horizontal frames this node's texture image has. Modifying this will change the value of the Sprite2D.hframes property in the $Sprite2D child.


@export var link_to_item = ""

Links the prop to a PopochiuInventoryItem by its script_name. This will make the prop disappear from the room, depending on whether or not said inventory item is inside the inventory.


obstacle

@export var obstacle : bool = false
  • Setter: set_obstacle

When true, this prop will be considered an obstacle and its obstacle polygon (if available) will be carved from all PopochiuWalkableAreas it intersects in the room. Set this to false to ignore its encoumbrance during pathfinding.


obstacle_polygon

@export var obstacle_polygon = []

Stores the outlines to assign to the ObstaclePolygon/Vertices child during runtime. This is used by PopochiuRoom to store the info in its .tscn.


obstacle_polygon_position

@export var obstacle_polygon_position = Vector2.ZERO

Stores the position to assign to the ObstaclePolygon/Vertices child during runtime. This is used by PopochiuRoom to store the info in its .tscn.


texture

@export var texture : Texture2D = set_texture
  • Setter: set_texture

The image to use as the Sprite2D.texture of the $Sprite2D child.


total_frames

var total_frames : get = get_total_frames
  • Getter: get_total_frames

Total frames available the texture image has. (frames * vframes)


v_frames

@export var v_frames = 1
  • Setter: set_v_frames

The number of vertical frames this node's texture image has. Modifying this will change the value of the Sprite2D.vframes property in the $Sprite2D child.


Method Descriptions

_on_linked_item_discarded

func _on_linked_item_discarded() -> void

This is a virtual method. Override it in your subclass.

Called when the PopochiuInventoryItem linked to this prop is discarded from the inventory.

Override this to add custom behavior such as playing an animation or update state variables that control game logic.


_on_linked_item_removed

func _on_linked_item_removed() -> void

This is a virtual method. Override it in your subclass.

Called when the PopochiuInventoryItem linked to this prop is removed from the inventory.

Override this to add custom behavior such as enabling the prop again, playing an animation, or update state variables that control game logic.


_on_movement_ended

func _on_movement_ended() -> void

This is a virtual method. Override it in your subclass.

Called when the prop stops moving.

Override this to add custom behavior such as stopping an animation, starting a cutscene, or speak a dialog line.

Useful with props that the player can drag around the room, or props that move as part of an animation sequence in the room's narrative.


_on_movement_started

func _on_movement_started() -> void

This is a virtual method. Override it in your subclass.

Called when the prop starts moving.

Override this to add custom behavior such as playing an animation, or speak a dialog line.

Useful with props that the player can drag around the room, or props that move as part of an animation sequence in the room's narrative.


change_frame

func change_frame(new_frame: int) -> void

Changes the prop's $Sprite2D frame to new_frame.


fade_in

func fade_in(duration: float, set_enablement: bool = false, trans = Tween.TransitionType.TRANS_LINEAR, ease = Tween.EaseType.EASE_IN_OUT) -> void

Gradually increases alpha to 1.0 over duration seconds. If set_enablement is true, enables the prop when complete.


fade_out

func fade_out(duration: float, set_enablement: bool = false, trans = Tween.TransitionType.TRANS_LINEAR, ease = Tween.EaseType.EASE_IN_OUT) -> void

Gradually decreases alpha to 0.0 over duration seconds. If set_enablement is true, disables the prop when complete.


fade_to

func fade_to(target_alpha: float, duration: float, set_enablement: bool = false, trans = Tween.TransitionType.TRANS_LINEAR, ease = Tween.EaseType.EASE_IN_OUT) -> void

Gradually transitions alpha to target_alpha (clamped between 0.0 and 1.0) over duration seconds. If set_enablement is true, enables/disables based on final alpha (0.0 means disabled, anything else means enabled).

trans and ease define the transition and easing types (see [Tween.TransitionType] and [Tween.EaseType]).


get_assigned_animation

func get_assigned_animation() -> String

Returns the string name of the currently assigned animation in the AnimationPlayer node.


get_current_animation_position

func get_current_animation_position() -> float

Returns the current animation position in seconds, or -1.0 on error.


get_navigation_obstacle

func get_navigation_obstacle() -> NavigationObstacle2D

Returns the NavigationObstacle2D if it has a defined polygon, null otherwise. This method checks if the obstacle has at least 3 vertices to form a valid polygon.


get_total_frames

func get_total_frames() -> int

is_animation_playing

func is_animation_playing() -> bool

Returns true if an animation is playing, false otherwise.


pause_animation

func pause_animation() -> void

Pauses the currently playing animation. Call play_animation() without parameters to resume.


play_animation

func play_animation(name: StringName = &"", custom_blend: float = -1, custom_speed: float = 1.0, from_end: bool = false) -> void

Plays the name animation if it exists in this prop's AnimationPlayer node. Optionally you can use the other play() parameters.


play_animation_backwards

func play_animation_backwards(name: StringName = &"", custom_blend: float = -1) -> void

Plays the name animation in reverse if it exists in this prop's AnimationPlayer node. This is a shorthand for play_animation() with custom_speed = -1.0 and from_end = true.


queue_change_frame

func queue_change_frame(new_frame: int) -> Callable

Changes the prop's $Sprite2D frame to new_frame.

This method is intended to be used inside a queue() of instructions.


queue_fade_in

func queue_fade_in(duration: float, set_enablement: bool = false, trans = Tween.TransitionType.TRANS_LINEAR, ease = Tween.EaseType.EASE_IN_OUT) -> Callable

Gradually increases alpha to 1.0 over duration seconds. If set_enablement is true, enables the prop when complete.

This method is intended to be used inside a queue() of instructions.


queue_fade_out

func queue_fade_out(duration: float, set_enablement: bool = false, trans = Tween.TransitionType.TRANS_LINEAR, ease = Tween.EaseType.EASE_IN_OUT) -> Callable

Gradually decreases alpha to 0.0 over duration seconds. If set_enablement is true, disables the prop when complete.

This method is intended to be used inside a queue() of instructions.


queue_fade_to

func queue_fade_to(target_alpha: float, duration: float, set_enablement: bool = false) -> Callable

Gradually transitions alpha to target_alpha (clamped between 0.0 and 1.0) over duration seconds. If set_enablement is true, enables/disables based on final alpha (0.0 means disabled, anything else means enabled).

This method is intended to be used inside a queue() of instructions.


queue_pause_animation

func queue_pause_animation() -> Callable

Pauses the currently playing animation. Call play_animation() without parameters to resume.

This method is intended to be used inside a queue() of instructions.


queue_play_animation

func queue_play_animation(name: StringName = &"", custom_blend: float = -1, custom_speed: float = 1.0, from_end: bool = false) -> Callable

Plays the name animation if it exists in this prop's AnimationPlayer node. Optionally you can use the other play() parameters.

This method is intended to be used inside a queue() of instructions.


queue_play_animation_backwards

func queue_play_animation_backwards(name: StringName = &"", custom_blend: float = -1) -> Callable

Plays the name animation in reverse if it exists in this prop's AnimationPlayer node. This is a shorthand for play_animation() with custom_speed = -1.0 and from_end = true.

This method is intended to be used inside a queue() of instructions.


queue_stop_animation

func queue_stop_animation(keep_state: bool = false) -> Callable

Stops the currently playing animation. The animation position is reset to 0 and custom_speed is reset to 1.0. Set keep_state to true to prevent visual updates.

This method is intended to be used inside a queue() of instructions.


set_alpha

func set_alpha(value: float) -> void

set_assigned_animation

func set_assigned_animation(name: StringName) -> void

Sets the animation key name for the currently assigned animation in the AnimationPlayer node.


set_current_frame

func set_current_frame(value: int) -> void

set_frames

func set_frames(value: int) -> void

set_obstacle

func set_obstacle(value: bool) -> void

set_texture

func set_texture(value: Texture2D) -> void

set_v_frames

func set_v_frames(value: int) -> void

stop_animation

func stop_animation(keep_state: bool = false) -> void

Stops the currently playing animation. The animation position is reset to 0 and custom_speed is reset to 1.0. Set keep_state to true to prevent visual updates.