made explosion forge compliant

This commit is contained in:
2026-05-05 10:55:12 +02:00
parent a139990390
commit 33f55d04f3
10 changed files with 223 additions and 35 deletions

View File

@@ -1,22 +1,42 @@
using Godot;
using System;
using System.Linq;
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Gamesmiths.Forge.Core;
using Gamesmiths.Forge.Cues;
using Gamesmiths.Forge.Tags;
using Movementtests.interfaces;
using Movementtests.tools;
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_projectile.png")]
public partial class Explosion : Area3D, IDamageDealer
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_projectile.png"), Meta(typeof(IAutoNode))]
public partial class Explosion : Area3D, IDamageDealer, IProvide<CuesManager>
{
[Export] public RDamage RDamage { get; set;}
[Export] public float Radius { get; set;}
public override void _Notification(int what) => this.Notify(what);
[Dependency]
public CuesManager CuesManager => this.DependOn<CuesManager>();
CuesManager IProvide<CuesManager>.Value() => CuesManager;
[Export] public RDamage RDamage { get; set; }
[Export] public float Radius { get; set; } = 1.0f;
[Export] public float ExplosionTime { get; set; } = 0.2f;
public override void _Ready()
[Node("CollisionShape3D")] public required CollisionShape3D CollisionShape { get; set; }
[Node("MeshInstance3D")] public required MeshInstance3D CollisionMesh { get; set; }
[Node("ForgeEntityNode")] public required ForgeEntityNode ForgeEntityNode { get; set; }
public void OnReady()
{
var sphereShape = GetNode<CollisionShape3D>("CollisionShape3D").Shape as SphereShape3D;
sphereShape!.Radius = Radius;
var sphereMesh = GetNode<MeshInstance3D>("MeshInstance3D").Mesh as SphereMesh;
sphereMesh!.Radius = Radius;
sphereMesh!.Height = Radius*2f;
if (CollisionShape.Shape is SphereShape3D sphereShape) sphereShape.Radius = Radius;
if (CollisionMesh.Mesh is not SphereMesh sphereMesh) return;
sphereMesh.Radius = Radius;
sphereMesh.Height = Radius * 2f;
}
public void OnResolved()
{
this.Provide();
GetTree().CreateTimer(ExplosionTime).Timeout += TriggerExplosion;
}
@@ -25,12 +45,10 @@ public partial class Explosion : Area3D, IDamageDealer
var bodies = GetOverlappingBodies();
foreach (var body in bodies)
{
if (body is IDamageable damageable)
damageable.TakeDamage(new DamageRecord(GlobalPosition, RDamage));
if (body is IStunnable stunnable)
stunnable.Stun();
if (body is not IForgeEntity target) continue;
foreach (var ability in ForgeEntityNode.Abilities.GrantedAbilities.Where(ability => ability.CanActivate(out _, target)))
ability.Activate(out _, target, RDamage.DamageDealt);
}
QueueFree();
}
}

View File

