2026-04-13 11:34:00 -05:00
|
|
|
class_name Building extends Node2D
|
|
|
|
|
|
2026-04-15 10:45:43 -05:00
|
|
|
var is_placing: bool = false:
|
|
|
|
|
set(value):
|
|
|
|
|
is_placing = value
|
|
|
|
|
building_area.monitoring = !is_placing
|
|
|
|
|
|
2026-04-13 11:34:00 -05:00
|
|
|
var starting_coord: Vector2i
|
2026-04-15 10:45:43 -05:00
|
|
|
var tile_rotation: Board.Direction = Board.Direction.UP
|
|
|
|
|
|
|
|
|
|
@onready var building_area: Area2D = %BuildingArea
|
2026-04-13 11:34:00 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func building_entered(body: Node2D) -> void:
|
|
|
|
|
if body is Citizen:
|
|
|
|
|
print("Activate building effect!")
|
|
|
|
|
|
2026-04-15 10:45:43 -05:00
|
|
|
|
2026-04-13 11:34:00 -05:00
|
|
|
func _on_building_area_entered(area: Area2D) -> void:
|
2026-04-15 10:45:43 -05:00
|
|
|
var tile = area.get_parent()
|
|
|
|
|
if tile is Ground and !is_placing:
|
|
|
|
|
tile.queue_free()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func get_rotation_count() -> int:
|
|
|
|
|
var rotation_count: int = 0
|
|
|
|
|
if tile_rotation == Board.Direction.UP:
|
|
|
|
|
rotation_count = 0
|
|
|
|
|
elif tile_rotation == Board.Direction.RIGHT:
|
|
|
|
|
rotation_count = 1
|
|
|
|
|
elif tile_rotation == Board.Direction.DOWN:
|
|
|
|
|
rotation_count = 2
|
|
|
|
|
elif tile_rotation == Board.Direction.LEFT:
|
|
|
|
|
rotation_count = 3
|
|
|
|
|
return rotation_count
|