Split project
This commit is contained in:
37
Ports/DataPorts/DataInPort.cs
Normal file
37
Ports/DataPorts/DataInPort.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Enigmos.Cables;
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
|
||||
namespace Enigmos.Ports.DataPorts;
|
||||
public partial class DataInPort : DataPort, IDataInPort
|
||||
{
|
||||
public new DataOutPort ConnectedPort
|
||||
{
|
||||
get => base.ConnectedPort as DataOutPort;
|
||||
set => base.ConnectedPort = value;
|
||||
}
|
||||
|
||||
public override bool IsMatch(IBasePort other) =>
|
||||
other is DataOutPort dataOut &&
|
||||
GlobalProvider.EnigmosProvider.DataPortTypeCompatible(DataType, dataOut.DataType);
|
||||
|
||||
|
||||
public IDataPackage GetData(RootModule root)
|
||||
{
|
||||
if (!Connected)
|
||||
return GlobalProvider.DataStructureProvider.DefaultDataPackage;
|
||||
if(!ConnectedPort.DataUpdated)
|
||||
ConnectedPort.DataUpdateRequest(root);
|
||||
return ConnectedPort.ResultData;
|
||||
}
|
||||
|
||||
public override BaseCable MakeCable(IBasePort other)
|
||||
{
|
||||
BaseCable res = base.MakeCable(other);
|
||||
res.PortFrom = this;
|
||||
res.PortTo = other;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
46
Ports/DataPorts/DataOutPort.cs
Normal file
46
Ports/DataPorts/DataOutPort.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Enigmos.Cables;
|
||||
using Enigmos.Modules.ComputationalModules;
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
|
||||
namespace Enigmos.Ports.DataPorts;
|
||||
|
||||
public partial class DataOutPort : DataPort, IDataOutPort
|
||||
{
|
||||
public bool DataUpdated { get; set; }
|
||||
|
||||
public new ComputationalModule Module
|
||||
{
|
||||
get => base.Module as ComputationalModule;
|
||||
set => base.Module = value;
|
||||
}
|
||||
|
||||
public void DataUpdateRequest(RootModule root) => Module.ComputeWithTimeoutHandle(root);
|
||||
|
||||
public DataOutPort()
|
||||
{
|
||||
DataUpdated = false;
|
||||
ResultData = GlobalProvider.DataStructureProvider.NewDataPackage();
|
||||
}
|
||||
|
||||
public new DataInPort ConnectedPort
|
||||
{
|
||||
get => base.ConnectedPort as DataInPort;
|
||||
set => base.ConnectedPort = value;
|
||||
}
|
||||
|
||||
public override bool IsMatch(IBasePort other) =>
|
||||
other is DataInPort inPort &&
|
||||
GlobalProvider.EnigmosProvider.DataPortTypeCompatible(inPort.DataType, DataType);
|
||||
public IDataPackage ResultData { get; set; }
|
||||
|
||||
public override BaseCable MakeCable(IBasePort other)
|
||||
{
|
||||
BaseCable res = base.MakeCable(other);
|
||||
res.PortFrom = other;
|
||||
res.PortTo = this;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
54
Ports/DataPorts/DataPort.cs
Normal file
54
Ports/DataPorts/DataPort.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using Enigmos.Cables;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
|
||||
namespace Enigmos.Ports.DataPorts;
|
||||
|
||||
public abstract partial class DataPort : BasePort, IDataPort
|
||||
{
|
||||
public new DataPort ConnectedPort
|
||||
{
|
||||
get => base.ConnectedPort as DataPort;
|
||||
set => base.ConnectedPort = value;
|
||||
}
|
||||
protected Sprite2D DataTypeTexture { get; set; }
|
||||
public StringName DataType { get; set; }
|
||||
public override void Init()
|
||||
{
|
||||
Console.WriteLine("XY");
|
||||
DataTypeTexture = GetNode<Sprite2D>("DataTypeTexture");
|
||||
DataTypeTexture.Visible = false;
|
||||
base.Init();
|
||||
}
|
||||
|
||||
|
||||
public void SetDataType(StringName val)
|
||||
{
|
||||
if(Connected && val != ConnectedPort.DataType)
|
||||
Disconnect();
|
||||
DataType = val;
|
||||
DataTypeTexture.Texture = GlobalProvider.EnigmosProvider.DataPortTypeMap[val];
|
||||
}
|
||||
|
||||
private void MouseEnterHandler() => DataTypeTexture.Visible = true;
|
||||
private void MouseExitHandler() => DataTypeTexture.Visible = false;
|
||||
|
||||
public override BaseCable MakeCable(IBasePort other)
|
||||
{
|
||||
BaseCable res = GlobalProvider.EnigmosProvider.DataCableScene.Instantiate<BaseCable>();
|
||||
res.Init();
|
||||
return res;
|
||||
}
|
||||
|
||||
public override void SetStatusNormal() =>
|
||||
TextureNormal = GlobalProvider.EnigmosProvider.DataPortStatusNormal;
|
||||
|
||||
public override void SetStatusPending() =>
|
||||
TextureNormal = GlobalProvider.EnigmosProvider.DataPortStatusPending;
|
||||
|
||||
public override void SetStatusConnected() =>
|
||||
TextureNormal = GlobalProvider.EnigmosProvider.DataPortStatusConnected;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user