0
\$\begingroup\$

I have a background in ECS by using C# Entitas. The library itself has a very nice feature which lets me able to query the entity with a specific value in the component.

For example, query an entity with the player component which has an id equal to 1.

However today I need to working on JS Ecsy ECS framework, And there is no way I could query the specific entity by providing a value I want.

What I could do is just iterate through all entities with a player component and filter out all player which isn't equal to 1.

So I want to know how to deal with this kind of query.

\$\endgroup\$
7
  • \$\begingroup\$ There are a few issues here: most of us don't know how Entitas works, so the amount of users being able to help you with it will be quite limited; you do not describe the current architecture you’re working with, nor which language you use. Also you seem to have though of a solution to the issue. Please keep in mind that there is no ECS police that will fine you if you don’t do it the right way, as there is not only one way to get things done. I suggest you try what you thought of, and then come back to us and tell us what issues there is with this approach and the outcome you’d like instead. \$\endgroup\$
    – Vaillancourt
    Commented Nov 11, 2021 at 13:30
  • \$\begingroup\$ Thanks for the comment. I've edited the question, Hope it's clearer. I'm still in the explore phase on what tech stack should be used, So I still have not encountered the actual problem yet. But it's the common use case in the past project I've done. \$\endgroup\$
    – kitta
    Commented Nov 11, 2021 at 14:10
  • \$\begingroup\$ Why exactly do you need to find this specific entity? Dealing with specific entities seems somewhat against the general ECS idea of performing general actions against components inside systems. \$\endgroup\$
    – user35344
    Commented Nov 11, 2021 at 15:32
  • \$\begingroup\$ I still can't see how we could avoid that. For example, Each game item belong to a player, A player could have tons of item. And game also have tons of player. Picking an item will decrease the player health. \$\endgroup\$
    – kitta
    Commented Nov 11, 2021 at 15:45
  • 1
    \$\begingroup\$ You can add a reference from the component "item" to the component "player" if that's what you need. Also, if it doesn't make sense for something to be in the ECS, don't try to fit it in. If the items are in the player's inventory, and they don't "do" anything in your game world, maybe they belong to a database instead? \$\endgroup\$
    – Vaillancourt
    Commented Nov 11, 2021 at 15:49

0

You must log in to answer this question.

Browse other questions tagged .