reorganizing stuff
This commit is contained in:
33
components/health/CHealth.cs
Normal file
33
components/health/CHealth.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Movementtests.interfaces;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class CHealth : Node, IHealthable
|
||||
{
|
||||
public event Action<IHealthable, float> HealthChanged;
|
||||
public event Action<IHealthable> HealthDepleted;
|
||||
|
||||
[Export]
|
||||
public RHealth RHealth { get; set; }
|
||||
|
||||
public float CurrentHealth { get; set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
CurrentHealth = RHealth.StartingHealth;
|
||||
}
|
||||
|
||||
public void ReduceHealth(IDamageable source, DamageRecord damageRecord)
|
||||
{
|
||||
GD.Print(CurrentHealth);
|
||||
CurrentHealth -= damageRecord.Damage.DamageDealt;
|
||||
HealthChanged?.Invoke(this, CurrentHealth);
|
||||
|
||||
if (CurrentHealth <= 0)
|
||||
{
|
||||
CurrentHealth = 0;
|
||||
HealthDepleted?.Invoke(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
1
components/health/CHealth.cs.uid
Normal file
1
components/health/CHealth.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bjwrpv3jpsc1e
|
||||
6
components/health/CHealth.tscn
Normal file
6
components/health/CHealth.tscn
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://c4ikbhojckpnc"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bjwrpv3jpsc1e" path="res://components/health/CHealth.cs" id="1_75uyt"]
|
||||
|
||||
[node name="CHealth" type="Node"]
|
||||
script = ExtResource("1_75uyt")
|
||||
12
components/health/RDeathEffect.cs
Normal file
12
components/health/RDeathEffect.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Movementtests.interfaces;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class RDeathEffect : Resource, IKillable
|
||||
{
|
||||
public void Kill(IHealthable source)
|
||||
{
|
||||
GD.Print($"Death Effect triggered on {source}");
|
||||
}
|
||||
}
|
||||
1
components/health/RDeathEffect.cs.uid
Normal file
1
components/health/RDeathEffect.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b4cwruitopcee
|
||||
20
components/health/RHealth.cs
Normal file
20
components/health/RHealth.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Movementtests.interfaces;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class RHealth : Resource
|
||||
{
|
||||
[Export]
|
||||
public float StartingHealth = 100.0f;
|
||||
|
||||
public RHealth()
|
||||
{
|
||||
StartingHealth = 100.0f;
|
||||
}
|
||||
|
||||
public RHealth(float startingHealth)
|
||||
{
|
||||
StartingHealth = startingHealth;
|
||||
}
|
||||
}
|
||||
1
components/health/RHealth.cs.uid
Normal file
1
components/health/RHealth.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://baiapod3csndf
|
||||
Reference in New Issue
Block a user