// Copyright © Gamesmiths Guild.
using Gamesmiths.Forge.Core;
using Gamesmiths.Forge.Statescript;
using Gamesmiths.Forge.Statescript.Properties;
using Godot;
using ForgeNode = Gamesmiths.Forge.Statescript.Node;
namespace Gamesmiths.Forge.Godot.Resources.Statescript;
///
/// Base resource for all Statescript property resolvers. Each resolver type derives from this and implements the
/// binding methods to wire serialized editor data into the core runtime graph.
///
///
/// Subclasses must override to return a unique string that matches the corresponding
/// editor's ResolverTypeId. This enables automatic discovery and matching without hardcoded registrations.
///
[Tool]
[GlobalClass]
public partial class StatescriptResolverResource : Resource
{
///
/// Gets the unique type identifier for this resolver, used to match serialized resources to their corresponding
/// editor. Subclasses must override this to return a non-empty string that matches their editor's
/// ResolverTypeId.
///
public virtual string ResolverTypeId => string.Empty;
///
/// Binds this resolver as an input property on a runtime node. Implementations should register any necessary
/// variable or property definitions on the graph and call with the appropriate
/// name.
///
/// The runtime graph being built.
/// The runtime node to bind the input on.
/// The serialized node identifier, used for generating unique property names.
/// The zero-based index of the input property to bind.
public virtual void BindInput(Graph graph, ForgeNode runtimeNode, string nodeId, byte index)
{
}
///
/// Binds this resolver as an output variable on a runtime node. Implementations should call
/// with the appropriate variable name.
///
/// The runtime node to bind the output on.
/// The zero-based index of the output variable to bind.
public virtual void BindOutput(ForgeNode runtimeNode, byte index)
{
}
///
/// Creates an from this resolver resource. Used when this resolver appears as a
/// nested operand inside another resolver (e.g., left/right side of a comparison).
///
/// The runtime graph being built, used for looking up variable type information.
/// The property resolver instance, or a default zero-value resolver if the resource is not configured.
///
public virtual IPropertyResolver BuildResolver(Graph graph)
{
return new VariantResolver(default, typeof(int));
}
}