Upgrade structure of code base
This commit is contained in:
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