Skip to main content
11 votes
Accepted

Event handling in Pure Entity Component Systems, is this approach correct?

Merging systems, such as collision and collision response, is a bad idea. The reason being that there can be many different responses to collisions: Physics based, and game-logic based. In most game ...
Ian Young's user avatar
  • 2,679
10 votes
Accepted

Dealing with more complex entities in an ECS architecture

Games typically approach this type of issue using a transformation hierarchy. In this model, each entity can be treated as a "child" of a "parent" entity. The entity's local ...
DMGregory's user avatar
  • 139k
8 votes

Entity Component System: system and components relation

One of the big reasons some ECS proponents favour a strict separation of components and systems is that it helps architect game functionality in a data-oriented style. In the ideal data-oriented flow,...
DMGregory's user avatar
  • 139k
5 votes
Accepted

Should entities auto-register to systems based on their component signature?

TL;DR Entities SHOULD NOT auto-register to systems based on component signatures; prefer instead to explicitly declare component sets/nodes to register your entities to systems that operate on ...
Danny Yaroslavski's user avatar
5 votes
Accepted

Appropriate Cache Friendly Associative Container For An Entity Component System

Do the simplest thing that works, especially early on. If you've ever seen videos of triple-A titles in alpha, you'll know how slow / buggy they are. This is normal; in fact, it's desirable. And it's ...
Engineer's user avatar
  • 30.4k
5 votes
Accepted

How to implement n-body in an Entity Component System

One nice thing about systems in an ECS architecture is that they don't all necessarily need to follow the same structure of ...
Philipp's user avatar
  • 122k
4 votes
Accepted

ECS component dependencies / sharing and cache locality

Reducing cache misses doesn't need to mean getting rid of them entirely, so we do need to be wary of "making the perfect the enemy of the good enough" After all, the absolute worst performance your ...
DMGregory's user avatar
  • 139k
3 votes
Accepted

Implementation details of Command Pattern in conjunction with Entity Component System

How do I populate the execute command if there isn't any logic that "belongs" to an entity? But there is a mechanism for applying logic to an entity: Systems. In ECS, Systems map behavior to ...
Mattia's user avatar
  • 408
3 votes
Accepted

ECS - Components inside components?

First of all, there is no "right" or "wrong" way to structure a game's software architecture. Just ways which work or don't work for you. Usually you wouldn't nest components. What you would do ...
Philipp's user avatar
  • 122k
3 votes

Event handling in Pure Entity Component Systems, is this approach correct?

Your question boils down to Is it a good idea to use a publisher-subscriber-based GUI and to keep this subsystem distinct from my ECS (while enabling interop between them)? Yes, keep your UI and ...
Engineer's user avatar
  • 30.4k
3 votes

Should entities auto-register to systems based on their component signature?

I think you may be overthinking this. The point of ECS is to be simple: An entity is nothing more than an aggregate of components. A system is only interested in a subset of those components. For ...
Ian Young's user avatar
  • 2,679
3 votes

How to Implement ECS Archetypes in C#?

Here is a sketch of how you can implement an archetype in C#: ...
DMGregory's user avatar
  • 139k
2 votes
Accepted

ECS -- Textures and Game Objects

You could have a map in graphicsSystem where the key is the name of the texture file and the value is a reference to the loaded texture object. When adding ...
George Hanna's user avatar
2 votes
Accepted

Entity component system design. Should ID of entities be continuous?

The concern that @philipp mentioned can be eliminated with a bit of fancy bit manipulation. Rather than treat your Entity's ID as a single 32-bit value, split that value into two parts, one which ...
Naros's user avatar
  • 2,022
2 votes
Accepted

Component based architecture in TypeScript

I've got some good suggestions on Phaser forum, the solution shown by user @flyovergames was what I was looking for: ...
Guilherme Recchi Cardozo's user avatar
2 votes
Accepted

C++ structure for component list

Given the constraints (unknown number of components, components can be added or removed at runtime, components have different memory footprints, components derive from the same class), the ...
Peter's user avatar
  • 9,945
2 votes

Entity Component System: system and components relation

My point is: if the Systems are the ones responsible for the actual game logic update (practically speaking, the game logic code is written inside the system), is there a 1:1 relation between ...
sebas's user avatar
  • 490
2 votes

How to handle Entity Initialisation and Destruction

This is one of the common problems with ECS architecture: Intersystem communication. There is no silver bullet solution, and research is ongoing, but common solutions are: Observer patterns. Any ...
Ian Young's user avatar
  • 2,679
2 votes
Accepted

Event-Based Entity-Componenty-System

Entity movement is a great example. In most games, they do not care what triggers the movement, only that entities move in a common and standardized way. So the idea is to design some middle-man ...
Naros's user avatar
  • 2,022
2 votes

Appropriate Cache Friendly Associative Container For An Entity Component System

ArcaneEngineer's advice is good, particularly for early development (to an extent - once you configure your engine to work a particular way, it can be significantly hard to rework it later). For ...
metamorphosis's user avatar
2 votes

Implementations for storing entities in an ECS system

Neither of the three approaches are typical. The first approach could be considered a "naive" approach as it works, but is not very efficient because you'd need to check for every entity if it matches ...
Sander Mertens's user avatar
2 votes

Pass data down to components

Will you have networking? I understand that you are probably making a single player game engine. However, thinking about how to deal with the network very, very, very early in the desgin will push ...
Theraot's user avatar
  • 28k
2 votes
Accepted

Where should I put units and items in a squad-combat ECS-based game?

As a general disclaimer and as DMGregory already stated it: The rules of ECS are not written in stone. Doing it on way has benefits, doing it another way has some others. So, you need to know, what ...
PSquall's user avatar
  • 1,332
2 votes
Accepted

How to Implement ECS Archetypes in C#?

Those Archetypes are IEnumerable<TComponentKind>, where TComponentKind is what you use to identify components. You can, of ...
Theraot's user avatar
  • 28k
1 vote

Event-Based Entity-Componenty-System

As Naro's said, you need a component for every player, that joins a Guild / Party / Alliance to save the information, that they are in that alliance or whatever. But you most likely need a serverside ...
PSquall's user avatar
  • 1,332
1 vote

How does an ECS work for a world subdivided into chunks (example)?

This answer is focused on how I would approach solving the problem instead of a prebaked specific answer. For google reference, the basic ideas are based on broad phase and narrow phase collision ...
Kal_Torak's user avatar
  • 146

Only top scored, non community-wiki answers of a minimum length are eligible