2023-12-09 22:45:18 +02:00
|
|
|
extends Node3D
|
|
|
|
|
2023-12-19 00:15:48 +02:00
|
|
|
@onready var wall_corners = $Ceiling/WallCorners
|
|
|
|
@onready var wall_edges = $Ceiling/WallEdges
|
2023-12-09 22:45:18 +02:00
|
|
|
@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-09 22:45:18 +02:00
|
|
|
|
2023-12-19 00:15:48 +02:00
|
|
|
@onready var state_machine = $StateMachine
|
2023-12-09 22:45:18 +02:00
|
|
|
|
2023-12-19 00:15:48 +02:00
|
|
|
var editable: bool = false:
|
|
|
|
set(value):
|
2023-12-09 22:45:18 +02:00
|
|
|
if value:
|
2023-12-19 00:15:48 +02:00
|
|
|
state_machine.change_to("Edit")
|
2023-12-09 22:45:18 +02:00
|
|
|
else:
|
2023-12-19 00:15:48 +02:00
|
|
|
state_machine.change_to("View")
|
2023-12-09 22:45:18 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
2023-12-09 22:45:18 +02:00
|
|
|
for corner in data["corners"]:
|
2023-12-19 00:15:48 +02:00
|
|
|
state_machine.current_state.add_corner(corner)
|
2023-12-09 22:45:18 +02:00
|
|
|
|
2023-12-19 00:15:48 +02:00
|
|
|
state_machine.change_to("View")
|