Comments (7)
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.
Merchant, Potion, Mob is an odd enumeration to have. What do they have in common?
from apecs.
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.
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.
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.
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.
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)
- Add Generic instances for Component, Elem, Expl[Get|Set|Destroy|Members] HOT 10
- Argument order in Reacts.react HOT 2
- Passing keys between members/exists and get/set HOT 3
- apecs-physics 0.4.5 marked as broken on nix - 'readGenericPackageDescription' not in scope HOT 6
- Template Haskell function requires me to import some symbols unqualified HOT 2
- apecs-stm: newEntity_ leads to a compilation error, not newEntity HOT 4
- Unable to load package `apecs-physics-0.4.5' HOT 20
- Community chat? HOT 4
- Build failure with GHC 9.2.1 HOT 1
- Why is there no getAll / members? HOT 12
- Please enhance Benchmark Comparison chart HOT 5
- error destroying component for entity seemingly guaranteed to have that component HOT 4
- lazy cfoldr and cfoldMap HOT 2
- Physics documentation is inaccurate HOT 6
- Judy-backed storage in IO HOT 5
- fails to build with ghc-9.4/Cabal-3.8 for Stackage Nightly
- New article for Apecs - maybe depreciate outdated one? HOT 1
- Apecs-Physics collision handlers still nonfunctional HOT 1
- Need help getting Enemy AI to follow player HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apecs.