duncgibbs 14e2073322
All checks were successful
linting & formatting / build (push) Successful in 25s
itch.io publish action / build (web, html) (push) Successful in 3m51s
mostly implements networked board state; but also adds voting and a few buildings
2026-04-24 12:19:34 -05:00

47 lines
1.0 KiB
GDScript

class_name Tile extends Node2D
@warning_ignore("unused_signal")
signal tile_selected(tile: Tile)
@export var coords: Vector2i
@export var cost: int = 0
@export var day_placed: int = 0
@export var player: Player:
set = _set_player
var highlighted: bool = false
var is_placing: bool = false
func handle_mouse_entered() -> void:
highlighted = true
func handle_mouse_exited() -> void:
highlighted = false
func _set_player(value: Player) -> void:
player = value
func serialize() -> Dictionary:
var result = {}
result["scene_file_path"] = scene_file_path
result["coords"] = coords
result["cost"] = cost
result["day_placed"] = day_placed
if player != null:
result["player"] = player.serialize()
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"]
tile.day_placed = data["day_placed"]
if data.get("player") != null:
tile.player = Player.deserialize(data["player"])
return tile