Enemy debris

This commit is contained in:
Marco 2025-08-05 16:24:21 +02:00
commit 0293291315
19 changed files with 175 additions and 27 deletions

View file

@ -0,0 +1,22 @@
using Cirno.Scripts.Resources;
using Godot;
namespace Cirno.Scripts.Actors;
public partial class DeathDebris3D : Node3D
{
[Export] public EnemyResource EnemyResource { get; private set; }
[Export] public AnimatedSprite3D Sprite { get; private set; }
public void Init(EnemyResource enemyResource)
{
EnemyResource = enemyResource;
if (EnemyResource.DeathAnimation is not null)
{
Sprite.SetSpriteFrames(enemyResource.DeathAnimation);
}
Sprite.Play();
}
}

View file

@ -0,0 +1 @@
uid://cd2j7yiat8uuh

View file

@ -1,4 +1,5 @@
using Cirno.Scripts.Enums;
using Cirno.Scripts.Actors;
using Cirno.Scripts.Enums;
using Godot;
namespace Cirno.Scripts.Components.FSM.Enemy._3D;
@ -15,5 +16,15 @@ public partial class Dead : EnemyStateBase3D
// player detection
// damage receiver will be a module
MainObject.Hide();
if (Storage.EnemyData.DebrisScene is not null)
{
var debris = Storage.EnemyData.DebrisScene.Instantiate<DeathDebris3D>();
MainObject.GetParent().AddChild(debris);
debris.GlobalPosition = MainObject.GlobalPosition;
debris.Init(Storage.EnemyData);
}
MainObject.QueueFree();
}
}

View file

@ -33,9 +33,13 @@ public partial class EnemyResource : Resource
/// </summary>
[Export] public float ResponseTime { get; private set; } = 0.5f;
[ExportCategory("Graphics")]
[Export] public Texture2D IconSprite { get; private set; }
[Export] public SpriteFrames AnimationFrames { get; private set; }
[Export] public PackedScene DebrisScene { get; private set; }
[Export] public SpriteFrames DeathAnimation { get; private set; }
[ExportCategory("Scripts")]
[Export] public BossScript BossScript { get; private set; }
}