2024-05-05 07:52:06 +00:00
|
|
|
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Rokojori
|
|
|
|
{
|
2025-06-10 13:16:36 +00:00
|
|
|
[Tool][GlobalClass, Icon("res://addons/rokojori_action_library/Icons/OnEvent.svg") ]
|
2024-05-05 07:52:06 +00:00
|
|
|
public partial class OnSensor: Node
|
|
|
|
{
|
2025-07-22 14:08:22 +00:00
|
|
|
[Export]
|
2025-01-08 18:46:17 +00:00
|
|
|
public Sensor sensor;
|
2024-05-05 07:52:06 +00:00
|
|
|
|
|
|
|
[Export]
|
2025-01-08 18:46:17 +00:00
|
|
|
public Action onStart;
|
2024-05-05 07:52:06 +00:00
|
|
|
|
|
|
|
[Export]
|
2025-01-08 18:46:17 +00:00
|
|
|
public Action onActive;
|
2024-05-05 07:52:06 +00:00
|
|
|
|
|
|
|
[Export]
|
2025-01-08 18:46:17 +00:00
|
|
|
public Action onEnd;
|
2024-05-05 07:52:06 +00:00
|
|
|
|
2025-07-22 14:08:22 +00:00
|
|
|
[ExportGroup("Condition")]
|
|
|
|
[Export]
|
|
|
|
public Condition condition;
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
public SceneCondition sceneCondition;
|
|
|
|
|
2024-05-05 07:52:06 +00:00
|
|
|
public override void _Process( double delta)
|
|
|
|
{
|
2025-07-22 14:08:22 +00:00
|
|
|
if ( sensor == null )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2024-05-05 07:52:06 +00:00
|
|
|
|
2025-07-22 14:08:22 +00:00
|
|
|
if ( condition != null && ! condition.Evaluate() )
|
2024-05-05 07:52:06 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2025-07-22 14:08:22 +00:00
|
|
|
if ( sceneCondition != null && ! sceneCondition.Evaluate() )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-05-05 07:52:06 +00:00
|
|
|
|
2025-07-22 14:08:22 +00:00
|
|
|
if ( sensor.isDown )
|
2024-05-05 07:52:06 +00:00
|
|
|
{
|
2025-01-08 18:46:17 +00:00
|
|
|
Action.Trigger( onStart );
|
2024-05-05 07:52:06 +00:00
|
|
|
}
|
|
|
|
|
2025-07-22 14:08:22 +00:00
|
|
|
if ( sensor.isHold )
|
2024-05-05 07:52:06 +00:00
|
|
|
{
|
2025-01-08 18:46:17 +00:00
|
|
|
Action.Trigger( onActive );
|
2024-05-05 07:52:06 +00:00
|
|
|
}
|
|
|
|
|
2025-07-22 14:08:22 +00:00
|
|
|
if ( sensor.isUp )
|
2024-05-05 07:52:06 +00:00
|
|
|
{
|
2025-01-08 18:46:17 +00:00
|
|
|
Action.Trigger( onActive );
|
2024-05-05 07:52:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|