Code Monkey home page Code Monkey logo

Comments (7)

dpwiz avatar dpwiz commented on June 13, 2024

You can have a tag that would answer exact this query, irrespective of an entity being a merchant/potion/mob.
Tags are fast, can be cached and are a good option to pre-filter entities before getting into further details.

from apecs.

dpwiz avatar dpwiz commented on June 13, 2024

Merchant, Potion, Mob is an odd enumeration to have. What do they have in common?

from apecs.

Raveline avatar Raveline commented on June 13, 2024

You can have a tag that would answer exact this query, irrespective of an entity being a merchant/potion/mob.
Tags are fast, can be cached and are a good option to pre-filter entities before getting into further details.

You mean something like a data IsCollidable ? That would indeed let me do a query, but then I'd be back to the issue "how do I know which are the components of the collided entity". My question is more: "How do I get into the further details, is there a better option that doing a lot of exists ?"

Merchant, Potion, Mob is an odd enumeration to have. What do they have in common?

Agreed on this, obviously I want to avoid this !

from apecs.

dpwiz avatar dpwiz commented on June 13, 2024

how do I know which are the components of the collided entity

But, again, how would the collision (?) system behave differently for different kinds of colliding objects?

How do I get into the further details, is there a better option that doing a lot of exists ?

You can collect Entity ids and then do a per-kind processing in other systems.
Alternatively (perhaps better), you can make collision system add Collided tag, and then run per-kind queries with it.
The answer is basically "decompose your system". Let the colliders collide, then let the mobs mob and items item.

from apecs.

dpwiz avatar dpwiz commented on June 13, 2024

There's another option, the way apecs-physics does it. You put your callbacks into a component and the collision system invokes it blindly, letting the entity sort it out by itself.

from apecs.

dpwiz avatar dpwiz commented on June 13, 2024

This is clearly verbose and unoptimised.

Actually, this looks... okay. You can optimize it later IF it becomes a problem and with an appropriate tool (like spatial indexing) instead of shuffling the syntactic furniture around for a more presentable code. Don't let yourself be pre-blocked (:

from apecs.

Raveline avatar Raveline commented on June 13, 2024

This is perhaps also just a case of "ECS are not always a good fit for roguelikes" - a statement I've often read, without knowing if it was true or not.

The callback mechanism from apecs-physics is also interesting, but I'm trying to keep my components as simple as possible and I'm not ready to add callbacks to them right now.

You are right: I'm letting myself be pre-blocked.I think your decomposition principle is sound, and I'm reassured that another pair of eyes find that the multiple cMaps don't look so bad. I'll get on with this and see if this needs any optimisation later on. Thank you for your input !

from apecs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.