iFactory.Godot/Mods/工业数据采集与分析应用分享/Scripts/ProductionAnimation.cs

34 lines
800 B
C#

using Godot;
using System;
namespace BITKit;
[Tool]
public partial class ProductionAnimation : ScriptableAnimation
{
[Export] protected ProgressBar progressBar;
[Export] protected Godot.Collections.Array<NodePath> visibleNodes;
protected override void OnSetValue(float newValue)
{
if (Engine.IsEditorHint()) return;
if (progressBar is null)
{
throw new Exception($"ProgressBar is Null");
}
for (var i = 0; i < visibleNodes.Count; i++)
{
var currentNode =GetNode<Control>( visibleNodes[i]);
var threshold = (i+1) / (float)visibleNodes.Count * 100;
//GD.Print($"当前Node:{currentNode.Name},阈值{threshold} / {newValue}");
if (threshold <= newValue)
{
currentNode.Show();
}
else
{
currentNode.Hide();
}
}
progressBar.Value = newValue;
}
}