feat: indexed fields multi-add api #255
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Indexed fields introduces "association by value" which means that when you add a component to an entity it no longer is associated by its type alone. Instead components are now associated by their indexed field values.
Give the above example we have a component called
AssociatedWithA
that has an indexed field calledhello
. An entity may addAssociatedWithA
like normal, however, if the value ofhello
is different then the component is effectively a different component.This adds a wrinkle with
remove_component
,update_component
, andhas_component
. We no longer have the ability to specify whichAssociatedWithA
component to update or remove. This PR introduces slight tweaks to ourremove_component
andupdate_component
methods requiring you to pass in the indexed fields values.These of course translate to the
context
methods as well.You can also update an indexed field as well. Very similar to the remove example above.
It's worth noting that you cannot call
has
,get
,update
, orremove
without also giving the indexed fields. Doing so is considered user error, but our C++ (and other language) wrappers are designed to prevent these mistakes from happening.