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="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://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"]
|
||||
atlas = ExtResource("1_p1crr")
|
||||
|
||||
@@ -15,10 +15,10 @@ func _ready() -> void:
|
||||
if _emitters.size() < 10:
|
||||
var particles = CPUParticles2D.new()
|
||||
particles.amount = 8
|
||||
particles.spread = 8
|
||||
particles.spread = 8 * (_distance / 128)
|
||||
particles.material = ParticleProcessMaterial.new()
|
||||
particles.radial_accel_max = _distance * -2.5
|
||||
particles.radial_accel_min = _distance * -2.55
|
||||
particles.damping_max = _distance * -2.5
|
||||
particles.damping_min = _distance * -2.55
|
||||
particles.gravity = Vector2.ZERO
|
||||
particles.direction = _direction
|
||||
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)
|
||||
pickup_value = 20
|
||||
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:
|
||||
if not resources.has(resource):
|
||||
resources[resource] = 0
|
||||
resources[resource] += resource.pickup_value
|
||||
var changed_resources := {
|
||||
resource: resource.pickup_value
|
||||
}
|
||||
changed_resource.emit(ResourceChangedSignal.new(changed_resources))
|
||||
var pickup_amount = min(resource.pickup_value, resource.storage_max - resources[resource])
|
||||
if pickup_amount > 0:
|
||||
resources[resource] += pickup_amount
|
||||
var changed_resources := {
|
||||
resource: pickup_amount
|
||||
}
|
||||
changed_resource.emit(ResourceChangedSignal.new(changed_resources))
|
||||
|
||||
func has_amount(res: GameResource, amount: int) -> bool:
|
||||
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
|
||||
|
||||
func get_resource() -> GameResource:
|
||||
return layer_info[Constants.TilemapLayerss.ENVIRONMENT] as GameResource
|
||||
return layer_info[Constants.TilemapLayers.ENVIRONMENT] as GameResource
|
||||
|
||||
func has_resource() -> bool:
|
||||
return has_layer(Constants.TilemapLayers.ENVIRONMENT)
|
||||
|
||||
@@ -7,6 +7,7 @@ signal gained_resource(res: GameResource)
|
||||
@export var pickup_value: int
|
||||
@export var name: String
|
||||
@export var spawn_patterns: Array[SpawnPattern]
|
||||
@export var storage_max: int
|
||||
|
||||
func _to_string() -> String:
|
||||
return name
|
||||
|
||||
@@ -21,7 +21,6 @@ func _on_resource_manager_changed_resource(changed: ResourceChangedSignal) -> vo
|
||||
resource_container.add_child(img)
|
||||
|
||||
var label := Label.new()
|
||||
label.text = str(changed.changed_resources[resource])
|
||||
resource_container.add_child(label)
|
||||
|
||||
var data := ResourceData.new()
|
||||
@@ -29,10 +28,12 @@ func _on_resource_manager_changed_resource(changed: ResourceChangedSignal) -> vo
|
||||
data.label = label
|
||||
data.value = changed.changed_resources[resource]
|
||||
_resource_displays[resource] = data
|
||||
|
||||
label.text = "%s / %s" % [data.value, resource.storage_max]
|
||||
else:
|
||||
var data: ResourceData = _resource_displays[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:
|
||||
var image: TextureRect
|
||||
|
||||
Reference in New Issue
Block a user