From 161a166141e98592c85b01d5c1d541102a45bae0 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 7 Sep 2025 09:54:18 +0200 Subject: [PATCH] continuation of implementing ECS --- src/EngineSharp.Core/EngineSharp.Core/ECS/Entity.cs | 11 +++++++++++ .../EngineSharp.Core/ECS/GameObject.cs | 12 ------------ .../EngineSharp.Core/ECS/LogicComponent.cs | 11 +++++++++++ 3 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 src/EngineSharp.Core/EngineSharp.Core/ECS/Entity.cs delete mode 100644 src/EngineSharp.Core/EngineSharp.Core/ECS/GameObject.cs create mode 100644 src/EngineSharp.Core/EngineSharp.Core/ECS/LogicComponent.cs diff --git a/src/EngineSharp.Core/EngineSharp.Core/ECS/Entity.cs b/src/EngineSharp.Core/EngineSharp.Core/ECS/Entity.cs new file mode 100644 index 0000000..3d12846 --- /dev/null +++ b/src/EngineSharp.Core/EngineSharp.Core/ECS/Entity.cs @@ -0,0 +1,11 @@ +namespace EngineSharp.Core.ECS; + +// Maybe look at this C# ECS to get an idea of how to implement one myself +// https://github.com/friflo/Friflo.Engine.ECS/tree/main + +public struct Entity +{ + public readonly long Id; + + private List _logicComponents; +} \ No newline at end of file diff --git a/src/EngineSharp.Core/EngineSharp.Core/ECS/GameObject.cs b/src/EngineSharp.Core/EngineSharp.Core/ECS/GameObject.cs deleted file mode 100644 index b8dfa71..0000000 --- a/src/EngineSharp.Core/EngineSharp.Core/ECS/GameObject.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace EngineSharp.Core.ECS; - -// TODO: A GameObject would have a list of Components. A GameObject is basically what will be stored in the scene graph and all components of all GameObjects will have their Update methods etc. be called - -// Maybe look at this C# ECS to get an idea of how to implement one myself -// https://github.com/friflo/Friflo.Engine.ECS/tree/main -public abstract class GameObject -{ - private long Id { get; set; } - - public abstract void OnUpdate(double deltaTime); -} \ No newline at end of file diff --git a/src/EngineSharp.Core/EngineSharp.Core/ECS/LogicComponent.cs b/src/EngineSharp.Core/EngineSharp.Core/ECS/LogicComponent.cs new file mode 100644 index 0000000..7439bde --- /dev/null +++ b/src/EngineSharp.Core/EngineSharp.Core/ECS/LogicComponent.cs @@ -0,0 +1,11 @@ +namespace EngineSharp.Core.ECS; + +// TODO: A LogicComponent would have a list of Components. A LogicComponent is basically what will be stored in the scene graph and all components of all LogicComponents will have their Update methods etc. be called + +public abstract class LogicComponent +{ + internal Entity _entity; // the entity this component belongs to + + public abstract void Start(); + public abstract void OnUpdate(double deltaTime); +} \ No newline at end of file