Create a gist now

Instantly share code, notes, and snippets.

Entity Component Systems compared with pseudo-code (variants: GameplayKit, Adam Martin, Scott Bilas)

Full ECS discussion gist: https://gist.github.com/LearnCocos2D/77f0ced228292676689f

ECS by Scott Bilas (GDC 2002, Dungeon Siege)

foreach entity in allEntities do
    foreach component in entity.components do
	    component.update()
	end
end

ECS by Scott Bilas (fixed-order component update)

foreach componentSystem in allComponentSystems do
	foreach component in componentSystem.components do
		component.update()
	end
end

ECS by Apple's GameplayKit

foreach componentSystem in allComponentSystems do
	componentSystem.update() // inner loop encapsulated by GKComponentSystem
end

ECS by Adam Martin

foreach componentSystem in allComponentSystems do
	foreach component in componentSystem.components do
		// component (data) processing logic inlined here ...
	end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment