-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relationships #79
Comments
Hi @Ziboo, Generally speaking, entities shouldn't directly relate to each other directly. One specific entity shouldn't be tagged directly to any other specific entity. If you have a case where all the type A entities need to interact with all the type B entities, you can usually push this logic up to the Processor. You can also use single Components to "tag" entities. What is the type of behavior that you're trying to accomplish? |
Hi I need to be able to link a Plants to a specific Farm. I can have multiple Farms. I think the simplest example where relationship are useful is Inventory for instance. Right now for my exemple above I'm storing the Farm entity id on the plant component for filtering later but it's not ideal
|
As I understand it, Farm should be entity here, not the Component. The question is, why do you want it to be Component in the first place. Regardless, I have similar question, so will just post it here as another example. Is making Target Component owning entity as attribute fine? This seems to violate a bit what was written here, about making pure Components. @benmoran56 |
Probably I've found some answers here: https://ajmmertens.medium.com/building-games-in-ecs-with-entity-relationships-657275ba2c6c |
@gretkierewicz Sorry I missed your messages. I only briefly looked at that blog post, but I do use the concept of a |
Yeah I'm using that for now too, but I think when my project will grow I'll implement relationship feature anyway. If so, I'll create pull request with it as well |
Closing this for now, as there isn't really a single recomended method. However, using a "Target" style of Component seems reasonable enough. |
I made some tests using a |
Hello,
Do you have any best practices to create relationships between entities ?
For instance I have a Farm component and a Plant Component
Not sure what would be the best things to do...
A list of Plants or Entity Ids on the Farm class ?
Thanks a lot !
The text was updated successfully, but these errors were encountered: