Replicated the weapon flying tick setup using resources
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 26s
Create tag and build when new code gets to main / Export (push) Successful in 5m42s

This commit is contained in:
2026-04-07 16:32:26 +02:00
parent cc7cb90041
commit 1d856fd937
145 changed files with 12943 additions and 109 deletions

View File

@@ -12,7 +12,7 @@ using Godot.Collections;
namespace Gamesmiths.Forge.Godot.Editor.Attributes;
[Tool]
public partial class AttributeSetClassEditorProperty : EditorProperty
public partial class AttributeSetClassEditorProperty : EditorProperty, ISerializationListener
{
private OptionButton _optionButton = null!;
@@ -32,26 +32,40 @@ public partial class AttributeSetClassEditorProperty : EditorProperty
var className = _optionButton.GetItemText((int)x);
EmitChanged(GetEditedProperty(), className);
GodotObject obj = GetEditedObject();
if (obj is not null)
GodotObject @object = GetEditedObject();
if (@object is not null)
{
var dict = new Dictionary<string, AttributeValues>();
var dictionary = new Dictionary<string, AttributeValues>();
var assembly = Assembly.GetAssembly(typeof(ForgeAttributeSet));
Type? targetType = System.Array.Find(assembly?.GetTypes() ?? [], x => x.Name == className);
if (targetType is not null)
{
System.Collections.Generic.IEnumerable<PropertyInfo> attrProps = targetType
System.Collections.Generic.IEnumerable<PropertyInfo> attributeProperties = targetType
.GetProperties(BindingFlags.Public | BindingFlags.Instance)
.Where(x => x.PropertyType == typeof(EntityAttribute));
foreach (PropertyInfo? pi in attrProps)
foreach (var propertyName in attributeProperties.Select(x => x.Name))
{
dict[pi.Name] = new AttributeValues(0, 0, int.MaxValue);
if (@object is not ForgeAttributeSet forgeAttributeSet)
{
dictionary[propertyName] = new AttributeValues(0, 0, int.MaxValue);
continue;
}
AttributeSet? attributeSet = forgeAttributeSet.GetAttributeSet();
if (attributeSet is null)
{
dictionary[propertyName] = new AttributeValues(0, 0, int.MaxValue);
continue;
}
EntityAttribute key = attributeSet.AttributesMap[className + "." + propertyName];
dictionary[propertyName] = new AttributeValues(key.CurrentValue, key.Min, key.Max);
}
}
EmitChanged("InitialAttributeValues", dict);
EmitChanged("InitialAttributeValues", dictionary);
}
};
}
@@ -70,5 +84,19 @@ public partial class AttributeSetClassEditorProperty : EditorProperty
}
}
}
public void OnBeforeSerialize()
{
for (var i = GetChildCount() - 1; i >= 0; i--)
{
Node child = GetChild(i);
RemoveChild(child);
child.Free();
}
}
public void OnAfterDeserialize()
{
}
}
#endif