@@ -2,6 +2,15 @@
[ext_resource type="Script" uid="uid://cnlu64l7oxvv3" path="res://scenes/explosion/Explosion.cs" id="1_82hkh"]
[ext_resource type="Script" uid="uid://jitubgv6judn" path="res://scenes/components/damage/RDamage.cs" id="2_hys74"]
[ext_resource type="Script" uid="uid://rpcbb54q4atx" path="res://forge/ForgeEntityNode.cs" id="3_wikc1"]
[ext_resource type="Script" uid="uid://dps0oef50noil" path="res://addons/forge/nodes/ForgeEffect.cs" id="4_f5lqq"]
[ext_resource type="Resource" uid="uid://nns16d5uhtl8" path="res://forge/resources/ability_datas/explosion_hit.tres" id="5_nphml"]
[ext_resource type="Script" uid="uid://1hgogislo1l6" path="res://addons/forge/resources/magnitudes/ForgeScalableInt.cs" id="5_nqbbv"]
[ext_resource type="Script" uid="uid://b83hf13nj37k3" path="res://addons/forge/resources/ForgeEffectData.cs" id="8_qslwq"]
[ext_resource type="Script" uid="uid://cxihb42t2mfqi" path="res://addons/forge/nodes/ForgeAttributeSet.cs" id="10_1ve7p"]
[ext_resource type="Script" uid="uid://72kj3n4lm1em" path="res://addons/forge/resources/components/ForgeGrantAbilityConfig.cs" id="11_l63t1"]
[ext_resource type="Script" uid="uid://ccovd5i0wr3kk" path="res://addons/forge/editor/attributes/AttributeValues.cs" id="11_nqbbv"]
[ext_resource type="Script" uid="uid://b3wo2uge4ddnj" path="res://addons/forge/resources/components/GrantAbility.cs" id="12_e6gfx"]
[sub_resource type="Resource" id="Resource_ffdh3"]
script = ExtResource("2_hys74")
@@ -19,6 +28,40 @@ transparency = 1
cull_mode = 2
albedo_color = Color(0.9607843, 0.27058825, 0, 0.7176471)
[sub_resource type="Resource" id="Resource_5c2oj"]
script = ExtResource("5_nqbbv")
BaseValue = 1
[sub_resource type="Resource" id="Resource_17s7w"]
script = ExtResource("11_l63t1")
AbilityData = ExtResource("5_nphml")
AbilityLevel = SubResource("Resource_5c2oj")
metadata/_custom_type_script = "uid://72kj3n4lm1em"
[sub_resource type="Resource" id="Resource_pmtlp"]
script = ExtResource("12_e6gfx")
GrantAbilityConfigs = [SubResource("Resource_17s7w")]
metadata/_custom_type_script = "uid://b3wo2uge4ddnj"
[sub_resource type="Resource" id="Resource_pvvi5"]
script = ExtResource("5_nqbbv")
BaseValue = 1
[sub_resource type="Resource" id="Resource_4lkfq"]
script = ExtResource("5_nqbbv")
BaseValue = 1
[sub_resource type="Resource" id="Resource_pjqsn"]
script = ExtResource("8_qslwq")
Name = "Grant Explosion Ability"
Modifiers = []
Components = Array[Object]([SubResource("Resource_pmtlp")])
Executions = []
StackLimit = SubResource("Resource_4lkfq")
InitialStack = SubResource("Resource_pvvi5")
Cues = []
metadata/_custom_type_script = "uid://b83hf13nj37k3"
[node name="Explosion" type="Area3D" unique_id=1876014452]
collision_layer = 0
collision_mask = 16
@@ -32,3 +75,23 @@ shape = SubResource("SphereShape3D_82hkh")
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=1864409522]
mesh = SubResource("SphereMesh_82hkh")
surface_material_override/0 = SubResource("StandardMaterial3D_hys74")
[node name="ForgeEntityNode" type="Node3D" parent="." unique_id=806020391]
script = ExtResource("3_wikc1")
metadata/_custom_type_script = "uid://rpcbb54q4atx"
[node name="ForgeEffect" type="Node" parent="ForgeEntityNode" unique_id=2068515708]
script = ExtResource("4_f5lqq")
EffectData = SubResource("Resource_pjqsn")
metadata/_custom_type_script = "uid://dps0oef50noil"
[node name="ForgeAttributeSet" type="Node" parent="ForgeEntityNode" unique_id=813420941]
script = ExtResource("10_1ve7p")
AttributeSetClass = "MetaAttributeSet"
InitialAttributeValues = Dictionary[String, ExtResource("11_nqbbv")]({
"IncomingDamage": Object(RefCounted,"script":ExtResource("11_nqbbv"),"Default":0,"Min":0,"Max":1000)
,
"Level": Object(RefCounted,"script":ExtResource("11_nqbbv"),"Default":1,"Min":1,"Max":1000)
})
metadata/_custom_type_script = "uid://cxihb42t2mfqi"