Data-oriented ECS possible in Defold?

First, here’s what I mean by data-oriented ECS (entity component system):

  • Components: Pure data holders. No logic.
  • Systems: Operate on components, modifying data. No data nor state in themselves.
  • Events: Used for system-to-system communication.

Defold uses a similar ECS approach, but the components both hold data and have logic. I’m looking into the ECS approach described above.

Is this possible, or would it interfere with Defold’s architecture too much to cause problems?

3 Likes

In that case I would use Lua-modules as components that can be required by scripts that would modify the data in them. The scripts would be systems that communicate with messages (Events)

Thank you!

Yeah. In that case, I would lose the handy component property editor, where you can set values a component exposes, right?

It would probably be possible to build such a system on top of Defold, and it might be a fun exercise in learning the ins and outs of the engine, but I must say I’m a bit sceptical. I think what Defold provides is in many ways similar to the system you describe:

Components - The Game Objects themselves, along with attached components such as sprites, sound, particle effects and so on
Systems - The scripts and Lua modules
Events - In the Defold world this would correspond to the message passing (using msg.post)

3 Likes

I’m coming actually with the same question and I know the answer is basically yes, but I wonder how to do it practically.

In my project I try to separate data from logic and use events as much as possible. But I also incorporate state machine, which handles some of the logic and have some data and there are also other smaller things that are missing the point of ECS - so I wanted to untangle the spaghetti code parts and make some easily digesting dishes out of it - separated and logical, with possibility to maintain a whole bunch of already developed features of a very big game (you know which one :smiley: ). Maybe you have some suggestions worth noting down? :wink:

P.S. There is inter alia this awesome talk: Understanding data-oriented design for entity component systems - Unity at GDC 2019 - YouTube

One of the basis I was investigating was this 4yo example: https://github.com/britzl/lowrezadventure - I know it was rather untouched, but what do you guys think about it today?

I’ve since switched to a different and very straightforward approach. I just have components (data) and functions (logic) that operate on the components and other arbitrary data that’s required. That’s all.

4 Likes