diff --git a/forge/ForgeEntityNode.cs b/forge/ForgeEntityNode.cs index a7da5ccc..f4b9f3a2 100644 --- a/forge/ForgeEntityNode.cs +++ b/forge/ForgeEntityNode.cs @@ -29,6 +29,8 @@ public partial class ForgeEntityNode : Node3D, IForgeEntity [Export] public ForgeTagContainer? BaseTags { get; set; } [Export] + public Godot.Collections.Array AttributeSets { get; set; } = []; + [Export] public ForgeSharedVariableSet? SharedVariableDefinitions { get; set; } public required EntityAttributes Attributes { get; set; } @@ -51,7 +53,7 @@ public partial class ForgeEntityNode : Node3D, IForgeEntity { BaseTags ??= new ForgeTagContainer(); Tags = new EntityTags(BaseTags.GetTagContainer()); - Attributes = new EntityAttributes([.. ForgeUtils.CollectAttributeList(this)]); + Attributes = new EntityAttributes([.. ForgeUtils.CollectAttributeList(AttributeSets)]); Abilities = new EntityAbilities(this); Events = new EventManager(); diff --git a/forge/calculators/ForgeDamageExecution.cs b/forge/calculators/ForgeDamageExecution.cs index 18de2328..edb39893 100644 --- a/forge/calculators/ForgeDamageExecution.cs +++ b/forge/calculators/ForgeDamageExecution.cs @@ -30,7 +30,6 @@ public class DamageExecution : CustomExecution public DamageExecution(DamageType damageType, ForgeTagContainer? damageDealerEventTags, ForgeTagContainer? damageReceiverEventTags) { - // Capture target mana and magic resistance TargetHealth = new AttributeCaptureDefinition( "CharacterAttributeSet.Health", @@ -60,8 +59,6 @@ public class DamageExecution : CustomExecution effect, target, effectEvaluatedData); - - GD.Print(targetIncomingDamage); if (targetIncomingDamage <= 0) { diff --git a/scenes/enemies/flying_enemy/flying_enemy.tscn b/scenes/enemies/flying_enemy/flying_enemy.tscn index 0540832d..58a57631 100644 --- a/scenes/enemies/flying_enemy/flying_enemy.tscn +++ b/scenes/enemies/flying_enemy/flying_enemy.tscn @@ -103,6 +103,7 @@ RMovement = ExtResource("4_dejyg") [node name="ForgeEntityNode" type="Node3D" parent="." unique_id=1255429192] script = ExtResource("7_46wn3") BaseTags = ExtResource("8_oj1ws") +AttributeSets = Array[int]([0, 4, 2]) metadata/_custom_type_script = "uid://rpcbb54q4atx" [node name="CharacterAttributeSet" type="Node" parent="ForgeEntityNode" unique_id=418635308] diff --git a/scenes/enemies/grounded_enemy/grounded_enemy.tscn b/scenes/enemies/grounded_enemy/grounded_enemy.tscn index a09e4e22..f667bd4c 100644 --- a/scenes/enemies/grounded_enemy/grounded_enemy.tscn +++ b/scenes/enemies/grounded_enemy/grounded_enemy.tscn @@ -56,15 +56,15 @@ BaseValue = 1 [sub_resource type="Resource" id="Resource_5eesh"] script = ExtResource("13_jryek") Name = "Grant abilities" -Modifiers = null +Modifiers = [] Components = Array[Object]([SubResource("Resource_3gkmr")]) -Executions = null +Executions = [] StackLimit = SubResource("Resource_q86ag") InitialStack = SubResource("Resource_oo2a1") -Cues = null +Cues = [] metadata/_custom_type_script = "uid://b83hf13nj37k3" -[sub_resource type="ViewportTexture" id="ViewportTexture_5lf6m"] +[sub_resource type="ViewportTexture" id="ViewportTexture_4jf2q"] viewport_path = NodePath("SubViewport") [sub_resource type="Resource" id="Resource_6d4gl"] @@ -95,7 +95,6 @@ radius = 2.0 collision_layer = 16 collision_mask = 273 script = ExtResource("1_r6506") -HitAbility = ExtResource("6_4jf2q") EnemyHeight = 2.0 RKnockback = ExtResource("11_8k3xb") RMovement = ExtResource("4_na24f") @@ -103,6 +102,7 @@ RMovement = ExtResource("4_na24f") [node name="ForgeEntityNode" type="Node3D" parent="." unique_id=289553407] script = ExtResource("7_f22p3") BaseTags = ExtResource("8_4jf2q") +AttributeSets = Array[int]([0, 4, 2]) metadata/_custom_type_script = "uid://rpcbb54q4atx" [node name="CharacterAttributeSet" type="Node" parent="ForgeEntityNode" unique_id=1699781551] @@ -141,7 +141,7 @@ metadata/_custom_type_script = "uid://dps0oef50noil" [node name="CHealthBar" parent="." unique_id=1278247727 instance=ExtResource("7_18xwy")] transform = Transform3D(0.4, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.2, 0) -texture = SubResource("ViewportTexture_5lf6m") +texture = SubResource("ViewportTexture_4jf2q") [node name="CMovement" parent="." unique_id=1080640834 node_paths=PackedStringArray("WallInFrontRayCast") instance=ExtResource("7_qyswd")] RMovement = SubResource("Resource_6d4gl") diff --git a/scenes/enemies/projectile_enemy/projectile_enemy.tscn b/scenes/enemies/projectile_enemy/projectile_enemy.tscn index 4ebd7480..139291d8 100644 --- a/scenes/enemies/projectile_enemy/projectile_enemy.tscn +++ b/scenes/enemies/projectile_enemy/projectile_enemy.tscn @@ -183,6 +183,7 @@ RMovement = ExtResource("4_0f52b") [node name="ForgeEntityNode" type="Node3D" parent="." unique_id=289553407] script = ExtResource("5_ya0fp") BaseTags = ExtResource("6_ttkdf") +AttributeSets = Array[int]([0, 4, 2]) metadata/_custom_type_script = "uid://rpcbb54q4atx" [node name="CharacterAttributeSet" type="Node" parent="ForgeEntityNode" unique_id=1699781551] diff --git a/scenes/explosion/explosion.tscn b/scenes/explosion/explosion.tscn index d15796f7..76a122e1 100644 --- a/scenes/explosion/explosion.tscn +++ b/scenes/explosion/explosion.tscn @@ -78,6 +78,7 @@ surface_material_override/0 = SubResource("StandardMaterial3D_hys74") [node name="ForgeEntityNode" type="Node3D" parent="." unique_id=806020391] script = ExtResource("3_wikc1") BaseTags = SubResource("Resource_nqbbv") +AttributeSets = Array[int]([0]) metadata/_custom_type_script = "uid://rpcbb54q4atx" [node name="ForgeEffect" type="Node" parent="ForgeEntityNode" unique_id=2068515708] diff --git a/scenes/player_controller/components/weapon/weapon.tscn b/scenes/player_controller/components/weapon/weapon.tscn index 050db17e..51525b79 100644 --- a/scenes/player_controller/components/weapon/weapon.tscn +++ b/scenes/player_controller/components/weapon/weapon.tscn @@ -130,6 +130,7 @@ PlantedTickAbility = ExtResource("3_7bruw") [node name="ForgeEntityNode" type="Node3D" parent="." unique_id=1798885192] script = ExtResource("5_7bruw") BaseTags = SubResource("Resource_rgbou") +AttributeSets = Array[int]([3]) metadata/_custom_type_script = "uid://rpcbb54q4atx" [node name="WeaponAttributeSet" type="Node" parent="ForgeEntityNode" unique_id=14845649] diff --git a/scenes/projectile/Projectile.tscn b/scenes/projectile/Projectile.tscn index e593825a..e49ae402 100644 --- a/scenes/projectile/Projectile.tscn +++ b/scenes/projectile/Projectile.tscn @@ -206,6 +206,7 @@ HomingFactor = 0.8 [node name="ForgeEntityNode" type="Node3D" parent="." unique_id=1961065393] script = ExtResource("3_0m0gv") +AttributeSets = Array[int]([0]) metadata/_custom_type_script = "uid://rpcbb54q4atx" [node name="ForgeAttributeSet" type="Node" parent="ForgeEntityNode" unique_id=100377985] diff --git a/tools/ForgeUtils.cs b/tools/ForgeUtils.cs index 29226545..fe1d3626 100644 --- a/tools/ForgeUtils.cs +++ b/tools/ForgeUtils.cs @@ -1,12 +1,37 @@ +using System; using System.Collections.Generic; +using System.Linq; using Gamesmiths.Forge.Attributes; using Gamesmiths.Forge.Godot.Nodes; using Godot; +using Godot.Collections; +using Movementtests.forge.attribute_sets; +using Movementtests.scenes.enemies; +using Movementtests.scenes.player_controller.components.weapon; +using Movementtests.scenes.player_controller.scripts; namespace Movementtests.tools; public static class ForgeUtils { + public enum AttributeSetType + { + Meta, + Player, + Enemy, + Weapon, + Character + } + + public static System.Collections.Generic.Dictionary> AttributeSetMap { get; } = new() + { + { AttributeSetType.Meta, () => new MetaAttributeSet() }, + { AttributeSetType.Player, () => new PlayerAttributeSet() }, + { AttributeSetType.Enemy, () => new EnemyAttributeSet() }, + { AttributeSetType.Weapon, () => new WeaponAttributeSet() }, + { AttributeSetType.Character, () => new CharacterAttributeSet() }, + }; + public static List CollectAttributeList(Node node) { List attributeSetList = []; @@ -19,4 +44,9 @@ public static class ForgeUtils } return attributeSetList; } + + public static List CollectAttributeList(Array types) + { + return types.Select(type => AttributeSetMap[type]()).ToList(); + } } \ No newline at end of file