diff --git a/scenes/levels/world.tscn b/scenes/levels/world.tscn index 2177ef7..4a3567c 100644 --- a/scenes/levels/world.tscn +++ b/scenes/levels/world.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=35 format=3 uid="uid://bg7g48sbn5na8"] +[gd_scene load_steps=36 format=3 uid="uid://bg7g48sbn5na8"] [ext_resource type="PackedScene" uid="uid://fgpto6xwiehx" path="res://scenes/characters/plant.tscn" id="1_hy1fl"] [ext_resource type="PackedScene" uid="uid://ethfqolg7tpy" path="res://assets/models/world/world_sphere.glb" id="1_w6odn"] @@ -25,6 +25,7 @@ [ext_resource type="PackedScene" uid="uid://touox4x6ip7l" path="res://assets/models/city/city.glb" id="17_rp11v"] [ext_resource type="PackedScene" path="res://scenes/props/tree.tscn" id="22_dqnln"] [ext_resource type="PackedScene" uid="uid://dqxhamrsiplmr" path="res://assets/models/barrel/Empty Barrel.glb" id="25_rrnhn"] +[ext_resource type="PackedScene" uid="uid://btnpd8nq3wmio" path="res://scenes/objects/sprinkler.tscn" id="26_scyh7"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_ngwyh"] sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1) @@ -446,7 +447,10 @@ transform = Transform3D(-0.751966, 0, 0.659201, 0, 1, 0, -0.659201, 0, -0.751966 transform = Transform3D(-0.666129, 0, -0.745836, 0, 1, 0, 0.745836, 0, -0.666129, -2.29801, 0.224026, -2.40271) [node name="Manhole" parent="Interactable" instance=ExtResource("7_cfvaw")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 11.7519, 0.128385, 6.74314) +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 12.4659, -0.046853, 6.10257) +direction = Vector3(-1, 1, -0.5) +force = 12.0 +interval = 0.25 [node name="Ladybug2" parent="Interactable" instance=ExtResource("11_nn7mv")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.515731, 0.209344, 0.12833) @@ -470,3 +474,8 @@ pixel_size = 0.08 [node name="BarrelEmpty" parent="Interactable" instance=ExtResource("25_rrnhn")] transform = Transform3D(6.47824, -0.00842768, 6.70653, -6.11579e-10, 9.32444, 0.0117174, -6.70654, -0.00814079, 6.47823, -90.0538, -0.735255, -61.1986) + +[node name="Sprinkler" parent="Interactable" instance=ExtResource("26_scyh7")] +transform = Transform3D(-0.840784, 0, -0.541371, 0, 1, 0, 0.541371, 0, -0.840784, 2.68783, 0, 3.91572) +nutrient_volume = 0.002 +launch_force = Vector2(7, 6) diff --git a/scenes/objects/droplet.tscn b/scenes/objects/droplet.tscn index 6ac13fc..aabf1f5 100644 --- a/scenes/objects/droplet.tscn +++ b/scenes/objects/droplet.tscn @@ -9,14 +9,14 @@ nutrient_type = 0 volume = 0.2 [sub_resource type="BoxShape3D" id="BoxShape3D_o7exb"] -size = Vector3(0.02, 0.02, 0.02) +size = Vector3(0.04, 0.04, 0.04) [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_a5py2"] albedo_color = Color(0.364706, 0.631373, 1, 1) [sub_resource type="BoxMesh" id="BoxMesh_mtjpa"] material = SubResource("StandardMaterial3D_a5py2") -size = Vector3(0.02, 0.02, 0.02) +size = Vector3(0.04, 0.04, 0.04) [node name="Droplet" type="RigidBody3D"] collision_layer = 0 diff --git a/scenes/objects/fertilizer.tscn b/scenes/objects/fertilizer.tscn index 12f23ad..dfa4bb3 100644 --- a/scenes/objects/fertilizer.tscn +++ b/scenes/objects/fertilizer.tscn @@ -14,11 +14,14 @@ size = Vector3(0.469727, 0.662354, 0.243408) [node name="Fertilizer" type="RigidBody3D" node_paths=PackedStringArray("spawn_point", "spawn_point_target", "animatable", "collision_object")] freeze_mode = 1 script = ExtResource("1_bikd7") +override_nutrient_value = 0.001 override_nutrient_type = 2 +shake_factor = 1.8 particle = ExtResource("6_mwqe2") spawn_point = NodePath("FertilizerSpawnPoint") spawn_point_target = NodePath("FertilizerSpawnPointTarget") animatable = NodePath("CollisionShape3D/Fertilizer") +speed = 0.15 collision_object = NodePath(".") [node name="Clickable" type="Node3D" parent="."] diff --git a/scenes/objects/fertilizer_particle.tscn b/scenes/objects/fertilizer_particle.tscn index 7cb1ea0..020b151 100644 --- a/scenes/objects/fertilizer_particle.tscn +++ b/scenes/objects/fertilizer_particle.tscn @@ -6,7 +6,7 @@ [sub_resource type="Resource" id="Resource_36ut0"] script = ExtResource("2_6d4nn") nutrient_type = 2 -volume = 0.2 +volume = 0.02 [sub_resource type="BoxShape3D" id="BoxShape3D_d0fx2"] size = Vector3(0.06, 0.06, 0.06) @@ -20,7 +20,7 @@ size = Vector3(0.06, 0.06, 0.06) [node name="FertilizerParticle" type="RigidBody3D" groups=["Particle"]] collision_layer = 256 -collision_mask = 397 +collision_mask = 388 script = ExtResource("1_510ek") nutrient = SubResource("Resource_36ut0") diff --git a/scenes/objects/manhole.tscn b/scenes/objects/manhole.tscn index f96abb5..6627bf5 100644 --- a/scenes/objects/manhole.tscn +++ b/scenes/objects/manhole.tscn @@ -1,15 +1,19 @@ -[gd_scene load_steps=6 format=3 uid="uid://c1icuiig1k6xn"] +[gd_scene load_steps=9 format=3 uid="uid://c1icuiig1k6xn"] [ext_resource type="PackedScene" uid="uid://yoaubit78jdv" path="res://scenes/objects/clickable_object.tscn" id="1_7mg8k"] [ext_resource type="Script" path="res://scripts/objects/manhole.gd" id="1_eet7d"] [ext_resource type="PackedScene" uid="uid://bmyidg0rpcb4d" path="res://assets/models/sewer/Manhole.glb" id="2_0pdp8"] [ext_resource type="PackedScene" uid="uid://c1mw82iu1ebpv" path="res://assets/models/sewer/Sewer entrance.glb" id="2_6eja0"] +[ext_resource type="PackedScene" uid="uid://bakw5x6pqj6pd" path="res://scenes/objects/nutrient_stream.tscn" id="5_avv6x"] +[ext_resource type="PackedScene" uid="uid://b54q5xk3084ih" path="res://scenes/objects/droplet.tscn" id="6_q1m56"] +[ext_resource type="PackedScene" uid="uid://djgadgaoeoss8" path="res://scenes/objects/fertilizer_particle.tscn" id="6_rf04n"] [sub_resource type="BoxShape3D" id="BoxShape3D_dolpo"] size = Vector3(0.909058, 0.178543, 0.911316) [node name="Manhole" type="Node3D"] script = ExtResource("1_eet7d") +interval = 0.5 [node name="ClickableObject" parent="." instance=ExtResource("1_7mg8k")] @@ -26,4 +30,15 @@ visible = false [node name="ClosedModel" parent="." instance=ExtResource("2_6eja0")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.00284022, 0) +[node name="FertStream" parent="." instance=ExtResource("5_avv6x")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.132999, 0.269987, -0.190831) +nutrient_volume = 0.03 +nutrient_type = 2 +nutrient_scene = ExtResource("6_rf04n") + +[node name="WaterStream" parent="." instance=ExtResource("5_avv6x")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.181884, 0.269987, -0.190831) +nutrient_volume = 0.015 +nutrient_scene = ExtResource("6_q1m56") + [connection signal="clicked" from="ClickableObject" to="." method="on_click" flags=6] diff --git a/scenes/objects/nutrient_stream.tscn b/scenes/objects/nutrient_stream.tscn new file mode 100644 index 0000000..b0f6722 --- /dev/null +++ b/scenes/objects/nutrient_stream.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=3 uid="uid://bakw5x6pqj6pd"] + +[ext_resource type="Script" path="res://scripts/objects/nutrient_stream.gd" id="1_b4si6"] + +[node name="NutrientStream" type="Node3D"] +script = ExtResource("1_b4si6") + +[node name="Direction" type="Marker3D" parent="."] + +[node name="ShootTimer" type="Timer" parent="."] + +[connection signal="timeout" from="ShootTimer" to="." method="shoot"] diff --git a/scenes/objects/pipette.tscn b/scenes/objects/pipette.tscn index 9520d5d..f4871c3 100644 --- a/scenes/objects/pipette.tscn +++ b/scenes/objects/pipette.tscn @@ -24,8 +24,7 @@ shape = SubResource("BoxShape3D_mk8fx") transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0.00213623, 0.00177002, -0.877942) script = ExtResource("3_dx5xx") physic_body = NodePath("../..") -watering_power = null -magic_speed_number = null +watering_power = 0.02 [node name="DropletAudio" type="AudioStreamPlayer3D" parent="CollisionShape3D/Pipette"] transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0.235809, -1.03075e-08) diff --git a/scenes/objects/sprinkler.tscn b/scenes/objects/sprinkler.tscn index beeae7e..ddc5c6c 100644 --- a/scenes/objects/sprinkler.tscn +++ b/scenes/objects/sprinkler.tscn @@ -1,25 +1,39 @@ -[gd_scene load_steps=4 format=3 uid="uid://btnpd8nq3wmio"] +[gd_scene load_steps=8 format=3 uid="uid://btnpd8nq3wmio"] [ext_resource type="PackedScene" uid="uid://daqbj6cvcg34r" path="res://assets/models/sprinkler/Small Sprinkler.glb" id="1_2ghv6"] +[ext_resource type="Script" path="res://scripts/objects/sprinkler.gd" id="1_tgsec"] [ext_resource type="PackedScene" uid="uid://c52scekv4ff3l" path="res://scenes/objects/water_stream.tscn" id="2_dyvvl"] +[ext_resource type="Script" path="res://scripts/resources/nutrient.gd" id="3_w2bvh"] +[ext_resource type="PackedScene" uid="uid://yoaubit78jdv" path="res://scenes/objects/clickable_object.tscn" id="4_yfmh8"] + +[sub_resource type="Resource" id="Resource_sp7of"] +script = ExtResource("3_w2bvh") +nutrient_type = 0 +volume = 0.02 [sub_resource type="BoxShape3D" id="BoxShape3D_fob55"] size = Vector3(0.12085, 0.314392, 0.12207) [node name="Sprinkler" type="Node3D"] +script = ExtResource("1_tgsec") + +[node name="WaterStream" parent="." instance=ExtResource("2_dyvvl")] +nutrient = SubResource("Resource_sp7of") +arch_in_degrees = 71.036 +arch_speed = 30.0 +arch_deviation = 0.4 +tilt_deviation = 0.02 -[node name="StaticBody3D" type="StaticBody3D" parent="."] +[node name="ClickableObject" parent="." instance=ExtResource("4_yfmh8")] + +[node name="StaticBody3D" type="StaticBody3D" parent="ClickableObject"] collision_layer = 3 -[node name="SprinklerModel" parent="StaticBody3D" instance=ExtResource("1_2ghv6")] +[node name="SprinklerModel" parent="ClickableObject/StaticBody3D" instance=ExtResource("1_2ghv6")] transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0) -[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] +[node name="CollisionShape3D" type="CollisionShape3D" parent="ClickableObject/StaticBody3D"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00134277, 0.154205, 0.000488281) shape = SubResource("BoxShape3D_fob55") -[node name="WaterStream" parent="." instance=ExtResource("2_dyvvl")] -arch_in_degrees = 71.036 -arch_speed = 30.0 -arch_deviation = 0.4 -tilt_deviation = 0.02 +[connection signal="clicked" from="ClickableObject" to="." method="on_clicked"] diff --git a/scenes/objects/watering_can.tscn b/scenes/objects/watering_can.tscn index dfa4411..f529970 100644 --- a/scenes/objects/watering_can.tscn +++ b/scenes/objects/watering_can.tscn @@ -18,9 +18,11 @@ script/source = "extends Node3D ## Dependecy @export var physics_body : PhysicsBody3D @export var _holes : Array[Node] +@export var water_hole: Marker3D #@export var drops_per_second := 6 -@export var another_magic_number := 10 +@export var watering_power: float +@export var another_magic_number := 10.0 var _velocity = Vector3.ZERO var _watering = false: set = _set_watering @@ -31,8 +33,9 @@ func _process(_delta: float) -> void: var hole = _holes[randi_range(0, _holes.size()-1)] var droplet = droplet_scene.instantiate() as NutrientParticle - physics_body.get_parent().add_child(droplet) - droplet.configure(_velocity * another_magic_number, hole, physics_body, 6) + get_tree().root.add_child(droplet) + var force_dir = water_hole.get_global_transform().basis.z + droplet.configure(_velocity + (force_dir * another_magic_number) + (Utils.rand_pos_in_sphere() * 0.3), hole, physics_body, watering_power, Nutrient.Nutrients.Water) func _on_droped(): @@ -64,11 +67,14 @@ freeze_mode = 1 transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.000648499, 0.219836, 0.286344) shape = SubResource("BoxShape3D_swr2n") -[node name="WateringCan" parent="." node_paths=PackedStringArray("physics_body", "_holes") instance=ExtResource("1_xnttj")] +[node name="WateringCan" parent="." node_paths=PackedStringArray("physics_body", "_holes", "water_hole") instance=ExtResource("1_xnttj")] transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0, 0, 0.25) script = SubResource("GDScript_pe44m") physics_body = NodePath("..") _holes = [NodePath("CanHole"), NodePath("CanHole2"), NodePath("CanHole3"), NodePath("CanHole4"), NodePath("CanHole5")] +water_hole = NodePath("Hole") +watering_power = 0.008 +another_magic_number = 1.6 [node name="CanHole" type="Node3D" parent="WateringCan"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.500037, 0.46332, 0.0586642) @@ -109,6 +115,9 @@ mesh = SubResource("SphereMesh_ody2w") transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.620137, 0.449778, -3.24976e-08) stream = ExtResource("2_4pl00") +[node name="Hole" type="Marker3D" parent="WateringCan"] +transform = Transform3D(-3.26435e-08, -0.487006, 0.873398, -4.25754e-08, 0.873398, 0.487006, -1, -2.12877e-08, -4.92453e-08, 0.530061, 0.415897, 2.31697e-08) + [node name="Clickable" type="Node3D" parent="."] script = ExtResource("2_20kk0") diff --git a/scripts/global/growth_timer.gd b/scripts/global/growth_timer.gd index 8c6908e..fda59b0 100644 --- a/scripts/global/growth_timer.gd +++ b/scripts/global/growth_timer.gd @@ -1,7 +1,7 @@ extends Node ## Total time available for growth (in seconds) -@export var total_time: float = 5.0 * 60 +@export var total_time: float = 3.0 * 60 var time_left: float = total_time var is_running: bool = false diff --git a/scripts/global/utils.gd b/scripts/global/utils.gd index 1ee1dad..527403d 100644 --- a/scripts/global/utils.gd +++ b/scripts/global/utils.gd @@ -11,3 +11,7 @@ static func screen_to_3d_object(node: Node3D, collision_mask: int = 4294967295) ## Query the 3d direct space state, retrives a dictionary with collision return node.get_world_3d().direct_space_state.intersect_ray(query) + +static func rand_pos_in_sphere(): + var rand_vector = Vector3(randf_range(-1.0, 1.0), randf_range(-1.0, 1.0), randf_range(-1.0, 1.0)) + return rand_vector * (1.0 / rand_vector.length()) \ No newline at end of file diff --git a/scripts/objects/components/nutrient_particle.gd b/scripts/objects/components/nutrient_particle.gd index 57c47e6..8a749c2 100644 --- a/scripts/objects/components/nutrient_particle.gd +++ b/scripts/objects/components/nutrient_particle.gd @@ -14,7 +14,7 @@ func _init() -> void: max_contacts_reported = 1 -func configure(initial_speed: Vector3, origin: Node3D, collision_exception: PhysicsBody3D = null, nutrient_value = 0.2, nutrient_type := Nutrient.Nutrients.Water): +func configure(initial_speed: Vector3, origin: Node3D, collision_exception: PhysicsBody3D, nutrient_value, nutrient_type): if not nutrient: nutrient = nut_source.new(nutrient_type, nutrient_value) diff --git a/scripts/objects/components/shakable.gd b/scripts/objects/components/shakable.gd index ae523d1..7f31538 100644 --- a/scripts/objects/components/shakable.gd +++ b/scripts/objects/components/shakable.gd @@ -3,7 +3,7 @@ extends Node3D @export_category("Tuning") @export_subgroup("Nutrient") -@export var override_nutrient_value := 10 +@export var override_nutrient_value: float = 0.04 @export var override_nutrient_type := Nutrient.Nutrients.Water @export_subgroup("Gameplay") @@ -36,7 +36,7 @@ func _process(delta: float) -> void: if _shaking <= 0: return - _shaking = clampf(_shaking - delta, 0, 10) + _shaking = clampf(_shaking - (delta * 4), 0, 10) # Call for do some animation considering _shaking as anim speed _shake_animatable(delta) diff --git a/scripts/objects/components/water_stream.gd b/scripts/objects/components/water_stream.gd index 181099d..bdc1859 100644 --- a/scripts/objects/components/water_stream.gd +++ b/scripts/objects/components/water_stream.gd @@ -2,21 +2,23 @@ class_name Sprinkler extends Node3D #Dependency -@export var stream_target : Node3D +@export var stream_target: Node3D +@export var nutrient: Nutrient + @export_category("Tuning") ## Not very elegant, but min and max for the force applied to the water @export var launch_force := Vector2.ZERO @export_range(5.0, 90.0) var arch_in_degrees := 20.0 -@export var arch_speed : float = 2 -@export var arch_deviation : float -@export var tilt_deviation : float -@export var firing_rate : float -@export var firing_deviation : float +@export var arch_speed: float = 2 +@export var arch_deviation: float +@export var tilt_deviation: float +@export var firing_rate: float +@export var firing_deviation: float @onready var droplet_scene := preload("res://scenes/objects/droplet.tscn") -var _enabled := true +var _enabled := false var _current_arch: float = 0 var _fired_delta: float = 0 var _arch_direction = 1 @@ -38,7 +40,7 @@ func _process(delta): _fired_delta = 0 ## Get all the variations - var force_v = randf_range(launch_force.x, launch_force.y) + var force_v = randf_range(launch_force.x, launch_force.y) var arch_v = randf_range(-arch_deviation, arch_deviation) + _current_arch var tilt_v = randf_range(-tilt_deviation, tilt_deviation) @@ -48,7 +50,7 @@ func _process(delta): var droplet = droplet_scene.instantiate() as NutrientParticle owner.add_child(droplet) - droplet.configure(dir, self) + droplet.configure(dir, self, null, nutrient.volume, nutrient.nutrient_type) func _on_enabled() -> void: diff --git a/scripts/objects/manhole.gd b/scripts/objects/manhole.gd index 4e18fd3..16e7050 100644 --- a/scripts/objects/manhole.gd +++ b/scripts/objects/manhole.gd @@ -1,8 +1,13 @@ extends Node3D +@export var direction: Vector3 +@export var force: float +@export var interval: float + @onready var open_model: Node3D = $OpenModel @onready var closed_model: Node3D = $ClosedModel - +@onready var fert_stream: NutrientStream = $FertStream +@onready var water_stream: NutrientStream = $WaterStream var is_open = false @@ -14,4 +19,10 @@ func _ready(): func on_click(): open_model.visible = true closed_model.visible = false - is_open = true \ No newline at end of file + is_open = true + fert_stream.interval = interval + fert_stream.launch_force = direction.normalized() * force + fert_stream.toggle() + water_stream.interval = interval + water_stream.launch_force = direction.normalized() * force + water_stream.toggle() \ No newline at end of file diff --git a/scripts/objects/nutrient_stream.gd b/scripts/objects/nutrient_stream.gd new file mode 100644 index 0000000..de8ae6a --- /dev/null +++ b/scripts/objects/nutrient_stream.gd @@ -0,0 +1,32 @@ +class_name NutrientStream +extends Node3D + +@export var enabled := false +@export var nutrient_volume: float +@export var nutrient_type: Nutrient.Nutrients +@export var launch_force: Vector3 +@export var force_variation_mult: float +@export var interval: float +@export var nutrient_scene: PackedScene + +@onready var dir_marker: Marker3D = $Direction +@onready var shoot_timer: Timer = $ShootTimer + +func _ready(): + if enabled: + shoot_timer.start(interval) + +func toggle(): + enabled = not enabled + if enabled: + shoot_timer.start(interval) + else: + shoot_timer.stop() + +func shoot(): + print("Shoooot!") + #var dir = dir_marker.get_global_transform().basis.z + var force = launch_force + (Utils.rand_pos_in_sphere()*launch_force*force_variation_mult) + var droplet = nutrient_scene.instantiate() as NutrientParticle + get_tree().root.add_child(droplet) + droplet.configure(force, dir_marker, null, nutrient_volume, nutrient_type) diff --git a/scripts/objects/pipette.gd b/scripts/objects/pipette.gd index fc5916a..1abc487 100644 --- a/scripts/objects/pipette.gd +++ b/scripts/objects/pipette.gd @@ -5,7 +5,7 @@ extends Node3D @export var physic_body : PhysicsBody3D @export var watering_power: float = 1 -@export var magic_speed_number := 10.0 +@export var magic_speed_number := 100.0 @onready var droplet_scene := preload("res://scenes/objects/droplet.tscn") @onready var droplet_audio: AudioStreamPlayer3D = $DropletAudio @@ -17,7 +17,7 @@ func on_used(using: bool) -> void: var droplet := droplet_scene.instantiate() as NutrientParticle assert(physic_body != null) physic_body.get_parent().add_child(droplet) - droplet.configure(_velocity * magic_speed_number, physic_body) + droplet.configure(_velocity * magic_speed_number, physic_body, null, watering_power, Nutrient.Nutrients.Water) droplet_audio.play() diff --git a/scripts/objects/sprinkler.gd b/scripts/objects/sprinkler.gd index 037b5c0..3d54411 100644 --- a/scripts/objects/sprinkler.gd +++ b/scripts/objects/sprinkler.gd @@ -1,52 +1,19 @@ class_name WaterStreamer extends Node3D -#Dependency -@export var water_origin : Node3D -@export var stream_target : Node3D +@export var nutrient_volume: float +@export var nutrient_type: Nutrient.Nutrients +@export var launch_force: Vector2 -@export_category("Tuning") -## Not very elegant, but min and max for the force applied to the water -@export var launch_force := Vector2.ZERO -@export_range(5.0, 90.0) var arch_in_degrees := 20.0 -@export var arch_deviation : float -@export var tilt_deviation : float -@export var firing_rate : float -@export var firing_deviation : float +@onready var water_stream: Sprinkler = $WaterStream -@onready var droplet_scene := preload("res://scenes/objects/droplet.tscn") -var _enabled := true -var _current_arch: float = 0 -var _fired_delta: float = 0 +func _ready(): + var nutrient = Nutrient.new(nutrient_type, nutrient_volume) + print("My nutrient is null?", nutrient == null) + water_stream.nutrient = nutrient + water_stream.launch_force = launch_force - -func _process(delta): - _fired_delta += delta + randf_range(-firing_deviation, firing_deviation) - _current_arch += delta - - if _current_arch >= arch_in_degrees /2.0: - _current_arch = -arch_in_degrees / 2.0 - - if not _enabled or _fired_delta < firing_rate: - return - ## Reset fire cooldown - _fired_delta = 0 - - ## Get all the deviations - var force_v = randf_range(launch_force.x, launch_force.y) - var arch_v = randf_range(-arch_deviation, arch_deviation) + _current_arch - var tilt_v = randf_range(-tilt_deviation, tilt_deviation) - - var dir = water_origin.global_position.direction_to(stream_target.global_position) - dir = dir.rotated(Vector3.RIGHT, deg_to_rad(tilt_v)).rotated(Vector3.UP, deg_to_rad(arch_v)) * 1000 - dir = dir.limit_length(force_v) - - var droplet = droplet_scene.instantiate() as NutrientParticle - owner.add_child(droplet) - droplet.configure(dir, water_origin) - - -func _on_enabled() -> void: - _enabled = !_enabled +func on_clicked(): + water_stream._enabled = not water_stream._enabled \ No newline at end of file diff --git a/scripts/resources/nutrient.gd b/scripts/resources/nutrient.gd index ae8a34e..7fd75e1 100644 --- a/scripts/resources/nutrient.gd +++ b/scripts/resources/nutrient.gd @@ -6,7 +6,7 @@ extends Resource enum Nutrients {Water, Minerals, Fertilizer} -func _init(nt := Nutrients.Water, vol := 0.2) -> void: +func _init(nt: Nutrients, vol: float) -> void: nutrient_type = nt volume = vol