Use composition instead of inheritance for Entities #17
Labels
No labels
bug
improvement
needs testing
new feature
pondering
priority
high
priority
low
priority
normal
priority
shelved
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nexustix/godot-nexustix-utilities#17
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
It is unclear if this is going to be worth it. Since Entities are plain data objects most of the Node based approaches won't work properly. Using nodes would require to declare a bunch of "Data Scenes" and that might be a silly idea.
The idea is that Entities should be mostly plain data with utility functions, so inheritance should work well enough for now.
If composition is to be used there needs to be a cleaner way to check for a "has a" relationship, and so far none has been discovered.
There is an option for a blind approach using
"best_component" in Entitychecks. That would require calling code to be aware of all viable components ahead of time, and necessitate the components to always be registered under the same name.This may be viable and worth a try, since it would stay reasonably clean from a data point of view. And clean structuring with consistent naming scheme would be desirable anyway.
It needs to be decided what to do if an Entity needs more than one of a component; should lists be used?
@nexustix wrote in #17 (comment):
Attempted implementation of Inventory and Item using this approach:
489f866cf8The current approach has been refined a bit
7df1509936. Things seem to be in a good enough place to put a pin into this for now, and check if i gather new insights when consuming them in an actual project.