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.

Required fields*

4
  • Does this answer your question? How to tackle a 'branched' arrow head anti-pattern? Commented Feb 4, 2021 at 10:39
  • 2
    If you can't modify or wrap the components then there's no particularly good solutions. Instanceof it is. If you can modify them, then the visitor pattern would likely be a good solution. Commented Feb 4, 2021 at 10:50
  • 2
    You're right that the visitor makes more sense, but I'd like to point out something else: Components are the central abstraction in ECS (everything depends on a robust set of components). It's not your components that need to be polymorphic, it's the editor views (within the view rendering abstraction). With ECS, there should already be a mechanism that lets you recognize component types, so you can use that as an input to a view-producing factory (create a different view for each component type), data-bind each view to the corresponding component, and just plug it into the GUI framework. Commented Feb 4, 2021 at 12:40
  • 1
    If you are already using a GUI framework of some sort (3rd party or homegrown), you likely already have some base class or an interface that can play the role of IComponent in Philip Kendall's answer (you don't necessarily have to introduce a new interface). Also, note that here, the usage pattern of one view for each component in the same entity is different from the typical ECS scenario where a system handles a bunch of components of the same type, so there is some justification to go outside of the usual ECS paradigm. Commented Feb 4, 2021 at 12:40