iFactory.Godot/BITKit/Scripts/Channel/MultiplexGroup.cs

34 lines
830 B
C#
Raw Normal View History

2023-06-29 01:01:52 +08:00
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);
}
}
}
}