27 lines
709 B
GDScript
27 lines
709 B
GDScript
class_name TileState
|
|
extends RefCounted
|
|
|
|
var cell: Vector2i
|
|
var kind: GridMapState.CellKind
|
|
var room_id: StringName = &""
|
|
|
|
func _init(new_cell: Vector2i, new_kind: GridMapState.CellKind, new_room_id: StringName = &"") -> void:
|
|
cell = new_cell
|
|
kind = new_kind
|
|
room_id = new_room_id
|
|
|
|
func to_dict() -> Dictionary:
|
|
return {
|
|
"cell": [cell.x, cell.y],
|
|
"kind": int(kind),
|
|
"room_id": String(room_id),
|
|
}
|
|
|
|
static func from_dict(data: Dictionary) -> TileState:
|
|
var coordinates: Array = data.get("cell", [0, 0])
|
|
return TileState.new(
|
|
Vector2i(int(coordinates[0]), int(coordinates[1])),
|
|
int(data.get("kind", GridMapState.CellKind.WALL)) as GridMapState.CellKind,
|
|
StringName(data.get("room_id", ""))
|
|
)
|