66 lines
1.0 KiB
C#
66 lines
1.0 KiB
C#
|
|
using Godot;
|
|
|
|
|
|
namespace Rokojori
|
|
{
|
|
[Tool][GlobalClass, Icon("res://addons/rokojori_action_library/Icons/OnEvent.svg") ]
|
|
public partial class OnSensor: Node
|
|
{
|
|
[Export]
|
|
public Sensor sensor;
|
|
|
|
[Export]
|
|
public Action onStart;
|
|
|
|
[Export]
|
|
public Action onActive;
|
|
|
|
[Export]
|
|
public Action onEnd;
|
|
|
|
[ExportGroup("Condition")]
|
|
[Export]
|
|
public Condition condition;
|
|
|
|
[Export]
|
|
public SceneCondition sceneCondition;
|
|
|
|
public override void _Process( double delta)
|
|
{
|
|
if ( sensor == null )
|
|
{
|
|
return;
|
|
}
|
|
|
|
if ( condition != null && ! condition.Evaluate() )
|
|
{
|
|
return;
|
|
}
|
|
|
|
if ( sceneCondition != null && ! sceneCondition.Evaluate() )
|
|
{
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( sensor.isDown )
|
|
{
|
|
Action.Trigger( onStart );
|
|
}
|
|
|
|
if ( sensor.isHold )
|
|
{
|
|
Action.Trigger( onActive );
|
|
}
|
|
|
|
if ( sensor.isUp )
|
|
{
|
|
Action.Trigger( onActive );
|
|
}
|
|
|
|
}
|
|
}
|
|
} |