From 3b2d8514a37428b5fdba17929e56c9a301b7d29b Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sun, 18 Feb 2024 18:30:52 +0100 Subject: [PATCH] Improved dash skill --- client/Main.gd | 3 ++- client/Main.tscn | 11 +++++++++-- client/skill/SkillInstance.gd | 2 ++ client/skill/dash/dash.gd | 25 +++++++++++++++++++++++-- client/ui/settings/Settings.tscn | 2 +- client/world/AudioBusLayout.tres | 8 ++++---- client/world/generator/Generator.gd | 13 ++++++++++++- 7 files changed, 53 insertions(+), 11 deletions(-) diff --git a/client/Main.gd b/client/Main.gd index 1572e00..c6810b3 100644 --- a/client/Main.gd +++ b/client/Main.gd @@ -5,9 +5,10 @@ extends Node func _enter_tree(): connect_main() connect_ui() - pause(true) func _ready(): + pause(true) + var args := OS.get_cmdline_args() var offline := args.has("--offline") diff --git a/client/Main.tscn b/client/Main.tscn index 2fe5ffe..ae019f0 100644 --- a/client/Main.tscn +++ b/client/Main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=35 format=3 uid="uid://b40y7iuskv1ar"] +[gd_scene load_steps=36 format=3 uid="uid://b40y7iuskv1ar"] [ext_resource type="Script" path="res://Main.gd" id="1_cw3ws"] [ext_resource type="Script" path="res://network/Client.gd" id="2_8hxcx"] @@ -29,6 +29,7 @@ [ext_resource type="Material" uid="uid://dw754wh1xcwgr" path="res://world/trees/LeafMaterial1.tres" id="21_v66do"] [ext_resource type="Material" uid="uid://cxlib6jo32hxg" path="res://world/trees/LeafMaterial2.tres" id="22_k67l0"] [ext_resource type="Material" uid="uid://c8o7cihkhrqf6" path="res://world/trees/LeafMaterial3.tres" id="23_lxn2x"] +[ext_resource type="AudioStream" uid="uid://b36mntcqlt553" path="res://assets/audio/ambience/Wind-Vegetation-Leaves-Gusts.wav" id="30_b3a1m"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_he5c5"] diffuse_mode = 3 @@ -131,6 +132,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0) shape = SubResource("BoxShape3D_yg2lt") [node name="Grass" type="MultiMeshInstance3D" parent="World"] +visible = false layers = 2 material_override = ExtResource("18_tja64") cast_shadow = 0 @@ -142,7 +144,7 @@ scene = ExtResource("20_xjraj") noise = SubResource("FastNoiseLite_xy4ll") size_x = 100.0 size_z = 100.0 -step = 10.0 +step = 15.0 density = 0.3 scale_max = 2.0 @@ -172,6 +174,11 @@ tilt = 0.15 [node name="Follow" parent="World" instance=ExtResource("12_aljdh")] +[node name="Ambience" type="AudioStreamPlayer" parent="World"] +stream = ExtResource("30_b3a1m") +autoplay = true +bus = &"Ambience" + [node name="Players" type="Node3D" parent="."] unique_name_in_owner = true script = ExtResource("16_dp6bj") diff --git a/client/skill/SkillInstance.gd b/client/skill/SkillInstance.gd index 4a111d3..0560517 100644 --- a/client/skill/SkillInstance.gd +++ b/client/skill/SkillInstance.gd @@ -4,11 +4,13 @@ extends Node var state: StateComponent var animation: AnimationComponent var voice: VoiceComponent +var movement: MovementComponent func _enter_tree(): state = get_parent().get_node("State") as StateComponent animation = get_parent().get_node("Animation") as AnimationComponent voice = get_parent().get_node("Voice") as VoiceComponent + movement = get_parent().get_node("Movement") as MovementComponent state.current = StateComponent.State.Skill func end(): diff --git a/client/skill/dash/dash.gd b/client/skill/dash/dash.gd index b6c7347..c3013ea 100644 --- a/client/skill/dash/dash.gd +++ b/client/skill/dash/dash.gd @@ -1,6 +1,27 @@ extends SkillInstance +var direction: Vector3 + func _ready(): - animation.play("human/roll") - await get_tree().create_timer(1.0).timeout + direction = movement.direction + + if direction == Vector3.ZERO: + direction = (get_parent() as CharacterBody3D).global_basis.z + + movement.set_physics_process(false) + set_physics_process(true) + animation.play("human/dash") + await get_tree().create_timer(0.3).timeout + movement.set_physics_process(true) + set_physics_process(false) end() + +func _physics_process(_delta): + if movement.direction: + direction = movement.direction + + var body := get_parent() as CharacterBody3D + body.velocity.x = direction.x * movement.move_speed * 3.0 + body.velocity.y = 0 + body.velocity.z = direction.z * movement.move_speed * 3.0 + body.move_and_slide() \ No newline at end of file diff --git a/client/ui/settings/Settings.tscn b/client/ui/settings/Settings.tscn index f91de33..8a2bfdb 100644 --- a/client/ui/settings/Settings.tscn +++ b/client/ui/settings/Settings.tscn @@ -273,7 +273,7 @@ layout_mode = 2 [node name="Voices" parent="VBoxContainer/TabContainer/Audio/VBoxContainer" instance=ExtResource("14_pvo80")] layout_mode = 2 -[node name="Environment" parent="VBoxContainer/TabContainer/Audio/VBoxContainer" instance=ExtResource("14_pvo80")] +[node name="Ambience" parent="VBoxContainer/TabContainer/Audio/VBoxContainer" instance=ExtResource("14_pvo80")] layout_mode = 2 [node name="Skills" parent="VBoxContainer/TabContainer/Audio/VBoxContainer" instance=ExtResource("14_pvo80")] diff --git a/client/world/AudioBusLayout.tres b/client/world/AudioBusLayout.tres index 630e26b..b09f782 100644 --- a/client/world/AudioBusLayout.tres +++ b/client/world/AudioBusLayout.tres @@ -1,6 +1,6 @@ [gd_resource type="AudioBusLayout" load_steps=2 format=3 uid="uid://c4mndkm5mss5f"] -[sub_resource type="AudioEffectReverb" id="AudioEffectReverb_f5en5"] +[sub_resource type="AudioEffectReverb" id="AudioEffectReverb_hjj00"] resource_name = "Reverb" [resource] @@ -22,13 +22,13 @@ bus/3/mute = false bus/3/bypass_fx = false bus/3/volume_db = -10.0741 bus/3/send = &"Master" -bus/4/name = &"Environment" +bus/4/name = &"Ambience" bus/4/solo = false bus/4/mute = false bus/4/bypass_fx = false -bus/4/volume_db = -25.0 +bus/4/volume_db = -12.9785 bus/4/send = &"Master" -bus/4/effect/0/effect = SubResource("AudioEffectReverb_f5en5") +bus/4/effect/0/effect = SubResource("AudioEffectReverb_hjj00") bus/4/effect/0/enabled = true bus/5/name = &"Footsteps" bus/5/solo = false diff --git a/client/world/generator/Generator.gd b/client/world/generator/Generator.gd index fbd4080..a2d0924 100644 --- a/client/world/generator/Generator.gd +++ b/client/world/generator/Generator.gd @@ -16,6 +16,11 @@ func _ready(): if !visible: return + rebuild() + +func rebuild(): + remove_children() + for x in range(-size_x, size_x, step): for z in range(-size_z, size_z, step): if noise.get_noise_2d(x, z) < 1 - density * 2: @@ -37,4 +42,10 @@ func generate(x: int, z: int) -> Node3D: var uniform_scale := scale_min + randf() * (scale_max - scale_min) t.scale = Vector3(uniform_scale, uniform_scale, uniform_scale) - return t \ No newline at end of file + return t + +func remove_children(): + var num_children = get_child_count() + + for n in range(num_children): + get_child(num_children - 1 - n).queue_free() \ No newline at end of file