From a11e61b2c28bbe3015f2d5d5589c9d07945f2612 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 11 Sep 2025 14:10:14 +0200 Subject: [PATCH] Enemy sounds --- Resources/Enemies/Base_Fairy_3D.tres | 8 +- Resources/Enemies/Base_Fairy_Special_3D.tres | 8 +- Resources/Enemies/Fairy_Guard_3D.tres | 8 +- Resources/Weapons/IcicleGun_3D.tres | 6 +- SFX/fairy_death.wav | 3 + SFX/fairy_death.wav.import | 24 ++++++ SFX/fairy_stop.wav | 3 + SFX/fairy_stop.wav.import | 24 ++++++ Scenes/Actors/Generic_Enemy_FSM_3D.tscn | 29 ++++++- Scenes/Weapons/BaseWeapon_3D.tscn | 2 +- .../Actors/3D/EnemySoundModule3D.cs | 84 +++++++++++++++++++ .../Actors/3D/EnemySoundModule3D.cs.uid | 1 + Scripts/Components/Actors/DamageReceiver3D.cs | 48 ++++++----- Scripts/Components/FSM/Enemy/3D/Dead.cs | 9 +- Scripts/Resources/EnemyResource.cs | 5 ++ 15 files changed, 224 insertions(+), 38 deletions(-) create mode 100644 SFX/fairy_death.wav create mode 100644 SFX/fairy_death.wav.import create mode 100644 SFX/fairy_stop.wav create mode 100644 SFX/fairy_stop.wav.import create mode 100644 Scripts/Components/Actors/3D/EnemySoundModule3D.cs create mode 100644 Scripts/Components/Actors/3D/EnemySoundModule3D.cs.uid diff --git a/Resources/Enemies/Base_Fairy_3D.tres b/Resources/Enemies/Base_Fairy_3D.tres index 2a2fab15..2c9180c9 100644 --- a/Resources/Enemies/Base_Fairy_3D.tres +++ b/Resources/Enemies/Base_Fairy_3D.tres @@ -1,11 +1,14 @@ -[gd_resource type="Resource" script_class="EnemyResource" load_steps=19 format=3 uid="uid://4qxicyti4hwr"] +[gd_resource type="Resource" script_class="EnemyResource" load_steps=22 format=3 uid="uid://4qxicyti4hwr"] [ext_resource type="SpriteFrames" uid="uid://chjsokgyo0e33" path="res://Resources/Sprites/base_fairy.tres" id="1_gbbb4"] [ext_resource type="Texture2D" uid="uid://xgxxdq37pykh" path="res://Sprites/Actors/Fairy.png" id="1_ihub2"] +[ext_resource type="AudioStream" uid="uid://rh8w0qte7wup" path="res://SFX/fairy_stop.wav" id="1_rx5mb"] [ext_resource type="Script" uid="uid://cq65aed620ijo" path="res://Scripts/Resources/Loot/LootDrop.cs" id="2_gbbb4"] [ext_resource type="SpriteFrames" uid="uid://bhpipyiuydlul" path="res://Resources/Sprites/Fairy_Base_Dead.tres" id="2_oni0r"] [ext_resource type="Resource" uid="uid://ct1fa2huvy34n" path="res://Resources/Items/Ammo1.tres" id="3_6fuej"] [ext_resource type="PackedScene" uid="uid://l7a5p3vfsbn0" path="res://Scenes/Actors/Generic_Enemy_Debris_3D.tscn" id="3_kno8n"] +[ext_resource type="AudioStream" uid="uid://c2lpt24ft01go" path="res://SFX/fairy_death.wav" id="4_7vfm8"] +[ext_resource type="AudioStream" uid="uid://bwr26ypv2rg6c" path="res://SFX/enemy_hit.wav" id="4_kno8n"] [ext_resource type="Resource" uid="uid://dy53gia1tmkah" path="res://Resources/Items/Points_Pickup.tres" id="4_oni0r"] [ext_resource type="Resource" uid="uid://bhbufxodybsw4" path="res://Resources/Items/Shield_Pickup.tres" id="5_kno8n"] [ext_resource type="Resource" uid="uid://dodwpect0ldjf" path="res://Resources/Items/Heart_Pickup.tres" id="6_jnpnu"] @@ -67,4 +70,7 @@ IconSprite = SubResource("AtlasTexture_ppsgt") AnimationFrames = ExtResource("1_gbbb4") DebrisScene = ExtResource("3_kno8n") DeathAnimation = ExtResource("2_oni0r") +HitSound = ExtResource("4_kno8n") +DeathSound = ExtResource("4_7vfm8") +AlertSound = ExtResource("1_rx5mb") metadata/_custom_type_script = "uid://cd5o0ceb50jki" diff --git a/Resources/Enemies/Base_Fairy_Special_3D.tres b/Resources/Enemies/Base_Fairy_Special_3D.tres index b466b728..a630f6cd 100644 --- a/Resources/Enemies/Base_Fairy_Special_3D.tres +++ b/Resources/Enemies/Base_Fairy_Special_3D.tres @@ -1,12 +1,15 @@ -[gd_resource type="Resource" script_class="EnemyResource" load_steps=19 format=3 uid="uid://c48vva6qw2h12"] +[gd_resource type="Resource" script_class="EnemyResource" load_steps=22 format=3 uid="uid://c48vva6qw2h12"] [ext_resource type="Texture2D" uid="uid://callpd48wwnlw" path="res://Sprites/Actors/Fairy_Special.png" id="1_0afqr"] +[ext_resource type="AudioStream" uid="uid://rh8w0qte7wup" path="res://SFX/fairy_stop.wav" id="1_6ilmv"] [ext_resource type="SpriteFrames" uid="uid://cnl6ju3qlr2bj" path="res://Resources/Sprites/base_fairy_special.tres" id="1_6r34r"] [ext_resource type="SpriteFrames" uid="uid://bhpipyiuydlul" path="res://Resources/Sprites/Fairy_Base_Dead.tres" id="2_1l422"] [ext_resource type="Script" uid="uid://cq65aed620ijo" path="res://Scripts/Resources/Loot/LootDrop.cs" id="2_6r34r"] [ext_resource type="Resource" uid="uid://ct1fa2huvy34n" path="res://Resources/Items/Ammo1.tres" id="3_dkgyx"] [ext_resource type="PackedScene" uid="uid://l7a5p3vfsbn0" path="res://Scenes/Actors/Generic_Enemy_Debris_3D.tscn" id="3_fanfp"] [ext_resource type="Resource" uid="uid://dy53gia1tmkah" path="res://Resources/Items/Points_Pickup.tres" id="4_1l422"] +[ext_resource type="AudioStream" uid="uid://bwr26ypv2rg6c" path="res://SFX/enemy_hit.wav" id="4_fanfp"] +[ext_resource type="AudioStream" uid="uid://c2lpt24ft01go" path="res://SFX/fairy_death.wav" id="4_i2y7h"] [ext_resource type="Resource" uid="uid://bhbufxodybsw4" path="res://Resources/Items/Shield_Pickup.tres" id="5_fanfp"] [ext_resource type="Resource" uid="uid://dodwpect0ldjf" path="res://Resources/Items/Heart_Pickup.tres" id="6_y2gca"] [ext_resource type="Resource" uid="uid://clr1gln7nxa1o" path="res://Resources/Items/Power_Pickup.tres" id="7_6ilmv"] @@ -67,4 +70,7 @@ IconSprite = SubResource("AtlasTexture_c0hok") AnimationFrames = ExtResource("1_6r34r") DebrisScene = ExtResource("3_fanfp") DeathAnimation = ExtResource("2_1l422") +HitSound = ExtResource("4_fanfp") +DeathSound = ExtResource("4_i2y7h") +AlertSound = ExtResource("1_6ilmv") metadata/_custom_type_script = "uid://cd5o0ceb50jki" diff --git a/Resources/Enemies/Fairy_Guard_3D.tres b/Resources/Enemies/Fairy_Guard_3D.tres index 9140726a..95e3b5d2 100644 --- a/Resources/Enemies/Fairy_Guard_3D.tres +++ b/Resources/Enemies/Fairy_Guard_3D.tres @@ -1,10 +1,13 @@ -[gd_resource type="Resource" script_class="EnemyResource" load_steps=19 format=3 uid="uid://ccym6mcq4fbul"] +[gd_resource type="Resource" script_class="EnemyResource" load_steps=22 format=3 uid="uid://ccym6mcq4fbul"] [ext_resource type="SpriteFrames" uid="uid://ch2ll1on8im2p" path="res://Resources/Sprites/FairyGuard.tres" id="1_b2551"] +[ext_resource type="AudioStream" uid="uid://rh8w0qte7wup" path="res://SFX/fairy_stop.wav" id="1_ili73"] [ext_resource type="Texture2D" uid="uid://xhwfgbv0fjbr" path="res://Sprites/Actors/FairyGuard.png" id="2_c6xyh"] [ext_resource type="SpriteFrames" uid="uid://xiirmmgfsya6" path="res://Resources/Sprites/Fairy_Guard_Dead.tres" id="2_juf1x"] [ext_resource type="Script" uid="uid://cq65aed620ijo" path="res://Scripts/Resources/Loot/LootDrop.cs" id="3_juf1x"] [ext_resource type="PackedScene" uid="uid://l7a5p3vfsbn0" path="res://Scenes/Actors/Generic_Enemy_Debris_3D.tscn" id="3_m2lqx"] +[ext_resource type="AudioStream" uid="uid://c2lpt24ft01go" path="res://SFX/fairy_death.wav" id="4_7ibiq"] +[ext_resource type="AudioStream" uid="uid://bwr26ypv2rg6c" path="res://SFX/enemy_hit.wav" id="4_80clb"] [ext_resource type="Resource" uid="uid://ct1fa2huvy34n" path="res://Resources/Items/Ammo1.tres" id="4_m2lqx"] [ext_resource type="Resource" uid="uid://dy53gia1tmkah" path="res://Resources/Items/Points_Pickup.tres" id="5_80clb"] [ext_resource type="Resource" uid="uid://bhbufxodybsw4" path="res://Resources/Items/Shield_Pickup.tres" id="6_ili73"] @@ -67,4 +70,7 @@ IconSprite = SubResource("AtlasTexture_n54y5") AnimationFrames = ExtResource("1_b2551") DebrisScene = ExtResource("3_m2lqx") DeathAnimation = ExtResource("2_juf1x") +HitSound = ExtResource("4_80clb") +DeathSound = ExtResource("4_7ibiq") +AlertSound = ExtResource("1_ili73") metadata/_custom_type_script = "uid://cd5o0ceb50jki" diff --git a/Resources/Weapons/IcicleGun_3D.tres b/Resources/Weapons/IcicleGun_3D.tres index f0eb0052..98784b55 100644 --- a/Resources/Weapons/IcicleGun_3D.tres +++ b/Resources/Weapons/IcicleGun_3D.tres @@ -11,14 +11,14 @@ Name = &"Icicle Gun" BulletData = ExtResource("1_d2kl0") Priority = 10 AmmoPerShot = 5 -RateOfFire = 0.052999999999883585 +RateOfFire = 0.05299999999988358 BulletCapacity = 100 ReloadTime = 0.5 InfiniteAmmo = false ItemKey = &"ICICLE_GUN" AmmoKey = &"BATTERY" -RechargeTime = 0.19999999999708962 -RechargeAmount = 5 +RechargeTime = 0.1999999999970896 +RechargeAmount = 10 SpreadAngle = 5.0 RandomSpread = 2.5 ReloadSound = ExtResource("2_sdmjb") diff --git a/SFX/fairy_death.wav b/SFX/fairy_death.wav new file mode 100644 index 00000000..b9295f8c --- /dev/null +++ b/SFX/fairy_death.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:90481f43fbd1779bbf04bf4244d8b5193be7621ae62c903bb21aec8029d2c583 +size 110636 diff --git a/SFX/fairy_death.wav.import b/SFX/fairy_death.wav.import new file mode 100644 index 00000000..1d446db5 --- /dev/null +++ b/SFX/fairy_death.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://c2lpt24ft01go" +path="res://.godot/imported/fairy_death.wav-11cb1ad267f96dacc2a9d5f6d54567d1.sample" + +[deps] + +source_file="res://SFX/fairy_death.wav" +dest_files=["res://.godot/imported/fairy_death.wav-11cb1ad267f96dacc2a9d5f6d54567d1.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/SFX/fairy_stop.wav b/SFX/fairy_stop.wav new file mode 100644 index 00000000..5e828281 --- /dev/null +++ b/SFX/fairy_stop.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:93f445e358735e1b8e77e003d88dad656ea45e61fb21e1a903a532e4e4a4f2f5 +size 15648 diff --git a/SFX/fairy_stop.wav.import b/SFX/fairy_stop.wav.import new file mode 100644 index 00000000..84eb404c --- /dev/null +++ b/SFX/fairy_stop.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://rh8w0qte7wup" +path="res://.godot/imported/fairy_stop.wav-cae41700750f72d9cf6fe84e576390ef.sample" + +[deps] + +source_file="res://SFX/fairy_stop.wav" +dest_files=["res://.godot/imported/fairy_stop.wav-cae41700750f72d9cf6fe84e576390ef.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=2 diff --git a/Scenes/Actors/Generic_Enemy_FSM_3D.tscn b/Scenes/Actors/Generic_Enemy_FSM_3D.tscn index 31d2886d..fda44bce 100644 --- a/Scenes/Actors/Generic_Enemy_FSM_3D.tscn +++ b/Scenes/Actors/Generic_Enemy_FSM_3D.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=33 format=3 uid="uid://bh3vxmqflijgj"] +[gd_scene load_steps=34 format=3 uid="uid://bh3vxmqflijgj"] [ext_resource type="Script" uid="uid://dwregubt4iila" path="res://Scripts/Components/FSM/Enemy/3D/EnemyProxy3D.cs" id="1_a3crc"] [ext_resource type="Resource" uid="uid://ccym6mcq4fbul" path="res://Resources/Enemies/Fairy_Guard_3D.tres" id="2_jgarc"] @@ -25,6 +25,7 @@ [ext_resource type="Script" uid="uid://cqwvssstkrdmw" path="res://Scripts/Components/Actors/ActorResourceProvider.cs" id="18_4fnoq"] [ext_resource type="Script" uid="uid://dvln1783wvvuw" path="res://Scripts/Components/Actors/ShadowProvider.cs" id="19_4fnoq"] [ext_resource type="Script" uid="uid://qrdor3gk6x37" path="res://Scripts/Components/FSM/Enemy/3D/GravityProvider.cs" id="25_qg061"] +[ext_resource type="Script" uid="uid://khph8rethll7" path="res://Scripts/Components/Actors/3D/EnemySoundModule3D.cs" id="26_ojvcb"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_jgarc"] radius = 0.343 @@ -88,7 +89,7 @@ Storage = NodePath("../../Storage") PlayerDetection = NodePath("../../PlayerDetectionProvider") GravityProvider = NodePath("../../GravityProvider") DebugEnabled = true -_moduleNodes = [NodePath("../../DamageModule"), NodePath("../../AnimationModule")] +_moduleNodes = [NodePath("../../DamageModule"), NodePath("../../AnimationModule"), NodePath("../../SoundModule")] [node name="Alert" type="Node" parent="StateMachine" node_paths=PackedStringArray("Storage", "PlayerDetection", "NavigationModule", "GravityProvider", "_moduleNodes")] script = ExtResource("6_jgarc") @@ -97,7 +98,7 @@ PlayerDetection = NodePath("../../PlayerDetectionProvider") NavigationModule = NodePath("../../NavigationProvider") GravityProvider = NodePath("../../GravityProvider") DebugEnabled = true -_moduleNodes = [NodePath("../../DamageModule"), NodePath("../../AnimationModule")] +_moduleNodes = [NodePath("../../DamageModule"), NodePath("../../AnimationModule"), NodePath("../../SoundModule")] [node name="Shooting" type="Node" parent="StateMachine" node_paths=PackedStringArray("Storage", "PlayerDetection", "EquippedWeapon", "NavigationModule", "GravityProvider", "_moduleNodes")] script = ExtResource("7_rg1hb") @@ -106,7 +107,7 @@ PlayerDetection = NodePath("../../PlayerDetectionProvider") EquippedWeapon = NodePath("../../Weapon") NavigationModule = NodePath("../../NavigationProvider") GravityProvider = NodePath("../../GravityProvider") -_moduleNodes = [NodePath("../../DamageModule"), NodePath("../../AnimationModule")] +_moduleNodes = [NodePath("../../DamageModule"), NodePath("../../AnimationModule"), NodePath("../../SoundModule")] [node name="Dead" type="Node" parent="StateMachine" node_paths=PackedStringArray("Storage")] script = ExtResource("8_5j04l") @@ -203,6 +204,26 @@ script = ExtResource("25_qg061") Gravity = -20.0 MaxFallSpeed = 50.0 +[node name="SoundModule" type="Node" parent="." node_paths=PackedStringArray("DamageReceiver", "StorageModule", "HitPlayer", "DeathPlayer", "AlertPlayer")] +script = ExtResource("26_ojvcb") +DamageReceiver = NodePath("../DamageReceiver") +StorageModule = NodePath("../Storage") +HitPlayer = NodePath("HitPlayer") +DeathPlayer = NodePath("DeathPlayer") +AlertPlayer = NodePath("AlertPlayer") + +[node name="HitPlayer" type="AudioStreamPlayer3D" parent="SoundModule"] +unit_size = 30.0 +bus = &"Effects" + +[node name="AlertPlayer" type="AudioStreamPlayer3D" parent="SoundModule"] +unit_size = 30.0 +bus = &"Effects" + +[node name="DeathPlayer" type="AudioStreamPlayer3D" parent="SoundModule"] +unit_size = 30.0 +bus = &"Effects" + [connection signal="body_entered" from="PlayerDetectionProvider" to="PlayerDetectionProvider" method="_on_body_entered"] [connection signal="body_exited" from="PlayerDetectionProvider" to="PlayerDetectionProvider" method="_on_body_exited"] [connection signal="velocity_computed" from="NavigationAgent3D" to="NavigationProvider" method="_on_navigation_agent_3d_velocity_computed"] diff --git a/Scenes/Weapons/BaseWeapon_3D.tscn b/Scenes/Weapons/BaseWeapon_3D.tscn index 4b2e8681..71a64b12 100644 --- a/Scenes/Weapons/BaseWeapon_3D.tscn +++ b/Scenes/Weapons/BaseWeapon_3D.tscn @@ -24,7 +24,7 @@ billboard = 1 texture_filter = 0 texture = ExtResource("3_6jcxd") -[node name="SoundModule" type="Node" parent="." node_paths=PackedStringArray("Weapon", "ShootSound", "ReloadSound", "EmptySound")] +[node name="SoundModule" type="Node3D" parent="." node_paths=PackedStringArray("Weapon", "ShootSound", "ReloadSound", "EmptySound")] script = ExtResource("3_s6td3") Weapon = NodePath("..") ShootSound = NodePath("ShootSound") diff --git a/Scripts/Components/Actors/3D/EnemySoundModule3D.cs b/Scripts/Components/Actors/3D/EnemySoundModule3D.cs new file mode 100644 index 00000000..2284b68e --- /dev/null +++ b/Scripts/Components/Actors/3D/EnemySoundModule3D.cs @@ -0,0 +1,84 @@ +using Cirno.Scripts.Components.FSM; +using Cirno.Scripts.Components.FSM.Enemy._3D; +using Cirno.Scripts.Enums; +using Cirno.Scripts.Weapons; +using Godot; + +namespace Cirno.Scripts.Components.Actors._3D; + +public partial class EnemySoundModule3D : ModuleBase +{ + + [ExportCategory("References")] + [Export] public DamageReceiver3D DamageReceiver { get; private set; } + [Export] public EnemyStorage3D StorageModule { get; private set; } + + + [ExportCategory("Players")] + [Export] public AudioStreamPlayer3D HitPlayer { get; private set; } + [Export] public AudioStreamPlayer3D DeathPlayer { get; private set; } + [Export] public AudioStreamPlayer3D AlertPlayer { get; private set; } + + private bool _initialized = false; + private bool _enabled = false; + + public override void EnterState(EnemyState state) + { + + _enabled = true; + } + + public override void ExitState(EnemyState state) + { + _enabled = false; + } + + private IStateMachine _machine; + + public override void Init(IStateMachine machine) + { + if (_initialized) return; + + _machine = machine; + if (StorageModule.EnemyData.HitSound is not null) + { + HitPlayer.Stream = StorageModule.EnemyData.HitSound; + DamageReceiver.BulletHit += DamageReceiverOnBulletHit; + } + + if (StorageModule.EnemyData.DeathSound is not null) + { + DeathPlayer.Stream = StorageModule.EnemyData.DeathSound; + DamageReceiver.HealthProvider.ResourceDepleted += HealthProviderOnResourceDepleted; + } + + if (StorageModule.EnemyData.AlertSound is not null) + { + AlertPlayer.Stream = StorageModule.EnemyData.AlertSound; + + } + + _initialized = true; + } + + private void HealthProviderOnResourceDepleted() + { + GD.Print("Played death sound"); + DeathPlayer.Play(); + } + + private void DamageReceiverOnBulletHit(Bullet3D bullet, Vector3 position, Vector3 direction) + { + HitPlayer.Play(); + } + + public override void Process(double delta) + { + + } + + public override void PhysicsProcess(double delta) + { + + } +} \ No newline at end of file diff --git a/Scripts/Components/Actors/3D/EnemySoundModule3D.cs.uid b/Scripts/Components/Actors/3D/EnemySoundModule3D.cs.uid new file mode 100644 index 00000000..85e0bf1b --- /dev/null +++ b/Scripts/Components/Actors/3D/EnemySoundModule3D.cs.uid @@ -0,0 +1 @@ +uid://khph8rethll7 diff --git a/Scripts/Components/Actors/DamageReceiver3D.cs b/Scripts/Components/Actors/DamageReceiver3D.cs index 6a83f352..e9258d9b 100644 --- a/Scripts/Components/Actors/DamageReceiver3D.cs +++ b/Scripts/Components/Actors/DamageReceiver3D.cs @@ -7,7 +7,7 @@ using Godot.Collections; namespace Cirno.Scripts.Components.Actors; -public partial class DamageReceiver3D : Area3D, IHittable +public partial class DamageReceiver3D : Area3D, IHittable { [Export] public ActorResourceProvider HealthProvider { get; private set; } @@ -16,22 +16,23 @@ public partial class DamageReceiver3D : Area3D, IHittable [Export] public BulletOwner BulletGroup { get; set; } = BulletOwner.None; [Export] public PackedScene Debris { get; set; } - + [Export] public Array DamageResistances { get; set; } = []; [Export] public bool DeleteParentOnDeath { get; private set; } = true; [Signal] public delegate void ShieldHitEventHandler(); - - [Signal] public delegate void BulletHitEventHandler(Bullet3D bullet, Vector3 position, Vector3 direction); - + + [Signal] + public delegate void BulletHitEventHandler(Bullet3D bullet, Vector3 position, Vector3 direction); + //[Signal] public delegate void DeathEventHandler(); - + private Node3D _parent; - + public bool Enabled { get; private set; } = true; - + public override void _Ready() { _parent = GetParent(); @@ -43,7 +44,7 @@ public partial class DamageReceiver3D : Area3D, IHittable { Enabled = enabled; } - + private void _on_damage_hitbox_area_entered(Area3D area) { if (!Enabled) return; @@ -52,50 +53,53 @@ public partial class DamageReceiver3D : Area3D, IHittable { EmitSignalShieldHit(); return; - }; + } + + ; if (BulletGroup is BulletOwner.None) { this.Hit(bullet.Damage, bullet.DamageType); - + EmitSignalBulletHit(bullet, area.GlobalPosition, (this.GlobalPosition - area.GlobalPosition).Normalized()); - + bullet.RequestCollisionDestruction(); return; } - if (bullet.BulletInfo.Owner == BulletGroup) return; - + if (bullet.BulletInfo.Owner == BulletGroup) return; + this.Hit(bullet.Damage, bullet.DamageType); - + EmitSignalBulletHit(bullet, area.GlobalPosition, (this.GlobalPosition - area.GlobalPosition).Normalized()); - + bullet.RequestCollisionDestruction(); } - + public void Hit(float damage, DamageType damageType = DamageType.Neutral) { if (!Enabled) return; if (Invulnerable) return; - + // Change value based on difficulty float difficultyReducedDmg = damage * GlobalState.Instance.SessionSettings.DifficultyDamageMultiplier; - var dmg = DamageResistances.Aggregate(difficultyReducedDmg, (current, resistance) => current * resistance.CalculateDamage(current, damageType)); + var dmg = DamageResistances.Aggregate(difficultyReducedDmg, + (current, resistance) => current * resistance.CalculateDamage(current, damageType)); HealthProvider.CurrentResource -= dmg; } - + private void OnDeath() { if (Debris is not null) { _parent.CreateSibling(Debris); } - + // Not needed because the health provider is accessible //EmitSignal(SignalName.Death); - + if (DeleteParentOnDeath) { _parent.QueueFree(); diff --git a/Scripts/Components/FSM/Enemy/3D/Dead.cs b/Scripts/Components/FSM/Enemy/3D/Dead.cs index 1cb97ddd..562882c3 100644 --- a/Scripts/Components/FSM/Enemy/3D/Dead.cs +++ b/Scripts/Components/FSM/Enemy/3D/Dead.cs @@ -7,8 +7,8 @@ namespace Cirno.Scripts.Components.FSM.Enemy._3D; public partial class Dead : EnemyStateBase3D { public override EnemyState StateId => EnemyState.Dead; - - [Export] public EnemyStorage3D Storage { get; private set; } + + [Export] public EnemyStorage3D Storage { get; private set; } public override void EnterState() { @@ -23,8 +23,7 @@ public partial class Dead : EnemyStateBase3D debris.GlobalPosition = MainObject.GlobalPosition; debris.Init(Storage.EnemyData); } - - - MainObject.QueueFree(); + + //MainObject.QueueFree(); } } \ No newline at end of file diff --git a/Scripts/Resources/EnemyResource.cs b/Scripts/Resources/EnemyResource.cs index 91fa6f1c..17abdde3 100644 --- a/Scripts/Resources/EnemyResource.cs +++ b/Scripts/Resources/EnemyResource.cs @@ -42,4 +42,9 @@ public partial class EnemyResource : Resource [ExportCategory("Scripts")] [Export] public BossScript BossScript { get; private set; } + [ExportCategory("Sounds")] + [Export] public AudioStream HitSound { get; private set; } + [Export] public AudioStream DeathSound { get; private set; } + [Export] public AudioStream AlertSound { get; private set; } + } \ No newline at end of file