Upgrade structure of code base

This commit is contained in:
h z
2024-07-03 12:20:08 +08:00
parent d382481cd4
commit 42e06a0d0c
82 changed files with 864 additions and 116 deletions

View 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;
}

View 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; }
}

View 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;
}

View 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;
}
}

View 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; }
}

View 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);
}

View 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);
}

View 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>();
}

View 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);
}

View File

@@ -0,0 +1,10 @@
using Godot;
using Nocturnis.Scenes;
namespace Nocturnis.GlobalManagement.Providers;
public interface ISceneProvider
{
IRootScene RootScene { get; set; }
PackedScene AssetMapper<T>();
}

View File

@@ -0,0 +1,8 @@
using Godot;
namespace Nocturnis.GlobalManagement.Providers;
public interface IUIProvider
{
bool Overlap(Vector2 a, Vector2 b, Vector2 c, Vector2 d);
}