ES composite components vs entities

Hi,

I’m in trouble concerning entity design. I wish an advise on “complex” component. I’m working on m’y spaceships, which are entities. Spaceships as weapons, with type, hitpoints,target,… but spaceships can have multiple weapon of same type, e.g. 5 phaser and 2 photon. As they can have different targets, I can’t just accumulate values in one component per type. As components are unique, I can’t put many of them.

So the question is what is the best design :
*a Weapons component that hold a map of class, and follow should hold class be component (if there is only one weapon, no need to create à composite)
*each weapon is an independant entity, with components for hitpoints, target, parent, etc.

For now, I’ve no opinion. Maybe the second one is heavier. If someone can help.

Thanks.

Weapons are entities in this case.

I thought there was a list of “I may be an entity if…” type stuff but I don’t know and don’t have time to look at the JME wiki and the Zay-es wiki at the moment. But certainly if you have “more than one” of something “for some entity”… then 99.9999999% of the time that “more than one” thing is an entity.

More to the point, you are probably not asking for “all entities with weapons” and instead asking for “all weapons” in some system.

If you have no systems using these things then they aren’t even needed.

That’s what I’ve done tonight : entity, and a system that loop on on weapon to resolve attacks. Way far simpler than the other option… thanks.

Yes, you can create an entity for each weapon. Optionally you can have a component which specifies the parent id. So, eg if you destroy a spaceship, you remove all its weapons too.

That’s exactly what he’s said he’s done now.