Add new buildings.
This commit is contained in:
parent
7e2b5ab350
commit
8de97e6a94
|
@ -2,12 +2,13 @@ extends GridMap
|
|||
|
||||
var postprocess_done: bool = false
|
||||
|
||||
var postprocess_delay: float = 5.0
|
||||
var postprocess_delay: float = 1.0
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if postprocess_delay > 0:
|
||||
postprocess_delay -= delta
|
||||
if postprocess_delay <= 0 and !postprocess_done:
|
||||
#bake_navigation = true
|
||||
if !NavigationServer3D.get_maps().is_empty():
|
||||
postprocess_done = true
|
||||
var regions_deleted: int = 0
|
||||
|
|
|
@ -3,32 +3,33 @@
|
|||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://u1hpdb62rxlc"
|
||||
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
|
||||
path.s3tc="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.s3tc.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
"imported_formats": ["s3tc_bptc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
|
||||
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.s3tc.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/normal_map=1
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
roughness/mode=1
|
||||
roughness/src_normal="res://icon.png"
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
detect_3d/compress_to=0
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
[gd_resource type="Resource" script_class="Item" load_steps=6 format=3 uid="uid://ed64yksg1y6m"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://kcdpck5ufgcc" path="res://scripts/item.gd" id="1_5qyf8"]
|
||||
[ext_resource type="Texture2D" uid="uid://denfapnjlvmku" path="res://assets/images/bullet.png" id="1_ubihn"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_5qyf8"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_5qyf8"]
|
||||
transparency = 2
|
||||
alpha_scissor_threshold = 0.5
|
||||
alpha_antialiasing_mode = 0
|
||||
albedo_texture = ExtResource("1_ubihn")
|
||||
billboard_mode = 2
|
||||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_ubihn"]
|
||||
material = SubResource("StandardMaterial3D_5qyf8")
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_5qyf8")
|
||||
icon = SubResource("AtlasTexture_5qyf8")
|
||||
name = "Bullets"
|
||||
model = SubResource("QuadMesh_ubihn")
|
||||
metadata/_custom_type_script = "uid://kcdpck5ufgcc"
|
|
@ -1,10 +1,12 @@
|
|||
[gd_resource type="Resource" script_class="Item" load_steps=3 format=3 uid="uid://dbkxys3mr5u80"]
|
||||
[gd_resource type="Resource" script_class="Item" load_steps=4 format=3 uid="uid://dbkxys3mr5u80"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://kcdpck5ufgcc" path="res://scripts/item.gd" id="1_a88ho"]
|
||||
[ext_resource type="Texture2D" uid="uid://xpm6i82tui2o" path="res://assets/images/watchtower.png" id="1_jdpiu"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://c6yj8uwsgqxv0" path="res://assets/models/Ingot.obj" id="2_iy2ff"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_a88ho")
|
||||
icon = ExtResource("1_jdpiu")
|
||||
name = "Metal"
|
||||
model = ExtResource("2_iy2ff")
|
||||
metadata/_custom_type_script = "uid://kcdpck5ufgcc"
|
||||
|
|
108
node_3d.tscn
108
node_3d.tscn
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,7 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://b1fnsl3k1mo5c"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://b1fnsl3k1mo5c"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dvgo3kpjr2mmj" path="res://scripts/building_components/building.gd" id="1_k07no"]
|
||||
[ext_resource type="Script" uid="uid://bcp3fwf3nds3k" path="res://scripts/nav_obstacle.gd" id="2_0gk2u"]
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_cee1v"]
|
||||
size = Vector3(2, 2, 2)
|
||||
|
@ -8,6 +9,15 @@ size = Vector3(2, 2, 2)
|
|||
[sub_resource type="BoxShape3D" id="BoxShape3D_k07no"]
|
||||
size = Vector3(2, 2, 2)
|
||||
|
||||
[sub_resource type="NavigationMesh" id="NavigationMesh_0gk2u"]
|
||||
vertices = PackedVector3Array(-0.75, 2.5, -0.75, -0.75, 2.5, 0.75, 0.75, 2.5, 0.75, 0.75, 2.5, -0.75)
|
||||
polygons = [PackedInt32Array(3, 2, 0), PackedInt32Array(0, 2, 1)]
|
||||
agent_radius = 0.2
|
||||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_oywkk"]
|
||||
size = Vector2(2, 2)
|
||||
orientation = 1
|
||||
|
||||
[node name="Building" type="StaticBody3D"]
|
||||
script = ExtResource("1_k07no")
|
||||
|
||||
|
@ -19,10 +29,18 @@ mesh = SubResource("BoxMesh_cee1v")
|
|||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
shape = SubResource("BoxShape3D_k07no")
|
||||
|
||||
[node name="NavObstacle" type="Node3D" parent="."]
|
||||
script = ExtResource("2_0gk2u")
|
||||
make_solid = false
|
||||
|
||||
[node name="NavigationObstacle3D" type="NavigationObstacle3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
radius = 1.0
|
||||
vertices = PackedVector3Array(-1, 0, -1, 1, 0, -1, 1, 0, 1, -1, 0, 1)
|
||||
affect_navigation_mesh = true
|
||||
carve_navigation_mesh = true
|
||||
use_3d_avoidance = true
|
||||
radius = 2.0
|
||||
height = 2.0
|
||||
|
||||
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="."]
|
||||
navigation_mesh = SubResource("NavigationMesh_0gk2u")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="NavigationRegion3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
|
||||
visible = false
|
||||
mesh = SubResource("QuadMesh_oywkk")
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://dhfqv26h4i0i3"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cnoyykkcidp1d" path="res://scripts/buildings/conveyor.gd" id="1_m8ga5"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://bv225xw8xssl4" path="res://assets/models/Conveyor.obj" id="2_dyib0"]
|
||||
[ext_resource type="Script" uid="uid://bshiyw2k3op02" path="res://scripts/building_components/consumer.gd" id="3_vjqud"]
|
||||
[ext_resource type="Script" uid="uid://c4fquatkjmsgu" path="res://scripts/building_components/producer.gd" id="4_d3uke"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://c6yj8uwsgqxv0" path="res://assets/models/Ingot.obj" id="5_w2262"]
|
||||
|
||||
[sub_resource type="Curve3D" id="Curve3D_r3fl7"]
|
||||
_data = {
|
||||
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -3),
|
||||
"tilts": PackedFloat32Array(0, 0)
|
||||
}
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="MultiMesh" id="MultiMesh_6iypd"]
|
||||
transform_format = 1
|
||||
instance_count = 1
|
||||
mesh = ExtResource("5_w2262")
|
||||
buffer = PackedFloat32Array(1, 8.40779e-44, 8.54792e-44, 9.10844e-44, 8.54792e-44, 1, 9.10844e-44, 0.325, 8.82818e-44, 9.10844e-44, 1, 8.96831e-44)
|
||||
|
||||
[node name="Conveyor" type="Path3D"]
|
||||
curve = SubResource("Curve3D_r3fl7")
|
||||
script = ExtResource("1_m8ga5")
|
||||
item_offset = Vector3(0, 0.325, 0)
|
||||
|
||||
[node name="PathMesh3D" type="PathMesh3D" parent="." node_paths=PackedStringArray("path_3d")]
|
||||
mesh = ExtResource("2_dyib0")
|
||||
path_3d = NodePath("..")
|
||||
surface_0/tile_rotation = Vector3(0, 0, 0)
|
||||
surface_0/tile_rotation_order = 2
|
||||
surface_0/distribution = 0
|
||||
surface_0/alignment = 0
|
||||
surface_0/warp_along_curve = true
|
||||
surface_0/sample_cubic = false
|
||||
surface_0/tilt = true
|
||||
surface_0/offset = Vector2(0, 0)
|
||||
surface_1/tile_rotation = Vector3(0, 0, 0)
|
||||
surface_1/tile_rotation_order = 2
|
||||
surface_1/distribution = 0
|
||||
surface_1/alignment = 0
|
||||
surface_1/warp_along_curve = true
|
||||
surface_1/sample_cubic = false
|
||||
surface_1/tilt = true
|
||||
surface_1/offset = Vector2(0, 0)
|
||||
|
||||
[node name="Consumer" type="Node" parent="."]
|
||||
script = ExtResource("3_vjqud")
|
||||
storage_size = 1
|
||||
metadata/_custom_type_script = "uid://bshiyw2k3op02"
|
||||
|
||||
[node name="Producer" type="Node" parent="." node_paths=PackedStringArray("consumers")]
|
||||
script = ExtResource("4_d3uke")
|
||||
consumers = [null]
|
||||
metadata/_custom_type_script = "uid://c4fquatkjmsgu"
|
||||
|
||||
[node name="MultiMeshInstance3D" type="MultiMeshInstance3D" parent="."]
|
||||
multimesh = SubResource("MultiMesh_6iypd")
|
||||
|
||||
[connection signal="item_added" from="Consumer" to="." method="consumer_has_item"]
|
|
@ -0,0 +1,21 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://chd531mdaek3"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b1fnsl3k1mo5c" path="res://objects/buildings/building.tscn" id="1_8r86l"]
|
||||
[ext_resource type="Script" uid="uid://6dy54s70qf0x" path="res://scripts/buildings/miner.gd" id="2_k13eg"]
|
||||
[ext_resource type="PackedScene" uid="uid://cjg7f5ktk20yq" path="res://assets/blends/Miner.blend" id="2_la0h1"]
|
||||
[ext_resource type="Resource" uid="uid://dbkxys3mr5u80" path="res://items/metal.tres" id="3_8y6s2"]
|
||||
[ext_resource type="Script" uid="uid://c4fquatkjmsgu" path="res://scripts/building_components/producer.gd" id="5_65oni"]
|
||||
|
||||
[node name="Miner" instance=ExtResource("1_8r86l")]
|
||||
script = ExtResource("2_k13eg")
|
||||
mined_item = ExtResource("3_8y6s2")
|
||||
mine_period = 1.0
|
||||
|
||||
[node name="MeshInstance3D" parent="." index="0"]
|
||||
visible = false
|
||||
|
||||
[node name="Miner2" parent="." index="5" instance=ExtResource("2_la0h1")]
|
||||
|
||||
[node name="Producer" type="Node" parent="." index="6"]
|
||||
script = ExtResource("5_65oni")
|
||||
metadata/_custom_type_script = "uid://c4fquatkjmsgu"
|
|
@ -1,7 +1,11 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://c6e1nifka3h4v"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://c6e1nifka3h4v"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b1fnsl3k1mo5c" path="res://objects/buildings/building.tscn" id="1_hxugg"]
|
||||
[ext_resource type="Script" uid="uid://c3bqfgoof2c83" path="res://scripts/buildings/processor.gd" id="2_evfwj"]
|
||||
[ext_resource type="Script" uid="uid://kcdpck5ufgcc" path="res://scripts/item.gd" id="3_3h7kv"]
|
||||
[ext_resource type="Resource" uid="uid://ed64yksg1y6m" path="res://items/bullets.tres" id="4_3h7kv"]
|
||||
[ext_resource type="Script" uid="uid://bshiyw2k3op02" path="res://scripts/building_components/consumer.gd" id="4_dx8de"]
|
||||
[ext_resource type="Resource" uid="uid://dbkxys3mr5u80" path="res://items/metal.tres" id="4_miqab"]
|
||||
[ext_resource type="Script" uid="uid://c4fquatkjmsgu" path="res://scripts/building_components/producer.gd" id="5_p3dou"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_evfwj"]
|
||||
|
@ -12,14 +16,20 @@ material = SubResource("StandardMaterial3D_evfwj")
|
|||
size = Vector3(2, 2, 2)
|
||||
|
||||
[node name="Processor" instance=ExtResource("1_hxugg")]
|
||||
script = ExtResource("2_evfwj")
|
||||
ingredients = Dictionary[ExtResource("3_3h7kv"), int]({
|
||||
ExtResource("4_miqab"): 2
|
||||
})
|
||||
process_time = 1.0
|
||||
created_item = ExtResource("4_3h7kv")
|
||||
|
||||
[node name="MeshInstance3D" parent="." index="0"]
|
||||
mesh = SubResource("BoxMesh_3h7kv")
|
||||
|
||||
[node name="Consumer" type="Node" parent="." index="3"]
|
||||
[node name="Consumer" type="Node" parent="." index="2"]
|
||||
script = ExtResource("4_dx8de")
|
||||
metadata/_custom_type_script = "uid://bshiyw2k3op02"
|
||||
|
||||
[node name="Producer" type="Node" parent="." index="4"]
|
||||
[node name="Producer" type="Node" parent="." index="3"]
|
||||
script = ExtResource("5_p3dou")
|
||||
metadata/_custom_type_script = "uid://c4fquatkjmsgu"
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://cw3vtaevqx20y"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b1fnsl3k1mo5c" path="res://objects/buildings/building.tscn" id="1_cgb0l"]
|
||||
[ext_resource type="Script" uid="uid://bl78fqp1abxd6" path="res://scripts/buildings/turret.gd" id="2_brx0q"]
|
||||
[ext_resource type="Script" uid="uid://bshiyw2k3op02" path="res://scripts/building_components/consumer.gd" id="2_wh3b5"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_cgb0l"]
|
||||
albedo_color = Color(0, 0.00397563, 1, 1)
|
||||
|
||||
[node name="Turret" instance=ExtResource("1_cgb0l")]
|
||||
script = ExtResource("2_brx0q")
|
||||
|
||||
[node name="MeshInstance3D" parent="." index="0"]
|
||||
material_override = SubResource("StandardMaterial3D_cgb0l")
|
||||
|
||||
[node name="Consumer" type="Node" parent="." index="5"]
|
||||
script = ExtResource("2_wh3b5")
|
||||
metadata/_custom_type_script = "uid://bshiyw2k3op02"
|
|
@ -0,0 +1,62 @@
|
|||
[gd_scene load_steps=12 format=3 uid="uid://cav22qho14o47"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://jtlad4viky6j" path="res://addons/GPUTrail/shaders/trail.gdshader" id="1_ucnj8"]
|
||||
[ext_resource type="Shader" uid="uid://cxd8wfunwre2a" path="res://addons/GPUTrail/shaders/trail_draw_pass.gdshader" id="2_rsjgb"]
|
||||
[ext_resource type="Script" uid="uid://cdubip3a6325r" path="res://addons/GPUTrail/GPUTrail3D.gd" id="4_pt3a8"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_3ndsa"]
|
||||
radius = 0.1
|
||||
height = 0.3
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_fsn5s"]
|
||||
shader = ExtResource("1_ucnj8")
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_6sxjd"]
|
||||
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
|
||||
|
||||
[sub_resource type="GradientTexture1D" id="GradientTexture1D_od3fb"]
|
||||
gradient = SubResource("Gradient_6sxjd")
|
||||
|
||||
[sub_resource type="Curve" id="Curve_tmmim"]
|
||||
bake_resolution = 16
|
||||
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0.1), 0.0, 0.0, 0, 0]
|
||||
point_count = 2
|
||||
|
||||
[sub_resource type="CurveTexture" id="CurveTexture_7thed"]
|
||||
curve = SubResource("Curve_tmmim")
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_xbcx7"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("2_rsjgb")
|
||||
shader_parameter/uv_offset = Vector2(0, 0)
|
||||
shader_parameter/color_ramp = SubResource("GradientTexture1D_od3fb")
|
||||
shader_parameter/curve = SubResource("CurveTexture_7thed")
|
||||
shader_parameter/emmission_transform = Projection(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
|
||||
shader_parameter/flags = 44
|
||||
|
||||
[sub_resource type="QuadMesh" id="QuadMesh_ucnj8"]
|
||||
material = SubResource("ShaderMaterial_xbcx7")
|
||||
size = Vector2(10, 10)
|
||||
|
||||
[node name="Bullet" type="RigidBody3D"]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
shape = SubResource("CapsuleShape3D_3ndsa")
|
||||
|
||||
[node name="GPUTrail3D" type="GPUParticles3D" parent="."]
|
||||
transform = Transform3D(0.233971, -0.972243, 0, 0.972243, 0.233971, 0, 0, 0, 1, 0, 0, 0)
|
||||
amount = 19
|
||||
lifetime = 19.0
|
||||
explosiveness = 1.0
|
||||
fixed_fps = 59
|
||||
process_material = SubResource("ShaderMaterial_fsn5s")
|
||||
draw_pass_1 = SubResource("QuadMesh_ucnj8")
|
||||
script = ExtResource("4_pt3a8")
|
||||
length = 19
|
||||
length_seconds = 0.322034
|
||||
width = 10.0
|
||||
color_ramp = SubResource("GradientTexture1D_od3fb")
|
||||
curve = SubResource("CurveTexture_7thed")
|
||||
billboard = true
|
||||
_defaults_have_been_set = true
|
||||
metadata/_custom_type_script = "uid://cdubip3a6325r"
|
|
@ -33,8 +33,10 @@ max_speed = 5.0
|
|||
path_desired_distance = 0.5
|
||||
target_desired_distance = 0.5
|
||||
path_max_distance = 1.01
|
||||
avoidance_enabled = true
|
||||
radius = 1.0
|
||||
time_horizon_obstacles = 1.0
|
||||
max_speed = 5.0
|
||||
debug_enabled = true
|
||||
debug_path_custom_color = Color(1, 0, 0.0808306, 1)
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
|
|
|
@ -43,7 +43,7 @@ version_control/autoload_on_startup=true
|
|||
|
||||
[editor_plugins]
|
||||
|
||||
enabled=PackedStringArray("res://addons/PathMesh3D/plugin.cfg", "res://addons/git_describe/plugin.cfg", "res://addons/resources_spreadsheet_view/plugin.cfg")
|
||||
enabled=PackedStringArray("res://addons/GPUTrail/plugin.cfg", "res://addons/PathMesh3D/plugin.cfg", "res://addons/git_describe/plugin.cfg", "res://addons/resources_spreadsheet_view/plugin.cfg")
|
||||
|
||||
[layer_names]
|
||||
|
||||
|
@ -64,10 +64,6 @@ enabled=PackedStringArray("res://addons/PathMesh3D/plugin.cfg", "res://addons/gi
|
|||
3d/default_edge_connection_margin=0.6
|
||||
3d/default_link_connection_radius=0.5
|
||||
|
||||
[physics]
|
||||
|
||||
common/physics_interpolation=true
|
||||
|
||||
[rendering]
|
||||
|
||||
lights_and_shadows/directional_shadow/soft_shadow_filter_quality=0
|
||||
|
|
|
@ -12,7 +12,7 @@ enum BuildState {
|
|||
|
||||
var hp: int = max_hp
|
||||
|
||||
var build_state: BuildState = BuildState.BUILDING:
|
||||
var build_state: BuildState = BuildState.READY:
|
||||
set(state):
|
||||
build_state = state
|
||||
|
||||
|
|
|
@ -5,19 +5,24 @@ signal item_added(item: Item)
|
|||
@export var accepted_items: Array[Item] = []
|
||||
@export var storage_size: int = 4
|
||||
@export var max_inputs: int = 1
|
||||
@export var void_excess_items: bool = false
|
||||
|
||||
var storage_total: int = 0
|
||||
var storage: Dictionary[Item, int] = {}
|
||||
|
||||
func can_accept_item(item: Item) -> bool:
|
||||
return (storage_total < storage_size) and (accepted_items.has(item) or accepted_items.is_empty())
|
||||
return ((storage_total < storage_size) or void_excess_items) \
|
||||
and (accepted_items.has(item) or accepted_items.is_empty())
|
||||
|
||||
func offer_item(item: Item) -> bool:
|
||||
if !can_accept_item(item):
|
||||
return false
|
||||
storage_total += 1
|
||||
if storage_total >= storage_size and void_excess_items:
|
||||
return true # void item
|
||||
var old_count: int = storage.get(item, 0)
|
||||
storage.set(item, old_count + 1)
|
||||
storage_total += 1
|
||||
print("Added %s to %s storage; previously had %d, new total %d" % [item.name, get_parent().name, old_count, storage_total])
|
||||
item_added.emit(item)
|
||||
return true
|
||||
|
||||
|
@ -39,4 +44,6 @@ func take_items_from_storage(items: Dictionary[Item, int]) -> bool:
|
|||
for item in items.keys():
|
||||
var old_count: int = storage.get(item, 0)
|
||||
storage.set(item, old_count - items[item])
|
||||
storage_total -= items[item]
|
||||
print("Removed %s from %s storage; previously had %d, new total %d" % [item.name, get_parent().name, old_count, storage_total])
|
||||
return true
|
||||
|
|
|
@ -3,8 +3,8 @@ class_name Producer
|
|||
|
||||
@export var output_period: float = 0.1
|
||||
@export var max_outputs: int = 1
|
||||
@export var consumers: Array[Consumer]
|
||||
|
||||
var consumers: Array[Consumer]
|
||||
var next_consumer_idx: int = 0
|
||||
#var output_timer: float = 0.0
|
||||
#var output_item: Item
|
||||
|
|
|
@ -1,21 +1,27 @@
|
|||
extends Path3D
|
||||
|
||||
@export var speed: float = 1.0
|
||||
@export var item_offset: Vector3 = Vector3(0,1,0)
|
||||
@export var item_offset: Vector3 = Vector3(0,2.0,0)
|
||||
@export var extra_distance_start: float = 1.0
|
||||
@export var extra_distance_end: float = 1.0
|
||||
|
||||
var transported_items: Dictionary[Item, PackedFloat64Array] = {}
|
||||
|
||||
@onready var consumer: Consumer = $Consumer
|
||||
@onready var producer: Producer = $Producer
|
||||
@onready var multimesh: MultiMeshInstance3D = $MultiMeshInstance3D
|
||||
|
||||
var test_timer: float = 0
|
||||
@onready var test_item: Item = load("res://items/metal.tres")
|
||||
|
||||
func _ready() -> void:
|
||||
multimesh.multimesh = multimesh.multimesh.duplicate()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
test_timer += delta
|
||||
if test_timer >= 2.0:
|
||||
test_timer -= 2.0
|
||||
add_item(test_item)
|
||||
#test_timer += delta
|
||||
#if test_timer >= 2.0:
|
||||
#test_timer -= 2.0
|
||||
#add_item(test_item)
|
||||
|
||||
var belt_moving: bool = check_items_at_end()
|
||||
if belt_moving:
|
||||
|
@ -25,18 +31,25 @@ func _process(delta: float) -> void:
|
|||
for i in range(offsets.size()):
|
||||
offsets[i] += (delta * speed)
|
||||
position_item(i, transported_item_type, offsets[i])
|
||||
|
||||
func consumer_has_item(item: Item) -> void:
|
||||
if consumer.take_item_from_storage(item):
|
||||
add_item(item)
|
||||
|
||||
func add_item(item: Item) -> void:
|
||||
if item.model != multimesh.multimesh.mesh:
|
||||
multimesh.multimesh.mesh = item.model
|
||||
|
||||
var offsets: PackedFloat64Array
|
||||
if transported_items.has(item):
|
||||
offsets = transported_items[item]
|
||||
else:
|
||||
offsets = []
|
||||
offsets.append(0.0)
|
||||
offsets.append(get_start_offset())
|
||||
transported_items[item] = offsets
|
||||
|
||||
func check_items_at_end() -> bool:
|
||||
var length: float = curve.get_baked_length()
|
||||
var length: float = get_end_offset()
|
||||
var belt_moving: bool = true
|
||||
for transported_item_type in transported_items.keys():
|
||||
var offsets: PackedFloat64Array = transported_items[transported_item_type]
|
||||
|
@ -51,8 +64,28 @@ func check_items_at_end() -> bool:
|
|||
for d in to_delete:
|
||||
offsets.remove_at(d)
|
||||
return belt_moving
|
||||
|
||||
func get_start_offset() -> float:
|
||||
return -extra_distance_start
|
||||
|
||||
func get_end_offset() -> float:
|
||||
return curve.get_baked_length() + extra_distance_end
|
||||
|
||||
func position_item(instance: int, item: Item, offset: float) -> void:
|
||||
var trans: Transform3D = curve.sample_baked_with_rotation(offset).translated_local(item_offset)
|
||||
var trans: Transform3D
|
||||
trans = sample_curve_with_extrapolation(offset).translated_local(item_offset)
|
||||
multimesh.multimesh.set_instance_transform(instance, trans)
|
||||
|
||||
func sample_curve_with_extrapolation(offset: float) -> Transform3D:
|
||||
var end_offset: float = curve.get_baked_length()
|
||||
if offset <= 0:
|
||||
var zero: Transform3D = curve.sample_baked_with_rotation(0)
|
||||
var almost_zero: Transform3D = curve.sample_baked_with_rotation(0.1)
|
||||
return almost_zero.interpolate_with(zero, (0.1-offset) * 10)
|
||||
elif offset > end_offset:
|
||||
var end: Transform3D = curve.sample_baked_with_rotation(end_offset)
|
||||
var almost_end: Transform3D = curve.sample_baked_with_rotation(end_offset-0.1)
|
||||
return almost_end.interpolate_with(end, (offset - (end_offset - 0.1)) * 10)
|
||||
else:
|
||||
return curve.sample_baked_with_rotation(offset)
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
extends Building
|
||||
|
||||
@export var mined_item: Item = preload("res://items/metal.tres")
|
||||
@export var mine_period: float = 1.0
|
||||
|
||||
@onready var producer: Producer = $Producer
|
||||
var mine_timer: float = 0.0
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
mine_timer += delta
|
||||
if mine_timer >= mine_period:
|
||||
mine_timer -= mine_period
|
||||
mine()
|
||||
|
||||
func mine() -> void:
|
||||
producer.send_item(mined_item)
|
|
@ -0,0 +1 @@
|
|||
uid://6dy54s70qf0x
|
|
@ -6,6 +6,8 @@ extends Building
|
|||
|
||||
var process_timer: float = 0.0
|
||||
var processing: bool = false
|
||||
@onready var consumer: Consumer = $Consumer
|
||||
@onready var producer: Producer = $Producer
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if is_functional():
|
||||
|
@ -16,9 +18,10 @@ func _process(delta: float) -> void:
|
|||
if process_timer >= process_time:
|
||||
process_timer -= process_time
|
||||
produce_item()
|
||||
processing = false
|
||||
|
||||
func consume_ingredients() -> bool:
|
||||
return $Consumer.take_items_from_storage(ingredients)
|
||||
return consumer.take_items_from_storage(ingredients)
|
||||
|
||||
func produce_item() -> void:
|
||||
$Producer.set_output_item(created_item)
|
||||
producer.send_item(created_item)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
extends Building
|
|
@ -0,0 +1 @@
|
|||
uid://bl78fqp1abxd6
|
|
@ -7,18 +7,19 @@ class_name Unit
|
|||
@export var stuck_time: float = 1.0
|
||||
|
||||
var target_velocity: Vector3 = Vector3()
|
||||
var avoidance_velocity: Vector3 = Vector3()
|
||||
var avoidance_timeout: float = 0.0
|
||||
var last_distance_to_target: float = 0.0
|
||||
var stuck_timer: float = 0.0
|
||||
|
||||
func _ready() -> void:
|
||||
#$NavigationAgent3D.connect("velocity_computed", avoidance_velocity_computed)
|
||||
$NavigationAgent3D.connect("velocity_computed", avoidance_velocity_computed)
|
||||
pass
|
||||
|
||||
func avoidance_velocity_computed(velocity: Vector3) -> void:
|
||||
if velocity != target_velocity:
|
||||
#DebugDraw3D.draw_line(global_position, global_position + velocity, Color.ORANGE)
|
||||
#print("Avoidance issued!")
|
||||
target_velocity = velocity
|
||||
avoidance_velocity = velocity
|
||||
avoidance_timeout = 0.5
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if $NavigationAgent3D.is_target_reached() \
|
||||
|
@ -39,13 +40,13 @@ func _process(delta: float) -> void:
|
|||
else:
|
||||
$Label3D.modulate = Color.WHITE
|
||||
stuck_timer = 0
|
||||
DebugDraw3D.draw_sphere($NavigationAgent3D.target_position, 0.5, Color.RED)
|
||||
#DebugDraw3D.draw_sphere($NavigationAgent3D.target_position, 0.5, Color.RED)
|
||||
var next_point: Vector3 = $NavigationAgent3D.get_next_path_position()
|
||||
DebugDraw3D.draw_sphere(next_point, 0.1, Color.YELLOW)
|
||||
#DebugDraw3D.draw_sphere(next_point, 0.1, Color.YELLOW)
|
||||
var direction: Vector3 = (next_point - global_position).normalized()
|
||||
#DebugDraw3D.draw_line(global_position, global_position + linear_velocity, Color.BLUE)
|
||||
target_velocity= direction * max_speed
|
||||
#$NavigationAgent3D.velocity = target_velocity
|
||||
target_velocity = direction * max_speed
|
||||
$NavigationAgent3D.velocity = target_velocity
|
||||
#DebugDraw3D.draw_line(global_position, global_position + target_velocity, Color.MAGENTA)
|
||||
#DebugDraw3D.draw_text(global_position + Vector3(0,1,0), "%f" % $NavigationAgent3D.distance_to_target())
|
||||
|
||||
|
@ -56,7 +57,12 @@ func unstuck() -> void:
|
|||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if $ShapeCast3D.is_colliding():
|
||||
var force_direction: Vector3 = (target_velocity-linear_velocity)
|
||||
var actual_target_velocity: Vector3 = target_velocity
|
||||
if avoidance_timeout > 0:
|
||||
avoidance_timeout -= delta
|
||||
actual_target_velocity = actual_target_velocity.slerp(avoidance_velocity, 0.25)
|
||||
#DebugDraw3D.draw_line(global_position, global_position + actual_target_velocity, Color.ORANGE)
|
||||
var force_direction: Vector3 = (actual_target_velocity-linear_velocity)
|
||||
var normal: Vector3 = $ShapeCast3D.get_collision_normal(0)
|
||||
#DebugDraw3D.draw_line(global_position, global_position + normal, Color.DODGER_BLUE)
|
||||
var force: Vector3 = (force_direction * movement_force).slide(normal)
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
shader_type spatial;
|
||||
|
||||
render_mode unshaded,blend_add,world_vertex_coords,cull_disabled;
|
||||
|
||||
uniform sampler2D tex;
|
||||
|
||||
void vertex(){
|
||||
vec3 a = mix(WORLD_MATRIX[3].xyz,WORLD_MATRIX[2].xyz,UV.y);
|
||||
vec3 b = mix(WORLD_MATRIX[0].xyz,WORLD_MATRIX[1].xyz,UV.y);
|
||||
VERTEX = mix(a,b,UV.x);
|
||||
|
||||
UV.x = (INSTANCE_CUSTOM.w-1.0 - UV.x)/INSTANCE_CUSTOM.z;
|
||||
}
|
||||
|
||||
void fragment(){
|
||||
vec4 T = texture(tex,UV);
|
||||
ALBEDO = T.xyz;
|
||||
ALPHA = T.w;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
uid://ccg7rqw0lq13u
|
Loading…
Reference in New Issue