immersive-home/content/system/room/room.gd

42 lines
974 B
GDScript3
Raw Normal View History

extends Node3D
2023-12-19 00:15:48 +02:00
@onready var wall_corners = $Ceiling/WallCorners
@onready var wall_edges = $Ceiling/WallEdges
@onready var wall_mesh = $WallMesh
@onready var wall_collisions = $WallCollisions
2023-12-19 00:15:48 +02:00
@onready var room_floor = $Floor
@onready var room_ceiling = $Ceiling
2023-12-19 00:15:48 +02:00
@onready var state_machine = $StateMachine
2023-12-19 00:15:48 +02:00
var editable: bool = false:
set(value):
if value:
2023-12-19 00:15:48 +02:00
state_machine.change_to("Edit")
else:
2023-12-19 00:15:48 +02:00
state_machine.change_to("View")
func get_corner(index: int) -> MeshInstance3D:
return wall_corners.get_child(index % wall_corners.get_child_count())
func get_edge(index: int) -> MeshInstance3D:
return wall_edges.get_child(index % wall_edges.get_child_count())
func _save():
return {
"corners": wall_corners.get_children().map(func(corner): return corner.position),
}
func _load(data):
2023-12-11 13:17:59 +02:00
await ready
2023-12-19 00:15:48 +02:00
return
state_machine.change_to("Edit")
2023-12-11 13:17:59 +02:00
for corner in data["corners"]:
2023-12-19 00:15:48 +02:00
state_machine.current_state.add_corner(corner)
2023-12-19 00:15:48 +02:00
state_machine.change_to("View")