Github https://github.com/Winteradio/ECS-with-Scene-and-Node
Github https://github.com/Winteradio/Log
Github https://github.com/Winteradio/MemoryPool
Summary
- Rebuilding ECS (Entity Component System)
🛠️ Technology Stack and Libraries
- Language
- Libraries
- Log Project
- Memory Project
- Rpc (UUID)
📝 Concept Explanation
What is ECS (Entity Component System)?
- A DOTS-based system under development in Unity.
- DOTS vs OOP
- What is DOTS?
- Data-Oriented Technology Stack.
- A data-centric programming approach.
- How is it different from OOP?
- Data-centric
- Focuses on optimizing performance and accessing data directly.
- Continuous memory accessibility
- Unlike OOP objects, stores data of the same type in contiguous memory.
- Optimizes memory access patterns to increase cache hit probability.
- Ease of parallel processing
- Allows independent construction of methods (or systems) for different data types.
- Systems operate on data, not objects (entities), enabling separation of objects and systems.
- Entity Component System (ECS)
- What is an Entity?
- An abstraction representing individual objects such as game objects or characters.
- Serves as a simple identifier (naming) and does not directly hold data.
- Example:
- Entity ID: "John Doe"
- "Abilities" Component - "John Doe"
- "Skills" Component - "John Doe"
- "Weapon" Component - "John Doe"
- In this example, the Entity serves as an identifier for the components.
- What is a Component?
- Represents actual data used by entities.
- Identified by Entity ID when attached to an entity.
- Components of the same type should be stored in contiguous memory.
- What is a System?
- Logic that processes and manipulates components.
- Each system has access rights to the components it requires.
- Systems can be processed in parallel, but dependencies between them must be considered.
- Example:
- System: "Render"
- System: "Move"
Types of ECS: Sparse Set vs. Archetype
- Sparse Set
- A method of linking Entity IDs with each component.
- Uses a Dense Set to store Entity IDs and a Sparse Set for components.
- Allows rapid access to components in contiguous memory using the Entity ID.
- Related Site: Entt Library on Github
- Archetype
- Groups of entities with similar component compositions.
- Each archetype has a unique component composition.
- Unlike Sparse Set, it doesn't store components in contiguous memory but stores similar types of archetypes in contiguous memory.
- Related Site: Unity's ECS Archetype
Why Implement ECS in C++, an OOP Language?
- Understanding Game Engine Structure
- Need for a continuously usable library.
- Lack of understanding of how the engine's internals work.
- How project files are structured.
- How play, pause, and building within the engine work.
- Whether the engine and the game are developed separately.
- Difficulty in implementing information from UML diagrams of other engines.
- Implementation of Independent Systems
- Need for a basic engine to implement functionality like collision and fluid simulation.
- Different Approach to ECS
- Issues with Sparse Set:
- Limited to accessing only one component via the Entity ID.
- Not all systems can use just one component.
- Issues with Archetype:
- Even if you want to add just one or two components to a specific archetype, you need to create a new archetype by duplicating data.
- Example:
- When you want to create objects that emit light and render, you need a new "Light Render Archetype."
- This would require duplicating the required components and removing them from the existing archetype.
- Introduction of the "Node" Concept
📝 Development Details