One of the tricky issues I’m sorting out right now is how to handle removing a Component from an Entity. When a component is added to an entity, its values are merged into the entity’s grab-bag type collection of attributes, and the component can perform initialization tasks. Certain components overlap in terms of which attributes they modify, so the process of removing a component isn’t straightforward.
The specific case I have in mind is a Part entity (that is, an object that is part of something else), which is pretty simple to clean up manually if need be (it adds some TAKE
checks and not much else), but there are almost certainly more complex use cases.
Given that not all components need to be removable, the most straightforward approach may be to define an (optional) onRemove function at the Component level, and let each component decide how to handle its own removal. No refactoring required for components that don’t need to support the new behavior.