Entity System

Started by
7 comments, last by /a/non 11 years, 3 months ago

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

Advertisement

[quote name='bubbaray97' timestamp='1357247329' post='5017248']
I'm sure there is no hard and fast rule here, just trying to get an idea for best practice before I redo everything
[/quote]

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)

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.

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.

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

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

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.

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"

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, Watch Dogs: Legion

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() { ShowUI("TestMenu.html");
}

This topic is closed to new replies.

Advertisement