52 lines
1.7 KiB
C#
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();
|
|
}
|
|
} |