Upgrade structure of code base
This commit is contained in:
@@ -1,36 +1,36 @@
|
||||
using Enigmos.Cables;
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Cables;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Ports.DataPorts;
|
||||
public partial class DataInPort : DataPort, IDataInPort
|
||||
{
|
||||
public new DataOutPort ConnectedPort
|
||||
public new IDataOutPort? ConnectedPort
|
||||
{
|
||||
get => base.ConnectedPort as DataOutPort;
|
||||
get => (base.ConnectedPort as IDataOutPort)!;
|
||||
set => base.ConnectedPort = value;
|
||||
}
|
||||
|
||||
public override bool IsMatch(IBasePort other) =>
|
||||
other is DataOutPort dataOut &&
|
||||
GlobalProvider.DataPackageTypeProvider.DataPortTypeCompatible(DataType, dataOut.DataType);
|
||||
|
||||
GlobalProvider.DataPackageTypeProvider!.DataPortTypeCompatible(DataType!, dataOut.DataType!);
|
||||
|
||||
public IDataPackage GetData(IRootModule root)
|
||||
public DataCache GetData => Connected ? ConnectedPort!.OutData : DataCache.Null;
|
||||
|
||||
/*public IDataPackage GetData(IRootModule root)
|
||||
{
|
||||
if (!Connected)
|
||||
return GlobalProvider.DataStructureProvider.DefaultDataPackage;
|
||||
return GlobalProvider.DataStructureProvider!.DefaultDataPackage;
|
||||
if(!ConnectedPort.DataUpdated)
|
||||
ConnectedPort.DataUpdateRequest(root);
|
||||
return ConnectedPort.ResultData;
|
||||
}
|
||||
return ConnectedPort!.ResultData;
|
||||
}*/
|
||||
|
||||
public override BaseCable MakeCable(IBasePort other)
|
||||
public override IBaseCable MakeCable(IBasePort other)
|
||||
{
|
||||
BaseCable res = base.MakeCable(other);
|
||||
IBaseCable res = base.MakeCable(other);
|
||||
res.PortFrom = this;
|
||||
res.PortTo = other;
|
||||
return res;
|
||||
|
||||
@@ -1,47 +1,40 @@
|
||||
using Enigmos.Cables;
|
||||
using Enigmos.Modules.ComputationalModules;
|
||||
using Enigmos.Modules.ControllingModules;
|
||||
using Nocturnis.DataStructures;
|
||||
using Nocturnis.Enigmos.Modules;
|
||||
using Nocturnis.Enigmos.Cables;
|
||||
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Ports.DataPorts;
|
||||
|
||||
public partial class DataOutPort : DataPort, IDataOutPort
|
||||
{
|
||||
public bool DataUpdated { get; set; }
|
||||
|
||||
public new ComputationalModule Module
|
||||
public new IComputationalModule Module
|
||||
{
|
||||
get => base.Module as ComputationalModule;
|
||||
get => (base.Module as IComputationalModule)!;
|
||||
set => base.Module = value;
|
||||
}
|
||||
|
||||
public void DataUpdateRequest(IRootModule root) => Module.ComputeWithTimeoutHandle(root);
|
||||
//public void DataUpdateRequest(IRootModule root) => Module.ComputeWithTimeoutHandle(root);
|
||||
|
||||
|
||||
public DataOutPort()
|
||||
public new IDataInPort? ConnectedPort
|
||||
{
|
||||
DataUpdated = false;
|
||||
ResultData = GlobalProvider.DataStructureProvider.NewDataPackage();
|
||||
}
|
||||
|
||||
public new DataInPort ConnectedPort
|
||||
{
|
||||
get => base.ConnectedPort as DataInPort;
|
||||
get => (base.ConnectedPort as IDataInPort)!;
|
||||
set => base.ConnectedPort = value;
|
||||
}
|
||||
|
||||
public override bool IsMatch(IBasePort other) =>
|
||||
other is DataInPort inPort &&
|
||||
GlobalProvider.DataPackageTypeProvider.DataPortTypeCompatible(inPort.DataType, DataType);
|
||||
public IDataPackage ResultData { get; set; }
|
||||
GlobalProvider.DataPackageTypeProvider!.DataPortTypeCompatible(inPort.DataType!, DataType!);
|
||||
|
||||
public override BaseCable MakeCable(IBasePort other)
|
||||
public override IBaseCable MakeCable(IBasePort other)
|
||||
{
|
||||
BaseCable res = base.MakeCable(other);
|
||||
IBaseCable res = base.MakeCable(other);
|
||||
res.PortFrom = other;
|
||||
res.PortTo = this;
|
||||
return res;
|
||||
}
|
||||
|
||||
public DataCache OutData { get; set; } = new(x => (0, ""));
|
||||
}
|
||||
|
||||
@@ -1,54 +1,53 @@
|
||||
using Enigmos.Cables;
|
||||
using Godot;
|
||||
using Nocturnis.Enigmos.Cables;
|
||||
using Nocturnis.Enigmos.Ports;
|
||||
using TabulaSmaragdina;
|
||||
using Nocturnis.Enigmos.Ports.DataPorts;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
|
||||
namespace Enigmos.Ports.DataPorts;
|
||||
|
||||
public abstract partial class DataPort : BasePort, IDataPort
|
||||
{
|
||||
public new DataPort ConnectedPort
|
||||
public new IDataPort? ConnectedPort
|
||||
{
|
||||
get => base.ConnectedPort as DataPort;
|
||||
get => (base.ConnectedPort as IDataPort)!;
|
||||
set => base.ConnectedPort = value;
|
||||
}
|
||||
protected Sprite2D DataTypeTexture { get; set; }
|
||||
public StringName DataType { get; set; }
|
||||
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();
|
||||
if(Connected && val != ConnectedPort!.DataType)
|
||||
this.Disconnect();
|
||||
DataType = val;
|
||||
DataTypeTexture.Texture = GlobalProvider.EnigmosProvider.DataPortTypeMap[val];
|
||||
DataTypeTexture!.Texture = GlobalProvider.EnigmosProvider!.DataPortTypeMap[val];
|
||||
}
|
||||
|
||||
private void MouseEnterHandler() => DataTypeTexture.Visible = true;
|
||||
private void MouseExitHandler() => DataTypeTexture.Visible = false;
|
||||
private void MouseEnterHandler() => DataTypeTexture!.Visible = true;
|
||||
private void MouseExitHandler() => DataTypeTexture!.Visible = false;
|
||||
|
||||
public override BaseCable MakeCable(IBasePort other)
|
||||
public override IBaseCable MakeCable(IBasePort other)
|
||||
{
|
||||
BaseCable res = GlobalProvider.EnigmosProvider.DataCableScene.Instantiate<BaseCable>();
|
||||
BaseCable res = GlobalProvider.EnigmosProvider!.DataCableScene.Instantiate<BaseCable>();
|
||||
res.Init();
|
||||
return res;
|
||||
}
|
||||
|
||||
public override void SetStatusNormal() =>
|
||||
TextureNormal = GlobalProvider.EnigmosProvider.DataPortStatusNormal;
|
||||
TextureNormal = GlobalProvider.EnigmosProvider!.DataPortStatusNormal;
|
||||
|
||||
public override void SetStatusPending() =>
|
||||
TextureNormal = GlobalProvider.EnigmosProvider.DataPortStatusPending;
|
||||
TextureNormal = GlobalProvider.EnigmosProvider!.DataPortStatusPending;
|
||||
|
||||
public override void SetStatusConnected() =>
|
||||
TextureNormal = GlobalProvider.EnigmosProvider.DataPortStatusConnected;
|
||||
TextureNormal = GlobalProvider.EnigmosProvider!.DataPortStatusConnected;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user