34 lines
830 B
C#
34 lines
830 B
C#
|
using Godot;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using BITKit;
|
||
|
|
||
|
namespace BITKit;
|
||
|
public partial class MultiplexGroup : Node
|
||
|
{
|
||
|
[Export] private Godot.Collections.Dictionary<string, Node> dictionary;
|
||
|
[Export] public string CurrentElement { get; protected set; }
|
||
|
public override void _Ready()
|
||
|
{
|
||
|
if (dictionary.Count > 0)
|
||
|
{
|
||
|
SetCurrentElement(dictionary.Keys.First());
|
||
|
}
|
||
|
}
|
||
|
public void SetCurrentElement(string currentElement)
|
||
|
{
|
||
|
foreach (var x in dictionary)
|
||
|
{
|
||
|
if (x.Value is IActivable activable)
|
||
|
{
|
||
|
activable.Enabled = x.Key == currentElement;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
x.Value?.SetProcess(x.Key == currentElement);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|