top | item 29641731

(no title)

ncake | 4 years ago

Unpopular opinion, but I personally think ECS has no place in C/C++ game dev. Every supposed advantage is either curbed by limitations of the language (e.g. serialization) or can be implemented more logically in a stateless manner.

discuss

order

jayd16|4 years ago

In some ways ECS could be considered stateless, as the entity holds the game state as raw data, while the system operates on that data without holding a state of its own.

How would you implement ECS, a system for tracking the state of game entities, in a stateless manner? Can you expand on that?

ncake|4 years ago

I'll try to explain what I mean. Suppose you want an in game character to change the displayed weapon in their inventory.

Stateful way: your Inventory Manager component iterates through its private array of item entities to mark their model components as shown or hidden, then calls the dependency injected character's avatar component to update its animation state.

Stateless way: you flip an integer in character's struct, and the rendering function does something different.

BoorishBears|4 years ago

I can't even imagine game dev without ECS. There's more performant architectures but it's such a useful mental model for the type of rapid iteration games need that so many people are willing to put up with the drawbacks

verdagon|4 years ago

What are some of the more performant architectures?