using Godot; namespace Rokojori { [Tool] [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/RJSensor.svg")] public partial class Sensor: Resource { [Export] public bool continous = false; [ExportGroup("Read Only")] [Export] public float _value = 0; [Export] public bool _wasActive = false; [Export] public bool _active = false; [Export] public float _activeTreshold = 0.5f; public void ProcessSensor( SensorRunner runner, float delta ) { _wasActive = _active; UpdateValue(); } public bool isDown => ! _wasActive && _active; public bool isUp => _wasActive && ! _active; public bool wasActive => _wasActive; public bool isActive => _active; public bool isHold => _active; public bool isInactive => ! _active; public bool isActivated => isDown; public bool isDeactivated => isUp; public float value => _value; protected virtual void UpdateValue() { } protected void SetBoolValue( bool activeState ) { _active = activeState; _value = activeState ? 1 : 0; } protected void SetFloatValue( float value ) { _value = value; _active = value > _activeTreshold; } } }