mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-20 02:33:46 +00:00
Destroyable chests
This commit is contained in:
parent
f1f542efc4
commit
80e0eda977
14 changed files with 253 additions and 27 deletions
|
|
@ -1,8 +1,10 @@
|
|||
using Godot;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot.Collections;
|
||||
|
||||
public partial class Barrel : Area2D, IDestructible
|
||||
{
|
||||
|
|
@ -19,6 +21,7 @@ public partial class Barrel : Area2D, IDestructible
|
|||
[Export] public BulletResource ExplosionData { get; set; }
|
||||
|
||||
[Export] public BulletOwner BulletGroup { get; set; } = BulletOwner.None;
|
||||
[Export] public Array<DamageResistance> DamageResistances { get; set; } = [];
|
||||
|
||||
[ExportCategory("On Death Activation")]
|
||||
[Export]
|
||||
|
|
@ -136,7 +139,9 @@ public partial class Barrel : Area2D, IDestructible
|
|||
{
|
||||
if (_isDestroyed || Indestructible) return;
|
||||
|
||||
_currentHealth -= damage;
|
||||
var dmg = DamageResistances.Aggregate(damage, (current, resistance) => current * resistance.CalculateDamage(current, damageType));
|
||||
|
||||
_currentHealth -= dmg;
|
||||
if (_currentHealth > 0) return;
|
||||
_isDestroyed = true;
|
||||
Explode();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue