58 lines
1.8 KiB
C#
58 lines
1.8 KiB
C#
using Enigmos.Cables;
|
|
using Godot;
|
|
using Nocturnis.DataStructures.DataTypes;
|
|
using Nocturnis.Enigmos.Cables;
|
|
using Nocturnis.Enigmos.Ports;
|
|
using Nocturnis.Enigmos.Ports.DataPorts;
|
|
using Nocturnis.GlobalManagement.Constants;
|
|
using Nocturnis.GlobalManagement.Providers;
|
|
|
|
namespace Enigmos.Ports.DataPorts;
|
|
|
|
public abstract partial class DataPort : BasePort, IDataPort
|
|
{
|
|
public new IDataPort ConnectedPort
|
|
{
|
|
get => (base.ConnectedPort as IDataPort)!;
|
|
set => base.ConnectedPort = value;
|
|
}
|
|
protected Sprite2D DataTypeTexture { get; set; }
|
|
public DataType DataType { get; set; } = new(DataTypeConstant.BaseDataTypeNames.Null);
|
|
public override void Init()
|
|
{
|
|
DataTypeTexture = GetNode<Sprite2D>("DataTypeTexture");
|
|
DataTypeTexture.Visible = false;
|
|
base.Init();
|
|
}
|
|
public void SetDataType(DataType val)
|
|
{
|
|
if(Connected && val != ConnectedPort!.DataType)
|
|
this.Disconnect();
|
|
DataType = val;
|
|
DataTypeTexture!.Texture = GlobalProvider.DataTypeTexture[DataType.Type];
|
|
}
|
|
|
|
private void MouseEnterHandler() => DataTypeTexture!.Visible = true;
|
|
private void MouseExitHandler() => DataTypeTexture!.Visible = false;
|
|
|
|
public override IBaseCable 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()
|
|
{
|
|
base.SetStatusConnected();
|
|
TextureNormal = GlobalProvider.EnigmosProvider!.DataPortStatusConnected;
|
|
}
|
|
}
|
|
|