diff --git a/Zennysoft.Game.Godot.Implementation/Audio/DimmableAudioStreamPlayer3D.cs b/Zennysoft.Game.Godot.Implementation/Audio/DimmableAudioStreamPlayer3D.cs index 04da6b6e1..7597bdfda 100644 --- a/Zennysoft.Game.Godot.Implementation/Audio/DimmableAudioStreamPlayer3D.cs +++ b/Zennysoft.Game.Godot.Implementation/Audio/DimmableAudioStreamPlayer3D.cs @@ -47,4 +47,8 @@ public partial class DimmableAudioStreamPlayer3D : AudioStreamPlayer3D, IDimmabl FADE_DURATION ).SetTrans(Tween.TransitionType.Circ).SetEase(ease); } + + public override void _EnterTree() => FadeIn(); + + public override void _ExitTree() => FadeOut(); } diff --git a/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.Input.cs b/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.Input.cs index 17a5f270b..fed5f7f28 100644 --- a/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.Input.cs +++ b/Zennysoft.Game.Ma.Implementation/Player/State/PlayerLogic.Input.cs @@ -8,8 +8,6 @@ public partial class PlayerLogic { public readonly record struct PhysicsTick(double Delta); - public readonly record struct Moved(Vector3 GlobalPosition, Transform3D GlobalTransform); - public readonly record struct Enable; public readonly record struct Attack; diff --git a/Zennysoft.Game.Ma/project.godot b/Zennysoft.Game.Ma/project.godot index 46162e048..31b83a673 100644 --- a/Zennysoft.Game.Ma/project.godot +++ b/Zennysoft.Game.Ma/project.godot @@ -79,6 +79,10 @@ folder_colors={ import/blender/enabled=false +[global_group] + +DimmableAudio="" + [importer_defaults] texture={ diff --git a/Zennysoft.Game.Ma/src/audio/AmbientSFXPlayer.cs b/Zennysoft.Game.Ma/src/audio/AmbientSFXPlayer.cs index 77746b954..4427588f3 100644 --- a/Zennysoft.Game.Ma/src/audio/AmbientSFXPlayer.cs +++ b/Zennysoft.Game.Ma/src/audio/AmbientSFXPlayer.cs @@ -2,4 +2,5 @@ public partial class AmbientSFXPlayer : DimmableAudioStreamPlayer { + public override void _EnterTree() => FadeIn(); } diff --git a/Zennysoft.Game.Ma/src/audio/AmbientSFXPlayer3D.cs b/Zennysoft.Game.Ma/src/audio/AmbientSFXPlayer3D.cs index 0a92942bb..c14de368f 100644 --- a/Zennysoft.Game.Ma/src/audio/AmbientSFXPlayer3D.cs +++ b/Zennysoft.Game.Ma/src/audio/AmbientSFXPlayer3D.cs @@ -2,4 +2,5 @@ public partial class AmbientSFXPlayer3D : DimmableAudioStreamPlayer3D { + public override void _EnterTree() => FadeIn(); } diff --git a/Zennysoft.Game.Ma/src/game/Game.cs b/Zennysoft.Game.Ma/src/game/Game.cs index 0dc24c1e2..bbbe0e065 100644 --- a/Zennysoft.Game.Ma/src/game/Game.cs +++ b/Zennysoft.Game.Ma/src/game/Game.cs @@ -383,7 +383,6 @@ public partial class Game : Node3D, IGame private void FloorClearMenu_Exit() { _player.Deactivate(); - _map.ClearMap(); InGameUI.Hide(); } diff --git a/Zennysoft.Game.Ma/src/map/IMap.cs b/Zennysoft.Game.Ma/src/map/IMap.cs index b15c5ea77..5fa9272a9 100644 --- a/Zennysoft.Game.Ma/src/map/IMap.cs +++ b/Zennysoft.Game.Ma/src/map/IMap.cs @@ -12,8 +12,6 @@ public interface IMap : INode3D Task LoadFloor(string sceneName); - void ClearMap(); - IDungeonFloor CurrentFloor { get; } (Vector3 Rotation, Vector3 Position) GetPlayerSpawnPosition(); diff --git a/Zennysoft.Game.Ma/src/map/Map.cs b/Zennysoft.Game.Ma/src/map/Map.cs index 821f6a18d..945fab4bf 100644 --- a/Zennysoft.Game.Ma/src/map/Map.cs +++ b/Zennysoft.Game.Ma/src/map/Map.cs @@ -5,6 +5,7 @@ using Godot; using System; using System.Linq; using System.Threading.Tasks; +using Zennysoft.Game.Abstractions; namespace Zennysoft.Game.Ma; @@ -32,11 +33,35 @@ public partial class Map : Node3D, IMap public event Action FloorLoaded; + private string _sceneName; + public void OnResolved() { + AnimationPlayer.AnimationFinished += AnimationPlayer_AnimationFinished; this.Provide(); } + private async void AnimationPlayer_AnimationFinished(StringName animName) + { + if (animName == "fade_out") + { + await LoadNewFloor(); + } + } + + private async Task LoadNewFloor() + { + CurrentFloor?.CallDeferred(MethodName.QueueFree, []); + SpawnPointCreated?.Invoke((Vector3.Forward, new Vector3(-999, -999, -999))); + var newFloor = await LoadNewFloor(_sceneName); + AddChild(newFloor); + InitializeFloor(newFloor); + var floor = MapOrder.GetChildren().OfType().ElementAt(CurrentFloorNumber.Value); + if (CurrentFloor is DungeonFloor dungeonFloor && floor is DungeonFloorNode dungeonFloorNode) + dungeonFloor.SpawnEnemies(dungeonFloorNode); + AnimationPlayer.CallDeferred(AnimationPlayer.MethodName.Play, ("fade_in")); + } + public void InitializeMapData() { CurrentFloorNumber.OnNext(-1); @@ -65,21 +90,10 @@ public partial class Map : Node3D, IMap public async Task LoadFloor(string sceneName) { AnimationPlayer.CallDeferred(AnimationPlayer.MethodName.Play, "fade_out"); - ClearMap(); - var newFloor = await LoadNewFloor(sceneName); - AddChild(newFloor); - InitializeFloor(newFloor); - var floor = MapOrder.GetChildren().OfType().ElementAt(CurrentFloorNumber.Value); - if (CurrentFloor is DungeonFloor dungeonFloor && floor is DungeonFloorNode dungeonFloorNode) - dungeonFloor.SpawnEnemies(dungeonFloorNode); - AnimationPlayer.CallDeferred(AnimationPlayer.MethodName.Play, ("fade_in")); - } - - public void ClearMap() - { - AnimationPlayer.CallDeferred(AnimationPlayer.MethodName.Play, "fade_out"); - CurrentFloor?.CallDeferred(MethodName.QueueFree, []); - SpawnPointCreated?.Invoke((Vector3.Forward, new Vector3(-999, -999, -999))); + _sceneName = sceneName; + var dimmableAudio = GetTree().GetNodesInGroup("DimmableAudio").OfType(); + foreach (var node in dimmableAudio) + node.FadeOut(); } private void InitializeFloor(Node newFloor) diff --git a/Zennysoft.Game.Ma/src/map/dungeon/code/Altar.cs b/Zennysoft.Game.Ma/src/map/dungeon/code/Altar.cs index 24ee9d5d3..dfb73f2b8 100644 --- a/Zennysoft.Game.Ma/src/map/dungeon/code/Altar.cs +++ b/Zennysoft.Game.Ma/src/map/dungeon/code/Altar.cs @@ -2,7 +2,6 @@ using Chickensoft.AutoInject; using Chickensoft.Introspection; using Godot; using System.Linq; -using Zennysoft.Game.Abstractions; using Zennysoft.Ma.Adapter; namespace Zennysoft.Game.Ma; @@ -22,49 +21,37 @@ public partial class Altar : SpecialFloor, IDungeonFloor [Node] private Area3D NoExitArea { get; set; } = default!; - [Node] private Node DimmableAudio { get; set; } = default!; - [Export] public Resource Dialogue { get; set; } = default!; public void OnResolved() { - Show(); - Exit.AreaEntered += Exit_AreaEntered; - NoExitArea.AreaEntered += NoExitArea_AreaEntered; - FloorIsLoaded = true; - var dimmableAudio = DimmableAudio.GetChildren().OfType(); - foreach (var dimmable in dimmableAudio) - dimmable.FadeIn(); - } - - public override void FadeOutAudio() - { - var dimmableAudio = DimmableAudio.GetChildren().OfType(); - foreach (var dimmable in dimmableAudio) - dimmable.FadeOut(); + Show(); + Exit.AreaEntered += Exit_AreaEntered; + NoExitArea.AreaEntered += NoExitArea_AreaEntered; + FloorIsLoaded = true; } private void _player_PointUpFinished() { - _player.Activate(); + _player.Activate(); } private void NoExitArea_AreaEntered(Area3D area) { - DialogueController.ShowDialogue(Dialogue, "no_exit"); + DialogueController.ShowDialogue(Dialogue, "no_exit"); } private void Exit_AreaEntered(Area3D area) { - if (area.GetOwner() is IPlayer) - ExitReached(); + if (area.GetOwner() is IPlayer) + ExitReached(); } public void ExitReached() => Game.FloorExitReached(); public void OnExitTree() { - Exit.AreaEntered -= Exit_AreaEntered; - NoExitArea.AreaEntered -= NoExitArea_AreaEntered; + Exit.AreaEntered -= Exit_AreaEntered; + NoExitArea.AreaEntered -= NoExitArea_AreaEntered; } } diff --git a/Zennysoft.Game.Ma/src/map/dungeon/floors/Special Floors/00. Altar.tscn b/Zennysoft.Game.Ma/src/map/dungeon/floors/Special Floors/00. Altar.tscn index 781261464..e5160a3b3 100644 --- a/Zennysoft.Game.Ma/src/map/dungeon/floors/Special Floors/00. Altar.tscn +++ b/Zennysoft.Game.Ma/src/map/dungeon/floors/Special Floors/00. Altar.tscn @@ -5,7 +5,7 @@ [ext_resource type="PackedScene" uid="uid://co0fmuno2pjc7" path="res://src/map/dungeon/models/Special Floors & Rooms/Altar/02_ALTAR_FLOOR_ZER0_VER.1.glb" id="2_xpi6o"] [ext_resource type="Script" uid="uid://cstc8tdapyrst" path="res://src/audio/AmbientSFXPlayer.cs" id="5_7xfp0"] [ext_resource type="Shader" uid="uid://c4a68uhm5o2h4" path="res://src/map/map shaders/Altar Sky Environment.gdshader" id="27_lb4gb"] -[ext_resource type="AudioStream" uid="uid://bmiitw4fcs68e" path="res://src/audio/AMB/amb_wind_loop_altar.wav" id="28_je2oh"] +[ext_resource type="AudioStream" uid="uid://c4ud110da8efp" path="res://src/audio/AMB/amb_wind_loop_altar.wav" id="28_je2oh"] [sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_aqomv"] data = PackedVector3Array(-3.3925, -0.4692, 0.404, -3.3925, 8.7018, 0.404, -2.2486, 8.7018, -2.8922, -3.3925, -0.4692, 0.404, -2.2486, 8.7018, -2.8922, -2.2486, -0.4692, -2.8922, -0.1133, -0.4692, -2.7502, -0.1133, 8.7018, -2.7502, 1.7984, 8.7018, -2.5918, -0.1133, -0.4692, -2.7502, 1.7984, 8.7018, -2.5918, 1.7984, -1.3386, -2.5918, 1.7984, -1.3386, -2.5918, 1.7984, 8.7018, -2.5918, 3.6849, 8.7018, 1.9957, 1.7984, -1.3386, -2.5918, 3.6849, 8.7018, 1.9957, 3.6849, -1.3386, 1.9957, 1.5401, -0.4692, 3.0749, 1.5401, 8.7018, 3.0749, -3.3925, 8.7018, 0.404, 1.5401, -0.4692, 3.0749, -3.3925, 8.7018, 0.404, -3.3925, -0.4692, 0.404, 3.6849, -1.3386, 1.9957, 3.6849, 8.7018, 1.9957, 1.5401, 8.7018, 3.0749, 3.6849, -1.3386, 1.9957, 1.5401, 8.7018, 3.0749, 1.5401, -0.4692, 3.0749, -2.2486, -0.4692, -2.8922, -2.2486, 8.7018, -2.8922, -0.1133, 8.7018, -2.7502, -2.2486, -0.4692, -2.8922, -0.1133, 8.7018, -2.7502, -0.1133, -0.4692, -2.7502, 28.9379, 7.7244, 15.9431, 28.9379, -1.3923, 15.9431, 48.2187, -1.3923, 15.9401, 28.9379, 7.7244, 15.9431, 48.2187, -1.3923, 15.9401, 48.2187, 7.7244, 15.9401, 48.2187, 7.7244, 15.9401, 48.2187, -1.3923, 15.9401, 99.6775, -1.3923, 15.9401, 48.2187, 7.7244, 15.9401, 99.6775, -1.3923, 15.9401, 99.6775, 7.7244, 15.9401, 99.6775, 7.7244, 15.9401, 99.6775, -1.3923, 15.9401, 106.285, -1.3923, 15.9255, 99.6775, 7.7244, 15.9401, 106.285, -1.3923, 15.9255, 106.285, 7.6793, 15.9255, 106.285, -1.3923, 15.9255, 106.285, 7.6793, 7.4851, 106.285, 7.6793, 15.9255, 106.285, -1.3923, 15.9255, 106.285, -1.3923, 7.4851, 106.285, 7.6793, 7.4851, 99.6775, -1.3923, 7.4705, 106.285, 7.6793, 7.4851, 106.285, -1.3923, 7.4851, 99.6775, -1.3923, 7.4705, 99.6775, 7.7244, 7.4705, 106.285, 7.6793, 7.4851, 48.2187, -1.3923, 7.4705, 99.6775, 7.7244, 7.4705, 99.6775, -1.3923, 7.4705, 48.2187, -1.3923, 7.4705, 48.2187, 7.7244, 7.4705, 99.6775, 7.7244, 7.4705, 28.9655, -1.3923, 7.3823, 48.2187, 7.7244, 7.4705, 48.2187, -1.3923, 7.4705, 28.9655, -1.3923, 7.3823, 28.9655, 7.7244, 7.3823, 48.2187, 7.7244, 7.4705, 15.064, -1.7563, 24.808, 15.96, 7.4601, 24.7014, 12.7212, 7.5296, 28.7235, 15.064, -1.7563, 24.808, 12.7212, 7.5296, 28.7235, 11.7712, -1.7681, 29.3285, 11.7712, -1.7681, 29.3285, 12.7212, 7.5296, 28.7235, 11.4389, 7.7088, 33.2736, 11.7712, -1.7681, 29.3285, 11.4389, 7.7088, 33.2736, 11.7145, -2.7115, 33.2538, 2.6504, -1.3923, 33.0209, 2.6504, 7.7244, 33.0209, -1.1454, 7.7244, 31.7354, 2.6504, -1.3923, 33.0209, -1.1454, 7.7244, 31.7354, -1.1454, -1.3923, 31.7354, 7.4643, -1.3923, 33.5284, 2.6504, 7.7244, 33.0209, 2.6504, -1.3923, 33.0209, -1.1454, -1.3923, 31.7354, -1.1454, 7.7244, 31.7354, -4.8429, 7.7244, 29.6798, 7.4643, -1.3923, 33.5284, 7.4643, 7.7244, 33.5284, 2.6504, 7.7244, 33.0209, 11.7145, -2.7115, 33.2538, 7.4643, 7.7244, 33.5284, 7.4643, -1.3923, 33.5284, 11.7145, -2.7115, 33.2538, 11.4389, 7.7088, 33.2736, 7.4643, 7.7244, 33.5284, -1.1454, -1.3923, 31.7354, -4.8429, 7.7244, 29.6798, -4.8429, -1.3923, 29.6798, -4.8429, -1.3923, 29.6798, -4.8429, 7.7244, 29.6798, -7.902, 7.7244, 27.0575, -4.8429, -1.3923, 29.6798, -7.902, 7.7244, 27.0575, -7.902, -1.3923, 27.0575, -7.902, -1.3923, 27.0575, -7.902, 7.7244, 27.0575, -10.8759, 7.7244, 23.6101, -7.902, -1.3923, 27.0575, -10.8759, 7.7244, 23.6101, -10.8759, -1.3923, 23.6101, -10.8759, -1.3923, 23.6101, -10.8759, 7.7244, 23.6101, -12.8775, 7.7244, 19.9487, -10.8759, -1.3923, 23.6101, -12.8775, 7.7244, 19.9487, -12.8775, -1.3923, 19.9487, -12.8775, -1.3923, 19.9487, -12.8775, 7.7244, 19.9487, -14.1277, 7.7244, 15.8222, -12.8775, -1.3923, 19.9487, -14.1277, 7.7244, 15.8222, -14.1277, -1.3923, 15.8222, -14.1277, -1.3923, 15.8222, -14.1277, 7.7244, 15.8222, -14.5688, 7.7244, 11.5878, -14.1277, -1.3923, 15.8222, -14.5688, 7.7244, 11.5878, -14.5688, -1.3923, 11.5878, -14.5688, -1.3923, 11.5878, -14.5688, 7.7244, 11.5878, -14.0407, 7.7244, 7.2613, -14.5688, -1.3923, 11.5878, -14.0407, 7.7244, 7.2613, -14.0407, -1.3923, 7.2613, -14.0407, -1.3923, 7.2613, -14.0407, 7.7244, 7.2613, -12.7306, 7.7244, 3.2389, -14.0407, -1.3923, 7.2613, -12.7306, 7.7244, 3.2389, -12.7306, -1.3923, 3.2389, -12.7306, -1.3923, 3.2389, -12.7306, 7.7244, 3.2389, -10.6617, 7.7244, -0.5608, -12.7306, -1.3923, 3.2389, -10.6617, 7.7244, -0.5608, -10.6617, -1.3923, -0.5608, -10.6617, -1.3923, -0.5608, -10.6617, 7.7244, -0.5608, -8.034, 7.7244, -3.8647, -10.6617, -1.3923, -0.5608, -8.034, 7.7244, -3.8647, -8.034, -1.3923, -3.8647, -8.034, -1.3923, -3.8647, -8.034, 7.7244, -3.8647, -4.7388, 7.7244, -6.5357, -8.034, -1.3923, -3.8647, -4.7388, 7.7244, -6.5357, -4.7388, -2.7124, -6.5357, -4.7388, -2.7124, -6.5357, -4.7388, 7.7244, -6.5357, -0.9806, 7.7244, -8.5873, -4.7388, -2.7124, -6.5357, -0.9806, 7.7244, -8.5873, -0.9806, -2.2617, -8.5873, -0.9806, -2.2617, -8.5873, -0.9806, 7.7244, -8.5873, 3.078, 7.7244, -9.8366, -0.9806, -2.2617, -8.5873, 3.078, 7.7244, -9.8366, 3.078, -1.3923, -9.8366, 3.078, -1.3923, -9.8366, 3.078, 7.7244, -9.8366, 7.4609, 7.7244, -10.258, 3.078, -1.3923, -9.8366, 7.4609, 7.7244, -10.258, 7.4609, -1.3923, -10.258, 7.4609, -1.3923, -10.258, 7.4609, 7.7244, -10.258, 11.6687, 7.7244, -9.8342, 7.4609, -1.3923, -10.258, 11.6687, 7.7244, -9.8342, 11.6687, -1.3923, -9.8342, 11.6687, -1.3923, -9.8342, 11.6687, 7.7244, -9.8342, 15.9042, 7.7244, -8.4866, 11.6687, -1.3923, -9.8342, 15.9042, 7.7244, -8.4866, 15.9042, -1.3923, -8.4866, 15.9042, -1.3923, -8.4866, 15.9042, 7.7244, -8.4866, 19.6803, 7.7244, -6.5368, 15.9042, -1.3923, -8.4866, 19.6803, 7.7244, -6.5368, 19.6803, -1.3923, -6.5368, 19.6803, -1.3923, -6.5368, 19.6803, 7.7244, -6.5368, 22.9495, 7.7244, -3.829, 19.6803, -1.3923, -6.5368, 22.9495, 7.7244, -3.829, 22.9495, -1.3923, -3.829, 22.9495, -1.3923, -3.829, 22.9495, 7.7244, -3.829, 25.7208, 7.7244, -0.4618, 22.9495, -1.3923, -3.829, 25.7208, 7.7244, -0.4618, 25.7207, -1.3923, -0.4618, 25.7207, -1.3923, -0.4618, 25.7208, 7.7244, -0.4618, 27.7178, 7.7244, 3.3401, 25.7207, -1.3923, -0.4618, 27.7178, 7.7244, 3.3401, 27.7178, -1.3923, 3.3401, 27.7178, -1.3923, 3.3401, 27.7178, 7.7244, 3.3401, 28.9655, 7.7244, 7.3823, 27.7178, -1.3923, 3.3401, 28.9655, 7.7244, 7.3823, 28.9655, -1.3923, 7.3823, 28.9379, -1.3923, 15.9431, 28.9379, 7.7244, 15.9431, 27.7153, 7.7244, 20.2713, 28.9379, -1.3923, 15.9431, 27.7153, 7.7244, 20.2713, 27.7153, -1.3923, 20.2713, 27.7153, -1.3923, 20.2713, 27.7153, 7.7244, 20.2713, 25.5887, 7.7244, 24.1355, 27.7153, -1.3923, 20.2713, 25.5887, 7.7244, 24.1355, 25.5887, -1.3923, 24.1355, 25.5887, -1.3923, 24.1355, 25.5887, 7.7244, 24.1355, 23.0552, 7.7244, 27.2603, 25.5887, -1.3923, 24.1355, 23.0552, 7.7244, 27.2603, 23.0552, -1.3923, 27.2603, 23.0552, -1.3923, 27.2603, 23.0552, 7.7244, 27.2603, 18.7068, 7.7014, 26.4664, 23.0552, -1.3923, 27.2603, 18.7068, 7.7014, 26.4664, 18.7096, -1.9203, 26.809, 18.7096, -1.9203, 26.809, 18.7068, 7.7014, 26.4664, 15.96, 7.4601, 24.7014, 18.7096, -1.9203, 26.809, 15.96, 7.4601, 24.7014, 15.064, -1.7563, 24.808) @@ -202,10 +202,7 @@ shadow_blur = 2.832 environment = SubResource("Environment_c86uk") camera_attributes = SubResource("CameraAttributesPractical_ojbcg") -[node name="DimmableAudio" type="Node3D" parent="."] -unique_name_in_owner = true - -[node name="AmbientWind" type="AudioStreamPlayer" parent="DimmableAudio"] +[node name="AmbientWind" type="AudioStreamPlayer" parent="." groups=["DimmableAudio"]] process_mode = 3 stream = ExtResource("28_je2oh") volume_db = -8.0 diff --git a/Zennysoft.Game.Ma/src/map/dungeon/floors/Special Floors/Overworld.tscn b/Zennysoft.Game.Ma/src/map/dungeon/floors/Special Floors/Overworld.tscn index 0ac3e0446..6b24f02ef 100644 --- a/Zennysoft.Game.Ma/src/map/dungeon/floors/Special Floors/Overworld.tscn +++ b/Zennysoft.Game.Ma/src/map/dungeon/floors/Special Floors/Overworld.tscn @@ -3267,7 +3267,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -350.758, -3.90238, 113.556) unique_name_in_owner = true transform = Transform3D(1.51515, 0, 0, 0, 1.51515, 0, 0, 0, 1.51515, 137.047, -0.658938, -5.82563) -[node name="Interior" type="AudioStreamPlayer3D" parent="Node3D/Audio/DimmableAudio"] +[node name="Interior" type="AudioStreamPlayer3D" parent="Node3D/Audio/DimmableAudio" groups=["DimmableAudio"]] process_mode = 3 transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 22.4453, 0, 5.97604) stream = ExtResource("2_wbbo3") @@ -3278,7 +3278,7 @@ max_distance = 100.0 bus = &"AMBIENT" script = ExtResource("66_q7hpd") -[node name="Interior2" type="AudioStreamPlayer3D" parent="Node3D/Audio/DimmableAudio"] +[node name="Interior2" type="AudioStreamPlayer3D" parent="Node3D/Audio/DimmableAudio" groups=["DimmableAudio"]] process_mode = 3 transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -231.692, 6.43338, -92.712) stream = ExtResource("2_wbbo3") @@ -3289,7 +3289,7 @@ max_distance = 54.99 bus = &"AMBIENT" script = ExtResource("66_q7hpd") -[node name="Ocean" type="AudioStreamPlayer3D" parent="Node3D/Audio/DimmableAudio"] +[node name="Ocean" type="AudioStreamPlayer3D" parent="Node3D/Audio/DimmableAudio" groups=["DimmableAudio"]] process_mode = 3 transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -210.527, -9.55156, -81.5173) stream = ExtResource("3_pvi8n") @@ -3301,7 +3301,7 @@ bus = &"AMBIENT" attenuation_filter_cutoff_hz = 20500.0 script = ExtResource("66_q7hpd") -[node name="Ocean2" type="AudioStreamPlayer3D" parent="Node3D/Audio/DimmableAudio"] +[node name="Ocean2" type="AudioStreamPlayer3D" parent="Node3D/Audio/DimmableAudio" groups=["DimmableAudio"]] process_mode = 3 transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 109.176, -130.646, -48.6352) stream = ExtResource("3_pvi8n") @@ -3314,7 +3314,7 @@ bus = &"AMBIENT" attenuation_filter_db = -34.0 script = ExtResource("66_q7hpd") -[node name="Ocean3" type="AudioStreamPlayer3D" parent="Node3D/Audio/DimmableAudio"] +[node name="Ocean3" type="AudioStreamPlayer3D" parent="Node3D/Audio/DimmableAudio" groups=["DimmableAudio"]] process_mode = 3 transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -329.209, -9.13597, -39.3283) stream = ExtResource("3_pvi8n") @@ -3328,7 +3328,7 @@ attenuation_filter_cutoff_hz = 691.0 attenuation_filter_db = -34.0 script = ExtResource("66_q7hpd") -[node name="Waterfall" type="AudioStreamPlayer3D" parent="Node3D/Audio/DimmableAudio"] +[node name="Waterfall" type="AudioStreamPlayer3D" parent="Node3D/Audio/DimmableAudio" groups=["DimmableAudio"]] process_mode = 3 transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -107.057, 0, -48.0532) stream = ExtResource("3_c2gp5") diff --git a/Zennysoft.Game.Ma/src/map/dungeon/rooms/Set A/19. Floor Exit A.tscn b/Zennysoft.Game.Ma/src/map/dungeon/rooms/Set A/19. Floor Exit A.tscn index 29dfeb567..834b9f29d 100644 --- a/Zennysoft.Game.Ma/src/map/dungeon/rooms/Set A/19. Floor Exit A.tscn +++ b/Zennysoft.Game.Ma/src/map/dungeon/rooms/Set A/19. Floor Exit A.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=119 format=4 uid="uid://cihbmyo0ltq4m"] +[gd_scene load_steps=120 format=4 uid="uid://cihbmyo0ltq4m"] [ext_resource type="Texture2D" uid="uid://bfybovehfclqr" path="res://src/map/dungeon/models/Area 1/Exit/A1-Exit_FLOOR1.jpg" id="2_m7ked"] [ext_resource type="Script" uid="uid://bd824eigybu51" path="res://src/map/dungeon/code/ExitRoom.cs" id="2_umdkt"] @@ -22,6 +22,7 @@ [ext_resource type="Texture2D" uid="uid://cu2xk2pn7yki7" path="res://src/map/dungeon/models/Area 1/Exit/A1-Exit_brick3.png" id="16_bastv"] [ext_resource type="Texture2D" uid="uid://pyy25p14q8g5" path="res://src/map/dungeon/models/Area 1/Exit/A1-Exit_COLUM2N.png" id="17_7wx2a"] [ext_resource type="PackedScene" uid="uid://cxwyge2s1yswu" path="res://src/map/Placeables/A1-Socket.tscn" id="18_tgauh"] +[ext_resource type="Script" uid="uid://b83kye8yinfxs" path="res://src/audio/AmbientSFXPlayer3D.cs" id="22_23ip1"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_tio5r"] resource_name = "Material.024" @@ -1352,7 +1353,7 @@ billboard = 2 sprite_frames = SubResource("SpriteFrames_s0p2a") autoplay = "default" -[node name="FLAME1" type="AudioStreamPlayer3D" parent="VFX/Flame1"] +[node name="FLAME1" type="AudioStreamPlayer3D" parent="VFX/Flame1" groups=["DimmableAudio"]] process_mode = 3 transform = Transform3D(1.62602, 0, 0, 0, 2.24719, 0, 0, 0, 2.24719, -0.237626, -1.0051, -0.623936) stream = ExtResource("6_54fgm") @@ -1360,6 +1361,7 @@ autoplay = true max_distance = 25.0 bus = &"AMBIENT" parameters/looping = true +script = ExtResource("22_23ip1") [node name="OmniLight3D2" type="OmniLight3D" parent="VFX/Flame1"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.180455, -0.538921, -0.0176468) @@ -1376,7 +1378,7 @@ billboard = 2 sprite_frames = SubResource("SpriteFrames_s0p2a") autoplay = "default" -[node name="FLAME2" type="AudioStreamPlayer3D" parent="VFX/Flame2"] +[node name="FLAME2" type="AudioStreamPlayer3D" parent="VFX/Flame2" groups=["DimmableAudio"]] process_mode = 3 transform = Transform3D(1.62602, 0, 0, 0, 2.24719, 0, 0, 0, 2.24719, -0.237626, -1.0051, -0.623936) stream = ExtResource("6_54fgm") @@ -1384,6 +1386,7 @@ autoplay = true max_distance = 25.0 bus = &"AMBIENT" parameters/looping = true +script = ExtResource("22_23ip1") [node name="OmniLight3D2" type="OmniLight3D" parent="VFX/Flame2"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.180455, -0.538921, -0.0176468) diff --git a/Zennysoft.Game.Ma/src/player/Player.cs b/Zennysoft.Game.Ma/src/player/Player.cs index 43a39e1f2..769958a3b 100644 --- a/Zennysoft.Game.Ma/src/player/Player.cs +++ b/Zennysoft.Game.Ma/src/player/Player.cs @@ -49,7 +49,7 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide #region Exports [ExportGroup("Movement")] - [Export(PropertyHint.Range, "0, 100, 0.1")] + [Export(PropertyHint.Range, "0, 60, 0.1")] public float RotationSpeed { get; set; } = 1.5f; [Export(PropertyHint.Range, "0, 100, 0.1")] @@ -296,7 +296,6 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide public void OnPhysicsProcess(double delta) { PlayerLogic.Input(new PlayerLogic.Input.PhysicsTick(delta)); - PlayerLogic.Input(new PlayerLogic.Input.Moved(GlobalPosition, GlobalTransform)); } public void Equip(EquipableItem equipable) @@ -700,20 +699,25 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide var transform = Transform; transform.Basis = new Basis(Vector3.Up, Settings.RotationSpeed * -rawInput.X * delta) * transform.Basis; var moveDirection = new Vector3(strafeRightInput - strafeLeftInput, 0, rawInput.Z).Normalized(); - var velocity = Basis * moveDirection * Settings.MoveSpeed * Settings.Acceleration; + + if (moveDirection.Length() > 0.25f) + { + var rng = new RandomNumberGenerator(); + rng.Randomize(); + WalkSFX.PitchScale = rng.RandfRange(0.5f, 1.5f); + if (!WalkSFX.Playing) + WalkSFX.Play(); + } + else if (WalkSFX.Playing) + WalkSFX.Stop(); + + var velocity = (Basis * moveDirection * Settings.MoveSpeed * Settings.Acceleration); if (_debugSprint) velocity *= 2; _knockbackStrength *= 0.9f; Transform = Transform with { Basis = transform.Basis }; Velocity = velocity + (_knockbackDirection * _knockbackStrength); - var rng = new RandomNumberGenerator(); - rng.Randomize(); - WalkSFX.PitchScale = rng.RandfRange(0.5f, 1.5f); - if (!WalkSFX.Playing && !Velocity.IsZeroApprox()) - WalkSFX.Play(); - else if (Velocity.IsZeroApprox()) - WalkSFX.Stop(); MoveAndSlide(); }