murks wrote:Putting the coordinates in a sort of object with other stuff would require either redundancy or I would end up with a OOP-ish thing, the thing I tried to avoid in the first place.
I don't think it's wrong or "OOP-ish" to have tables as components. I think this quote bears repeating,
especially the parenthesized part...
S0lll0s wrote:Also it's not OOP until you put all the methods in there (and ECS and OOP are not mutually exclusive).
Now, there are different ideas about what ECS really means. Some people use a lot of functions or methods attached to components (or maybe the components themselves are methods). This is probably what you mean by "OOP-ish." Others believe that components should not have any functionality, and should just be data; after all, the functionality belongs in the systems, right?
Just because the components should be data, though, doesn't mean they need to be primitive data. They can just as well be tables of things that go together. Do you really want four components for an RGBA value? Would you couch it in a string to avoid a table? There's no advantage to that over using a table.
Here's my personal view on components with functionality versus components with only data; it's just my opinion and you can take it or leave it. In my view an important part of ECS is that
systems focus on components and not on entities, since this is where the decoupling benefits come from.
For the most part, components should only contain data, and systems should process that data, but I think it's useful to make an exception for things that need to happen
to the entity rather than with its components. Any functionality concerned with the entity (for example, adding or removing the entity in the entity list, or adding/removing components) can (and maybe should) be moved into components, so that systems can be strictly component-centric and can work without any knowledge of entities at all.
Incidentally, you might follow that idea to the conclusion that a system's "process" function should actually receive individual components as its arguments instead of an entity, and if you wanted to modify those components,
all primitives would need to be boxed anyway since we have no pass-by-reference for primitives in Lua.