36 lines
612 B
C#
36 lines
612 B
C#
|
|
||
|
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 );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|