Replies: 1 comment 2 replies
-
Hi, sorry for the late reply. Can I ask you what version of EnTT are you using? void copy_value(
entt::storage<write_component>& storage,
const read_component& read,
const entt::entity entity
) { ... } Although the final result is mostly the same. As for the best solution, here you're literaly asking for a matter of tastes since all the proposed ones are just right. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello. I was wanting to hear from others to see what their opinions were on
these different ways to do the same thing.
I apologise if this is not the place to discuss this, or if I am overthinking.
The scenario is performing any function on any entity's components.
The problem is the best way to implement this function, to easily allow for
reusing the same function on different sets of entities.
This has the advantage of being simple.
This has the disadvantage of duplicated code. Forgetting to change one, will
most likely cause a lot of issues. Remembering to change all instances is also
effort that should be solved through code.
This has the advantage of no code duplication.
This has the disadvantage of being slightly less simple for the view,
and not so simple to invoke manually.
Additionally, I need to manually invoke
patch()
ason_update
does nottrigger to the getting on non-const references.
Forgetting to do this might cause issues when I am relying on
on_update
.This has the adventages of being usable on individual entities,
and having the easiest syntax.
This has the disadvantage of a duplication of data, in that both the view and
the function have to keep what components they use in sync. A mistake could
easily be made which means the view no longer matches what the function
needs, or vice versa.
For now, I am using Method 2, but I feel like I am missing some easier way of doing what I want. Easier as in less verbose, and without needing to tell the registry that I have updated a component. It is not too unmanagable, so if there is not anything I am missing then I will continue onwards with this approach.
Passing in the registry and entity only to call
patch()
also seems like overkill, as the components have already been passed in, but the components could be accessed from the registry with the entity directly - which seems redundant.Method 3 passes in minimal information, but mistakes are more likely. A middleground would be nice, but I can not think of what that could be.
Beta Was this translation helpful? Give feedback.
All reactions