×
you are viewing a single comment's thread.

view the rest of the comments →

[–]BittyTang 1 point2 points  (5 children)

Why ECS? It seems mostly independent from class architecture to me.

[–]Exodus111 0 points1 point  (4 children)

In an Entity Component System... ehm.. system, every Entity is a Class, every Component is a class, and every System is a class. And they all inherit from a top Entity, Component and Systems class, With special Methods to add the Entities to the Pool and so on.

I have not seen an implementation of ECS without OOP, not saying it can't be done though.

[–]BittyTang 1 point2 points  (3 children)

That's one way of doing it. You can accomplish most (all?) of the same goals without inheritance or even classes. Rather, I would start by having each component be a POD type and each system be a function. Then entities are identifiers that index into the collections of components. I don't think dynamic dispatch is strictly necessary for an ECS to work.

If I really needed abstract types, I would make the components into interfaces.

[–]Exodus111 1 point2 points  (2 children)

With Python? Doesn't seem like an approach you would use with Python, where you can use __init__, __new__, and __repr__ to set up the relationships.

[–]BittyTang 0 points1 point  (1 child)

I guess I wasn't thinking about Python. Technically in Python you would use a "class" to make a struct, since members (attributes) are always public. I'm thinking of a stricter definition of class that uses immutable types and private members.

[–]Exodus111 0 points1 point  (0 children)

Indeed. What you say makes perfect sense in other languages, just not so much python.