I am using an entity system for my hobby game, specifically the Behaviour / Attribute model discussed in Radical Entertainment's Theory and Practice of Game Object Component Architecture presentation.
Say I am developing a top-down game that has has multiple units (entities) on screen. Each unit can be selected, which outlines the unit with a green box. Think Starcraft, where you can select units and then issue an order.
At the moment I have the classic
RenderBehaviour which simply draws the entity. I now want to add a
SelectableBehaviour. The SelectableBehaviour will have "logic" responsibilities such as ensuring the unit can be selected, deselecting the unit under certain circumstances (death events), etc.
My problem, essentially, is who is responsible for drawing the green outline around the unit when it is selected - the render behaviour, or the selectable behaviour?
I am trying to follow what the presentation says, which is that Behaviours should be very generic in their responsibilities. If possible I do not want to add code into the
RenderBehaviour that says "if entity has selectable behaviour" because now my behaviour is no longer generic - in fact, this exact scenario is mentioned on slide 16 of the presentation (but it just says "don't do it").
I am basically being mindful of mixing "presentation with logic". The only thing I can think of at the moment is to have another behaviour that is responsible for rendering the select box.
I understand there are no hard and fast rules regarding entity systems but I am curious to hear how this can be handled neatly.