0

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.

kitta
  • 99
  • 2
  • 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. – Vaillancourt Nov 11 '21 at 13:30
  • 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. – kitta Nov 11 '21 at 14:10
  • 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. –  Nov 11 '21 at 15:32
  • 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. – kitta Nov 11 '21 at 15:45
  • 1
    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? – Vaillancourt Nov 11 '21 at 15:49
  • So that's mean most of the complex games need db? – kitta Nov 19 '21 at 06:23
  • Not necessarily a DB. You can store you data in tables on disk and link them to objects in memory when you stat the game. If you have a more specific need, please edit the question and tell us about it. – Vaillancourt Nov 24 '21 at 20:54

0 Answers0