bracket system

This commit is contained in:
h z
2024-07-29 17:24:31 +01:00
parent 5fbbbe83a1
commit bae0a52e3f
36 changed files with 258 additions and 36 deletions

View File

@@ -16,6 +16,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="src\Configs\" />
<Folder Include="src\Enigmos\Modules\SubModules\" /> <Folder Include="src\Enigmos\Modules\SubModules\" />
<Folder Include="src\GlobalManagement\" /> <Folder Include="src\GlobalManagement\" />
</ItemGroup> </ItemGroup>

View File

@@ -6,7 +6,7 @@ using Nocturnis.Enigmos.Modules;
namespace Nocturnis.Communicators; namespace Nocturnis.Communicators;
public interface IBaseCommunicator public interface IBaseCommunicator : IControlNode
{ {
ICommunicateModule PairedModule { get; set; } ICommunicateModule PairedModule { get; set; }
DataVariable DataBuffer { get; set; } DataVariable DataBuffer { get; set; }

View File

@@ -5,6 +5,6 @@ namespace Nocturnis.Creatures.Characters;
public interface IPlayerCharacter : IBaseCharacter public interface IPlayerCharacter : IBaseCharacter
{ {
IDashboardTab DashboardTab { get; set; } IDashboardTab CurrentDashboardTab { get; set; }
IPrimaryBoard MotherBoard { get; set; } IPrimaryModuleBoard MotherBoard { get; set; }
} }

View File

@@ -0,0 +1,8 @@
using Nocturnis.Communicators;
namespace Nocturnis.Dashboards;
public interface IDashboard : INodeInterface
{
HashSet<IBaseCommunicator> Communicators { get; set; }
}

View File

@@ -33,55 +33,55 @@ public class DataVariable
public object Data { get; set; } public object Data { get; set; }
public DataType Type { get; set; } public DataType Type { get; set; }
//StringName? Type { get; set; } //StringName? Type { get; set; }
int Int public virtual int Int
{ {
get => (int)Data; get => (int)Data;
set => Data = value; set => Data = value;
} }
public double Real public virtual double Real
{ {
get => (double)Data; get => (double)Data;
set => Data = value; set => Data = value;
} }
public Complex Complex public virtual Complex Complex
{ {
get => (Complex)Data; get => (Complex)Data;
set => Data = value; set => Data = value;
} }
public DataVariable[] Array public virtual DataVariable[] Array
{ {
get => Data as DataVariable[]; get => Data as DataVariable[];
set => Data = value; set => Data = value;
} }
public R2 R2 public virtual R2 R2
{ {
get => Data as R2; get => Data as R2;
set => Data = value; set => Data = value;
} }
public C2 C2 public virtual C2 C2
{ {
get => Data as C2; get => Data as C2;
set => Data = value; set => Data = value;
} }
public bool Bit public virtual bool Bit
{ {
get => (bool)Data; get => (bool)Data;
set => Data = value; set => Data = value;
} }
public string String public virtual string String
{ {
get => Data as string; get => Data as string;
set => Data = value; set => Data = value;
} }
public Dictionary<StringName, DataVariable> Struct public virtual Dictionary<StringName, DataVariable> Struct
{ {
get => Data as Dictionary<StringName, DataVariable>; get => Data as Dictionary<StringName, DataVariable>;
set => Data = value; set => Data = value;

View File

@@ -0,0 +1,22 @@
using System.Numerics;
using Godot;
using Skeleton.Algebra;
using Skeleton.Algebra.DimensionProviders;
namespace Nocturnis.DataStructures.Data;
using R2 = CategoryOf<IDim2>.OnField<double>.FVector;
using C2 = CategoryOf<IDim2>.OnField<Complex>.FVector;
public class DefaultDataConst : DataVariable
{
public static DefaultDataConst Const = new();
public override int Int => 0;
public override double Real => 0;
public override Complex Complex => 0;
public override DataVariable[] Array => [];
public override R2 R2 => new ();
public override C2 C2 => new ();
public override bool Bit => false;
public override string String => "";
public override Dictionary<StringName, DataVariable> Struct => new();
}

View File

@@ -10,7 +10,12 @@ namespace Nocturnis.DataStructures;
public class DataCache : CacheItem<DataVariable> public class DataCache : CacheItem<DataVariable>
{ {
public new static DataCache Null => new (x => (null, DataTypeConstant.BaseDataTypes.Null)); public new static DataCache Null => new (x => (null, DataTypeConstant.BaseDataTypes.Null));
public DataCache(Func<CacheItem, DataVariable> rec) : base(rec) => throw new Exception("CONSTRUCTION NOT ALLOWED");
public DataCache(Func<CacheItem, DataVariable> rec)
{
Value = new DataVariable();
ProxyCalculator = c => (rec(c).Data, rec(c).Type);
}
public DataCache(Func<CacheItem, (object, DataType)> rec) public DataCache(Func<CacheItem, (object, DataType)> rec)
{ {

View File

@@ -0,0 +1,25 @@
using Nocturnis.DataStructures.Data;
using Nocturnis.DataStructures.DataTypes;
using Skeleton.DataStructure;
namespace Nocturnis.DataStructures;
public class DefaultDataCache : DataCache
{
public static readonly DefaultDataCache Default = new DefaultDataCache();
public DefaultDataCache() : base(cache => new DataVariable())
{
}
public override DataVariable Get => DefaultDataConst.Const;
public DefaultDataCache(Func<CacheItem, DataVariable> rec) : base(rec)
{
}
public DefaultDataCache(Func<CacheItem, (object, DataType)> rec) : base(rec)
{
}
}

View File

@@ -1,9 +0,0 @@
using Nocturnis.Enigmos.Modules;
namespace Nocturnis.Enigmos.Boards;
public interface IPrimaryBoard : IBaseBoard
{
IEngineModule Engine { get; set; }
IRootModule Root { get; set; }
}

View File

@@ -0,0 +1,14 @@
using Nocturnis.Creatures;
using Nocturnis.Creatures.Characters;
using Nocturnis.Enigmos.Modules;
namespace Nocturnis.Enigmos.Boards;
public interface IPrimaryModuleBoard : IBaseBoard
{
IEngineModule Engine { get; set; }
IRootModule Root { get; set; }
double IdlePower { get; }
void Init(IBaseCreature player);
void Start();
}

View File

@@ -56,7 +56,7 @@ public static class ECommunicateModule
} }
public static IBaseCommunicator[] CompatibleCommunicators(this ICommunicateModule module) => public static IBaseCommunicator[] CompatibleCommunicators(this ICommunicateModule module) =>
CreatureControl.Instance.CurrentCharacter!.DashboardTab.AllCommunicators CreatureControl.Instance.CurrentCharacter!.CurrentDashboardTab.AllCommunicators
.Where(module.IsMatch) .Where(module.IsMatch)
.ToArray(); .ToArray();
} }

View File

@@ -1,9 +1,19 @@
using Nocturnis.Enigmos.Ports.DataPorts.Directions;
namespace Nocturnis.Enigmos.Modules; namespace Nocturnis.Enigmos.Modules;
public static class ETerminalModule public static class ETerminalModule
{ {
public static void Consume(this ITerminalModule m) public static void Consume(this ITerminalModule m)
{ {
foreach (IDataInPort p in m.Ports.OfType<IDataInPort>())
{
if (!p.Connected)
{
m.Finished = true;
return;
}
}
m.Drain(); m.Drain();
m.Finished = true; m.Finished = true;
} }

View File

@@ -5,5 +5,5 @@ namespace Nocturnis.Enigmos.Ports.DataPorts.Directions;
public interface IDataInPort : IDataPort public interface IDataInPort : IDataPort
{ {
DataCache GetData { get; } DataCache GetData { get; }
new IDataOutPort? ConnectedPort { get; set; } new IDataOutPort ConnectedPort { get; set; }
} }

View File

@@ -8,9 +8,9 @@ public interface IBasePort
{ {
Vector2 PositionToBoard { get; } Vector2 PositionToBoard { get; }
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();
void SetStatusNormal(); void SetStatusNormal();
void SetStatusPending(); void SetStatusPending();

View File

@@ -5,7 +5,7 @@ namespace Nocturnis.Enigmos.Ports.SignalPorts.Directions;
public interface ISignalOutPort : ISignalPort public interface ISignalOutPort : ISignalPort
{ {
new IRoutingModule Module { get; set; } new IRoutingModule Module { get; set; }
new ISignalInPort? ConnectedPort { get; set; } new ISignalInPort ConnectedPort { get; set; }
void Route(); void Route();
} }

View File

@@ -19,5 +19,5 @@ public class CreatureControl
{ {
} }
public IPlayerCharacter? CurrentCharacter { get; set; } public IPlayerCharacter CurrentCharacter { get; set; }
} }

View File

@@ -24,14 +24,22 @@ public class EnigmosControl
public void ShutDownEngine() public void ShutDownEngine()
{ {
GlobalProvider.SceneProvider.RootScene.EngineSwitch.TextureNormal =
GlobalProvider.TextureProvider.EngineSwitchOff;
EngineUp = false; EngineUp = false;
} }
public void PowerUpEngine() public void PowerUpEngine()
{ {
CreatureControl.Instance.CurrentCharacter.MotherBoard.Reset();
GlobalProvider.SceneProvider.RootScene.EngineSwitch.TextureNormal =
GlobalProvider.TextureProvider.EngineSwitchOn;
EngineUp = true; EngineUp = true;
} }
public double Energy { get; set; } = 0d; public double Energy { get; set; } = 0d;
public bool EngineUp { get; private set; } public bool EngineUp { get; private set; }
public double IdlePower => CreatureControl.Instance.CurrentCharacter.MotherBoard.IdlePower + VoidPower;
public double VoidPower { get; set; } = 0;
} }

View File

@@ -14,6 +14,7 @@ public static class GlobalProvider
public static IPolymorphismProvider PolymorphismProvider { get; set; } public static IPolymorphismProvider PolymorphismProvider { get; set; }
public static IDataTypeProvider DataTypeProvider { get; set; } public static IDataTypeProvider DataTypeProvider { get; set; }
public static IProcessProvider ProcessProvider { get; set; } public static IProcessProvider ProcessProvider { get; set; }
public static ITextureProvider TextureProvider { get; set; }
public static class ModulePreviewMapper<TModule> public static class ModulePreviewMapper<TModule>
where TModule : IBaseModule where TModule : IBaseModule

View File

@@ -4,5 +4,6 @@ namespace Nocturnis.GlobalManagement.Providers;
public interface ISceneProvider public interface ISceneProvider
{ {
IRootScene? RootScene { get; set; } IRootScene RootScene { get; set; }
} }

View File

@@ -6,6 +6,8 @@ namespace Nocturnis.GlobalManagement.Providers;
public interface ITextureProvider public interface ITextureProvider
{ {
Texture2D ModuleTextureMapper(IBaseModule module); Texture2D EngineSwitchOn { get; set; }
Texture2D ItemTextureMapper(IBaseItem item); Texture2D EngineSwitchOff { get; set; }
} Texture2D LEDOn { get; set; }
Texture2D LEDOff { get; set; }
}

View File

@@ -0,0 +1,14 @@
using Skeleton.DataStructure.Tree;
namespace Nocturnis.Hermeteus;
public interface IBracketChapter : IBracketRouter
{
IBracketStory Story { get; set; }
string State { get; set; }
bool Finished { get; set; }
string Chapter { get; set; }
IBracketTopic CurrentTopic { get; set; }
HashSet<IBracketTopic> Children { get; set; }
HashSet<ICondition> Conditions { get; set; }
}

View File

@@ -0,0 +1,6 @@
namespace Nocturnis.Hermeteus;
public interface IBracketRouter
{
IBracketRouter Route();
}

View File

@@ -0,0 +1,9 @@
using Skeleton.DataStructure.Tree;
namespace Nocturnis.Hermeteus;
public interface IBracketStory : IBracketRouter
{
IBracketChapter CurrentChapter { get; set; }
IBracketChapter[] Children { get; set; }
}

View File

@@ -0,0 +1,17 @@
using Godot;
namespace Nocturnis.Hermeteus;
public interface IBracketTalk : IBracketRouter
{
IBracketTopic Topic { get; set; }
string TriggerStatus { get; set; }
string EnterStatus { get; set; }
double TriggerEsc { get; set; }
bool CleanPrevious { get; set; }
string[] BraLines { get; set; }
string[] KetLines { get; set; }
HashSet<ICondition> Conditions { get; set; }
Vector2[] ArrowMarkers { get; set; }
bool Finished { get; set; }
}

View File

@@ -0,0 +1,13 @@
using Skeleton.DataStructure.Tree;
namespace Nocturnis.Hermeteus;
public interface IBracketTopic : IBracketRouter
{
IBracketChapter Chapter { get; set; }
string Topic { get; set; }
bool Finished { get; set; }
HashSet<IBracketTalk> Children { get; set; }
IBracketTalk CurrentTalk { get; set; }
HashSet<ICondition> Conditions { get; set; }
}

View File

@@ -0,0 +1,6 @@
namespace Nocturnis.Hermeteus;
public interface ICondition
{
Func<bool> Check { get; set; }
}

View File

@@ -0,0 +1,16 @@
using Nocturnis.UIElements;
namespace Nocturnis.Hermeteus.Processors;
public interface IBracketProcessor
{
IInstructionHint Bra { get; }
IInstructionHint Ket { get; }
void BraCallback();
void KetCallback();
bool BraFinished { get; set; }
bool KetFinished { get; set; }
double BracketEsc { get; set; }
string Status { get; set; }
void Process(double delta);
}

9
src/IControlNode.cs Normal file
View File

@@ -0,0 +1,9 @@
using Godot;
namespace Nocturnis;
public interface IControlNode : INodeInterface
{
Vector2 Position { get; set; }
Vector2 Size { get; set; }
}

View File

@@ -4,5 +4,7 @@ namespace Nocturnis;
public interface INodeInterface public interface INodeInterface
{ {
void RemoveChild(Node node);
} void AddChild(Node node, bool forceReadableName = false, Node.InternalMode @internal = (Node.InternalMode)(0));
bool Visible { get; set; }
}

View File

@@ -4,5 +4,5 @@ namespace Nocturnis.Inventories.ItemSlots.ItemSlots;
public interface IChemicalItemSlot public interface IChemicalItemSlot
{ {
IBaseChemicalItem? Item { get; set; } IBaseChemicalItem Item { get; set; }
} }

View File

@@ -1,5 +1,6 @@
using Godot; using Godot;
using Nocturnis.UIElements; using Nocturnis.UIElements;
using Nocturnis.UIElements.Layers;
namespace Nocturnis.Scenes; namespace Nocturnis.Scenes;
@@ -7,4 +8,8 @@ public interface IRootScene
{ {
void ChangeScene(Node scene); void ChangeScene(Node scene);
IKeyListener KeyListener { get; set; } IKeyListener KeyListener { get; set; }
TextureButton EngineSwitch { get; set; }
IWindowLayer WindowLayer { get; set; }
IInstructionHint Bra { get; set; }
IInstructionHint Ket { get; set; }
} }

View File

@@ -0,0 +1,9 @@
using Godot;
using Nocturnis.UIElements.Layers;
namespace Nocturnis.Scenes.Worlds;
public interface IWorld : INodeInterface
{
IDashboardLayer DashboardLayer { get; set; }
}

View File

@@ -1,8 +1,12 @@
using Nocturnis.Communicators; using Nocturnis.Communicators;
using Nocturnis.Dashboards;
namespace Nocturnis.UIElements; namespace Nocturnis.UIElements;
public interface IDashboardTab public interface IDashboardTab : INodeInterface
{ {
IEnumerable<IBaseCommunicator> AllCommunicators { get; } IEnumerable<IBaseCommunicator> AllCommunicators { get; }
void Init();
void AddDashboard(IDashboard dashboard);
bool[] Used { get; set; }
} }

View File

@@ -0,0 +1,9 @@
namespace Nocturnis.UIElements;
public interface IInstructionHint : INodeInterface
{
void Load(string content);
void Load(string content, Action callBack);
void Clean();
void Clean(Action callBack);
}

View File

@@ -0,0 +1,9 @@
using Godot;
namespace Nocturnis.UIElements.Layers;
public interface IDashboardLayer : INodeInterface
{
IDashboardTab DashboardTab { get; set; }
}

View File

@@ -0,0 +1,6 @@
namespace Nocturnis.UIElements.Layers;
public interface IWindowLayer : INodeInterface
{
}