Name refactor
This commit is contained in:
parent
6f56fffb59
commit
e1cdf38dfb
21 changed files with 44 additions and 40 deletions
|
@ -1,7 +1,7 @@
|
||||||
[gd_resource type="Resource" script_class="Constructible" load_steps=5 format=3 uid="uid://dj524jjal1f0n"]
|
[gd_resource type="Resource" script_class="Prototype" load_steps=5 format=3 uid="uid://dj524jjal1f0n"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://c80sp6f77l5ha" path="res://scripts/constructible.gd" id="1_53h7j"]
|
[ext_resource type="Script" uid="uid://c80sp6f77l5ha" path="res://scripts/prototype.gd" id="1_53h7j"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cbtre16ilxte0" path="res://sprites/atlasses/Popekko.png" id="1_x27pp"]
|
[ext_resource type="Texture2D" uid="uid://dinyjq8853usn" path="res://sprites/atlasses/Popekko.png" id="1_x27pp"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b0h8dd82b3ox5" path="res://scenes/conveyor.tscn" id="2_hinjf"]
|
[ext_resource type="PackedScene" uid="uid://b0h8dd82b3ox5" path="res://scenes/conveyor.tscn" id="2_hinjf"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_uvy8r"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_uvy8r"]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[gd_resource type="Resource" script_class="Constructible" load_steps=5 format=3 uid="uid://yn1iesx30nfu"]
|
[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="Script" uid="uid://c80sp6f77l5ha" path="res://scripts/prototype.gd" id="1_mqcr0"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dinyjq8853usn" path="res://sprites/atlasses/Popekko.png" id="1_sh8t1"]
|
[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"]
|
[ext_resource type="PackedScene" uid="uid://dfatkxv6n55dw" path="res://scenes/debug_assembler.tscn" id="2_kf3x0"]
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
[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/placement_manager.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"]
|
[ext_resource type="Resource" uid="uid://yn1iesx30nfu" path="res://generic/constructibles/dbg_assembler.tres" id="5_ymyc2"]
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://b0h8dd82b3ox5"]
|
[gd_scene load_steps=4 format=3 uid="uid://b0h8dd82b3ox5"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://cbtre16ilxte0" path="res://sprites/atlasses/Popekko.png" id="1_kqxj7"]
|
[ext_resource type="Texture2D" uid="uid://dinyjq8853usn" path="res://sprites/atlasses/Popekko.png" id="1_kqxj7"]
|
||||||
[ext_resource type="Script" uid="uid://bbd7o2st8kmgl" path="res://scripts/construction.gd" id="1_y326v"]
|
[ext_resource type="Script" uid="uid://bbd7o2st8kmgl" path="res://scripts/structure.gd" id="1_y326v"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_uvy8r"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_uvy8r"]
|
||||||
atlas = ExtResource("1_kqxj7")
|
atlas = ExtResource("1_kqxj7")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://dfatkxv6n55dw"]
|
[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="Script" uid="uid://bbd7o2st8kmgl" path="res://scripts/structure.gd" id="1_k5y3y"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dinyjq8853usn" path="res://sprites/atlasses/Popekko.png" id="2_4befw"]
|
[ext_resource type="Texture2D" uid="uid://dinyjq8853usn" path="res://sprites/atlasses/Popekko.png" id="2_4befw"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xh4eg"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_xh4eg"]
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
[gd_scene load_steps=4 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/placement_zone.gd" id="2_bwire"]
|
||||||
[ext_resource type="Script" uid="uid://x5edy155eg0s" path="res://scripts/entity_holder.gd" id="3_qaudu"]
|
[ext_resource type="Script" uid="uid://x5edy155eg0s" path="res://scripts/grid_controller.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=")
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
[gd_scene load_steps=4 format=4 uid="uid://b7du4vul4bmpq"]
|
[gd_scene load_steps=4 format=4 uid="uid://b7du4vul4bmpq"]
|
||||||
|
|
||||||
[ext_resource type="TileSet" uid="uid://bv75bu0af04vs" path="res://generic/platform.tres" id="1_khkq2"]
|
[ext_resource type="TileSet" uid="uid://bv75bu0af04vs" path="res://generic/platform.tres" id="1_khkq2"]
|
||||||
[ext_resource type="Script" uid="uid://lw1ya3iu14uf" path="res://scripts/build_zone.gd" id="2_wpmwa"]
|
[ext_resource type="Script" uid="uid://lw1ya3iu14uf" path="res://scripts/placement_zone.gd" id="2_wpmwa"]
|
||||||
[ext_resource type="Script" uid="uid://x5edy155eg0s" path="res://scripts/entity_holder.gd" id="3_6hjoe"]
|
[ext_resource type="Script" uid="uid://x5edy155eg0s" path="res://scripts/grid_controller.gd" id="3_6hjoe"]
|
||||||
|
|
||||||
[node name="PlayerPlatform" type="Node2D"]
|
[node name="PlayerPlatform" type="Node2D"]
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,2 @@
|
||||||
|
## Global class for runtime
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
get_tree().scene_changed.connect(cleanup_runtime_cache)
|
|
||||||
|
|
||||||
func cleanup_runtime_cache():
|
|
||||||
build_zones.clear()
|
|
||||||
|
|
||||||
var build_zones : Array[BuildZone]
|
|
||||||
|
|
|
@ -1 +1,12 @@
|
||||||
|
## Global class for player in-game data
|
||||||
|
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
get_tree().scene_changed.connect(cleanup_runtime_cache)
|
||||||
|
|
||||||
|
## Method to cleanup all data that will be nulled
|
||||||
|
func cleanup_runtime_cache():
|
||||||
|
build_zones.clear()
|
||||||
|
|
||||||
|
var build_zones : Array[PlacementZone]
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
class_name EntityHolder
|
class_name GridController
|
||||||
|
|
||||||
const GRID_SIZE : Vector2 = Vector2(16,16)
|
const GRID_SIZE : Vector2 = Vector2(16,16)
|
||||||
|
|
||||||
@export var building_zone : BuildZone
|
@export var building_zone : PlacementZone
|
||||||
var constructions : Array[Construction]
|
var constructions : Array[Structure]
|
||||||
|
|
||||||
func _ready() -> void:
|
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 : Structure) -> bool:
|
||||||
var construction_dp = construction.get_dimension_points()
|
var construction_dp = construction.get_dimension_points()
|
||||||
for point in construction_dp:
|
for point in construction_dp:
|
||||||
if constructions[building_zone.indexify_global_point(construction.global_position + point)]:
|
if constructions[building_zone.indexify_global_point(construction.global_position + point)]:
|
||||||
|
@ -21,7 +21,7 @@ func add_construction(construction : Construction) -> bool:
|
||||||
constructions[building_zone.indexify_global_point(construction.global_position + point)] = construction
|
constructions[building_zone.indexify_global_point(construction.global_position + point)] = construction
|
||||||
return true
|
return true
|
||||||
|
|
||||||
func get_at(point : Vector2) -> Construction:
|
func get_at(point : Vector2) -> Structure:
|
||||||
return constructions[building_zone.indexify_global_point(point)]
|
return constructions[building_zone.indexify_global_point(point)]
|
||||||
|
|
||||||
func is_point_occupied(point : Vector2) -> bool:
|
func is_point_occupied(point : Vector2) -> bool:
|
|
@ -1,6 +1,6 @@
|
||||||
extends Button
|
extends Button
|
||||||
|
|
||||||
@export var constructible : Constructible
|
@export var constructible : Prototype
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
icon = constructible.preview
|
icon = constructible.preview
|
||||||
|
|
|
@ -2,5 +2,5 @@ extends Node
|
||||||
|
|
||||||
@warning_ignore_start("unused_signal")
|
@warning_ignore_start("unused_signal")
|
||||||
|
|
||||||
signal construction_selected(constructible : Constructible)
|
signal construction_selected(constructible : Prototype)
|
||||||
signal construction_placed(constructible : Constructible)
|
signal construction_placed(constructible : Prototype)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
var held_construction : Construction
|
var held_construction : Structure
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
GuiEventBus.construction_selected.connect(on_construction_selected)
|
GuiEventBus.construction_selected.connect(on_construction_selected)
|
||||||
|
@ -19,7 +19,7 @@ func _input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("plc_cancel"):
|
if event.is_action_pressed("plc_cancel"):
|
||||||
held_construction.queue_free()
|
held_construction.queue_free()
|
||||||
|
|
||||||
func on_construction_selected(constructible : Constructible):
|
func on_construction_selected(constructible : Prototype):
|
||||||
if held_construction:
|
if held_construction:
|
||||||
held_construction.queue_free()
|
held_construction.queue_free()
|
||||||
held_construction = constructible.scene.instantiate()
|
held_construction = constructible.scene.instantiate()
|
||||||
|
@ -36,8 +36,8 @@ func _process(_delta: float) -> void:
|
||||||
else:
|
else:
|
||||||
global_position = mouse_pos
|
global_position = mouse_pos
|
||||||
|
|
||||||
func try_get_zone(point : Vector2) -> BuildZone:
|
func try_get_zone(point : Vector2) -> PlacementZone:
|
||||||
for zone in Registry.build_zones:
|
for zone in RuntimePlayerData.build_zones:
|
||||||
if zone.is_global_point_in_zone(point):
|
if zone.is_global_point_in_zone(point):
|
||||||
return zone
|
return zone
|
||||||
return null
|
return null
|
|
@ -4,7 +4,7 @@
|
||||||
## Class that helps to manage construction sites
|
## Class that helps to manage construction sites
|
||||||
extends Marker2D
|
extends Marker2D
|
||||||
|
|
||||||
class_name BuildZone
|
class_name PlacementZone
|
||||||
|
|
||||||
## 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:
|
||||||
|
@ -15,11 +15,11 @@ class_name BuildZone
|
||||||
get:
|
get:
|
||||||
return building_rect
|
return building_rect
|
||||||
|
|
||||||
@export var entity_holder : EntityHolder
|
@export var entity_holder : GridController
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
if not Engine.is_editor_hint():
|
if not Engine.is_editor_hint():
|
||||||
Registry.build_zones.append(self)
|
RuntimePlayerData.build_zones.append(self)
|
||||||
|
|
||||||
func _draw() -> void:
|
func _draw() -> void:
|
||||||
if Engine.is_editor_hint() and EditorInterface.get_inspector().get_edited_object() == self:
|
if Engine.is_editor_hint() and EditorInterface.get_inspector().get_edited_object() == self:
|
|
@ -1,6 +1,6 @@
|
||||||
extends Resource
|
extends Resource
|
||||||
|
|
||||||
class_name Constructible
|
class_name Prototype
|
||||||
|
|
||||||
@export var scene : PackedScene
|
@export var scene : PackedScene
|
||||||
@export var preview : Texture2D
|
@export var preview : Texture2D
|
|
@ -1,7 +1,7 @@
|
||||||
@tool
|
@tool
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
class_name Construction
|
class_name Structure
|
||||||
|
|
||||||
@export var dimensions : Rect2i = Rect2i(0,0,1,1):
|
@export var dimensions : Rect2i = Rect2i(0,0,1,1):
|
||||||
set(value):
|
set(value):
|
||||||
|
@ -17,10 +17,10 @@ func _draw() -> void:
|
||||||
for y in range(dimensions.size.y):
|
for y in range(dimensions.size.y):
|
||||||
draw_circle((dimensions.position+Vector2i(x,y)) * Vector2i(Globals.GRID_SIZE),2,Color.AQUA)
|
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) -> Structure:
|
||||||
return get_parent().get_at(global_position+dv)
|
return get_parent().get_at(global_position+dv)
|
||||||
|
|
||||||
func can_be_placed(zone : BuildZone) -> bool:
|
func can_be_placed(zone : PlacementZone) -> bool:
|
||||||
for dp in get_dimension_points():
|
for dp in get_dimension_points():
|
||||||
var point = global_position + dp
|
var point = global_position + dp
|
||||||
if zone.is_global_point_in_zone(point) == false:
|
if zone.is_global_point_in_zone(point) == false:
|
||||||
|
@ -29,7 +29,7 @@ func can_be_placed(zone : BuildZone) -> bool:
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|
||||||
func try_place(zone : BuildZone) -> bool:
|
func try_place(zone : PlacementZone) -> bool:
|
||||||
if can_be_placed(zone) == false:
|
if can_be_placed(zone) == false:
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue