Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • Systems can't act on isolate components because they may require more than one component to register an entity. Indices are necessary if I want to keep the components in contiguous memory. Pointers don't work because of possible reallocations and references don't allow for a common interface. The user doesn't need to know about the implementation, a Mapper class is responsible for retrieving the appropriate component by accessing the entity. Commented Aug 27, 2014 at 18:41
  • @veritas - Systems can act on bundles of components then. If your components aren't somewhat isolated, then I question using that architecture. Having pointers (or references) to locations in an array is totally viable - even if it makes re-sizing the things a complete mess. Commented Aug 27, 2014 at 18:45
  • @Telastyn I've run into two cases where systems need access to the entity being processed and not just its components. A system might need to add a component to an entity, or remove one. It might also need to check if an entity is the same as the one being processed; for example imagine a system where you need to find the nearest entity to the entity being processed (that could probably be handled with some kind of "identity" component, but using the identity of the entity itself seems more straightforward). Commented Nov 26, 2014 at 8:21
  • @hey - I suppose, but changing the components at runtime seems like setting yourself up for failure (and debugging pain). In the second scenario, I would expect that component doing the check to reference itself, not its owner - or to have the entity ID passed in. Commented Nov 26, 2014 at 12:37
  • @Telastyn good point about the second case, the system could just check if two "position" components have the same identity. For the first case, the ability to change components on the fly is one of the things about this pattern that appeals to me. Maybe I'm abusing the pattern by doing this, but I assumed the OP here was doing the same: "Systems are responsible for the actually modifying the entities by changing their components." But maybe this means changing the properties of components, not changing which components an entity is composed of. I might write up a question about that later. Commented Nov 26, 2014 at 20:40