rj-action-library/Runtime/Sensors/TriggerOnSensor.cs

36 lines
612 B
C#
Raw Normal View History

2025-01-03 12:09:23 +00:00
using Godot;
namespace Rokojori
{
[GlobalClass, Icon("res://addons/rokojori_action_library/Icons/RJOnEvent.svg") ]
public partial class TriggerOnSensor: Node, SensorInputHandler
{
[Export]
public Sensor sensor;
[Export]
public RJAction action;
public override void _Ready()
{
SensorManager.Register( this, sensor );
}
public override void _ExitTree()
{
SensorManager.Unregister( this, sensor );
}
public void _OnSensor( SensorEvent se )
{
if ( se.IsDown( sensor ) )
{
Actions.Trigger( action );
}
}
}
}