PopochiuRegion
Inherits: Area2D
Description
Defines areas in a room that trigger events when characters enter or exit.
Regions can apply visual effects such as tinting characters or scaling them based on vertical position (useful for simulating depth in walkable areas).
Properties
| Type | Name | Default |
|---|---|---|
| Variant | description | "" |
| Variant | enabled | true |
| Variant | interaction_polygon | PackedVector2Array() |
| Variant | interaction_polygon_position | Vector2.ZERO |
| float | scale_bottom | 1.0 |
| float | scale_top | 1.0 |
| bool | scaling | false |
| Variant | script_name | "" |
| Variant | tint | Color.WHITE |
| Variant | walkable | true |
Methods
| Return Type | Method |
|---|---|
| void | _on_character_entered(chr: PopochiuCharacter) virtual |
| void | _on_character_exited(chr: PopochiuCharacter) virtual |
| Array[PopochiuCharacter] | get_characters() |
| PackedVector2Array | get_global_polygon() |
| Array[Marker2D] | get_markers() |
| bool | has_character(chr: PopochiuCharacter) |
| bool | has_marker(marker: Marker2D) |
Signals
- character_blocked(character: PopochiuCharacter)
Signal Descriptions
character_blocked
signal character_blocked(character: PopochiuCharacter)
Emitted when a character tries to enter this region while walkable is
false and the character does not ignore blocking regions.
Connect to this signal in the region's game script to react to the blocking event.
Property Descriptions
description
@export var description = ""
Can be used to show the name of the area to players.
enabled
@export var enabled = true
- Setter:
_set_enabled
Whether the region is or not enabled.
interaction_polygon
@export var interaction_polygon = PackedVector2Array()
Stores the vertices to assign to the InteractionPolygon child during runtime. This is used
by PopochiuRoom to store the info in its .tscn.
interaction_polygon_position
@export var interaction_polygon_position = Vector2.ZERO
Stores the position to assign to the InteractionPolygon child during runtime. This is used
by PopochiuRoom to store the info in its .tscn.
scale_bottom
@export var scale_bottom : float = 1.0
The scale to apply to the character inside the region when it moves to the bottom
(y) of it.
scale_top
@export var scale_top : float = 1.0
The scale to apply to the character inside the region when it moves to the top (y)
of it.
scaling
@export var scaling : bool = false
Whether the region will scale the character while it moves through it.
script_name
@export var script_name = ""
The identifier of the object used in scripts.
tint
@export var tint = Color.WHITE
The Color to apply to the character that enters this region.
walkable
@export var walkable = true
Whether characters can walk through this region. When false, characters whose
ignore_blocking_regions is also false will have their
movement interrupted upon entering. The region's state is saved as part of the room save data.
Method Descriptions
_on_character_entered
func _on_character_entered(chr: PopochiuCharacter) -> void
This is a virtual method. Override it in your subclass.
Called when chr enters this region.
Implement this to add custom behavior or update the game state.
_on_character_exited
func _on_character_exited(chr: PopochiuCharacter) -> void
This is a virtual method. Override it in your subclass.
Called when chr exits this region.
Implement this to add custom behavior or update the game state.
get_characters
func get_characters() -> Array[PopochiuCharacter]
Returns all PopochiuCharacters whose ScalingPolygon is currently inside this region.
get_global_polygon
func get_global_polygon() -> PackedVector2Array
Returns the vertices of this region's polygon in global (world) coordinates. Used by path-trimming in PopochiuCharacter to check segment intersections.
get_markers
func get_markers() -> Array[Marker2D]
Returns all Marker2Ds whose global position falls inside this region's polygon.
has_character
func has_character(chr: PopochiuCharacter) -> bool
Returns true if chr's ScalingPolygon is currently inside this region.
has_marker
func has_marker(marker: Marker2D) -> bool
Returns true if marker's global position is inside this region's polygon.