63 lines
1.0 KiB
C#
63 lines
1.0 KiB
C#
|
|
using Godot;
|
||
|
|
|
||
|
|
using Rokojori.Extensions;
|
||
|
|
namespace Rokojori;
|
||
|
|
|
||
|
|
[Tool]
|
||
|
|
[GlobalClass, Icon("res://addons/rokojori_action_library/Icons/StateTransition.svg")]
|
||
|
|
public partial class StateTransition:Node
|
||
|
|
{
|
||
|
|
[Export]
|
||
|
|
public SceneCondition sceneCondition;
|
||
|
|
|
||
|
|
[Export]
|
||
|
|
public Condition condition;
|
||
|
|
|
||
|
|
[Export]
|
||
|
|
public Receptor receptor;
|
||
|
|
|
||
|
|
// Transitioning to a null targetState ends the owning StateMachine.
|
||
|
|
[Export]
|
||
|
|
public State targetState;
|
||
|
|
|
||
|
|
|
||
|
|
[Export]
|
||
|
|
public Action onTransition;
|
||
|
|
|
||
|
|
|
||
|
|
[ExportToolButton( "Set Reference Name" )]
|
||
|
|
public Callable setReferencedNameButton => Callable.From(
|
||
|
|
()=>
|
||
|
|
{
|
||
|
|
if ( targetState == null )
|
||
|
|
{
|
||
|
|
this.Name = "▸ (nothing)";
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
this.Name = "▸ " + targetState.Name;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
);
|
||
|
|
|
||
|
|
public bool IsTriggered()
|
||
|
|
{
|
||
|
|
if ( sceneCondition?.Evaluate() ?? false )
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
if ( condition?.Evaluate() ?? false )
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
if ( receptor?.activated ?? false )
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|