Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm falling in love with simple grace of entity-component design, although I still have issues breaking from MVC and OOP practices. Some of my game entities have membership relationships with each other (ex: a player is a member of a city, a city is a member of a nation), and I am unsure on the best way to implement it.

My initial reaction is to have a a MemberOfCity component that points to the appropriate city component, but components are suppose to have no references to each other. My other option is to have a System do it, but that would require the system to persist data outside of a component.

Is there a clean way to do this in an entity-component design, or am I trying to use a hammer on a screw and should use a hybrid/another approach?

share|improve this question
1  
How are you going to use this membership information? How do you query your components? Try thinking in a mix of SQL and OOP: 'how do I get all components ("rows") that have given property ("field") value in a decoupled way?'. – Den Apr 11 '12 at 9:00
I plan on using my mini-engine for a minecraft plugin (can player place block here, can player a attack player b) and hopefully for my outerspace colony building game. I was thinking SQL for at least the former as the structure lends itself to a relational database. – croxis Apr 12 '12 at 2:15
Do you already have some implementation of your component system? Describing your existing architecture might make your question more answerable. – Den Apr 12 '12 at 16:18
I'm using the artemis framework in java. I haven't spent too much time on the components as I wasn't sure the best way to go forward. I also haven't found any good reading on how to structure components, just how to write a framework like artemis. – croxis Apr 14 '12 at 0:24

1 Answer

I'd do it the other way around: the city has a Population component that is a list of Person entities. Components should generally be linked if they are linked in definition.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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