0
\$\begingroup\$

I want to implement an association between 2 entities in a ECS architecture using Artemis framework, which handles Components, Entities and Systems very well for me.

I have an entity "Empire" (with several components like Empire ID, researched technologies, etc), and I would wish to establish "diplomacy" between 2 Empires (War, Peace).

In which way could I implement that with an ECS architecture? I know about unite components, but not relating entities.

Thank you

\$\endgroup\$
  • \$\begingroup\$ As long as object doesn't have any representation in the world (visual, audio, physics) I wouldn't make it an entity in ECS. So if the Empire is just information and statistics, and not something like area on game map, make it normal object. \$\endgroup\$ – Kikaimaru Dec 24 '13 at 11:24
  • \$\begingroup\$ Hey, that sounds like a plan! I was thinking the same, but I wasn't sure. Your words make me feel more confident at implementing that. Thank you \$\endgroup\$ – David Jiménez Martínez Dec 24 '13 at 11:51
3
\$\begingroup\$

You may be falling into a common trap. Entity component systems are very neat and useful, but they shouldn't be used for everything.

Simply add an Information component to your entities that contains, among other information, their empire affiliation.

This component can be utilized by lots of other systems, including the whatever Combat system you have. The Combat system can look at the empires and see if they're at war or not when deciding to attack.

The entire diplomacy system doesn't need to be in the entity component framework. It can be a separate system entirely.

\$\endgroup\$
  • \$\begingroup\$ To expand on the whole shoehorning problem, I don't know if ECS is right for these objects in the first place. I think you're trying too hard to use it for everything, when really it's only still useful in specific situations. \$\endgroup\$ – jmegaffin Dec 23 '13 at 22:09
  • \$\begingroup\$ So, in this case, if I have an entity "Empire", adding an Information component should do the trick? If so, which parameters should this information component contain in order to track the relationship status among several empires (e.g. Persians at War with Spartans, Spartans in Peace with Tebans)? Maybe a Dictionary of EmpireIDs + Diplomacy status enum? Or could it be a Dictionary of Entity pointers (guaranteeing they are Empires in some way?) I'm sorry if I ask too newbie questions, ECS is rather new for me. \$\endgroup\$ – David Jiménez Martínez Dec 23 '13 at 23:19
  • 1
    \$\begingroup\$ I'm suggesting you don't use the ECS for the empire at all. I think adding an information component to the other entities in your game, defining what empire they belong to is all you need. The empire system is a different system entirely, not using ECS. \$\endgroup\$ – MichaelHouse Dec 23 '13 at 23:35
  • \$\begingroup\$ I guess I can imagine how to implement this, yet I'm not 100% sure. When I try this solution, if I have any doubt, I will ask in these forums. thank you very much. \$\endgroup\$ – David Jiménez Martínez Dec 24 '13 at 8:57
0
\$\begingroup\$

I would approach this much like most games do using some form of a Faction system. Basically, a collective unit of objects, in your case the Empire; hold a FactionComponent managed by a faction system. As specific peace talks, treaties signed, etc occur you increase the faction level of one empire in relation to another empire. As specific events happen that are hostile between two empires, you lower the faction level between the two, perhaps placing them at war.

Based on the faction system, you can now differ between hostile and friendly targets quite easily all based on their level of faction between one another. The faction system becomes the glue or the association system that manages the relationship between the owners of these faction components.

\$\endgroup\$
  • \$\begingroup\$ Which members would that FactionComponent contain? And would that FactionSystem be processed every frame? Some implementation even in pseudocode to illustrate would be helpful. Thank you \$\endgroup\$ – David Jiménez Martínez Dec 23 '13 at 23:21
  • \$\begingroup\$ Based on your original question, you're treating an Empire as the entity much like a traditional game treats an NPC or player. Therefore, an Empire can have a many-to-many relationship on faction standing with other empires and thus would hold a map of empire ids that it has come into contact with throughout its lifetime and the current standing with them or any other pertinent information. As for the system, there isn't necessarily a need for it to tick each frame but it could somehow listen for specific game events to be raised and respond accordingly by manipulating the faction data. \$\endgroup\$ – Naros Dec 24 '13 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.