project update

This commit is contained in:
h z
2024-06-30 01:52:44 +08:00
parent 117835b503
commit 59d257c06a
67 changed files with 2268 additions and 92 deletions

View 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();
}
}