Audio fade
This commit is contained in:
@@ -47,4 +47,8 @@ public partial class DimmableAudioStreamPlayer3D : AudioStreamPlayer3D, IDimmabl
|
|||||||
FADE_DURATION
|
FADE_DURATION
|
||||||
).SetTrans(Tween.TransitionType.Circ).SetEase(ease);
|
).SetTrans(Tween.TransitionType.Circ).SetEase(ease);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void _EnterTree() => FadeIn();
|
||||||
|
|
||||||
|
public override void _ExitTree() => FadeOut();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ public partial class PlayerLogic
|
|||||||
{
|
{
|
||||||
public readonly record struct PhysicsTick(double Delta);
|
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 Enable;
|
||||||
|
|
||||||
public readonly record struct Attack;
|
public readonly record struct Attack;
|
||||||
|
|||||||
@@ -79,6 +79,10 @@ folder_colors={
|
|||||||
|
|
||||||
import/blender/enabled=false
|
import/blender/enabled=false
|
||||||
|
|
||||||
|
[global_group]
|
||||||
|
|
||||||
|
DimmableAudio=""
|
||||||
|
|
||||||
[importer_defaults]
|
[importer_defaults]
|
||||||
|
|
||||||
texture={
|
texture={
|
||||||
|
|||||||
@@ -2,4 +2,5 @@
|
|||||||
|
|
||||||
public partial class AmbientSFXPlayer : DimmableAudioStreamPlayer
|
public partial class AmbientSFXPlayer : DimmableAudioStreamPlayer
|
||||||
{
|
{
|
||||||
|
public override void _EnterTree() => FadeIn();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,4 +2,5 @@
|
|||||||
|
|
||||||
public partial class AmbientSFXPlayer3D : DimmableAudioStreamPlayer3D
|
public partial class AmbientSFXPlayer3D : DimmableAudioStreamPlayer3D
|
||||||
{
|
{
|
||||||
|
public override void _EnterTree() => FadeIn();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -383,7 +383,6 @@ public partial class Game : Node3D, IGame
|
|||||||
private void FloorClearMenu_Exit()
|
private void FloorClearMenu_Exit()
|
||||||
{
|
{
|
||||||
_player.Deactivate();
|
_player.Deactivate();
|
||||||
_map.ClearMap();
|
|
||||||
InGameUI.Hide();
|
InGameUI.Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ public interface IMap : INode3D
|
|||||||
|
|
||||||
Task LoadFloor(string sceneName);
|
Task LoadFloor(string sceneName);
|
||||||
|
|
||||||
void ClearMap();
|
|
||||||
|
|
||||||
IDungeonFloor CurrentFloor { get; }
|
IDungeonFloor CurrentFloor { get; }
|
||||||
|
|
||||||
(Vector3 Rotation, Vector3 Position) GetPlayerSpawnPosition();
|
(Vector3 Rotation, Vector3 Position) GetPlayerSpawnPosition();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Godot;
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Zennysoft.Game.Abstractions;
|
||||||
|
|
||||||
namespace Zennysoft.Game.Ma;
|
namespace Zennysoft.Game.Ma;
|
||||||
|
|
||||||
@@ -32,11 +33,35 @@ public partial class Map : Node3D, IMap
|
|||||||
|
|
||||||
public event Action FloorLoaded;
|
public event Action FloorLoaded;
|
||||||
|
|
||||||
|
private string _sceneName;
|
||||||
|
|
||||||
public void OnResolved()
|
public void OnResolved()
|
||||||
{
|
{
|
||||||
|
AnimationPlayer.AnimationFinished += AnimationPlayer_AnimationFinished;
|
||||||
this.Provide();
|
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<FloorNode>().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()
|
public void InitializeMapData()
|
||||||
{
|
{
|
||||||
CurrentFloorNumber.OnNext(-1);
|
CurrentFloorNumber.OnNext(-1);
|
||||||
@@ -65,21 +90,10 @@ public partial class Map : Node3D, IMap
|
|||||||
public async Task LoadFloor(string sceneName)
|
public async Task LoadFloor(string sceneName)
|
||||||
{
|
{
|
||||||
AnimationPlayer.CallDeferred(AnimationPlayer.MethodName.Play, "fade_out");
|
AnimationPlayer.CallDeferred(AnimationPlayer.MethodName.Play, "fade_out");
|
||||||
ClearMap();
|
_sceneName = sceneName;
|
||||||
var newFloor = await LoadNewFloor(sceneName);
|
var dimmableAudio = GetTree().GetNodesInGroup("DimmableAudio").OfType<IDimmableAudioStreamPlayer>();
|
||||||
AddChild(newFloor);
|
foreach (var node in dimmableAudio)
|
||||||
InitializeFloor(newFloor);
|
node.FadeOut();
|
||||||
var floor = MapOrder.GetChildren().OfType<FloorNode>().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)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeFloor(Node newFloor)
|
private void InitializeFloor(Node newFloor)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using Chickensoft.AutoInject;
|
|||||||
using Chickensoft.Introspection;
|
using Chickensoft.Introspection;
|
||||||
using Godot;
|
using Godot;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Zennysoft.Game.Abstractions;
|
|
||||||
using Zennysoft.Ma.Adapter;
|
using Zennysoft.Ma.Adapter;
|
||||||
|
|
||||||
namespace Zennysoft.Game.Ma;
|
namespace Zennysoft.Game.Ma;
|
||||||
@@ -22,8 +21,6 @@ public partial class Altar : SpecialFloor, IDungeonFloor
|
|||||||
|
|
||||||
[Node] private Area3D NoExitArea { get; set; } = default!;
|
[Node] private Area3D NoExitArea { get; set; } = default!;
|
||||||
|
|
||||||
[Node] private Node DimmableAudio { get; set; } = default!;
|
|
||||||
|
|
||||||
[Export] public Resource Dialogue { get; set; } = default!;
|
[Export] public Resource Dialogue { get; set; } = default!;
|
||||||
|
|
||||||
public void OnResolved()
|
public void OnResolved()
|
||||||
@@ -32,16 +29,6 @@ public partial class Altar : SpecialFloor, IDungeonFloor
|
|||||||
Exit.AreaEntered += Exit_AreaEntered;
|
Exit.AreaEntered += Exit_AreaEntered;
|
||||||
NoExitArea.AreaEntered += NoExitArea_AreaEntered;
|
NoExitArea.AreaEntered += NoExitArea_AreaEntered;
|
||||||
FloorIsLoaded = true;
|
FloorIsLoaded = true;
|
||||||
var dimmableAudio = DimmableAudio.GetChildren().OfType<IDimmableAudioStreamPlayer>();
|
|
||||||
foreach (var dimmable in dimmableAudio)
|
|
||||||
dimmable.FadeIn();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void FadeOutAudio()
|
|
||||||
{
|
|
||||||
var dimmableAudio = DimmableAudio.GetChildren().OfType<IDimmableAudioStreamPlayer>();
|
|
||||||
foreach (var dimmable in dimmableAudio)
|
|
||||||
dimmable.FadeOut();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _player_PointUpFinished()
|
private void _player_PointUpFinished()
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -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
|
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)
|
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
|
process_mode = 3
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 22.4453, 0, 5.97604)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 22.4453, 0, 5.97604)
|
||||||
stream = ExtResource("2_wbbo3")
|
stream = ExtResource("2_wbbo3")
|
||||||
@@ -3278,7 +3278,7 @@ max_distance = 100.0
|
|||||||
bus = &"AMBIENT"
|
bus = &"AMBIENT"
|
||||||
script = ExtResource("66_q7hpd")
|
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
|
process_mode = 3
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -231.692, 6.43338, -92.712)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -231.692, 6.43338, -92.712)
|
||||||
stream = ExtResource("2_wbbo3")
|
stream = ExtResource("2_wbbo3")
|
||||||
@@ -3289,7 +3289,7 @@ max_distance = 54.99
|
|||||||
bus = &"AMBIENT"
|
bus = &"AMBIENT"
|
||||||
script = ExtResource("66_q7hpd")
|
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
|
process_mode = 3
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -210.527, -9.55156, -81.5173)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -210.527, -9.55156, -81.5173)
|
||||||
stream = ExtResource("3_pvi8n")
|
stream = ExtResource("3_pvi8n")
|
||||||
@@ -3301,7 +3301,7 @@ bus = &"AMBIENT"
|
|||||||
attenuation_filter_cutoff_hz = 20500.0
|
attenuation_filter_cutoff_hz = 20500.0
|
||||||
script = ExtResource("66_q7hpd")
|
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
|
process_mode = 3
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 109.176, -130.646, -48.6352)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 109.176, -130.646, -48.6352)
|
||||||
stream = ExtResource("3_pvi8n")
|
stream = ExtResource("3_pvi8n")
|
||||||
@@ -3314,7 +3314,7 @@ bus = &"AMBIENT"
|
|||||||
attenuation_filter_db = -34.0
|
attenuation_filter_db = -34.0
|
||||||
script = ExtResource("66_q7hpd")
|
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
|
process_mode = 3
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -329.209, -9.13597, -39.3283)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -329.209, -9.13597, -39.3283)
|
||||||
stream = ExtResource("3_pvi8n")
|
stream = ExtResource("3_pvi8n")
|
||||||
@@ -3328,7 +3328,7 @@ attenuation_filter_cutoff_hz = 691.0
|
|||||||
attenuation_filter_db = -34.0
|
attenuation_filter_db = -34.0
|
||||||
script = ExtResource("66_q7hpd")
|
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
|
process_mode = 3
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -107.057, 0, -48.0532)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -107.057, 0, -48.0532)
|
||||||
stream = ExtResource("3_c2gp5")
|
stream = ExtResource("3_c2gp5")
|
||||||
|
|||||||
@@ -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="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"]
|
[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://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="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="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"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_tio5r"]
|
||||||
resource_name = "Material.024"
|
resource_name = "Material.024"
|
||||||
@@ -1352,7 +1353,7 @@ billboard = 2
|
|||||||
sprite_frames = SubResource("SpriteFrames_s0p2a")
|
sprite_frames = SubResource("SpriteFrames_s0p2a")
|
||||||
autoplay = "default"
|
autoplay = "default"
|
||||||
|
|
||||||
[node name="FLAME1" type="AudioStreamPlayer3D" parent="VFX/Flame1"]
|
[node name="FLAME1" type="AudioStreamPlayer3D" parent="VFX/Flame1" groups=["DimmableAudio"]]
|
||||||
process_mode = 3
|
process_mode = 3
|
||||||
transform = Transform3D(1.62602, 0, 0, 0, 2.24719, 0, 0, 0, 2.24719, -0.237626, -1.0051, -0.623936)
|
transform = Transform3D(1.62602, 0, 0, 0, 2.24719, 0, 0, 0, 2.24719, -0.237626, -1.0051, -0.623936)
|
||||||
stream = ExtResource("6_54fgm")
|
stream = ExtResource("6_54fgm")
|
||||||
@@ -1360,6 +1361,7 @@ autoplay = true
|
|||||||
max_distance = 25.0
|
max_distance = 25.0
|
||||||
bus = &"AMBIENT"
|
bus = &"AMBIENT"
|
||||||
parameters/looping = true
|
parameters/looping = true
|
||||||
|
script = ExtResource("22_23ip1")
|
||||||
|
|
||||||
[node name="OmniLight3D2" type="OmniLight3D" parent="VFX/Flame1"]
|
[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)
|
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")
|
sprite_frames = SubResource("SpriteFrames_s0p2a")
|
||||||
autoplay = "default"
|
autoplay = "default"
|
||||||
|
|
||||||
[node name="FLAME2" type="AudioStreamPlayer3D" parent="VFX/Flame2"]
|
[node name="FLAME2" type="AudioStreamPlayer3D" parent="VFX/Flame2" groups=["DimmableAudio"]]
|
||||||
process_mode = 3
|
process_mode = 3
|
||||||
transform = Transform3D(1.62602, 0, 0, 0, 2.24719, 0, 0, 0, 2.24719, -0.237626, -1.0051, -0.623936)
|
transform = Transform3D(1.62602, 0, 0, 0, 2.24719, 0, 0, 0, 2.24719, -0.237626, -1.0051, -0.623936)
|
||||||
stream = ExtResource("6_54fgm")
|
stream = ExtResource("6_54fgm")
|
||||||
@@ -1384,6 +1386,7 @@ autoplay = true
|
|||||||
max_distance = 25.0
|
max_distance = 25.0
|
||||||
bus = &"AMBIENT"
|
bus = &"AMBIENT"
|
||||||
parameters/looping = true
|
parameters/looping = true
|
||||||
|
script = ExtResource("22_23ip1")
|
||||||
|
|
||||||
[node name="OmniLight3D2" type="OmniLight3D" parent="VFX/Flame2"]
|
[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)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.180455, -0.538921, -0.0176468)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
|||||||
|
|
||||||
#region Exports
|
#region Exports
|
||||||
[ExportGroup("Movement")]
|
[ExportGroup("Movement")]
|
||||||
[Export(PropertyHint.Range, "0, 100, 0.1")]
|
[Export(PropertyHint.Range, "0, 60, 0.1")]
|
||||||
public float RotationSpeed { get; set; } = 1.5f;
|
public float RotationSpeed { get; set; } = 1.5f;
|
||||||
|
|
||||||
[Export(PropertyHint.Range, "0, 100, 0.1")]
|
[Export(PropertyHint.Range, "0, 100, 0.1")]
|
||||||
@@ -296,7 +296,6 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
|||||||
public void OnPhysicsProcess(double delta)
|
public void OnPhysicsProcess(double delta)
|
||||||
{
|
{
|
||||||
PlayerLogic.Input(new PlayerLogic.Input.PhysicsTick(delta));
|
PlayerLogic.Input(new PlayerLogic.Input.PhysicsTick(delta));
|
||||||
PlayerLogic.Input(new PlayerLogic.Input.Moved(GlobalPosition, GlobalTransform));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Equip(EquipableItem equipable)
|
public void Equip(EquipableItem equipable)
|
||||||
@@ -700,20 +699,25 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
|||||||
var transform = Transform;
|
var transform = Transform;
|
||||||
transform.Basis = new Basis(Vector3.Up, Settings.RotationSpeed * -rawInput.X * delta) * transform.Basis;
|
transform.Basis = new Basis(Vector3.Up, Settings.RotationSpeed * -rawInput.X * delta) * transform.Basis;
|
||||||
var moveDirection = new Vector3(strafeRightInput - strafeLeftInput, 0, rawInput.Z).Normalized();
|
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)
|
if (_debugSprint)
|
||||||
velocity *= 2;
|
velocity *= 2;
|
||||||
_knockbackStrength *= 0.9f;
|
_knockbackStrength *= 0.9f;
|
||||||
Transform = Transform with { Basis = transform.Basis };
|
Transform = Transform with { Basis = transform.Basis };
|
||||||
Velocity = velocity + (_knockbackDirection * _knockbackStrength);
|
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();
|
MoveAndSlide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user