Placement and platforms
This commit is contained in:
parent
a2164dca72
commit
d37c4ec858
31 changed files with 351 additions and 11 deletions
22
scripts/entity_holder.gd
Normal file
22
scripts/entity_holder.gd
Normal file
|
@ -0,0 +1,22 @@
|
|||
extends Node2D
|
||||
|
||||
class_name EntityHolder
|
||||
|
||||
const GRID_SIZE : Vector2 = Vector2(16,16)
|
||||
|
||||
@export var building_zone : BuildZone
|
||||
var constructions : Array[Construction]
|
||||
|
||||
func _ready() -> void:
|
||||
constructions.resize(building_zone.get_capacity())
|
||||
|
||||
func add_construction(construction : Construction) -> bool:
|
||||
if constructions[building_zone.indexify_global_point(construction.global_position)]:
|
||||
return false
|
||||
construction.reparent(self)
|
||||
construction.global_position = building_zone.get_placement_position(construction.global_position)
|
||||
constructions[building_zone.indexify_global_point(construction.global_position)] = construction
|
||||
return true
|
||||
|
||||
func get_at(point : Vector2):
|
||||
return constructions[building_zone.indexify_global_point(point)]
|
Loading…
Add table
Add a link
Reference in a new issue