• Create Account

Entity System

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

8 replies to this topic

#1bubbaray97  Members

217
Like
0Likes
Like

Posted 03 January 2013 - 03:08 PM

So for those of you building Entity Systems out there...I have a question about design.    I think for the game I'm working on it would be a great system to use given all the "exceptions" my rules for units seem to have so being able to have componets that I can swap out would be a big benefit to me.

Question is though do you try to treat everything as an entity or keep the "basic stuff" (i.e. title screens, main menus, dialogs, etc) as more traditional classes.    I guess what I'm asking is do I need to make like a MenuSystem which acts on MenuComponets and be able to have a DialogComponet (which may be the only thing a given entity had).    Or not worry about that and just save the entity system for actual gameplay elements.

I ask because when I look at the various example out there they are all focused on the actual gameplay objects and so I wasn't sure what the "right" way to go about it might be.

I'm sure there is no hard and fast rule here, just trying to get an idea for best practice before I redo everything

Thanks all

#2BeerNutts  Members

4289
Like
1Likes
Like

Posted 03 January 2013 - 04:10 PM

I'm sure there is no hard and fast rule here, just trying to get an idea for best practice before I redo everything

Do whatever makes the most sense to you.  Games fit the Entity System paradigm very well, but GUI's might not, and, if that's the case, don't attempt to use Entities for your basic menu screens.

I personally probably would just keep the game play within the Entity framework, and keep the typical menu system out of it.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

#3Khatharr  Members

7735
Like
1Likes
Like

Posted 03 January 2013 - 04:56 PM

Agreed. Typically an entity is any interactable object within the game world, so if your menu system is not integrated with the game world then you're probably better off separating them according to what belongs to the simulation and what belongs to the UI. There's no real rule, though, so if it makes sense to design your UI using entities then go for it.
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

#4smr  GDNet+

2390
Like
1Likes
Like

Posted 03 January 2013 - 05:00 PM

Right. Do what makes sense.

But I wonder what benefits there would be to implementing your UI elements as entities. I would think that UI elements are not a part of the game simulation, thus wouldn't be represented by entities within that simulation.

As far as your question about "traditional classes," component/entity systems /are/ traditional classes. They're just a specific way of organizing your relationships between classes. In my opinion if you implement OOP in the manner intended, most of your programs will tend to look like entity component systems in that you avoid deep hierarchies, keep classes small and single-purpose, etc.

Edited by smr, 03 January 2013 - 05:04 PM.

#5bubbaray97  Members

217
Like
0Likes
Like

Posted 03 January 2013 - 06:55 PM

Thanks all.   Very in line with what I was thinking, but figured I'd check with the experts

and yes smr I know they are "traditional classes"...I ment to seperate them from the way more hierachial class setup which I guess I should have been more specific...

Thanks again

#6Khatharr  Members

7735
Like
0Likes
Like

Posted 04 January 2013 - 12:06 AM

But I wonder what benefits there would be to implementing your UI elements as entities. I would think that UI elements are not a part of the game simulation, thus wouldn't be represented by entities within that simulation.

I was thinking of some of the more unique games I've seen where the UI actually is a part of the simulation. (Gimmicky, I know, but I always thought it was cute when I saw it.)
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

#7MaxDZ8  Members

4980
Like
2Likes
Like

Posted 04 January 2013 - 01:34 AM

When in doubt, try to do less. Nobody needs something which is not required by the game in the works.

Multiple iterations might be the key in better understanding the problem, the requirements and thus the solution. Overengineering is a serious problem.

Previously "Krohm"

#8NightCreature83  Members

4785
Like
0Likes
Like

Posted 04 January 2013 - 03:00 AM

UI's fit the lessons of the entity system quite well actually, even though they should be part of the state system in the game. The entity system comes in on the items that are on a screen as you can decompose all the actions a button should have into components which would allow you to attach these to other elements on the screen. For example a text field and a button would share a TextComponent which deals with setting the text on it.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max

#9/a/non  Members

148
Like
0Likes
Like

Posted 04 January 2013 - 10:17 PM

I managed to fit my UI system into my Entity system quite easily. You see all my entities are connected to a script, some entities can be visible (Player) others, invisible (Camera entity). I have my Menu Entity spawned in the world, and in it's corresponding script, I have a binded C++ function I call, something along the lines of;

function OnLoaded()
{
}