mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 06:45:33 +00:00
Enemy sounds
This commit is contained in:
parent
585befb932
commit
a11e61b2c2
15 changed files with 224 additions and 38 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
BIN
SFX/fairy_death.wav
(Stored with Git LFS)
Normal file
BIN
SFX/fairy_death.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
24
SFX/fairy_death.wav.import
Normal file
24
SFX/fairy_death.wav.import
Normal file
|
|
@ -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
|
||||
BIN
SFX/fairy_stop.wav
(Stored with Git LFS)
Normal file
BIN
SFX/fairy_stop.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
24
SFX/fairy_stop.wav.import
Normal file
24
SFX/fairy_stop.wav.import
Normal file
|
|
@ -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
|
||||
|
|
@ -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"]
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
84
Scripts/Components/Actors/3D/EnemySoundModule3D.cs
Normal file
84
Scripts/Components/Actors/3D/EnemySoundModule3D.cs
Normal file
|
|
@ -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<EnemyState, CharacterBody3D>
|
||||
{
|
||||
|
||||
[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<EnemyState, CharacterBody3D> _machine;
|
||||
|
||||
public override void Init(IStateMachine<EnemyState, CharacterBody3D> 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)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
1
Scripts/Components/Actors/3D/EnemySoundModule3D.cs.uid
Normal file
1
Scripts/Components/Actors/3D/EnemySoundModule3D.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://khph8rethll7
|
||||
|
|
@ -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<DamageResistance> 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<Node3D>();
|
||||
|
|
@ -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<Node3D>(Debris);
|
||||
}
|
||||
|
||||
|
||||
// Not needed because the health provider is accessible
|
||||
//EmitSignal(SignalName.Death);
|
||||
|
||||
|
||||
if (DeleteParentOnDeath)
|
||||
{
|
||||
_parent.QueueFree();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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; }
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue