I've just recently started working with LibGDX and Ashley, and I find it to be really useful and I like working with the whole entity/component/system workflow. But I've been starting to layout the GUI and other aspects of the interface that dont exactly, to me, seem like they should be entities.

When using an ECS should EVERYTHING in your game be an entity with components/a system to control them?

  • \$\begingroup\$ We get these questions from time to time, and it's important to realize that ECS is just one tool available to you as a developer. If you like working with it and it's helping you solve problems effectively, you can use it for just about everything. If you find it's really not fitting your needs and style for a particular aspect of your project, you can use something else for that bit. No ECS purity police will ban you from selling your game. \$\endgroup\$ – DMGregory May 30 '18 at 11:04

Yes, all game objects should be entities with an appropriate component set, and each component should have a system that controls it.

The whole idea of ECS architecture is compartmentalisation of tasks, and to favour composition over inheritance(google that phrase).

The benefit of this is you do not need a whole load of derived game objects which may or may not have an API that you do not wish to use, and completely avoids the inheritance based "deadly diamond" problem. This makes the architecture extremely flexible, and keeps the entity class extremely simple.

Furthermore, if you wish to create say, UI entities, then you can simply create them with a different component set, which has no relevance to the game world, but is of interest to the graphics and input systems.

I could go on and on about the benefits of this design philosophy, which would turn this answer into a wall of text, so I will stop here and say to check this link, which will give you some more general information about the pattern, including it's drawbacks.

  • \$\begingroup\$ Thank you, that makes sense! I appreciate the further reading. \$\endgroup\$ – Kynian May 31 '18 at 3:55
  • \$\begingroup\$ @Kynian No problem at all. As some side advice, I would recommend not getting tied down to a particular architecture in your head. Polymorphic architectures have their benefits (and drawbacks) too, and if you experiment with both, it will help you be a better programmer, and allow you to understand software architecture in a broader sense. And as DMGregory correctly said in his comment, nobody will enforce ECS purism on you, so feel free to experiment with hybrid architectures and choose what works for you. \$\endgroup\$ – Ian Young May 31 '18 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.