Files
MovementTests/tools/ForgeUtils.cs
Minimata 3cdb7e85c3
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 35s
Create tag and build when new code gets to main / Export (push) Successful in 7m50s
removed dependency on Forge Attribute Set node
2026-05-17 12:44:54 +02:00

52 lines
1.7 KiB
C#

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<AttributeSetType, Func<AttributeSet>> 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<AttributeSet> CollectAttributeList(Node node)
{
List<AttributeSet> attributeSetList = [];
foreach (var child in node.GetChildren())
{
if (child is not ForgeAttributeSet attributeSetNode) continue;
var attributeSet = attributeSetNode.GetAttributeSet();
if (attributeSet is not null)
attributeSetList.Add(attributeSet);
}
return attributeSetList;
}
public static List<AttributeSet> CollectAttributeList(Array<AttributeSetType> types)
{
return types.Select(type => AttributeSetMap[type]()).ToList();
}
}