Skip to content

Add Resource as an option for arguments in autoload calls #2613

@ryan-linehan

Description

@ryan-linehan

Is your feature request related to a problem? Please describe.
I want to be able to use 'game data' or godot resources to inform my autoload calls.

Describe the solution you'd like
Allow a user to select 'resource' from the argument editor in a dialogic timeline like so:

Image

We can simply allow the user to select any resource. Or we can enforce a base type that a resource needs to inherit to see it in the dropdown (cleaner ui). If we use a base type this should be a project setting specifically so c# users like myself can adjust it to a different class:

Image

Describe alternatives you've considered
In my specific use case I want to be able to use enumerations that I defined in c# to inform my autoloads. So in this sense the alternative is to hardcode magic numbers or add enumeration support in dialogic timeline editor but this idea is more flexible.

And in this case I want to be able to define a resource that represents my enumeration:
For example:

namespace Tavern.Enums;
[GlobalClass]
public partial class EmoteValueResource : DialogicResourceArgumentSharp
{
    [Export]
    public Emotes Value { get; set; } = Emotes.None;
    public override string ToString()
    {
        return $"{Value}";
    }
}

Allows me to create a resource file per enumeration value and then use that value strongly typed in my autoload like so:

    /// <summary>
    /// Sets the emote to be displayed after the cutscene ends
    /// </summary>
    /// <param name="emote"></param>
    public void SetPostCutsceneEmote(EmoteValueResource resource)
    {
// I get to use resource.value to have my strongly typed Emote enum in my autoload instead of having to cast a number
        CutsceneManager.Instance.CutsceneAdditionalData.Add(CutsceneManager.PostCutsceneEmoteCutsceneKey, Variant.From(resource.Value));
    }

Additional context

I've already coded a prototype up and it seemingly works and works well (the screenshots above are me editing field_flex_value.gd alone). Happy to submit a PR if it is something that would be wanted by people. I'm using it in my game would love it to be apart of the native plugin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions