mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +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,11 @@
|
|||
using Godot;
|
||||
using System.Linq;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Components.Actors;
|
||||
|
||||
public partial class DamageReceiverActorModule : ActorModule
|
||||
public partial class DamageReceiverActorModule : ActorModule, IHittable
|
||||
{
|
||||
protected Actor _actor;
|
||||
|
||||
|
|
@ -14,6 +17,8 @@ public partial class DamageReceiverActorModule : ActorModule
|
|||
|
||||
[Export] public BulletOwner BulletGroup { get; set; } = BulletOwner.None;
|
||||
|
||||
[Export] public Array<DamageResistance> DamageResistances { get; set; } = [];
|
||||
|
||||
public override void Init(Actor actor)
|
||||
{
|
||||
_actor = actor;
|
||||
|
|
@ -42,14 +47,14 @@ public partial class DamageReceiverActorModule : ActorModule
|
|||
|
||||
if (BulletGroup is BulletOwner.None)
|
||||
{
|
||||
this.Hit(bullet.Damage);
|
||||
this.Hit(bullet.Damage, bullet.DamageType);
|
||||
bullet.RequestCollisionDestruction();
|
||||
return;
|
||||
}
|
||||
|
||||
if (bullet.BulletInfo.Owner == BulletGroup) return;
|
||||
|
||||
this.Hit(bullet.Damage);
|
||||
this.Hit(bullet.Damage, bullet.DamageType);
|
||||
bullet.RequestCollisionDestruction();
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +63,9 @@ public partial class DamageReceiverActorModule : ActorModule
|
|||
if (_actor.IsDestroyed) return;
|
||||
if (Invulnerable) return;
|
||||
|
||||
HealthProvider.CurrentResource -= damage;
|
||||
var dmg = DamageResistances.Aggregate(damage, (current, resistance) => current * resistance.CalculateDamage(current, damageType));
|
||||
|
||||
HealthProvider.CurrentResource -= dmg;
|
||||
}
|
||||
|
||||
protected void OnDeath()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue