35 lines
575 B
C#
35 lines
575 B
C#
|
using Godot;
|
||
|
using System;
|
||
|
using System.Net.WebSockets;
|
||
|
|
||
|
namespace BITKit;
|
||
|
[Tool]
|
||
|
public partial class ScriptableAnimation : Node
|
||
|
{
|
||
|
[Export(PropertyHint.Range,"0,1")]
|
||
|
public float Value
|
||
|
{
|
||
|
get => _value;
|
||
|
set => SetValue(value);
|
||
|
}
|
||
|
private float _value;
|
||
|
[Export] protected bool autoPlay;
|
||
|
private void SetValue(float newValue)
|
||
|
{
|
||
|
_value =Math.Clamp(newValue,0,1);
|
||
|
OnSetValue(newValue);
|
||
|
}
|
||
|
protected virtual void OnSetValue(float newValue)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
public override void _Process(double delta)
|
||
|
{
|
||
|
if (autoPlay)
|
||
|
{
|
||
|
Value = (Value + (float)delta)%1;
|
||
|
}
|
||
|
}
|
||
|
}
|