rokojori_action_library/Runtime/Actions/Conditional/ConditionalAction.cs

45 lines
841 B
C#
Raw Normal View History

2025-05-27 06:51:48 +00:00
using Godot;
using System.Collections.Generic;
namespace Rokojori
{
[Tool]
[GlobalClass, Icon("res://addons/rokojori_action_library/Icons/ConditionalAction.svg")]
public partial class ConditionalAction : Action
{
[ExportGroup("Condition")]
[Export]
public Condition condition;
2025-10-24 11:38:51 +00:00
2025-05-27 06:51:48 +00:00
[Export]
public SceneCondition sceneCondition;
[ExportGroup("Actions")]
[Export]
public Action ifAction;
[Export]
public Action elseAction;
protected override void _OnTrigger()
{
2025-10-24 11:38:51 +00:00
var conditionActive = Condition.Evaluate( condition ) || SceneCondition.Evaluate( sceneCondition );
2025-05-27 06:51:48 +00:00
2025-06-12 09:03:02 +00:00
// this.LogInfo( "Condition is", conditionActive );
2025-05-27 06:51:48 +00:00
if ( conditionActive )
{
2026-05-02 10:32:42 +00:00
TriggerSafe( ifAction );
2025-05-27 06:51:48 +00:00
}
else
{
2026-05-02 10:32:42 +00:00
TriggerSafe( elseAction );
2025-05-27 06:51:48 +00:00
}
}
}
}