More building work
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="1_p1crr"]
|
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="1_p1crr"]
|
||||||
[ext_resource type="Script" path="res://data/buildings/building_group.gd" id="1_xphre"]
|
[ext_resource type="Script" path="res://data/buildings/building_group.gd" id="1_xphre"]
|
||||||
[ext_resource type="Resource" uid="uid://d38xgwstvtcm4" path="res://data/buildings/basic/harvester/harvester_building.tres" id="2_5rd2r"]
|
[ext_resource type="Resource" uid="uid://d38xgwstvtcm4" path="res://data/buildings/basic/harvester/harvester_building.tres" id="2_5rd2r"]
|
||||||
[ext_resource type="Resource" uid="uid://cta6ngelbwo8b" path="res://data/buildings/basic/warehouse_building.tres" id="3_vxs34"]
|
[ext_resource type="Resource" uid="uid://cta6ngelbwo8b" path="res://data/buildings/basic/warehouse/warehouse_building.tres" id="3_vxs34"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_nleix"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_nleix"]
|
||||||
atlas = ExtResource("1_p1crr")
|
atlas = ExtResource("1_p1crr")
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ func _ready() -> void:
|
|||||||
if _emitters.size() < 10:
|
if _emitters.size() < 10:
|
||||||
var particles = CPUParticles2D.new()
|
var particles = CPUParticles2D.new()
|
||||||
particles.amount = 8
|
particles.amount = 8
|
||||||
particles.spread = 8
|
particles.spread = 8 * (_distance / 128)
|
||||||
particles.material = ParticleProcessMaterial.new()
|
particles.material = ParticleProcessMaterial.new()
|
||||||
particles.radial_accel_max = _distance * -2.5
|
particles.damping_max = _distance * -2.5
|
||||||
particles.radial_accel_min = _distance * -2.55
|
particles.damping_min = _distance * -2.55
|
||||||
particles.gravity = Vector2.ZERO
|
particles.gravity = Vector2.ZERO
|
||||||
particles.direction = _direction
|
particles.direction = _direction
|
||||||
particles.initial_velocity_max = _distance * 2.25
|
particles.initial_velocity_max = _distance * 2.25
|
||||||
|
|||||||
7
data/buildings/basic/warehouse/warehouse.gd
Normal file
7
data/buildings/basic/warehouse/warehouse.gd
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
extends Building
|
||||||
|
|
||||||
|
func initialize(building: BuildingBase) -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
func ready(building: BuildingBase) -> void:
|
||||||
|
pass
|
||||||
18
data/buildings/basic/warehouse/warehouse_building.tres
Normal file
18
data/buildings/basic/warehouse/warehouse_building.tres
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
[gd_resource type="Resource" load_steps=5 format=3 uid="uid://cta6ngelbwo8b"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="1_t8g7q"]
|
||||||
|
[ext_resource type="Resource" uid="uid://bpjj0x7jr1k6u" path="res://data/game_resources/carbon/carbon_resource.tres" id="2_0uiah"]
|
||||||
|
[ext_resource type="Script" path="res://data/buildings/basic/warehouse/warehouse.gd" id="3_nvser"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_hcas6"]
|
||||||
|
atlas = ExtResource("1_t8g7q")
|
||||||
|
region = Rect2(1024, 64, 64, 64)
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource("3_nvser")
|
||||||
|
atlas_texture = SubResource("AtlasTexture_hcas6")
|
||||||
|
name = "Warehouse"
|
||||||
|
description = "Allows storage of more materials"
|
||||||
|
cost = {
|
||||||
|
ExtResource("2_0uiah"): 500
|
||||||
|
}
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
[gd_resource type="Resource" script_class="Building" load_steps=5 format=3 uid="uid://cta6ngelbwo8b"]
|
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://n806c03hgaq1" path="res://assets/scifi_tilesheet@2.png" id="1_24f36"]
|
|
||||||
[ext_resource type="Script" path="res://data/buildings/building.gd" id="1_aylgh"]
|
|
||||||
[ext_resource type="Resource" uid="uid://bpjj0x7jr1k6u" path="res://data/game_resources/carbon/carbon_resource.tres" id="2_s5ve8"]
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_pbx2g"]
|
|
||||||
atlas = ExtResource("1_24f36")
|
|
||||||
region = Rect2(1024, 64, 64, 64)
|
|
||||||
|
|
||||||
[resource]
|
|
||||||
script = ExtResource("1_aylgh")
|
|
||||||
atlas_texture = SubResource("AtlasTexture_pbx2g")
|
|
||||||
name = "Warehouse"
|
|
||||||
description = "Allows storage of more materials"
|
|
||||||
cost = {
|
|
||||||
ExtResource("2_s5ve8"): 500
|
|
||||||
}
|
|
||||||
@@ -8,4 +8,5 @@ script = ExtResource("1_4maxk")
|
|||||||
atlas_location = Vector2i(5, 3)
|
atlas_location = Vector2i(5, 3)
|
||||||
pickup_value = 20
|
pickup_value = 20
|
||||||
name = "Carbon"
|
name = "Carbon"
|
||||||
spawn_patterns = [ExtResource("2_eyt7m")]
|
spawn_patterns = Array[Resource("res://scripts/spawn_pattern.gd")]([ExtResource("2_eyt7m")])
|
||||||
|
storage_max = 2500
|
||||||
|
|||||||
@@ -13,11 +13,13 @@ func _on_gained_resource(res: GameResource) -> void:
|
|||||||
func pickup(resource: GameResource) -> void:
|
func pickup(resource: GameResource) -> void:
|
||||||
if not resources.has(resource):
|
if not resources.has(resource):
|
||||||
resources[resource] = 0
|
resources[resource] = 0
|
||||||
resources[resource] += resource.pickup_value
|
var pickup_amount = min(resource.pickup_value, resource.storage_max - resources[resource])
|
||||||
var changed_resources := {
|
if pickup_amount > 0:
|
||||||
resource: resource.pickup_value
|
resources[resource] += pickup_amount
|
||||||
}
|
var changed_resources := {
|
||||||
changed_resource.emit(ResourceChangedSignal.new(changed_resources))
|
resource: pickup_amount
|
||||||
|
}
|
||||||
|
changed_resource.emit(ResourceChangedSignal.new(changed_resources))
|
||||||
|
|
||||||
func has_amount(res: GameResource, amount: int) -> bool:
|
func has_amount(res: GameResource, amount: int) -> bool:
|
||||||
return resources[res] >= amount if resources.has(res) else false
|
return resources[res] >= amount if resources.has(res) else false
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ func change_building(data: BuildingBase) -> void:
|
|||||||
layer_info[Constants.TilemapLayers.BUILDINGS] = data
|
layer_info[Constants.TilemapLayers.BUILDINGS] = data
|
||||||
|
|
||||||
func get_resource() -> GameResource:
|
func get_resource() -> GameResource:
|
||||||
return layer_info[Constants.TilemapLayerss.ENVIRONMENT] as GameResource
|
return layer_info[Constants.TilemapLayers.ENVIRONMENT] as GameResource
|
||||||
|
|
||||||
func has_resource() -> bool:
|
func has_resource() -> bool:
|
||||||
return has_layer(Constants.TilemapLayers.ENVIRONMENT)
|
return has_layer(Constants.TilemapLayers.ENVIRONMENT)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ signal gained_resource(res: GameResource)
|
|||||||
@export var pickup_value: int
|
@export var pickup_value: int
|
||||||
@export var name: String
|
@export var name: String
|
||||||
@export var spawn_patterns: Array[SpawnPattern]
|
@export var spawn_patterns: Array[SpawnPattern]
|
||||||
|
@export var storage_max: int
|
||||||
|
|
||||||
func _to_string() -> String:
|
func _to_string() -> String:
|
||||||
return name
|
return name
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ func _on_resource_manager_changed_resource(changed: ResourceChangedSignal) -> vo
|
|||||||
resource_container.add_child(img)
|
resource_container.add_child(img)
|
||||||
|
|
||||||
var label := Label.new()
|
var label := Label.new()
|
||||||
label.text = str(changed.changed_resources[resource])
|
|
||||||
resource_container.add_child(label)
|
resource_container.add_child(label)
|
||||||
|
|
||||||
var data := ResourceData.new()
|
var data := ResourceData.new()
|
||||||
@@ -29,10 +28,12 @@ func _on_resource_manager_changed_resource(changed: ResourceChangedSignal) -> vo
|
|||||||
data.label = label
|
data.label = label
|
||||||
data.value = changed.changed_resources[resource]
|
data.value = changed.changed_resources[resource]
|
||||||
_resource_displays[resource] = data
|
_resource_displays[resource] = data
|
||||||
|
|
||||||
|
label.text = "%s / %s" % [data.value, resource.storage_max]
|
||||||
else:
|
else:
|
||||||
var data: ResourceData = _resource_displays[resource]
|
var data: ResourceData = _resource_displays[resource]
|
||||||
data.value += changed.changed_resources[resource]
|
data.value += changed.changed_resources[resource]
|
||||||
data.label.text = str(data.value)
|
data.label.text = "%s / %s" % [data.value, resource.storage_max]
|
||||||
|
|
||||||
class ResourceData:
|
class ResourceData:
|
||||||
var image: TextureRect
|
var image: TextureRect
|
||||||
|
|||||||
Reference in New Issue
Block a user