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,649
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
  • 135k
8 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
  • 135k
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
  • 30k
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
  • 120k
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
  • 135k
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
  • 30k
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,649
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
  • 120k
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
  • 398
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
  • 135k
2 votes
Accepted

Problem in nested parent-entity relationship in ecs

The relationship between the Gun and the Bullet is purely 'spawner/spawned'. It's not parent-child. In real-life, when you ...
Vaillancourt's user avatar
  • 16.3k
2 votes

Different objects interacting based on type

Okay, disclaimer: this has gone completely overkill. But it was a lot of fun to put together! The end product looks like this: ...
Quentin's user avatar
  • 1,178
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,935
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

Entity System and "composite" entities

You are possibly conflating two separate things. I'll explain them below, but first I'll strongly note that you should spend some time playing around with existing game engines and get a sense for how ...
Sean Middleditch's user avatar
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,649
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
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

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
  • 27.2k
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
  • 27.2k

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