using Godot; using Skeleton.Utils.Helpers; using R2 = Skeleton.Algebra.CategoryOf.OnField.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("Direction"); Magnitude = GetNode("Magnitude"); Direction.Play(); Magnitude.Play(); } }