mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 16:35:54 +00:00
Chain activables
This commit is contained in:
parent
a430554e27
commit
77b18d250e
5 changed files with 144 additions and 32 deletions
32
Scripts/Activables/ChainActivable.cs
Normal file
32
Scripts/Activables/ChainActivable.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Cirno.Scripts.Activables;
|
||||
|
||||
public partial class ChainActivable : Activable
|
||||
{
|
||||
[Export] private Array<Node2D> _targets;
|
||||
|
||||
protected void ActivateTargets()
|
||||
{
|
||||
foreach (var activationTarget in _targets)
|
||||
{
|
||||
ActivateTarget(activationTarget);
|
||||
}
|
||||
}
|
||||
|
||||
private bool ActivateTarget(Node2D activationTarget)
|
||||
{
|
||||
if (activationTarget is not IActivable target)
|
||||
{
|
||||
GD.PrintErr($"Target {activationTarget.Name} is not activable");
|
||||
return false;
|
||||
}
|
||||
|
||||
target?.Activate();
|
||||
|
||||
GD.Print($"{activationTarget.Name} activated");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue