using System.Diagnostics; using System.Collections; using System.Collections.Generic; using System; using Godot; using Rokojori.Extensions; namespace Rokojori { [Tool] [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/Selector.svg")] public partial class SelectManager:Node { [Export] public Node root; Dictionary _singleSelections = new Dictionary(); Dictionary> _listSelections = new Dictionary>(); public Node GetSelectionRoot() { return root == null ? GetTree().Root : root; } public Node Select( Selector selector ) { if ( selector == null ) { return null; } if ( ! _singleSelections.ContainsKey( selector ) ) { _singleSelections[ selector ] = GetSelectionRoot().Select( selector ); } return _singleSelections[ selector ]; } public List SelectAll( Selector selector ) { if ( selector == null ) { return new List(); } if ( ! _singleSelections.ContainsKey( selector ) ) { _listSelections[ selector ] = GetSelectionRoot().SelectAll( selector ); } return _listSelections[ selector ]; } } }