project update
This commit is contained in:
34
Modules/TerminalModules/TestingModules/R2Reader.cs
Normal file
34
Modules/TerminalModules/TestingModules/R2Reader.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Godot;
|
||||
using Skeleton.Utils.Helpers;
|
||||
using R2 = Skeleton.Algebra.CategoryOf<Skeleton.Algebra.DimensionProviders.IDim2>.OnField<double>.FVector;
|
||||
|
||||
namespace Enigmos.Modules.TerminalModules.TestingModules;
|
||||
|
||||
public partial class R2Reader : Control
|
||||
{
|
||||
private AnimatedSprite2D Direction { get; set; }
|
||||
private AnimatedSprite2D Magnitude { get; set; }
|
||||
public R2 UnderlyingVector { get; set; }
|
||||
private double TargetPhase() => Math.Atan2(UnderlyingVector[2], UnderlyingVector[1]);
|
||||
private double TargetLength() => UnderlyingVector.Magnitude;
|
||||
|
||||
private int TargetPhaseFrame =>
|
||||
Mathf.FloorToInt((TargetPhase() % (2d * Math.PI) + 2d * Math.PI) % (2d * Math.PI) * 44d / (2d * Math.PI));
|
||||
|
||||
private int TargetLengthFrame =>
|
||||
Mathf.FloorToInt(TargetLength().DoubleCut() * 9d);
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
Magnitude.SpeedScale = (TargetLengthFrame - Magnitude.Frame) / 7f;
|
||||
var debug = new[] { TargetPhaseFrame - Direction.Frame, TargetPhaseFrame + 44 - Direction.Frame };
|
||||
Direction.SpeedScale = debug.MinBy(Math.Abs) / 25f;
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
Direction = GetNode<AnimatedSprite2D>("Direction");
|
||||
Magnitude = GetNode<AnimatedSprite2D>("Magnitude");
|
||||
Direction.Play();
|
||||
Magnitude.Play();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user