cirnogodot/Scripts/Utils/ActivationHelper.cs

25 lines
715 B
C#
Raw Permalink Normal View History

2025-06-30 10:02:37 +02:00
using Godot;
namespace Cirno.Scripts.Utils;
public static class ActivationHelper
{
2025-07-09 12:00:23 +02:00
public static bool UseTargets(Node activator, string target, ActivationType activationType = ActivationType.Toggle)
2025-06-30 10:02:37 +02:00
{
2025-07-09 12:00:23 +02:00
var res = false;
2025-07-09 12:10:56 +02:00
//GD.Print($"Trying to use targets called: {target}");
2025-06-30 10:02:37 +02:00
var targetList = activator.GetTree().GetNodesInGroup(target);
foreach (var t in targetList)
{
//string f;
2025-07-09 12:10:56 +02:00
//GD.Print($"Trying to use {t.Name}");
2025-06-30 10:02:37 +02:00
if (t is IActivable activable)
{
2025-07-09 12:10:56 +02:00
//GD.Print($"Activating {t.Name}");
2025-07-09 12:00:23 +02:00
res |= activable.Activate(activationType);
2025-06-30 10:02:37 +02:00
}
}
2025-07-09 12:00:23 +02:00
return res;
2025-06-30 10:02:37 +02:00
}
}