Name refactor
This commit is contained in:
parent
6f56fffb59
commit
e1cdf38dfb
21 changed files with 44 additions and 40 deletions
28
scripts/grid_controller.gd
Normal file
28
scripts/grid_controller.gd
Normal file
|
@ -0,0 +1,28 @@
|
|||
extends Node2D
|
||||
|
||||
class_name GridController
|
||||
|
||||
const GRID_SIZE : Vector2 = Vector2(16,16)
|
||||
|
||||
@export var building_zone : PlacementZone
|
||||
var constructions : Array[Structure]
|
||||
|
||||
func _ready() -> void:
|
||||
constructions.resize(building_zone.get_capacity())
|
||||
|
||||
func add_construction(construction : Structure) -> bool:
|
||||
var construction_dp = construction.get_dimension_points()
|
||||
for point in construction_dp:
|
||||
if constructions[building_zone.indexify_global_point(construction.global_position + point)]:
|
||||
return false
|
||||
construction.reparent(self)
|
||||
construction.global_position = building_zone.get_placement_position(construction.global_position)
|
||||
for point in construction_dp:
|
||||
constructions[building_zone.indexify_global_point(construction.global_position + point)] = construction
|
||||
return true
|
||||
|
||||
func get_at(point : Vector2) -> Structure:
|
||||
return constructions[building_zone.indexify_global_point(point)]
|
||||
|
||||
func is_point_occupied(point : Vector2) -> bool:
|
||||
return get_at(point) != null
|
Loading…
Add table
Add a link
Reference in a new issue