Skip to content

Add support for Godot's node tree#25

Merged
neuecc merged 3 commits intoCysharp:mainfrom
chiepomme:godot-node-tree
Mar 17, 2025
Merged

Add support for Godot's node tree#25
neuecc merged 3 commits intoCysharp:mainfrom
chiepomme:godot-node-tree

Conversation

@chiepomme
Copy link
Copy Markdown

@chiepomme chiepomme commented Mar 16, 2025

This PR adds LINQ to tree support for Godot's node tree.
I copied Unity's LINQ to tree support and modified them for Godot. I tested it on Godot 4.4.

I'm worried about the way to change the behavior of NodeTraversable.
It uses includeWindow field to decide whether it traverses over a root Window or not.

readonly bool includeWindow;

public bool TryGetParent(out Node parent)
{
var maybeParent = node.GetParent();
if (maybeParent is null || (!includeWindow && maybeParent is Window))
{
parent = default!;
return false;
}
else
{
parent = maybeParent;
return true;
}
}

Is it OK? or should I make a dedicated struct like NodeTraversableIncludingWindow?

@neuecc
Copy link
Copy Markdown
Member

neuecc commented Mar 17, 2025

Thank you very much!
I'm glad you like the Godot support suggestion.
Regarding the includeWindow feature, it seems to only affect Ancestors, which I think creates a good balance in terms of usability.
I'll merge it right before the next release and include it in the release.

@chiepomme
Copy link
Copy Markdown
Author

Thank you for reviewing.
Could you wait for my next commit? I completely forgot child windows like pop-ups. I think we should not ignore windows in Godot, so I'll remove the includeWindow option.

@chiepomme
Copy link
Copy Markdown
Author

I removed includeWindow option, and added an example to get ancestors under current Window.

@neuecc
Copy link
Copy Markdown
Member

neuecc commented Mar 17, 2025

Thank you.
Since there are major changes in #28, the Traversable interface will change significantly.
I'd like to merge this before conflicts occur, then adapt it to the new interface before releasing.

@neuecc neuecc merged commit b29019f into Cysharp:main Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants