Upgrade structure of code base
This commit is contained in:
@@ -1,45 +1,38 @@
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Enigmos.Ports;
|
||||
using Enigmos.Ports.DataPorts;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Skeleton.Utils.Helpers;
|
||||
using TabulaSmaragdina.Constants;
|
||||
|
||||
namespace Enigmos.Modules.TerminalModules.TestingModules;
|
||||
|
||||
public partial class RealReaderModule : TerminalModule
|
||||
public partial class RealReaderModule : BaseModule, ITerminalModule, IOperationModule
|
||||
{
|
||||
private DataInPort Input1 { get; set; }
|
||||
private DataInPort Input2 { get; set; }
|
||||
private DataInPort Input3 { get; set; }
|
||||
private AnimatedSprite2D RealReader { get; set; }
|
||||
public override IEnumerable<BasePort> Ports => new[] { Input1, Input2, Input3 };
|
||||
private AnimatedSprite2D? RealReader { get; set; }
|
||||
public IDataInPort[] DataInPorts { get; set; } = Array.Empty<IDataInPort>();
|
||||
public override IEnumerable<IBasePort> Ports => DataInPorts;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Input1 = GetPort<DataInPort>("Input1");
|
||||
Input2 = GetPort<DataInPort>("Input2");
|
||||
Input3 = GetPort<DataInPort>("Input3");
|
||||
Input1.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
Input2.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
Input3.SetDataType(EnigmosConstant.DataPortTypes.Real);
|
||||
this.DataInInit("Input", 3);
|
||||
this.SetInputType(EnigmosConstant.DataPortTypes.Real);
|
||||
RealReader = GetNode<AnimatedSprite2D>("RealReader");
|
||||
RealReader.SpeedScale = 0;
|
||||
RealReader.Play();
|
||||
PostInit();
|
||||
}
|
||||
|
||||
protected override void Consume(RootModule root)
|
||||
public void Drain()
|
||||
{
|
||||
double max = Input1.GetData(root).Real;
|
||||
double min = Input3.GetData(root).Real;
|
||||
double value = Input2.GetData(root).Real;
|
||||
//DebugToolWindow.FreeInfo = $"{value}";
|
||||
double max = DataInPorts[0].GetData.Get!.Double;
|
||||
double min = DataInPorts[2].GetData.Get!.Double;
|
||||
double value = DataInPorts[1].GetData.Get!.Double;
|
||||
double range = max - min;
|
||||
double percentage = (range == 0 ? 0d : value / range).DoubleCut();
|
||||
int frame = Mathf.FloorToInt(percentage * 122);
|
||||
RealReader.SpeedScale = (frame - RealReader.Frame) / 60f;
|
||||
Finished = true;
|
||||
RealReader!.SpeedScale = (frame - RealReader.Frame) / 60f;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user