Upgrade structure of code base
This commit is contained in:
@@ -14,4 +14,8 @@
|
|||||||
<ProjectReference Include="..\VirtualChemistry\VirtualChemistry.csproj" />
|
<ProjectReference Include="..\VirtualChemistry\VirtualChemistry.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="src\GlobalManagement\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Nocturnis.Communicators;
|
|||||||
public interface IBaseCommunicator
|
public interface IBaseCommunicator
|
||||||
{
|
{
|
||||||
ICommunicateModule PairedModule { get; set; }
|
ICommunicateModule PairedModule { get; set; }
|
||||||
IDataPackage DataBuffer { get; set; }
|
IData DataBuffer { get; set; }
|
||||||
StringName CommunicationDataType { get; }
|
StringName CommunicationDataType { get; }
|
||||||
StringName CommunicationDirection { get; }
|
StringName CommunicationDirection { get; }
|
||||||
Texture2D IconTexture { get; }
|
Texture2D IconTexture { get; }
|
||||||
|
|||||||
@@ -4,4 +4,4 @@ public interface IBoolParameter : IConfigurableParameter<bool>
|
|||||||
{
|
{
|
||||||
string TrueDescription { get; set; }
|
string TrueDescription { get; set; }
|
||||||
string FalseDescription { get; set; }
|
string FalseDescription { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ namespace Nocturnis.DataStructures.ConfigurableParameters;
|
|||||||
public interface IKeyParameter : IConfigurableParameter<StringName>
|
public interface IKeyParameter : IConfigurableParameter<StringName>
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
44
src/DataStructures/DataCache.cs
Normal file
44
src/DataStructures/DataCache.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
using Godot;
|
||||||
|
using Nocturnis.GlobalManagement.Providers;
|
||||||
|
using Skeleton.DataStructure;
|
||||||
|
|
||||||
|
namespace Nocturnis.DataStructures;
|
||||||
|
|
||||||
|
public class DataCache : CacheItem<IData>
|
||||||
|
{
|
||||||
|
public new static DataCache Null => new DataCache(x => (0, ""));
|
||||||
|
public DataCache(Func<CacheItem?, IData> rec) : base(rec) => throw new Exception("CONSTRUCTION NOT ALLOWED");
|
||||||
|
|
||||||
|
public DataCache(Func<CacheItem?, (object, StringName)> rec)
|
||||||
|
{
|
||||||
|
Value = GlobalProvider.DataStructureProvider!.NewData(0, "");
|
||||||
|
ProxyCalculator = rec;
|
||||||
|
}
|
||||||
|
|
||||||
|
private new Func<CacheItem, (object, StringName)> ProxyCalculator { get; set; }
|
||||||
|
|
||||||
|
public override IData? Get
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (Expired)
|
||||||
|
{
|
||||||
|
(object val, StringName type) = ProxyCalculator(this);
|
||||||
|
Value!.Type = type;
|
||||||
|
Value.Data = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateCalculation(Func<CacheItem, (object, StringName)> rec)
|
||||||
|
{
|
||||||
|
Expire();
|
||||||
|
foreach (CacheItem item in Dependencies)
|
||||||
|
item.References.Remove(this);
|
||||||
|
Dependencies = new HashSet<CacheItem>();
|
||||||
|
ProxyCalculator = rec;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
6
src/DataStructures/DataPortGroups/IDataInGroup.cs
Normal file
6
src/DataStructures/DataPortGroups/IDataInGroup.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Nocturnis.DataStructures.DataPortGroups;
|
||||||
|
|
||||||
|
public interface IDataInGroup : IDataPortGroup, IEnumerable<IDataInGroup>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
8
src/DataStructures/DataPortGroups/IDataOutGroup.cs
Normal file
8
src/DataStructures/DataPortGroups/IDataOutGroup.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||||
|
|
||||||
|
namespace Nocturnis.DataStructures.DataPortGroups;
|
||||||
|
|
||||||
|
public interface IDataOutGroup : IDataPortGroup, IEnumerable<IDataOutPort>
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using Nocturnis.Enigmos.Ports;
|
|
||||||
|
|
||||||
namespace Nocturnis.DataStructures;
|
namespace Nocturnis.DataStructures.DataPortGroups;
|
||||||
|
|
||||||
public interface IDataPortGroup : IEnumerable<IDataPort>
|
public interface IDataPortGroup
|
||||||
{
|
{
|
||||||
StringName SelectedType { get; set; }
|
StringName SelectedType { get; set; }
|
||||||
StringName[] TypeOptions { get; set; }
|
StringName[] TypeOptions { get; set; }
|
||||||
25
src/DataStructures/IData.cs
Normal file
25
src/DataStructures/IData.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using Godot;
|
||||||
|
using System.Numerics;
|
||||||
|
using Skeleton.Algebra;
|
||||||
|
using Skeleton.Algebra.DimensionProviders;
|
||||||
|
|
||||||
|
namespace Nocturnis.DataStructures;
|
||||||
|
using R2 = CategoryOf<IDim2>.OnField<double>.FVector;
|
||||||
|
using C2 = CategoryOf<IDim2>.OnField<Complex>.FVector;
|
||||||
|
|
||||||
|
public interface IData
|
||||||
|
{
|
||||||
|
public void Assign(IData oth);
|
||||||
|
public void Assign(object v, StringName t);
|
||||||
|
object? Data { get; set; }
|
||||||
|
StringName? Type { get; set; }
|
||||||
|
int Int { get; set; }
|
||||||
|
double Double { get; set; }
|
||||||
|
Complex Complex { get; set; }
|
||||||
|
IData[] Array { get; set; }
|
||||||
|
R2 R2 { get; set; }
|
||||||
|
C2 C2 { get; set; }
|
||||||
|
bool Bit { get; set; }
|
||||||
|
StringName String { get; set; }
|
||||||
|
IStruct Struct { get; set; }
|
||||||
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
using System.Numerics;
|
|
||||||
using Godot;
|
|
||||||
using Skeleton.Algebra;
|
|
||||||
using Skeleton.Algebra.DimensionProviders;
|
|
||||||
|
|
||||||
namespace Nocturnis.DataStructures;
|
|
||||||
using R2 = CategoryOf<IDim2>.OnField<double>.FVector;
|
|
||||||
using C2 = CategoryOf<IDim2>.OnField<Complex>.FVector;
|
|
||||||
public interface IDataPackage
|
|
||||||
{
|
|
||||||
void Assign(IDataPackage val, StringName key);
|
|
||||||
bool Bit { get; set; }
|
|
||||||
double Real { get; set; }
|
|
||||||
Complex Complex { get; set; }
|
|
||||||
R2 R2 { get; set; }
|
|
||||||
C2 C2 { get; set; }
|
|
||||||
}
|
|
||||||
9
src/DataStructures/IStruct.cs
Normal file
9
src/DataStructures/IStruct.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Nocturnis.DataStructures;
|
||||||
|
|
||||||
|
public interface IStruct : IData
|
||||||
|
{
|
||||||
|
StringName TypeName { get; set; }
|
||||||
|
Dictionary<StringName, IData> Properties { get; set; }
|
||||||
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using Nocturnis.Enigmos.Cables;
|
using Nocturnis.Enigmos.Cables;
|
||||||
using Nocturnis.Enigmos.Modules;
|
|
||||||
using Nocturnis.Enigmos.Ports;
|
using Nocturnis.Enigmos.Ports;
|
||||||
using Nocturnis.UIElements.Layers;
|
using Nocturnis.UIElements.Layers;
|
||||||
|
|
||||||
@@ -13,6 +12,7 @@ public interface IBaseBoard
|
|||||||
HashSet<IBaseCable> FocusedCables { get; set; }
|
HashSet<IBaseCable> FocusedCables { get; set; }
|
||||||
bool ManualOpened { get; set; }
|
bool ManualOpened { get; set; }
|
||||||
bool CableVisualMode { get; set; }
|
bool CableVisualMode { get; set; }
|
||||||
IModuleManualLayer ModuleManualLayer { get; set; }
|
IModuleManualLayer? ModuleManualLayer { get; set; }
|
||||||
IModuleMovingLayer ModuleMovingLayer { get; set; }
|
IModuleMovingLayer? ModuleMovingLayer { get; set; }
|
||||||
|
void Reset();
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Nocturnis.Enigmos.Ports;
|
||||||
|
|
||||||
namespace Nocturnis.Enigmos.Cables;
|
namespace Nocturnis.Enigmos.Cables;
|
||||||
|
|
||||||
@@ -8,4 +9,6 @@ public interface IBaseCable
|
|||||||
void LineUpdate();
|
void LineUpdate();
|
||||||
Color Modulate { get; set; }
|
Color Modulate { get; set; }
|
||||||
Node AsNode { get; }
|
Node AsNode { get; }
|
||||||
|
IBasePort PortFrom { get; set; }
|
||||||
|
IBasePort PortTo { get; set; }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using Nocturnis.DataStructures;
|
||||||
|
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||||
|
using Skeleton.DataStructure;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||||
|
|
||||||
|
public static class EBinaryComputationalModule
|
||||||
|
{
|
||||||
|
public static IData X(this IBinaryComputationalModule p, CacheItem x) => p.DataInPorts[0].GetData.GetFrom(x)!;
|
||||||
|
public static IData Y(this IBinaryComputationalModule p, CacheItem x) => p.DataInPorts[1].GetData.GetFrom(x)!;
|
||||||
|
|
||||||
|
public static void BinaryInit(this IBinaryComputationalModule p)
|
||||||
|
{
|
||||||
|
p.DataInPorts = new IDataInPort[2];
|
||||||
|
p.DataInInit("Input", 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||||
|
|
||||||
|
public static class EComputationalModule
|
||||||
|
{
|
||||||
|
public static void DataOutInit(this IComputationalModule a, string prefix, int dI)
|
||||||
|
{
|
||||||
|
a.DataOutPorts = new IDataOutPort[dI];
|
||||||
|
for (int i = 1; i <= dI; i++)
|
||||||
|
a.DataOutPorts[i - 1] = a.GetPort<IDataOutPort>($"{prefix}{i}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using Godot;
|
||||||
|
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||||
|
using Skeleton.DataStructure;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||||
|
|
||||||
|
public static class EDuplicateOutputModule
|
||||||
|
{
|
||||||
|
public static void Define(this IDuplicateOutputModule m, Func<CacheItem, (object, StringName)> define)
|
||||||
|
{
|
||||||
|
foreach (IDataOutPort op in m.DataOutPorts)
|
||||||
|
op.OutData.UpdateCalculation(define);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetOutputType(this IDuplicateOutputModule m, StringName type)
|
||||||
|
{
|
||||||
|
foreach (IDataOutPort op in m.DataOutPorts)
|
||||||
|
op.SetDataType(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
15
src/Enigmos/Modules/ComputationalModules/ELogicModule.cs
Normal file
15
src/Enigmos/Modules/ComputationalModules/ELogicModule.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||||
|
using Nocturnis.GlobalManagement.Constants;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||||
|
|
||||||
|
public static class ELogicModule
|
||||||
|
{
|
||||||
|
public static void LogicModuleInit(this ILogicModule lm)
|
||||||
|
{
|
||||||
|
foreach (IDataOutPort op in lm.DataOutPorts)
|
||||||
|
op.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||||
|
foreach (IDataInPort ip in lm.DataInPorts)
|
||||||
|
ip.SetDataType(EnigmosConstant.DataPortTypes.Bit);
|
||||||
|
}
|
||||||
|
}
|
||||||
13
src/Enigmos/Modules/ComputationalModules/EOperationModule.cs
Normal file
13
src/Enigmos/Modules/ComputationalModules/EOperationModule.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using Godot;
|
||||||
|
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||||
|
|
||||||
|
public static class EOperationModule
|
||||||
|
{
|
||||||
|
public static void SetInputType(this IOperationModule m, StringName type)
|
||||||
|
{
|
||||||
|
foreach (IDataInPort ip in m.DataInPorts)
|
||||||
|
ip.SetDataType(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using Nocturnis.DataStructures;
|
||||||
|
using Skeleton.DataStructure;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||||
|
|
||||||
|
public static class ETernaryComputationalModule
|
||||||
|
{
|
||||||
|
public static IData X(this ITernaryComputationalModule m, CacheItem cache) =>
|
||||||
|
m.DataOutPorts[0].OutData.GetFrom(cache)!;
|
||||||
|
public static IData Y(this ITernaryComputationalModule m, CacheItem cache) =>
|
||||||
|
m.DataOutPorts[1].OutData.GetFrom(cache)!;
|
||||||
|
public static IData Z(this ITernaryComputationalModule m, CacheItem cache) =>
|
||||||
|
m.DataOutPorts[2].OutData.GetFrom(cache)!;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using Nocturnis.DataStructures;
|
||||||
|
using Skeleton.DataStructure;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||||
|
|
||||||
|
public static class EUnaryComputationalModule
|
||||||
|
{
|
||||||
|
public static IData X(this IUnaryComputationalModule m, CacheItem cache) =>
|
||||||
|
m.DataOutPorts[0].OutData.GetFrom(cache)!;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||||
|
|
||||||
|
public interface IBinaryComputationalModule : IComputationalModule, IParameterModule
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||||
|
|
||||||
|
public interface IComputationalModule : IBaseModule
|
||||||
|
{
|
||||||
|
IDataOutPort[] DataOutPorts { get; set; }
|
||||||
|
void Define();
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||||
|
|
||||||
|
public interface IDuplicateOutputModule : IComputationalModule
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||||
|
|
||||||
|
public interface IOperationModule : IParameterModule
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||||
|
|
||||||
|
public interface ITernaryComputationalModule: IParameterModule, IComputationalModule
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||||
|
|
||||||
|
public interface IUnaryComputationalModule: IComputationalModule, IOperationModule
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
19
src/Enigmos/Modules/EBaseModule.cs
Normal file
19
src/Enigmos/Modules/EBaseModule.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using Godot;
|
||||||
|
using Nocturnis.Enigmos.Ports;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
|
public static class EBaseModule
|
||||||
|
{
|
||||||
|
public static TPort GetPort<TPort>(this IBaseModule m, NodePath path)
|
||||||
|
where TPort : IBasePort
|
||||||
|
{
|
||||||
|
if (m.GetNode(path) is TPort port)
|
||||||
|
{
|
||||||
|
port.Init();
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Exception("NOT A PORT");
|
||||||
|
}
|
||||||
|
}
|
||||||
62
src/Enigmos/Modules/ECommunicateModule.cs
Normal file
62
src/Enigmos/Modules/ECommunicateModule.cs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
using Nocturnis.Communicators;
|
||||||
|
using Nocturnis.GlobalManagement.Constants;
|
||||||
|
using Nocturnis.GlobalManagement.Controls;
|
||||||
|
using Nocturnis.GlobalManagement.Providers;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
|
public static class ECommunicateModule
|
||||||
|
{
|
||||||
|
public static bool Paired(this ICommunicateModule module) => module.PairedCommunicator != null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determine if the module can be paired with given communicator
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsMatch(this ICommunicateModule module, IBaseCommunicator communicator) =>
|
||||||
|
module.CommunicationDataType == communicator.CommunicationDataType &&
|
||||||
|
GlobalProvider.EnigmosProvider!.CommunicationDirectionCompatible(
|
||||||
|
module.CommunicationDirection,
|
||||||
|
communicator.CommunicationDirection
|
||||||
|
);
|
||||||
|
/// <summary>
|
||||||
|
/// Pair the module with given communicator
|
||||||
|
/// </summary>
|
||||||
|
public static void Pair(this ICommunicateModule module, IBaseCommunicator communicator)
|
||||||
|
{
|
||||||
|
if(module.Paired())
|
||||||
|
module.Unpair();
|
||||||
|
module.PairedCommunicator = communicator;
|
||||||
|
communicator.PairedModule = module;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unpair the module with its paired communicator
|
||||||
|
/// </summary>
|
||||||
|
public static void Unpair(this ICommunicateModule module)
|
||||||
|
{
|
||||||
|
if (!module.Paired())
|
||||||
|
return;
|
||||||
|
module.PairedCommunicator!.PairedModule = null;
|
||||||
|
module.PairedCommunicator = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SendData(this ICommunicateModule module)
|
||||||
|
{
|
||||||
|
if (!module.Paired() || module.CommunicationDirection == EnigmosConstant.CommunicationDirections.Receive)
|
||||||
|
return;
|
||||||
|
module.PairedCommunicator!.DataBuffer.Assign(module.DataBuffer, module.CommunicationDataType);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void ReceiveData(this ICommunicateModule module)
|
||||||
|
{
|
||||||
|
if (!module.Paired() || module.CommunicationDirection == EnigmosConstant.CommunicationDirections.Send)
|
||||||
|
return;
|
||||||
|
module.DataBuffer.Assign(module.PairedCommunicator!.DataBuffer, module.CommunicationDataType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IBaseCommunicator[] CompatibleCommunicators(this ICommunicateModule module) =>
|
||||||
|
CreatureControl.Instance.CurrentCharacter!.DashboardTab.AllCommunicators
|
||||||
|
.Where(module.IsMatch)
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
13
src/Enigmos/Modules/EControllingModule.cs
Normal file
13
src/Enigmos/Modules/EControllingModule.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using Nocturnis.Enigmos.Ports.SignalPorts.Directions;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
|
public static class EControllingModule
|
||||||
|
{
|
||||||
|
public static void SignalInInit(this IControllingModule m, string prefix, int sI)
|
||||||
|
{
|
||||||
|
m.SignalInPorts = new ISignalInPort[sI];
|
||||||
|
for (int i = 1; i <= sI; i++)
|
||||||
|
m.SignalInPorts[i - 1] = m.GetPort<ISignalInPort>($"{prefix}{i}");
|
||||||
|
}
|
||||||
|
}
|
||||||
13
src/Enigmos/Modules/EParameterModule.cs
Normal file
13
src/Enigmos/Modules/EParameterModule.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
|
public static class EParameterModule
|
||||||
|
{
|
||||||
|
public static void DataInInit(this IParameterModule m, string prefix, int dI)
|
||||||
|
{
|
||||||
|
m.DataInPorts = new IDataInPort[dI];
|
||||||
|
for (int i = 1; i <= dI; i++)
|
||||||
|
m.DataInPorts[i - 1] = m.GetPort<IDataInPort>($"{prefix}{i}");
|
||||||
|
}
|
||||||
|
}
|
||||||
13
src/Enigmos/Modules/ERoutingModule.cs
Normal file
13
src/Enigmos/Modules/ERoutingModule.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using Nocturnis.Enigmos.Ports.SignalPorts.Directions;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
|
public static class ERoutingModule
|
||||||
|
{
|
||||||
|
public static void SignalOutInit(this IRoutingModule m, string prefix, int sO)
|
||||||
|
{
|
||||||
|
m.SignalOutPorts = new ISignalOutPort[sO];
|
||||||
|
for (int i = 1; i <= sO; i++)
|
||||||
|
m.SignalOutPorts[i - 1] = m.GetPort<ISignalOutPort>($"{prefix}{i}");
|
||||||
|
}
|
||||||
|
}
|
||||||
12
src/Enigmos/Modules/ESourceModule.cs
Normal file
12
src/Enigmos/Modules/ESourceModule.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
|
public static class ESourceModule
|
||||||
|
{
|
||||||
|
public static void Reset(this ISourceModule m)
|
||||||
|
{
|
||||||
|
foreach (IDataOutPort port in m.DataOutPorts)
|
||||||
|
port.OutData.Expire();
|
||||||
|
}
|
||||||
|
}
|
||||||
14
src/Enigmos/Modules/ETerminalModule.cs
Normal file
14
src/Enigmos/Modules/ETerminalModule.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
|
public static class ETerminalModule
|
||||||
|
{
|
||||||
|
public static void Consume(this ITerminalModule m)
|
||||||
|
{
|
||||||
|
foreach (IDataInPort ip in m.DataInPorts)
|
||||||
|
if(ip.GetData.Expired)
|
||||||
|
_ = ip.GetData.Get;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
6
src/Enigmos/Modules/IActionModule.cs
Normal file
6
src/Enigmos/Modules/IActionModule.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
|
public interface IActionModule : IControllingModule
|
||||||
|
{
|
||||||
|
void Act();
|
||||||
|
}
|
||||||
@@ -8,16 +8,19 @@ namespace Nocturnis.Enigmos.Modules;
|
|||||||
public interface IBaseModule
|
public interface IBaseModule
|
||||||
{
|
{
|
||||||
IEnumerable<IBasePort> Ports { get; }
|
IEnumerable<IBasePort> Ports { get; }
|
||||||
IBaseBoard Board { get; set; }
|
IBaseBoard? Board { get; set; }
|
||||||
Vector2 PositionToBoard { get; }
|
Vector2 PositionToBoard { get; }
|
||||||
Vector2 Size { get; set; }
|
Vector2 Size { get; set; }
|
||||||
double MaintenanceAlpha { get; }
|
double MaintenanceAlpha { get; }
|
||||||
double MaintenanceBeta { get; }
|
double MaintenanceBeta { get; }
|
||||||
string GetDescription { get; }
|
string GetDescription { get; }
|
||||||
ISimpleLabel Label { get; }
|
ISimpleLabel? Label { get; }
|
||||||
Node AsNode { get; }
|
Node AsNode { get; }
|
||||||
Vector2 Position { get; set; }
|
Vector2 Position { get; set; }
|
||||||
string LabelString { get; set; }
|
string LabelString { get; set; }
|
||||||
void UpdateCables();
|
void UpdateCables();
|
||||||
|
//T GetPort<T>(NodePath path);
|
||||||
}
|
Node GetNode(NodePath path);
|
||||||
|
void Init();
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ using Nocturnis.DataStructures;
|
|||||||
|
|
||||||
namespace Nocturnis.Enigmos.Modules;
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
public interface ICommunicateModule
|
public interface ICommunicateModule : IBaseModule
|
||||||
{
|
{
|
||||||
IBaseCommunicator PairedCommunicator { get; set; }
|
IBaseCommunicator? PairedCommunicator { get; set; }
|
||||||
StringName CommunicationDataType { get; }
|
StringName CommunicationDataType { get; }
|
||||||
StringName CommunicationDirection { get; }
|
StringName CommunicationDirection { get; }
|
||||||
IDataPackage DataBuffer { get; set; }
|
IData DataBuffer { get; set; }
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,5 @@ namespace Nocturnis.Enigmos.Modules;
|
|||||||
|
|
||||||
public interface IComputationalCompositeModule : ICompositeModule
|
public interface IComputationalCompositeModule : ICompositeModule
|
||||||
{
|
{
|
||||||
void Compute(IRootModule root);
|
|
||||||
Vector2 PositionToBoard { get; }
|
Vector2 PositionToBoard { get; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
|
using Nocturnis.Enigmos.Ports.SignalPorts.Directions;
|
||||||
|
|
||||||
namespace Nocturnis.Enigmos.Modules;
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
public interface IControllingModule : IBaseModule
|
public interface IControllingModule : IBaseModule
|
||||||
{
|
{
|
||||||
void RouteWithTimeoutHandle(IRootModule root);
|
ISignalInPort[] SignalInPorts { get; set; }
|
||||||
}
|
void Execute();
|
||||||
|
bool Visited { get; set; }
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
|
using Nocturnis.DataStructures;
|
||||||
|
|
||||||
namespace Nocturnis.Enigmos.Modules;
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
public interface IFilterModule : IProgrammableModule
|
public interface IFilterModule : IProgrammableModule
|
||||||
{
|
{
|
||||||
void FilterWithTimeoutHandle(IRootModule root);
|
void Filter();
|
||||||
}
|
IData[] CachedResult { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
using Nocturnis.Enigmos.Ports;
|
|
||||||
|
|
||||||
namespace Nocturnis.Enigmos.Modules;
|
|
||||||
|
|
||||||
public interface IInterlayerDataInModule : IInterlayerModule
|
|
||||||
{
|
|
||||||
IInterlayerDataOutModule? DualModule { get; set; }
|
|
||||||
IDataInPort? DataIn { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
using Nocturnis.Enigmos.Ports;
|
|
||||||
|
|
||||||
namespace Nocturnis.Enigmos.Modules;
|
|
||||||
|
|
||||||
public interface IInterlayerDataOutModule : IInterlayerModule
|
|
||||||
{
|
|
||||||
IInterlayerDataInModule? DualModule { get; set; }
|
|
||||||
IDataOutPort? DataOut { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
using Nocturnis.Enigmos.Ports;
|
|
||||||
|
|
||||||
namespace Nocturnis.Enigmos.Modules;
|
|
||||||
|
|
||||||
public interface IInterlayerSignalInModule : IInterlayerModule
|
|
||||||
{
|
|
||||||
IInterlayerSignalOutModule? DualModule { get; set; }
|
|
||||||
ISignalInPort? SignalIn { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
using Nocturnis.Enigmos.Ports;
|
|
||||||
|
|
||||||
namespace Nocturnis.Enigmos.Modules;
|
|
||||||
|
|
||||||
public interface IInterlayerSignalOutModule : IInterlayerModule
|
|
||||||
{
|
|
||||||
IInterlayerSignalInModule? DualModule { get; set; }
|
|
||||||
ISignalOutPort? SignalOut { get; set; }
|
|
||||||
}
|
|
||||||
8
src/Enigmos/Modules/ILogicModule.cs
Normal file
8
src/Enigmos/Modules/ILogicModule.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
|
public interface ILogicModule : IComputationalModule, IParameterModule
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
|
using Nocturnis.DataStructures;
|
||||||
|
|
||||||
namespace Nocturnis.Enigmos.Modules;
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
public interface IOptimizationModule : IProgrammableModule
|
public interface IOptimizationModule : IProgrammableModule
|
||||||
{
|
{
|
||||||
void OptimizeWithTimeoutHandle(IRootModule root);
|
IData CachedResult { get; set; }
|
||||||
}
|
bool Calculated { get; set; }
|
||||||
|
void Optimize();
|
||||||
|
}
|
||||||
|
|||||||
8
src/Enigmos/Modules/IParameterModule.cs
Normal file
8
src/Enigmos/Modules/IParameterModule.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
|
public interface IParameterModule : IBaseModule
|
||||||
|
{
|
||||||
|
IDataInPort[] DataInPorts { get; set; }
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
using Nocturnis.DataStructures;
|
|
||||||
using Nocturnis.DataStructures.ConfigurableParameters;
|
using Nocturnis.DataStructures.ConfigurableParameters;
|
||||||
|
|
||||||
namespace Nocturnis.Enigmos.Modules;
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Nocturnis.DataStructures;
|
using Nocturnis.DataStructures.DataPortGroups;
|
||||||
|
|
||||||
namespace Nocturnis.Enigmos.Modules;
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
using Godot;
|
|
||||||
|
|
||||||
namespace Nocturnis.Enigmos.Modules;
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
public interface IProgrammableModule : IBaseModule
|
public interface IProgrammableModule : IBaseModule
|
||||||
|
|||||||
@@ -3,10 +3,11 @@ using Nocturnis.Creatures;
|
|||||||
|
|
||||||
namespace Nocturnis.Enigmos.Modules;
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
public interface IRootModule : IControllingModule
|
public interface IRootModule : IRoutingModule
|
||||||
{
|
{
|
||||||
Stopwatch? Timer { get; set; }
|
Stopwatch? Timer { get; set; }
|
||||||
bool ActionFinished { get; set; }
|
bool ActionFinished { get; set; }
|
||||||
IBaseCreature ManagedBy { get; set; }
|
IBaseCreature? ManagedBy { get; set; }
|
||||||
|
void Start();
|
||||||
|
|
||||||
}
|
}
|
||||||
9
src/Enigmos/Modules/IRoutingModule.cs
Normal file
9
src/Enigmos/Modules/IRoutingModule.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using Nocturnis.Enigmos.Ports.SignalPorts.Directions;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
|
public interface IRoutingModule : IBaseModule
|
||||||
|
{
|
||||||
|
ISignalOutPort[] SignalOutPorts { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
8
src/Enigmos/Modules/ISourceModule.cs
Normal file
8
src/Enigmos/Modules/ISourceModule.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
|
public interface ISourceModule : IComputationalModule
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
7
src/Enigmos/Modules/ITerminalModule.cs
Normal file
7
src/Enigmos/Modules/ITerminalModule.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
namespace Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
|
public interface ITerminalModule : IParameterModule
|
||||||
|
{
|
||||||
|
void Drain();
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules.InterlayerModules;
|
||||||
|
|
||||||
|
public interface IInterlayerDataInModule : IInterlayerModule, IParameterModule
|
||||||
|
{
|
||||||
|
new IInterlayerDataOutModule? DualModule { get; set; }
|
||||||
|
IDataInPort? DataIn { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||||
|
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules.InterlayerModules;
|
||||||
|
|
||||||
|
public interface IInterlayerDataOutModule : IInterlayerModule, IComputationalModule
|
||||||
|
{
|
||||||
|
new IInterlayerDataInModule? DualModule { get; set; }
|
||||||
|
IDataOutPort? DataOut { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
using Nocturnis.Enigmos.Ports;
|
using Nocturnis.Enigmos.Ports;
|
||||||
|
|
||||||
namespace Nocturnis.Enigmos.Modules;
|
namespace Nocturnis.Enigmos.Modules.InterlayerModules;
|
||||||
|
|
||||||
public interface IInterlayerModule
|
public interface IInterlayerModule
|
||||||
{
|
{
|
||||||
IBasePort? UnderlyingPort { get; }
|
IBasePort? UnderlyingPort { get; }
|
||||||
IProgrammableModule? ParentModule { get; set; }
|
IProgrammableModule? ParentModule { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using Nocturnis.Enigmos.Ports.SignalPorts.Directions;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules.InterlayerModules;
|
||||||
|
|
||||||
|
public interface IInterlayerSignalInModule : IInterlayerModule, IControllingModule
|
||||||
|
{
|
||||||
|
new IInterlayerSignalOutModule? DualModule { get; set; }
|
||||||
|
ISignalInPort? SignalIn { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using Nocturnis.Enigmos.Ports.SignalPorts.Directions;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Modules.InterlayerModules;
|
||||||
|
|
||||||
|
public interface IInterlayerSignalOutModule : IInterlayerModule, IRoutingModule
|
||||||
|
{
|
||||||
|
new IInterlayerSignalInModule? DualModule { get; set; }
|
||||||
|
ISignalOutPort? SignalOut { get; set; }
|
||||||
|
}
|
||||||
10
src/Enigmos/Ports/DataPorts/Directions/IDataInPort.cs
Normal file
10
src/Enigmos/Ports/DataPorts/Directions/IDataInPort.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using Nocturnis.DataStructures;
|
||||||
|
using Skeleton.DataStructure;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||||
|
|
||||||
|
public interface IDataInPort : IDataPort
|
||||||
|
{
|
||||||
|
DataCache GetData { get; }
|
||||||
|
new IDataOutPort? ConnectedPort { get; set; }
|
||||||
|
}
|
||||||
13
src/Enigmos/Ports/DataPorts/Directions/IDataOutPort.cs
Normal file
13
src/Enigmos/Ports/DataPorts/Directions/IDataOutPort.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using Nocturnis.DataStructures;
|
||||||
|
using Nocturnis.Enigmos.Modules;
|
||||||
|
using Nocturnis.Enigmos.Modules.ComputationalModules;
|
||||||
|
using Skeleton.DataStructure;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||||
|
|
||||||
|
public interface IDataOutPort : IDataPort
|
||||||
|
{
|
||||||
|
new IDataInPort? ConnectedPort { get; set; }
|
||||||
|
new IComputationalModule Module { get; set; }
|
||||||
|
DataCache OutData { get; set; }
|
||||||
|
}
|
||||||
6
src/Enigmos/Ports/DataPorts/EDataPort.cs
Normal file
6
src/Enigmos/Ports/DataPorts/EDataPort.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Nocturnis.Enigmos.Ports.DataPorts;
|
||||||
|
|
||||||
|
public class EDataPort
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
10
src/Enigmos/Ports/DataPorts/IDataPort.cs
Normal file
10
src/Enigmos/Ports/DataPorts/IDataPort.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Ports.DataPorts;
|
||||||
|
|
||||||
|
public interface IDataPort : IBasePort
|
||||||
|
{
|
||||||
|
new IDataPort? ConnectedPort { get; set; }
|
||||||
|
StringName? DataType { get; set; }
|
||||||
|
void SetDataType(StringName type);
|
||||||
|
}
|
||||||
67
src/Enigmos/Ports/EBasePort.cs
Normal file
67
src/Enigmos/Ports/EBasePort.cs
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
using Godot;
|
||||||
|
using Nocturnis.Enigmos.Cables;
|
||||||
|
using Nocturnis.Inventories.Items.Items;
|
||||||
|
using VirtualChemistry.Chemistry.Mixtures.Implements;
|
||||||
|
|
||||||
|
namespace Nocturnis.Enigmos.Ports;
|
||||||
|
|
||||||
|
public static class EBasePort
|
||||||
|
{
|
||||||
|
public static void FixWith(this IBasePort p, IBaseChemicalItem c)
|
||||||
|
{
|
||||||
|
if (c.ContentMaterial.Amount == 0)
|
||||||
|
return;
|
||||||
|
HeterogeneousMixture material = c.ContentMaterial;
|
||||||
|
double s = 1; //material.LayerOrder.Last.Value.CayleyValue();
|
||||||
|
double u = 1;//material.LayerOrder.Last.Value.EuclidValue();
|
||||||
|
double usedAmount = Math.Min(1d, material.LayerOrder.Last.Value.Amount);
|
||||||
|
double dCond = usedAmount * (p.Module!.MaintenanceAlpha * s - p.Module.MaintenanceBeta * u);
|
||||||
|
double dQuality = usedAmount * (Math.Pow(p.Module.MaintenanceBeta, 2) * s - p.Module.MaintenanceAlpha * u);
|
||||||
|
c.ConsumeFromBottom(usedAmount);
|
||||||
|
p.Condition = Mathf.FloorToInt(Math.Max(0, Math.Min(100, p.Condition + dCond)));
|
||||||
|
p.Quality = Mathf.FloorToInt(Math.Max(0, Math.Min(20000, p.Quality + dQuality)));
|
||||||
|
}
|
||||||
|
public static void Connect(this IBasePort p)
|
||||||
|
{
|
||||||
|
if(p.Connected)
|
||||||
|
p.Disconnect();
|
||||||
|
if (p.Module!.Board!.ConnectPending == null)
|
||||||
|
{
|
||||||
|
p.SetStatusPending();
|
||||||
|
p.Module.Board.ConnectPending = p;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p.Module.Board.ConnectPending.IsMatch(p))
|
||||||
|
{
|
||||||
|
p.ConnectedPort = p.Module.Board.ConnectPending;
|
||||||
|
p.Module.Board.ConnectPending.ConnectedPort = p;
|
||||||
|
IBaseCable cable = p.MakeCable(p.Module.Board.ConnectPending);
|
||||||
|
p.Module.Board.CablePairing[p] = cable;
|
||||||
|
p.Module.Board.CablePairing[p.Module.Board.ConnectPending] = cable;
|
||||||
|
p.Module.Board.AddCable(cable);
|
||||||
|
cable.LineUpdate();
|
||||||
|
p.SetStatusConnected();
|
||||||
|
p.Module.Board.ConnectPending.SetStatusConnected();
|
||||||
|
p.Module.Board.ConnectPending = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
p.Module.Board.ConnectPending.SetStatusNormal();
|
||||||
|
p.Module.Board.ConnectPending = null;
|
||||||
|
}
|
||||||
|
public static void Disconnect(this IBasePort p)
|
||||||
|
{
|
||||||
|
if (!p.Connected)
|
||||||
|
return;
|
||||||
|
IBaseCable cable = p.Module!.Board!.CablePairing[p];
|
||||||
|
p.Module.Board.CablePairing.Remove(p.ConnectedPort!);
|
||||||
|
p.Module.Board.FocusedCables.Remove(p.Module.Board.CablePairing[p]);
|
||||||
|
p.Module.Board.CablePairing.Remove(p);
|
||||||
|
|
||||||
|
cable.Free();
|
||||||
|
p.ConnectedPort!.SetStatusNormal();
|
||||||
|
p.ConnectedPort.ConnectedPort = null;
|
||||||
|
p.SetStatusNormal();
|
||||||
|
p.ConnectedPort = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using Nocturnis.Enigmos.Cables;
|
||||||
using Nocturnis.Enigmos.Modules;
|
using Nocturnis.Enigmos.Modules;
|
||||||
using Nocturnis.Inventories.Items.Items;
|
|
||||||
|
|
||||||
namespace Nocturnis.Enigmos.Ports;
|
namespace Nocturnis.Enigmos.Ports;
|
||||||
|
|
||||||
public interface IBasePort
|
public interface IBasePort
|
||||||
{
|
{
|
||||||
bool Connected { get; }
|
bool Connected { get; }
|
||||||
IBaseModule Module { get; set; }
|
IBaseModule? Module { get; set; }
|
||||||
bool IsMatch(IBasePort oth);
|
bool IsMatch(IBasePort oth);
|
||||||
IBasePort? ConnectedPort { get; set; }
|
IBasePort? ConnectedPort { get; set; }
|
||||||
void SetStatusConnected();
|
void SetStatusConnected();
|
||||||
@@ -16,5 +16,7 @@ public interface IBasePort
|
|||||||
StringName Name { get; set; }
|
StringName Name { get; set; }
|
||||||
int Condition { get; set; }
|
int Condition { get; set; }
|
||||||
int Quality { get; set; }
|
int Quality { get; set; }
|
||||||
void FixWith(IBaseChemicalItem item);
|
//void FixWith(IBaseChemicalItem item);
|
||||||
}
|
void Init();
|
||||||
|
IBaseCable MakeCable(IBasePort port);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
using Nocturnis.DataStructures;
|
|
||||||
using Nocturnis.Enigmos.Modules;
|
|
||||||
|
|
||||||
namespace Nocturnis.Enigmos.Ports;
|
|
||||||
|
|
||||||
public interface IDataInPort : IDataPort
|
|
||||||
{
|
|
||||||
IDataPackage GetData(IRootModule root);
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
using Nocturnis.DataStructures;
|
|
||||||
|
|
||||||
namespace Nocturnis.Enigmos.Ports;
|
|
||||||
|
|
||||||
public interface IDataOutPort : IDataPort
|
|
||||||
{
|
|
||||||
IDataPackage ResultData { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
namespace Nocturnis.Enigmos.Ports;
|
|
||||||
|
|
||||||
public interface IDataPort : IBasePort
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using Nocturnis.Enigmos.Modules;
|
using Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
namespace Nocturnis.Enigmos.Ports;
|
namespace Nocturnis.Enigmos.Ports.SignalPorts.Directions;
|
||||||
|
|
||||||
public interface ISignalInPort : ISignalPort
|
public interface ISignalInPort : ISignalPort
|
||||||
{
|
{
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
using Nocturnis.Enigmos.Modules;
|
using Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
namespace Nocturnis.Enigmos.Ports;
|
namespace Nocturnis.Enigmos.Ports.SignalPorts.Directions;
|
||||||
|
|
||||||
public interface ISignalOutPort : ISignalPort
|
public interface ISignalOutPort : ISignalPort
|
||||||
{
|
{
|
||||||
new IControllingModule Module { get; set; }
|
new IRoutingModule Module { get; set; }
|
||||||
new ISignalInPort? ConnectedPort { get; set; }
|
new ISignalInPort? ConnectedPort { get; set; }
|
||||||
|
void Route();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Nocturnis.Enigmos.Ports;
|
namespace Nocturnis.Enigmos.Ports.SignalPorts;
|
||||||
|
|
||||||
public interface ISignalPort : IBasePort
|
public interface ISignalPort : IBasePort
|
||||||
{
|
{
|
||||||
31
src/GlobalManagement/Constants/EnigmosConstant.cs
Normal file
31
src/GlobalManagement/Constants/EnigmosConstant.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Nocturnis.GlobalManagement.Constants;
|
||||||
|
|
||||||
|
public static class EnigmosConstant
|
||||||
|
{
|
||||||
|
public static class DataPortTypes
|
||||||
|
{
|
||||||
|
public static readonly StringName Null = "Null";
|
||||||
|
public static readonly StringName Bit = "Bit";
|
||||||
|
public static readonly StringName Real = "Real";
|
||||||
|
public static readonly StringName Complex = "Complex";
|
||||||
|
public static readonly StringName R2 = "R2";
|
||||||
|
public static readonly StringName C2 = "C2";
|
||||||
|
public static readonly StringName RealArray = "RealArray";
|
||||||
|
public static readonly StringName AnyArrayType = "AnyArrayType";
|
||||||
|
public static readonly StringName[] NumericTypes = new[] { Real, Complex };
|
||||||
|
public static readonly StringName[] AnyTensor = new[] { Real, Complex, R2, C2 };
|
||||||
|
public static readonly StringName[] AnyType = new[] { Real, Complex, R2, C2 };
|
||||||
|
public static readonly StringName[] VectorTypes = new[] { R2, C2 };
|
||||||
|
public static readonly StringName[] AnyArray = Array.Empty<StringName>();
|
||||||
|
|
||||||
|
}
|
||||||
|
public static class CommunicationDirections
|
||||||
|
{
|
||||||
|
public static readonly StringName Send = "Send";
|
||||||
|
public static readonly StringName Receive = "Receive";
|
||||||
|
}
|
||||||
|
|
||||||
|
public const double IdlePower = 0.2d;
|
||||||
|
}
|
||||||
23
src/GlobalManagement/Controls/CreatureControl.cs
Normal file
23
src/GlobalManagement/Controls/CreatureControl.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using Nocturnis.Creatures.Characters;
|
||||||
|
|
||||||
|
namespace Nocturnis.GlobalManagement.Controls;
|
||||||
|
|
||||||
|
public class CreatureControl
|
||||||
|
{
|
||||||
|
private static CreatureControl _instance { get; set; }
|
||||||
|
private static object _lock = new();
|
||||||
|
public static CreatureControl Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock(_lock) _instance ??= new CreatureControl();
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private CreatureControl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public IBaseCharacter? CurrentCharacter { get; set; }
|
||||||
|
}
|
||||||
33
src/GlobalManagement/Controls/EnigmosControl.cs
Normal file
33
src/GlobalManagement/Controls/EnigmosControl.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using Nocturnis.Enigmos.Modules;
|
||||||
|
|
||||||
|
namespace Nocturnis.GlobalManagement.Controls;
|
||||||
|
|
||||||
|
public class EnigmosControl
|
||||||
|
{
|
||||||
|
private static EnigmosControl _instance { get; set; }
|
||||||
|
private static object _lock = new();
|
||||||
|
public static EnigmosControl Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock(_lock) _instance ??= new EnigmosControl();
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private EnigmosControl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public IRootModule RootModule { get; set; }
|
||||||
|
|
||||||
|
public void ShutDownEngine()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PowerUpEngine()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public double Energy { get; set; } = 0d;
|
||||||
|
}
|
||||||
32
src/GlobalManagement/Controls/ItemDraggingControl.cs
Normal file
32
src/GlobalManagement/Controls/ItemDraggingControl.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using Nocturnis.Inventories.Items;
|
||||||
|
using Nocturnis.Inventories.ItemSlots;
|
||||||
|
|
||||||
|
namespace Nocturnis.GlobalManagement.Controls;
|
||||||
|
|
||||||
|
public sealed class ItemDraggingControl
|
||||||
|
{
|
||||||
|
public IBaseItem? DraggingItem => DraggingFrom?.Item;
|
||||||
|
|
||||||
|
public IBaseItemSlot? DraggingFrom = null;
|
||||||
|
|
||||||
|
public bool Dragging => DraggingFrom != null;
|
||||||
|
|
||||||
|
private static ItemDraggingControl? _instance = null;
|
||||||
|
|
||||||
|
private static object _lock = new object();
|
||||||
|
|
||||||
|
public static ItemDraggingControl Instance
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
lock(_lock) _instance ??= new ItemDraggingControl();
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Release()
|
||||||
|
{
|
||||||
|
DraggingFrom = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
11
src/GlobalManagement/Providers/GlobalProvider.cs
Normal file
11
src/GlobalManagement/Providers/GlobalProvider.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace Nocturnis.GlobalManagement.Providers;
|
||||||
|
|
||||||
|
public static class GlobalProvider
|
||||||
|
{
|
||||||
|
public static IEnigmosProvider? EnigmosProvider { get; set; }
|
||||||
|
public static IDataStructureProvider? DataStructureProvider { get; set; }
|
||||||
|
public static IUIProvider? UIProvider { get; set; }
|
||||||
|
public static ISceneProvider? SceneProvider { get; set; }
|
||||||
|
public static IPolymorphismProvider? PolymorphismProvider { get; set; }
|
||||||
|
public static IDataPackageTypeProvider? DataPackageTypeProvider { get; set; }
|
||||||
|
}
|
||||||
13
src/GlobalManagement/Providers/IDataPackageTypeProvider.cs
Normal file
13
src/GlobalManagement/Providers/IDataPackageTypeProvider.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Nocturnis.GlobalManagement.Providers;
|
||||||
|
|
||||||
|
public interface IDataPackageTypeProvider
|
||||||
|
{
|
||||||
|
bool IsComplexTensorType(StringName type);
|
||||||
|
StringName ComplexVersionOf(StringName type);
|
||||||
|
StringName BuildType(StringName nType, int i, int j);
|
||||||
|
StringName GetBaseField(StringName type);
|
||||||
|
bool DataPortTypeCompatible(StringName inType, StringName outType);
|
||||||
|
StringName ToElement(StringName arrayType);
|
||||||
|
}
|
||||||
29
src/GlobalManagement/Providers/IDataStructureProvider.cs
Normal file
29
src/GlobalManagement/Providers/IDataStructureProvider.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using Godot;
|
||||||
|
using Nocturnis.DataStructures;
|
||||||
|
using Nocturnis.DataStructures.ConfigurableParameters;
|
||||||
|
using Nocturnis.DataStructures.DataPortGroups;
|
||||||
|
using Nocturnis.Enigmos.Modules;
|
||||||
|
using Nocturnis.Enigmos.Ports.DataPorts;
|
||||||
|
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
|
||||||
|
|
||||||
|
namespace Nocturnis.GlobalManagement.Providers;
|
||||||
|
|
||||||
|
public interface IDataStructureProvider
|
||||||
|
{
|
||||||
|
Variant NewVariantWithType(string type, Variant a);
|
||||||
|
IBoolParameter NewBoolParameter(string d, string t, string f, bool def);
|
||||||
|
|
||||||
|
IDataPortGroup NewDataPortGroup(IBaseModule m, IDataPort[] pts, string desc, StringName defType, StringName[] typeOpts);
|
||||||
|
|
||||||
|
IDataInGroup NewDataInGroup(IBaseModule m, IDataInPort[] pts, string desc, StringName defType, StringName[] typeOpts);
|
||||||
|
|
||||||
|
IDataOutGroup NewDataOutGroup(IBaseModule m, IDataOutPort[] pts, string desc, StringName defType, StringName[] typeOpts);
|
||||||
|
|
||||||
|
IData NewData(object data, StringName type);
|
||||||
|
|
||||||
|
IDoubleParameter NewDoubleParameter(string name, double min, double max, double def);
|
||||||
|
IKeyParameter NewKeyParameter(string a, string b);
|
||||||
|
IData NullData { get; }
|
||||||
|
IData DefaultData { get; }
|
||||||
|
StringName ArrayToElement(StringName arrayType);
|
||||||
|
}
|
||||||
23
src/GlobalManagement/Providers/IEnigmosProvider.cs
Normal file
23
src/GlobalManagement/Providers/IEnigmosProvider.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Nocturnis.GlobalManagement.Providers;
|
||||||
|
|
||||||
|
public interface IEnigmosProvider
|
||||||
|
{
|
||||||
|
Texture2D DataPortStatusNormal { get; set; }
|
||||||
|
Texture2D DataPortStatusPending { get; set; }
|
||||||
|
Texture2D DataPortStatusConnected { get; set; }
|
||||||
|
|
||||||
|
Texture2D SignalPortStatusNormal { get; set; }
|
||||||
|
Texture2D SignalPortStatusPending { get; set; }
|
||||||
|
Texture2D SignalPortStatusConnected { get; set; }
|
||||||
|
|
||||||
|
PackedScene SignalCableScene { get; set; }
|
||||||
|
PackedScene DataCableScene { get; set; }
|
||||||
|
Dictionary<StringName, Texture2D> DataPortTypeMap { get; set; }
|
||||||
|
|
||||||
|
bool CommunicationDirectionCompatible(StringName moduleDir, StringName communicatorDir);
|
||||||
|
|
||||||
|
string ModuleDescription<T>();
|
||||||
|
|
||||||
|
}
|
||||||
18
src/GlobalManagement/Providers/IPolymorphismProvider.cs
Normal file
18
src/GlobalManagement/Providers/IPolymorphismProvider.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using Godot;
|
||||||
|
using Nocturnis.DataStructures;
|
||||||
|
|
||||||
|
namespace Nocturnis.GlobalManagement.Providers;
|
||||||
|
|
||||||
|
public interface IPolymorphismProvider
|
||||||
|
{
|
||||||
|
(object, StringName) Square(IData a);
|
||||||
|
(object, StringName) Neg(IData a);
|
||||||
|
(object, StringName) Add(IData a, IData b);
|
||||||
|
(object, StringName) Sub(IData a, IData b);
|
||||||
|
(object, StringName) Div(IData a, IData b);
|
||||||
|
(object, StringName) Dot(IData a, IData b);
|
||||||
|
(object, StringName) Mul(IData a, IData b);
|
||||||
|
(object, StringName) Pow(IData a, IData b);
|
||||||
|
(object, StringName) ScalarDiv(IData a, IData b);
|
||||||
|
(object, StringName) ScalarMul(IData a, IData b);
|
||||||
|
}
|
||||||
10
src/GlobalManagement/Providers/ISceneProvider.cs
Normal file
10
src/GlobalManagement/Providers/ISceneProvider.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using Godot;
|
||||||
|
using Nocturnis.Scenes;
|
||||||
|
|
||||||
|
namespace Nocturnis.GlobalManagement.Providers;
|
||||||
|
|
||||||
|
public interface ISceneProvider
|
||||||
|
{
|
||||||
|
IRootScene RootScene { get; set; }
|
||||||
|
PackedScene AssetMapper<T>();
|
||||||
|
}
|
||||||
8
src/GlobalManagement/Providers/IUIProvider.cs
Normal file
8
src/GlobalManagement/Providers/IUIProvider.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace Nocturnis.GlobalManagement.Providers;
|
||||||
|
|
||||||
|
public interface IUIProvider
|
||||||
|
{
|
||||||
|
bool Overlap(Vector2 a, Vector2 b, Vector2 c, Vector2 d);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user