PopochiuRoomData
Inherits: Resource
Description
Stores persistent data for PopochiuRoom instances during save/load operations.
This data persists throughout game execution and is serialized when saving the game. It also stores the state of PopochiuProps, PopochiuHotspots, PopochiuWalkableAreas, PopochiuRegions, and PopochiuCharacters in the room.
Properties
| Type | Name | Default |
|---|---|---|
| Variant | characters | {} |
| Variant | hotspots | {} |
| Variant | props | {} |
| Variant | regions | {} |
| Variant | scene | "" |
| Variant | script_name | "" |
| Variant | visited | false |
| Variant | visited_first_time | false |
| Variant | visited_times | 0 |
| Variant | walkable_areas | {} |
Methods
| Return Type | Method |
|---|---|
| void | _on_load(_data: Dictionary) virtual |
| Dictionary | _on_save() virtual |
| void | save_characters() |
| void | save_children_states() |
Property Descriptions
characters
var characters = {}
Stores data about the PopochiuCharacters in the room. To see the stored data by default, check
save_characters().
hotspots
var hotspots = {}
Stores data about the PopochiuHotspots in the room.
props
var props = {}
Stores data about the PopochiuProps in the room.
regions
var regions = {}
Stores data about the PopochiuRegions in the room.
scene
@export_file("*.tscn") var scene = ""
The path to the scene file to be used when adding the character to the game during runtime.
script_name
@export var script_name = ""
The identifier of the object used in scripts.
visited
@export var visited = false
Whether the room was already visited by the player.
visited_first_time
@export var visited_first_time = false
Whether this is the first time the player visits the room.
visited_times
@export var visited_times = 0
The number of times the player has visited this room.
walkable_areas
var walkable_areas = {}
Stores data about the PopochiuWalkableAreas in the room.
Method Descriptions
_on_load
func _on_load(_data: Dictionary) -> void
This is a virtual method. Override it in your subclass.
Called when the game is loaded. The structure of data matches that returned by
_on_save().
Implement this to restore the custom properties you persisted in [_on_save].
_on_save
func _on_save() -> Dictionary
This is a virtual method. Override it in your subclass.
Called when the game is saved.
Implement this to persist custom properties that you added to this resource. Should return a Dictionary containing the data to be saved.
The returned Dictionary must contain only JSON-supported types: [bool], [int], [float], String.
save_characters
func save_characters() -> void
Save room data related to the characters in the room. The stored data contains:
{
x = PopochiuCharacter.position.x
y = PopochiuCharacter.position.y
facing = PopochiuCharacter._looking_dir
visible = PopochiuCharacter.visible
modulate = PopochiuCharacter.modulate
self_modulate = PopochiuCharacter.self_modulate
light_mask = PopochiuCharacter.light_mask
}
This method clears and rebuilds the characters dictionary from scratch, ensuring it
accurately reflects only the characters currently present in the room's $Characters node.
Characters that were removed via remove_character() will not be restored
when returning to the room.
save_children_states
func save_children_states() -> void
Stores the data of each of the children inside $WalkableAreas, $Props, $Hotspots, $Regions, and $Characters.
This method clears and rebuilds the state dictionaries from scratch, ensuring they accurately
reflect only the objects currently present in the room. Objects that were removed from the
room's scene tree (e.g., via remove_character()) will not be restored when
returning to the room.