PopochiuRoom
Inherits: Node2D
Description
Represents a location in the game where characters can move and interact with objects.
Rooms contain Props, Hotspots, Regions, Markers, Walkable Areas, and Characters. Characters navigate through walkable areas, interact with props and hotspots, react to regions, and reach markers.
Properties
| Type | Name | Default |
|---|---|---|
| Variant | has_player | true |
| int | height | 0 |
| Variant | hide_gui | false |
| Variant | is_current | false |
| Variant | script_name | "" |
| int | width | 0 |
Methods
Property Descriptions
has_player
@export var has_player = true
Whether this room should add the Player-controlled Character (PC) to its $Characters node when the room is loaded.
height
@export var height : int = 0
Defines the room's height. If this exceeds from the project's viewport height, this value is used to calculate the camera limits, ensuring it follows the player as they move within the room.
hide_gui
@export var hide_gui = false
If true the whole GUI will be hidden when the room is loaded. Useful for cutscenes,
splash screens and when showing game menus or popups.
is_current
var is_current = false
- Setter:
set_is_current
Whether this is the room in which players are. When true, the room starts processing
unhandled inputs.
script_name
@export var script_name = ""
The identifier of the object used in scripts.
width
@export var width : int = 0
Defines the room's width. If this exceeds from the project's viewport width, this value is used to calculate the camera limits, ensuring it follows the player as they move within the room.
Method Descriptions
_on_room_entered
func _on_room_entered() -> void
This is a virtual method. Override it in your subclass.
Called when Popochiu loads the room. At this point the room is in the tree but not visible.
Override this to setup the stage before the room is shown to the player (e.g. setting character position and facing direction, active walkable area, props visibility, etc.).
_on_room_exited
func _on_room_exited() -> void
This is a virtual method. Override it in your subclass.
Called before Popochiu unloads the room. At this point the room is not visible, is not processing inputs, and has no children in the $Characters node.
Override this to cleanup any custom data or states before leaving the room, if needed.
_on_room_transition_finished
func _on_room_transition_finished() -> void
This is a virtual method. Override it in your subclass.
Called when the room-changing transition finishes. At this point the room is visible.
Override this to start cutscenes, play sounds, etc.
add_character
func add_character(chr: PopochiuCharacter) -> void
Adds chr character to the room.
The idle animation is played on the newly added character.
clean_characters
func clean_characters() -> void
Removes all character from the room.
This method stores references to each character's child nodes before removal, so these can be properly reassigned to their respective PopochiuCharacter objects when the room is reloaded.
This method is used internally by the engine when changing rooms and is not intended to be used in game scripts. Use it only if you know what you are doing.
get_active_walkable_area
func get_active_walkable_area() -> PopochiuWalkableArea
Returns the current active PopochiuWalkableArea.
get_active_walkable_area_name
func get_active_walkable_area_name() -> String
Returns the script_name of current active PopochiuWalkableArea.
get_characters
func get_characters() -> Array
Returns all the PopochiuCharacters in the room.
get_characters_count
func get_characters_count() -> int
Returns the number of characters in the room.
get_hotspot
func get_hotspot(hotspot_name: String) -> PopochiuHotspot
Returns the PopochiuHotspot which script_name matches
hotspot_name.
get_hotspots
func get_hotspots() -> Array
Returns all the PopochiuHotspots in the room.
get_marker
func get_marker(marker_name: String) -> Marker2D
Returns the Marker2D which Node.name matches marker_name.
get_marker_position
func get_marker_position(marker_name: String) -> Vector2
Returns the global position of the Marker2D which Node.name matches
marker_name.
get_markers
func get_markers() -> Array
Returns all the Marker2Ds in the room.
get_navigation_path
func get_navigation_path(start_position: Vector2, end_position: Vector2, ignore_walkable_areas: bool = false, ignore_obstacles: bool = false) -> PackedVector2Array
Returns the navigation path from start to end position using the active walkable area. Returns empty array if no walkable area is set.
This method is used internally by the engine and is not intended to be used in game scripts. Use it only if you know what you are doing.
get_prop
func get_prop(prop_name: String) -> PopochiuProp
Returns the PopochiuProp which script_name matches
prop_name.
get_props
func get_props() -> Array
Returns all the PopochiuProps in the room.
get_region
func get_region(region_name: String) -> PopochiuRegion
Returns the PopochiuRegion which script_name matches
region_name.
get_regions
func get_regions() -> Array
Returns all the PopochiuRegions in the room.
get_walkable_area
func get_walkable_area(walkable_area_name: String) -> PopochiuWalkableArea
Returns the PopochiuWalkableArea which script_name matches
walkable_area_name.
get_walkable_areas
func get_walkable_areas() -> Array
Returns all the PopochiuWalkableAreas in the room.
has_character
func has_character(character_name: String) -> bool
Returns true if the PopochiuCharacter, whose script_name matches
character_name, is in the room.
hide_props
func hide_props() -> void
Hides all PopochiuProps in the room.
remove_character
func remove_character(chr: PopochiuCharacter) -> void
Removes chr character from the room without destroying the instance.
This removal persists across room transitions. A removed character will not
be restored when returning to the room. If you want the character to reappear on subsequent
visits, either use add_character() in the room's _on_room_entered() callback
or hide the character instead (character.disable()).
set_active_walkable_area
func set_active_walkable_area(walkable_area_name: String) -> void
Activates the PopochiuWalkableArea which Node.name matches
walkable_area_name.
Only one walkable area can be active at a time. If the requested area is disabled or not found, an error is printed and no changes are made.
set_is_current
func set_is_current(value: bool) -> void
update_navigation_obstacles
func update_navigation_obstacles() -> void
Manually triggers navigation obstacle rebaking for all walkable areas. Useful when props are moved or added/removed at runtime, or when you need to force a navigation mesh update. The rebaking happens in the next frame to avoid performance issues.