Dimensions for constructibles
This commit is contained in:
parent
d37c4ec858
commit
6f56fffb59
18 changed files with 135 additions and 25 deletions
15
generic/constructibles/dbg_assembler.tres
Normal file
15
generic/constructibles/dbg_assembler.tres
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
[gd_resource type="Resource" script_class="Constructible" load_steps=5 format=3 uid="uid://yn1iesx30nfu"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://c80sp6f77l5ha" path="res://scripts/constructible.gd" id="1_mqcr0"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dinyjq8853usn" path="res://sprites/atlasses/Popekko.png" id="1_sh8t1"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dfatkxv6n55dw" path="res://scenes/debug_assembler.tscn" id="2_kf3x0"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_kf3x0"]
|
||||||
|
atlas = ExtResource("1_sh8t1")
|
||||||
|
region = Rect2(32, 0, 32, 32)
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("1_mqcr0")
|
||||||
|
scene = ExtResource("2_kf3x0")
|
||||||
|
preview = SubResource("AtlasTexture_kf3x0")
|
||||||
|
metadata/_custom_type_script = "uid://c80sp6f77l5ha"
|
|
@ -18,8 +18,8 @@ config/icon="res://icon.svg"
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
GuiEventBus="*res://scripts/gui/gui_event_bus.gd"
|
GuiEventBus="*res://scripts/gui/gui_event_bus.gd"
|
||||||
RuntimePlayerData="*res://scripts/runtime_player_data.gd"
|
RuntimePlayerData="*res://scripts/autoloads/runtime_player_data.gd"
|
||||||
Registry="*res://scripts/registry.gd"
|
Registry="*res://scripts/autoloads/registry.gd"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
[gd_scene load_steps=9 format=3 uid="uid://u7thalwj5742"]
|
[gd_scene load_steps=10 format=3 uid="uid://u7thalwj5742"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://b7du4vul4bmpq" path="res://scenes/player_platform.tscn" id="1_4ia00"]
|
[ext_resource type="PackedScene" uid="uid://b7du4vul4bmpq" path="res://scenes/player_platform.tscn" id="1_4ia00"]
|
||||||
[ext_resource type="Script" uid="uid://db37xmo8ygwhg" path="res://scripts/gui/construction_button.gd" id="2_27lod"]
|
[ext_resource type="Script" uid="uid://db37xmo8ygwhg" path="res://scripts/gui/construction_button.gd" id="2_27lod"]
|
||||||
[ext_resource type="Resource" uid="uid://dj524jjal1f0n" path="res://generic/constructibles/conveyor.tres" id="3_2crwe"]
|
[ext_resource type="Resource" uid="uid://dj524jjal1f0n" path="res://generic/constructibles/conveyor.tres" id="3_2crwe"]
|
||||||
[ext_resource type="Script" uid="uid://b4nkk0ndqcto" path="res://scripts/construction_placer.gd" id="4_i7yte"]
|
[ext_resource type="Script" uid="uid://b4nkk0ndqcto" path="res://scripts/construction_placer.gd" id="4_i7yte"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bac552xgua68e" path="res://scenes/other_platform.tscn" id="5_mnxrb"]
|
[ext_resource type="PackedScene" uid="uid://bac552xgua68e" path="res://scenes/other_platform.tscn" id="5_mnxrb"]
|
||||||
|
[ext_resource type="Resource" uid="uid://yn1iesx30nfu" path="res://generic/constructibles/dbg_assembler.tres" id="5_ymyc2"]
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_bq5r8"]
|
[sub_resource type="Animation" id="Animation_bq5r8"]
|
||||||
length = 0.001
|
length = 0.001
|
||||||
|
@ -81,6 +82,24 @@ expand_icon = true
|
||||||
script = ExtResource("2_27lod")
|
script = ExtResource("2_27lod")
|
||||||
constructible = ExtResource("3_2crwe")
|
constructible = ExtResource("3_2crwe")
|
||||||
|
|
||||||
|
[node name="AssemblerButton" type="Button" parent="GUI/Panel"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = -1
|
||||||
|
anchor_left = 0.008
|
||||||
|
anchor_top = 0.086
|
||||||
|
anchor_right = 0.1
|
||||||
|
anchor_bottom = 0.88600004
|
||||||
|
offset_left = 50.904
|
||||||
|
offset_top = -0.01999998
|
||||||
|
offset_right = 50.8
|
||||||
|
offset_bottom = -0.020004272
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
theme_type_variation = &"CRT"
|
||||||
|
icon_alignment = 1
|
||||||
|
expand_icon = true
|
||||||
|
script = ExtResource("2_27lod")
|
||||||
|
constructible = ExtResource("5_ymyc2")
|
||||||
|
|
||||||
[node name="Placer" type="Node2D" parent="."]
|
[node name="Placer" type="Node2D" parent="."]
|
||||||
script = ExtResource("4_i7yte")
|
script = ExtResource("4_i7yte")
|
||||||
|
|
||||||
|
|
16
scenes/debug_assembler.tscn
Normal file
16
scenes/debug_assembler.tscn
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
[gd_scene load_steps=4 format=3 uid="uid://dfatkxv6n55dw"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://bbd7o2st8kmgl" path="res://scripts/construction.gd" id="1_k5y3y"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dinyjq8853usn" path="res://sprites/atlasses/Popekko.png" id="2_4befw"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_xh4eg"]
|
||||||
|
atlas = ExtResource("2_4befw")
|
||||||
|
region = Rect2(32, 0, 32, 32)
|
||||||
|
|
||||||
|
[node name="DebugAssembler" type="Node2D"]
|
||||||
|
script = ExtResource("1_k5y3y")
|
||||||
|
dimensions = Rect2i(0, 0, 2, 2)
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
texture = SubResource("AtlasTexture_xh4eg")
|
||||||
|
offset = Vector2(8, 8)
|
|
@ -1,13 +1,20 @@
|
||||||
[gd_scene load_steps=3 format=4 uid="uid://bac552xgua68e"]
|
[gd_scene load_steps=4 format=4 uid="uid://bac552xgua68e"]
|
||||||
|
|
||||||
[ext_resource type="TileSet" uid="uid://bv75bu0af04vs" path="res://generic/platform.tres" id="1_fs1oy"]
|
[ext_resource type="TileSet" uid="uid://bv75bu0af04vs" path="res://generic/platform.tres" id="1_fs1oy"]
|
||||||
[ext_resource type="Script" uid="uid://lw1ya3iu14uf" path="res://scripts/build_zone.gd" id="2_bwire"]
|
[ext_resource type="Script" uid="uid://lw1ya3iu14uf" path="res://scripts/build_zone.gd" id="2_bwire"]
|
||||||
|
[ext_resource type="Script" uid="uid://x5edy155eg0s" path="res://scripts/entity_holder.gd" id="3_qaudu"]
|
||||||
|
|
||||||
[node name="OtherPlatform" type="TileMapLayer"]
|
[node name="OtherPlatform" type="TileMapLayer"]
|
||||||
tile_map_data = PackedByteArray("AAAAAAAAAAAAAAAAAAAAAAEAAAAAAAEAAAAAAAIAAAAAAAEAAAAAAAMAAAAAAAEAAAAAAAQAAAAAAAEAAAABAAAAAAAAAAEAAAABAAEAAAAAAAEAAAABAAIAAAAAAAEAAAABAAMAAAAAAAAAAAABAAQAAAAAAAEAAAACAAAAAAAAAAAAAAACAAEAAAAAAAEAAAACAAIAAAAAAAEAAAACAAMAAAAAAAAAAAACAAQAAAAAAAAAAAD/////AAACAAEAAAD//wAAAAAEAAIAAAD//wEAAAAEAAIAAAD//wIAAAAEAAIAAAD//wMAAAAEAAIAAAD//wQAAAAEAAIAAAAAAP//AAABAAIAAAABAP//AAABAAIAAAACAP//AAABAAIAAAADAP//AAADAAEAAAD//wUAAAAEAAEAAAADAAUAAAAFAAEAAAAAAAUAAAAGAAEAAAABAAUAAAAGAAEAAAACAAUAAAAGAAEAAAADAAAAAAAFAAIAAAADAAEAAAAFAAIAAAADAAIAAAAFAAIAAAADAAMAAAAFAAIAAAADAAQAAAAFAAIAAAA=")
|
tile_map_data = PackedByteArray("AAAAAAAAAAAAAAAAAAAAAAEAAAAAAAEAAAAAAAIAAAAAAAEAAAAAAAMAAAAAAAEAAAAAAAQAAAAAAAEAAAABAAAAAAAAAAEAAAABAAEAAAAAAAEAAAABAAIAAAAAAAEAAAABAAMAAAAAAAAAAAABAAQAAAAAAAEAAAACAAAAAAAAAAAAAAACAAEAAAAAAAEAAAACAAIAAAAAAAEAAAACAAMAAAAAAAAAAAACAAQAAAAAAAAAAAD/////AAACAAEAAAD//wAAAAAEAAIAAAD//wEAAAAEAAIAAAD//wIAAAAEAAIAAAD//wMAAAAEAAIAAAD//wQAAAAEAAIAAAAAAP//AAABAAIAAAABAP//AAABAAIAAAACAP//AAABAAIAAAADAP//AAADAAEAAAD//wUAAAAEAAEAAAADAAUAAAAFAAEAAAAAAAUAAAAGAAEAAAABAAUAAAAGAAEAAAACAAUAAAAGAAEAAAADAAAAAAAFAAIAAAADAAEAAAAFAAIAAAADAAIAAAAFAAIAAAADAAMAAAAFAAIAAAADAAQAAAAFAAIAAAA=")
|
||||||
tile_set = ExtResource("1_fs1oy")
|
tile_set = ExtResource("1_fs1oy")
|
||||||
|
|
||||||
[node name="BuildZone" type="Marker2D" parent="."]
|
[node name="BuildZone" type="Marker2D" parent="." node_paths=PackedStringArray("entity_holder")]
|
||||||
script = ExtResource("2_bwire")
|
script = ExtResource("2_bwire")
|
||||||
building_rect = Rect2(0, 0, 48, 80)
|
building_rect = Rect2(0, 0, 48, 80)
|
||||||
|
entity_holder = NodePath("../EntityHolder")
|
||||||
metadata/_custom_type_script = "uid://lw1ya3iu14uf"
|
metadata/_custom_type_script = "uid://lw1ya3iu14uf"
|
||||||
|
|
||||||
|
[node name="EntityHolder" type="Node2D" parent="." node_paths=PackedStringArray("building_zone")]
|
||||||
|
script = ExtResource("3_qaudu")
|
||||||
|
building_zone = NodePath("../BuildZone")
|
||||||
|
metadata/_custom_type_script = "uid://x5edy155eg0s"
|
||||||
|
|
|
@ -10,9 +10,10 @@
|
||||||
tile_map_data = PackedByteArray("AAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAGA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AAEAAAARAAEAAAABAAEAAAARAAIAAAABAAEAAAARAAMAAAABAAEAAAARAAQAAAABAAEAAAARAAUAAAABAAEAAAARAAYAAAABAAEAAAARAAcAAAABAAEAAAD//wAAAAABAAAAAAD//wEAAAABAAAAAAD//wIAAAABAAAAAAD//wMAAAABAAAAAAD//wQAAAABAAAAAAD//wUAAAABAAAAAAD//wYAAAABAAAAAAD//wcAAAABAAAAAAAAAP//AAAAAAIAAAABAP//AAAAAAIAAAACAP//AAAAAAIAAAADAP//AAAAAAIAAAAEAP//AAAAAAIAAAAFAP//AAAAAAIAAAAGAP//AAAAAAIAAAAHAP//AAAAAAIAAAAIAP//AAAAAAIAAAAJAP//AAAAAAIAAAAKAP//AAAAAAIAAAALAP//AAAAAAIAAAAMAP//AAAAAAIAAAANAP//AAAAAAIAAAAOAP//AAAAAAIAAAAPAP//AAAAAAIAAAAQAP//AAAAAAIAAAD/////AAACAAIAAAARAP//AAADAAIAAAD//wgAAAADAAAAAAARAAgAAAAEAAAAAAAQAAgAAAACAAAAAAAPAAgAAAACAAAAAAAOAAgAAAACAAAAAAANAAgAAAACAAAAAAAMAAgAAAACAAAAAAALAAgAAAACAAAAAAAKAAgAAAACAAAAAAAJAAgAAAACAAAAAAAIAAgAAAACAAAAAAAHAAgAAAACAAAAAAAGAAgAAAACAAAAAAAFAAgAAAACAAAAAAAEAAgAAAACAAAAAAADAAgAAAACAAAAAAACAAgAAAACAAAAAAABAAgAAAACAAAAAAAAAAgAAAACAAAAAAA=")
|
tile_map_data = PackedByteArray("AAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAGAAAAAAAAAAEAAAAHAAAAAAAAAAAAAAAIAAAAAAAAAAEAAAAJAAAAAAAAAAEAAAAKAAAAAAAAAAEAAAALAAAAAAAAAAAAAAAMAAAAAAAAAAEAAAANAAAAAAAAAAEAAAAOAAAAAAAAAA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IAAAABAAAAAAD//wMAAAABAAAAAAD//wQAAAABAAAAAAD//wUAAAABAAAAAAD//wYAAAABAAAAAAD//wcAAAABAAAAAAAAAP//AAAAAAIAAAABAP//AAAAAAIAAAACAP//AAAAAAIAAAADAP//AAAAAAIAAAAEAP//AAAAAAIAAAAFAP//AAAAAAIAAAAGAP//AAAAAAIAAAAHAP//AAAAAAIAAAAIAP//AAAAAAIAAAAJAP//AAAAAAIAAAAKAP//AAAAAAIAAAALAP//AAAAAAIAAAAMAP//AAAAAAIAAAANAP//AAAAAAIAAAAOAP//AAAAAAIAAAAPAP//AAAAAAIAAAAQAP//AAAAAAIAAAD/////AAACAAIAAAARAP//AAADAAIAAAD//wgAAAADAAAAAAARAAgAAAAEAAAAAAAQAAgAAAACAAAAAAAPAAgAAAACAAAAAAAOAAgAAAACAAAAAAANAAgAAAACAAAAAAAMAAgAAAACAAAAAAALAAgAAAACAAAAAAAKAAgAAAACAAAAAAAJAAgAAAACAAAAAAAIAAgAAAACAAAAAAAHAAgAAAACAAAAAAAGAAgAAAACAAAAAAAFAAgAAAACAAAAAAAEAAgAAAACAAAAAAADAAgAAAACAAAAAAACAAgAAAACAAAAAAABAAgAAAACAAAAAAAAAAgAAAACAAAAAAA=")
|
||||||
tile_set = ExtResource("1_khkq2")
|
tile_set = ExtResource("1_khkq2")
|
||||||
|
|
||||||
[node name="BuildRect" type="Marker2D" parent="."]
|
[node name="BuildRect" type="Marker2D" parent="." node_paths=PackedStringArray("entity_holder")]
|
||||||
script = ExtResource("2_wpmwa")
|
script = ExtResource("2_wpmwa")
|
||||||
building_rect = Rect2(0, 0, 272, 128)
|
building_rect = Rect2(0, 0, 272, 128)
|
||||||
|
entity_holder = NodePath("../EntityHolder")
|
||||||
|
|
||||||
[node name="EntityHolder" type="Node2D" parent="." node_paths=PackedStringArray("building_zone")]
|
[node name="EntityHolder" type="Node2D" parent="." node_paths=PackedStringArray("building_zone")]
|
||||||
script = ExtResource("3_6hjoe")
|
script = ExtResource("3_6hjoe")
|
||||||
|
|
|
@ -6,8 +6,6 @@ extends Marker2D
|
||||||
|
|
||||||
class_name BuildZone
|
class_name BuildZone
|
||||||
|
|
||||||
const GRID_SIZE : Vector2 = Vector2(16,16)
|
|
||||||
|
|
||||||
## Rect that used for bounds check and conversions
|
## Rect that used for bounds check and conversions
|
||||||
@export var building_rect : Rect2:
|
@export var building_rect : Rect2:
|
||||||
set(value):
|
set(value):
|
||||||
|
@ -17,6 +15,8 @@ const GRID_SIZE : Vector2 = Vector2(16,16)
|
||||||
get:
|
get:
|
||||||
return building_rect
|
return building_rect
|
||||||
|
|
||||||
|
@export var entity_holder : EntityHolder
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
if not Engine.is_editor_hint():
|
if not Engine.is_editor_hint():
|
||||||
Registry.build_zones.append(self)
|
Registry.build_zones.append(self)
|
||||||
|
@ -37,7 +37,7 @@ func is_global_point_in_zone(point: Vector2) -> bool:
|
||||||
func indexify_point(point : Vector2) -> int:
|
func indexify_point(point : Vector2) -> int:
|
||||||
if is_point_in_zone(point) == false:
|
if is_point_in_zone(point) == false:
|
||||||
return -1
|
return -1
|
||||||
return int(point.x) / int(GRID_SIZE.x) + int(building_rect.size.x/GRID_SIZE.x)*(int(point.y) / int(GRID_SIZE.y))
|
return int(point.x) / int(Globals.GRID_SIZE.x) + int(building_rect.size.x/Globals.GRID_SIZE.x)*(int(point.y) / int(Globals.GRID_SIZE.y))
|
||||||
|
|
||||||
## Returns index of point (global coordinates) to be used in array
|
## Returns index of point (global coordinates) to be used in array
|
||||||
func indexify_global_point(point : Vector2) -> int:
|
func indexify_global_point(point : Vector2) -> int:
|
||||||
|
@ -45,7 +45,7 @@ func indexify_global_point(point : Vector2) -> int:
|
||||||
|
|
||||||
## Inverses indexification of point, returning snapped position
|
## Inverses indexification of point, returning snapped position
|
||||||
func inverse_index(index: int) -> Vector2:
|
func inverse_index(index: int) -> Vector2:
|
||||||
return to_global(Vector2(index%int(building_rect.size.x/GRID_SIZE.x)*GRID_SIZE.x,index / int(building_rect.size.x/GRID_SIZE.x) * GRID_SIZE.y))
|
return to_global(Vector2(index%int(building_rect.size.x/Globals.GRID_SIZE.x)*Globals.GRID_SIZE.x,index / int(building_rect.size.x/Globals.GRID_SIZE.x) * Globals.GRID_SIZE.y))
|
||||||
|
|
||||||
## Returns snapped position of point (global coordinates).
|
## Returns snapped position of point (global coordinates).
|
||||||
## Equivalent of [code]
|
## Equivalent of [code]
|
||||||
|
@ -54,8 +54,8 @@ func inverse_index(index: int) -> Vector2:
|
||||||
func get_placement_position(point : Vector2) -> Vector2:
|
func get_placement_position(point : Vector2) -> Vector2:
|
||||||
if is_global_point_in_zone(point) == false:
|
if is_global_point_in_zone(point) == false:
|
||||||
return Vector2.ZERO
|
return Vector2.ZERO
|
||||||
return to_global((to_local(point) / GRID_SIZE).floor()*GRID_SIZE + GRID_SIZE/2.0)
|
return to_global((to_local(point) / Globals.GRID_SIZE).floor()*Globals.GRID_SIZE + Globals.GRID_SIZE/2.0)
|
||||||
|
|
||||||
## Returns capacity of building zone to be used in the array
|
## Returns capacity of building zone to be used in the array
|
||||||
func get_capacity() -> int:
|
func get_capacity() -> int:
|
||||||
return int(building_rect.size.x/GRID_SIZE.x)*int(building_rect.size.y/GRID_SIZE.y)
|
return int(building_rect.size.x/Globals.GRID_SIZE.x)*int(building_rect.size.y/Globals.GRID_SIZE.y)
|
||||||
|
|
|
@ -1,6 +1,44 @@
|
||||||
|
@tool
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
class_name Construction
|
class_name Construction
|
||||||
|
|
||||||
|
@export var dimensions : Rect2i = Rect2i(0,0,1,1):
|
||||||
|
set(value):
|
||||||
|
dimensions = value
|
||||||
|
if Engine.is_editor_hint():
|
||||||
|
queue_redraw()
|
||||||
|
get:
|
||||||
|
return dimensions
|
||||||
|
|
||||||
|
func _draw() -> void:
|
||||||
|
if Engine.is_editor_hint():
|
||||||
|
for x in range(dimensions.size.x):
|
||||||
|
for y in range(dimensions.size.y):
|
||||||
|
draw_circle((dimensions.position+Vector2i(x,y)) * Vector2i(Globals.GRID_SIZE),2,Color.AQUA)
|
||||||
|
|
||||||
func get_relative(dv : Vector2) -> Construction:
|
func get_relative(dv : Vector2) -> Construction:
|
||||||
return get_parent().get_at(global_position+dv)
|
return get_parent().get_at(global_position+dv)
|
||||||
|
|
||||||
|
func can_be_placed(zone : BuildZone) -> bool:
|
||||||
|
for dp in get_dimension_points():
|
||||||
|
var point = global_position + dp
|
||||||
|
if zone.is_global_point_in_zone(point) == false:
|
||||||
|
return false
|
||||||
|
if zone.entity_holder.is_point_occupied(point):
|
||||||
|
return false
|
||||||
|
return true
|
||||||
|
|
||||||
|
func try_place(zone : BuildZone) -> bool:
|
||||||
|
if can_be_placed(zone) == false:
|
||||||
|
return false
|
||||||
|
|
||||||
|
return zone.entity_holder.add_construction(self)
|
||||||
|
|
||||||
|
func get_dimension_points() -> Array[Vector2]:
|
||||||
|
var result : Array[Vector2] = []
|
||||||
|
result.resize(dimensions.size.x*dimensions.size.y)
|
||||||
|
for x in range(dimensions.size.x):
|
||||||
|
for y in range(dimensions.size.y):
|
||||||
|
result[x + y * dimensions.size.x] = (Vector2(x,y)*Globals.GRID_SIZE + Vector2(dimensions.position))
|
||||||
|
return result
|
||||||
|
|
|
@ -13,7 +13,7 @@ func _input(event: InputEvent) -> void:
|
||||||
if zone == null:
|
if zone == null:
|
||||||
held_construction.queue_free()
|
held_construction.queue_free()
|
||||||
else:
|
else:
|
||||||
if zone.get_parent().get_node("EntityHolder").add_construction(held_construction):
|
if held_construction.try_place(zone):
|
||||||
held_construction = null
|
held_construction = null
|
||||||
|
|
||||||
if event.is_action_pressed("plc_cancel"):
|
if event.is_action_pressed("plc_cancel"):
|
||||||
|
@ -27,13 +27,14 @@ func on_construction_selected(constructible : Constructible):
|
||||||
|
|
||||||
|
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
if held_construction != null:
|
if held_construction == null:
|
||||||
var mouse_pos = get_global_mouse_position()
|
return
|
||||||
var zone = try_get_zone(mouse_pos)
|
var mouse_pos = get_global_mouse_position()
|
||||||
if zone:
|
var zone = try_get_zone(mouse_pos)
|
||||||
global_position = zone.get_placement_position(mouse_pos)
|
if zone and held_construction.can_be_placed(zone):
|
||||||
else:
|
global_position = zone.get_placement_position(mouse_pos)
|
||||||
global_position = mouse_pos
|
else:
|
||||||
|
global_position = mouse_pos
|
||||||
|
|
||||||
func try_get_zone(point : Vector2) -> BuildZone:
|
func try_get_zone(point : Vector2) -> BuildZone:
|
||||||
for zone in Registry.build_zones:
|
for zone in Registry.build_zones:
|
||||||
|
|
|
@ -11,12 +11,18 @@ func _ready() -> void:
|
||||||
constructions.resize(building_zone.get_capacity())
|
constructions.resize(building_zone.get_capacity())
|
||||||
|
|
||||||
func add_construction(construction : Construction) -> bool:
|
func add_construction(construction : Construction) -> bool:
|
||||||
if constructions[building_zone.indexify_global_point(construction.global_position)]:
|
var construction_dp = construction.get_dimension_points()
|
||||||
return false
|
for point in construction_dp:
|
||||||
|
if constructions[building_zone.indexify_global_point(construction.global_position + point)]:
|
||||||
|
return false
|
||||||
construction.reparent(self)
|
construction.reparent(self)
|
||||||
construction.global_position = building_zone.get_placement_position(construction.global_position)
|
construction.global_position = building_zone.get_placement_position(construction.global_position)
|
||||||
constructions[building_zone.indexify_global_point(construction.global_position)] = construction
|
for point in construction_dp:
|
||||||
|
constructions[building_zone.indexify_global_point(construction.global_position + point)] = construction
|
||||||
return true
|
return true
|
||||||
|
|
||||||
func get_at(point : Vector2):
|
func get_at(point : Vector2) -> Construction:
|
||||||
return constructions[building_zone.indexify_global_point(point)]
|
return constructions[building_zone.indexify_global_point(point)]
|
||||||
|
|
||||||
|
func is_point_occupied(point : Vector2) -> bool:
|
||||||
|
return get_at(point) != null
|
||||||
|
|
6
scripts/globals.gd
Normal file
6
scripts/globals.gd
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
@abstract
|
||||||
|
extends Object
|
||||||
|
|
||||||
|
class_name Globals
|
||||||
|
|
||||||
|
const GRID_SIZE : Vector2 = Vector2(16,16)
|
1
scripts/globals.gd.uid
Normal file
1
scripts/globals.gd.uid
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uid://bnmjkc8vfd7mo
|
Binary file not shown.
Before Width: | Height: | Size: 948 B After Width: | Height: | Size: 1.1 KiB |
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://cbtre16ilxte0"
|
uid="uid://dinyjq8853usn"
|
||||||
path="res://.godot/imported/Popekko.png-5c34a5f2a8c85fcf59453310fa6553d9.ctex"
|
path="res://.godot/imported/Popekko.png-5c34a5f2a8c85fcf59453310fa6553d9.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue