52 lines
884 B
C#
52 lines
884 B
C#
|
|
using Godot;
|
|
|
|
|
|
namespace Rokojori
|
|
{
|
|
[GlobalClass, Icon("res://addons/rokojori_action_library/Icons/RJOnEvent.svg") ]
|
|
public partial class OnSensor: Node
|
|
{
|
|
[Export]
|
|
public RJSensor sensor;
|
|
|
|
[Export]
|
|
public RJAction onStart;
|
|
|
|
[Export]
|
|
public RJAction onActive;
|
|
|
|
[Export]
|
|
public RJAction onEnd;
|
|
|
|
public override void _Process( double delta)
|
|
{
|
|
var active = sensor.IsActive();
|
|
var wasActive = sensor.WasActive();
|
|
|
|
if ( ! active && ! wasActive )
|
|
{
|
|
return;
|
|
}
|
|
|
|
var started = ! wasActive && active;
|
|
var ended = wasActive && ! active;
|
|
|
|
if ( started )
|
|
{
|
|
Actions.Trigger( onStart );
|
|
}
|
|
|
|
if ( active )
|
|
{
|
|
Actions.Trigger( onActive );
|
|
}
|
|
|
|
if ( ended )
|
|
{
|
|
Actions.Trigger( onActive );
|
|
}
|
|
|
|
}
|
|
}
|
|
} |