setup damage types and modifiers as resources
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 19s
Create tag and build when new code gets to main / Export (push) Successful in 10m48s

This commit is contained in:
2026-01-17 14:32:48 +01:00
parent b1e78df6c7
commit 6b97c226f1
16 changed files with 136 additions and 11 deletions

View File

@@ -14,6 +14,8 @@ public partial class FirstEnemy : CharacterBody3D, IDamageable, IKillable, IKnoc
[Export]
public RDamage GetDamageDealt { get; set; }
[Export]
public RDamageModifier[] DamageModifiers { get; set; }
private RayCast3D _wallInFrontRayCast;
private Area3D _damageBox;
@@ -53,6 +55,7 @@ public partial class FirstEnemy : CharacterBody3D, IDamageable, IKillable, IKnoc
public void TakeDamage(RDamage damage)
{
GD.Print("Emotional daaamaaage!", damage.DamageDealt);
foreach (var damageable in DamageModifiers.ToIDamageables())
damageable.TakeDamage(damage);
}
}

View File

@@ -13,6 +13,9 @@ public partial class FlyingEnemy : CharacterBody3D, IDamageable, IKillable, IKno
[Export]
public RDamage GetDamageDealt { get; set; }
[Export]
public RDamageModifier[] DamageModifiers { get; set; }
private RayCast3D _groundDistanceRaycast;
private Area3D _damageBox;
@@ -83,6 +86,7 @@ public partial class FlyingEnemy : CharacterBody3D, IDamageable, IKillable, IKno
public void TakeDamage(RDamage damage)
{
GD.Print("Oh no I'm falling!", damage.DamageDealt);
foreach (var damageable in DamageModifiers.ToIDamageables())
damageable.TakeDamage(damage);
}
}

View File

@@ -1,6 +1,11 @@
[gd_scene load_steps=7 format=3 uid="uid://dxt0e2ugmttqq"]
[gd_scene load_steps=9 format=3 uid="uid://dxt0e2ugmttqq"]
[ext_resource type="Script" uid="uid://bn7sc6id7n166" path="res://scenes/enemies/FirstEnemy.cs" id="1_4yfjf"]
[ext_resource type="Script" uid="uid://b6y3ugfydvch0" path="res://resource_definitions/RDamageModifier.cs" id="2_ylcc3"]
[sub_resource type="Resource" id="Resource_gsmti"]
script = ExtResource("2_ylcc3")
metadata/_custom_type_script = "uid://b6y3ugfydvch0"
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_62kkh"]
@@ -22,6 +27,7 @@ size = Vector3(1, 2, 2)
collision_layer = 16
collision_mask = 273
script = ExtResource("1_4yfjf")
DamageModifiers = Array[Object]([SubResource("Resource_gsmti")])
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)

View File

@@ -1,6 +1,17 @@
[gd_scene load_steps=7 format=3 uid="uid://cmlud1hwkd6sv"]
[gd_scene load_steps=10 format=3 uid="uid://cmlud1hwkd6sv"]
[ext_resource type="Script" uid="uid://cmvep0qi7qlvf" path="res://scenes/enemies/FlyingEnemy.cs" id="1_b46rq"]
[ext_resource type="Script" uid="uid://b6y3ugfydvch0" path="res://resource_definitions/RDamageModifier.cs" id="2_1bsgx"]
[sub_resource type="Resource" id="Resource_2pnje"]
script = ExtResource("2_1bsgx")
metadata/_custom_type_script = "uid://b6y3ugfydvch0"
[sub_resource type="Resource" id="Resource_1bsgx"]
script = ExtResource("2_1bsgx")
DamageType = 1
Modifier = 2.0
metadata/_custom_type_script = "uid://b6y3ugfydvch0"
[sub_resource type="SphereShape3D" id="SphereShape3D_b46rq"]
@@ -23,6 +34,7 @@ collision_layer = 16
collision_mask = 273
motion_mode = 1
script = ExtResource("1_b46rq")
DamageModifiers = Array[Object]([SubResource("Resource_2pnje"), SubResource("Resource_1bsgx")])
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_b46rq")

View File

@@ -4,5 +4,5 @@
[resource]
script = ExtResource("1_h6law")
DamageDealt = 1.0
DamageType = 3
metadata/_custom_type_script = "uid://jitubgv6judn"