chickensoft-games / chickensoft-games/AutoInject

Feature Request: An `IsResolved` property/method to be included to check if a node has had it's dependencies resolved

Open
#54 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
C#
Stars
237
Forks
14
Avg merge
6h 40m
Merged PRs (30d)
6

Description

One thing I find my self doing is the following structure.

[Meta(typeof(IDependent))]
public partial class Foo: Node
{
    [Dependency]
    public Bar Bar => this.DependOn<Bar>();
    
    private bool IsResolved { get; set; }
    
    public override void _Notification(int what)
    {
        this.Notify(what);
    }

    public void OnResolved()
    {
        Bar.SomeEvent += OnSomeEvent;
        IsResolved = true;
    }

    public override void _ExitTree()
    {
        if (IsResolved)
        {
            Bar.SomeEvent -= OnSomeEvent;
        }
    }

    private void OnSomeEvent() { }
}

Foo wants to unregister events from a dependency when it's removed from it's parent, but if it's removed before OnResolved() is called it might result in errors due to an unresolved dependency. So I have found the need to add a bool property to check if OnResolved() has been called.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the dependency lifecycle shown around DependOn(), OnResolved(), and _ExitTree(). Determine where resolution state is tracked and how the requested check should be exposed. Done means a node can safely determine whether its dependencies have been resolved before using or unregistering dependency events.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, godot
Domain
game-dev, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.