generated from krampus/template-godot4
34 lines
677 B
GDScript
34 lines
677 B
GDScript
class_name Tile extends Node2D
|
|
|
|
@warning_ignore("unused_signal")
|
|
signal tile_selected(tile: Tile)
|
|
|
|
@export var coords: Vector2i
|
|
@export var cost: int = 0
|
|
|
|
var highlighted: bool = false
|
|
var is_placing: bool = false
|
|
|
|
|
|
func handle_mouse_entered() -> void:
|
|
highlighted = true
|
|
|
|
|
|
func handle_mouse_exited() -> void:
|
|
highlighted = false
|
|
|
|
|
|
func serialize() -> Dictionary:
|
|
var result = {}
|
|
result["scene_file_path"] = scene_file_path
|
|
result["coords"] = coords
|
|
result["cost"] = cost
|
|
return result
|
|
|
|
|
|
static func deserialize(data: Dictionary) -> Tile:
|
|
var tile: Tile = load(data["scene_file_path"]).instantiate()
|
|
tile.coords = data["coords"]
|
|
tile.cost = data["cost"]
|
|
return tile
|