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

@@ -0,0 +1,65 @@
// Copyright © Gamesmiths Guild.
using Gamesmiths.Forge.Core;
using Gamesmiths.Forge.Godot.Resources.Statescript;
using Gamesmiths.Forge.Statescript;
using Godot;
using Godot.Collections;
namespace Gamesmiths.Forge.Godot.Resources;
/// <summary>
/// Resource containing a collection of shared variable definitions for an entity. Assign this to a
/// <see cref="Nodes.ForgeEntity"/> (or custom <see cref="IForgeEntity"/> implementation) to define which shared
/// variables the entity exposes at runtime.
/// </summary>
[Tool]
[GlobalClass]
[Icon("uid://cu6ncpuumjo20")]
public partial class ForgeSharedVariableSet : Resource
{
/// <summary>
/// Gets or sets the shared variable definitions.
/// </summary>
[Export]
public Array<ForgeSharedVariableDefinition> Variables { get; set; } = [];
/// <summary>
/// Populates a <see cref="Variables"/> bag with all the definitions in this set, using each variable's name and
/// initial value.
/// </summary>
/// <param name="target">The <see cref="Variables"/> instance to populate.</param>
public void PopulateVariables(Variables target)
{
foreach (ForgeSharedVariableDefinition definition in Variables)
{
if (string.IsNullOrEmpty(definition.VariableName))
{
continue;
}
var key = new StringKey(definition.VariableName);
if (definition.IsArray)
{
var initialValues = new Variant128[definition.InitialArrayValues.Count];
for (var i = 0; i < definition.InitialArrayValues.Count; i++)
{
initialValues[i] = StatescriptVariableTypeConverter.GodotVariantToForge(
definition.InitialArrayValues[i],
definition.VariableType);
}
target.DefineArrayVariable(key, initialValues);
}
else
{
Variant128 value = StatescriptVariableTypeConverter.GodotVariantToForge(
definition.InitialValue,
definition.VariableType);
target.DefineVariable(key, value);
}
}
}
}