47 lines
861 B
C#
47 lines
861 B
C#
|
|
||
|
using Godot;
|
||
|
|
||
|
|
||
|
namespace Rokojori
|
||
|
{
|
||
|
[GlobalClass,Icon("res://Scripts/Rokojori/Rokojori-Action-Library/Icons/RJSensor.svg")]
|
||
|
public partial class InputSensor : RJSensor
|
||
|
{
|
||
|
[Export]
|
||
|
public string inputActionName = "";
|
||
|
|
||
|
float _value = 0;
|
||
|
bool _wasActive = false;
|
||
|
bool _isActive = false;
|
||
|
|
||
|
public override float GetValue()
|
||
|
{
|
||
|
return _value;
|
||
|
}
|
||
|
|
||
|
public override bool IsActive()
|
||
|
{
|
||
|
return _isActive;
|
||
|
}
|
||
|
|
||
|
public override bool WasActive()
|
||
|
{
|
||
|
return _wasActive;
|
||
|
}
|
||
|
|
||
|
public override void UpdateValue( float value )
|
||
|
{
|
||
|
_value = value;
|
||
|
|
||
|
_wasActive = _isActive;
|
||
|
_isActive = _value > 0;
|
||
|
}
|
||
|
|
||
|
public override void _Process( double delta )
|
||
|
{
|
||
|
var inputValue = Input.GetActionRawStrength( inputActionName );
|
||
|
UpdateValue( inputValue );
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|