jeffcampbellmakesgames / Entitas-Redux

An entity-component framework for Unity with code generation and visual debugging
MIT License
103 stars 13 forks source link

[FEATURE REQUEST] API for adding, replacing components should be extended #8

Open jeffcampbellmakesgames opened 4 years ago

jeffcampbellmakesgames commented 4 years ago

Is your feature request related to a problem? Please describe.

Currently, the API for modifying components on an Entity involves passing all of the properties of that component into a method either adding that component or replacing an existing component.

image

This works alright for components with one or two fields, but after several fields this can be a bit exhausting, particularly if you only want to modify one or two fields.

Describe the solution you'd like

Ideally, there should be a way to be able to modify a subset of a component's fields without needing to call either Add or Replace with the superset of all of that component's fields AND still have the appropriate Events be called for Adding, Replacing, or Removing a component and work with component pooling. There are a couple of options to look into:

For all of these options, their internal implementation would obey the same logic rules for events, pooling and require additional unit tests to verify that.

Describe alternatives you've considered It is possible right now to get an existing component and modify one or two fields directly on it without calling Entity methods for Replacing, but this can only be done in this context and it does not trigger events for the entity's component being updated.

jeffcampbellmakesgames commented 4 years ago

With the addition of blueprints a new component API was added for Entities for Copy_ComponentName_To that enables a developer to copy the members of an existing component to an entity as a new component or a new one or an existing one.

jeffcampbellmakesgames commented 4 years ago

Pulling this off of a milestone for now as some partial progress has been made, but I want to brainstorm this over further to come up with a better defined set of API changes for this.