Skip to main content
GameDev.net gamedev.net
🔒 Locked

ECS

Started by Tristan Patrick Richter Nov 10, 2014 at 7:31 AM 6 replies 3k views
haegarr
haegarr

You know that there are many variations of ECS in the wild? I don't mean variation in implementation details but in architectural decisions. You should have at least an idea of what you want/need before start looking into code; otherwise you may become locked on the first thing you see. This forum has several threads discussing things like implicit vs. explicit entities, code in components vs code in sub-systems, direct access vs. messaging, and so on.

I doubt that anybody has done the work to formulate an ECS in pseudocode. Too much work IMHO. However, there are a few ECS implementations in source code available on the internet, for example the Artemis framework.

Ungunbu
Ungunbu

Why don't you google "open source entity component system"?

Stefan Fischlschweiger
Stefan Fischlschweiger

You could take a look at the ECS from the Almirante 2D game engine. There's a link to it somewhere here on the forum, just google it if you can't find it.

The code is well documented and IMO easily adaptable

AvengerDr
AvengerDr

If you want to have a look at another implementation, in my engine I have built another ECS inspired by the Artemis framework. Look for the Source/Odyssey.Talos subfolder. It's in C#.

Edit: Talos has now been renamed to "Epos" :)

AvengerDr
AvengerDr

It's still there sorry I renamed it to "Epos" (I like greek mythology). I thought Talos (an artificial bronze automaton) would suit better an AI library I am also starting :)

Norman Barrows
Norman Barrows

her's a quick stab at the concept:

first you have an entity list:

each entity has a reference to the following components in the component lists: render info, location, update method, and entity specific data.

then you have component lists:

render info

location

update method

entity specific data

to render an entity, you follow its references to get its render info and location info from the component lists, then use that info to render.

to update an entity, you follow its references to get its update method info, location info, and entity specific data from the component lists, then use that info to update.

the two main reasons to use ECS:

1. as a workaround for object hierarchy hell.

2. to allow non-coders to define new entity type from existing component types.

note that EXTREME cache optimization can lead to ECS-ish designs. but ECS in and of itself is not usually done for greater cache friendliness, and does not necessarily result in more cache friendly code.

Norm Barrows Rockland Software Productions "Building PC games since 1989"</

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.