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

38 lines
660 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]
2025-01-08 18:46:17 +00:00
public Action action;
2025-01-03 12:09:23 +00:00
public override void _Ready()
{
SensorManager.Register( this, sensor );
}
public override void _ExitTree()
{
SensorManager.Unregister( this, sensor );
}
public void _OnSensor( SensorEvent se )
{
2025-01-08 18:46:17 +00:00
RJLog.Log( se, se.IsDown( sensor ) );
2025-01-03 12:09:23 +00:00
if ( se.IsDown( sensor ) )
{
2025-01-08 18:46:17 +00:00
Action.Trigger( action );
2025-01-03 12:09:23 +00:00
}
}
}
}