mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-10 18:05:54 +00:00
Enhanced loot drops system
This commit is contained in:
parent
ddde409dbf
commit
acc61f9a0e
12 changed files with 661 additions and 443 deletions
|
|
@ -2,6 +2,7 @@
|
|||
using System.Linq;
|
||||
using Cirno.Scripts.Controllers;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Cirno.Scripts.Resources.Loot;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Cirno.Scripts.Weapons;
|
||||
using Godot;
|
||||
|
|
@ -30,12 +31,19 @@ public partial class Destructible3D : StaticBody3D, IDestructible
|
|||
[Export] public Node Target { get; private set; }
|
||||
[Export] public string TargetGroup { get; protected set; }
|
||||
|
||||
[ExportCategory("Loot Drops")]
|
||||
[Export] public Array<LootDrop> LootDrops { get; set; } = [];
|
||||
/// <summary>Radius of the circle in which dropped items are scattered uniformly.</summary>
|
||||
[Export] public float LootScatterRadius { get; set; } = 1.0f;
|
||||
/// <summary>Initial upward speed applied to each dropped item so it pops up before falling.</summary>
|
||||
[Export] public float LootLaunchUpSpeed { get; set; } = 3.0f;
|
||||
|
||||
[Signal]
|
||||
public delegate void ExplodedEventHandler();
|
||||
|
||||
private float _currentHealth = 0f;
|
||||
|
||||
private bool _isDestroyed = false;
|
||||
private readonly RandomNumberGenerator _rng = new();
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
|
@ -86,6 +94,7 @@ public partial class Destructible3D : StaticBody3D, IDestructible
|
|||
CreateExplosion();
|
||||
CreateParticles();
|
||||
CreateDebris();
|
||||
DropLoot();
|
||||
|
||||
QueueFree();
|
||||
|
||||
|
|
@ -137,6 +146,11 @@ public partial class Destructible3D : StaticBody3D, IDestructible
|
|||
particle.Emitting = true;
|
||||
}
|
||||
|
||||
private void DropLoot()
|
||||
{
|
||||
LootDropHelper.SpawnDrops(LootDrops, this, GlobalPosition, LootScatterRadius, LootLaunchUpSpeed, _rng);
|
||||
}
|
||||
|
||||
|
||||
public void Hit(float damage, DamageType damageType = DamageType.Neutral)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue