Skip to main content
Tweeted twitter.com/#!/StackGameDev/status/228392920628224000
added 3 characters in body
Source Link
jcora
  • 7.9k
  • 4
  • 53
  • 88

In an Entity System I am making, there is a central class called World, which stores all component instances. It's a dictionary-of-arrays, and entity ids are indexes for the arrays.

To access a component of an entity with id = 3 you would do this: world.storage["ComponentType"][3].

So, each loop of the game, these arrays would be fed to their respected systems ( movement(world.storage["Position"], world.storage["Velocity"]) ).

Now, I don't see why systems couldn't be implemented just as functions, as I showed. What optimizations can be made by using classes with data and methods (caching)?

Also, these systems would need to iterate over all the entities that exist, doesn't this make entity frameworks much slower than regular inheritance based engines? Why do some people "register" systems to the World claclass?

In an Entity System I am making, there is a central class called World, which stores all component instances. It's a dictionary-of-arrays, and entity ids are indexes for the arrays.

To access a component of an entity with id = 3 you would do this: world.storage["ComponentType"][3].

So, each loop of the game, these arrays would be fed to their respected systems ( movement(world.storage["Position"], world.storage["Velocity"]) ).

Now, I don't see why systems couldn't be implemented just as functions, as I showed. What optimizations can be made by using classes with data and methods (caching)?

Also, these systems would need to iterate over all the entities that exist, doesn't this make entity frameworks much slower than regular inheritance based engines? Why do some people "register" systems to the World cla

In an Entity System I am making, there is a central class called World, which stores all component instances. It's a dictionary-of-arrays, and entity ids are indexes for the arrays.

To access a component of an entity with id = 3 you would do this: world.storage["ComponentType"][3].

So, each loop of the game, these arrays would be fed to their respected systems ( movement(world.storage["Position"], world.storage["Velocity"]) ).

Now, I don't see why systems couldn't be implemented just as functions, as I showed. What optimizations can be made by using classes with data and methods (caching)?

Also, these systems would need to iterate over all the entities that exist, doesn't this make entity frameworks much slower than regular inheritance based engines? Why do some people "register" systems to the World class?

Source Link
jcora
  • 7.9k
  • 4
  • 53
  • 88

Benefits of implementing systems like classes instead of just functions

In an Entity System I am making, there is a central class called World, which stores all component instances. It's a dictionary-of-arrays, and entity ids are indexes for the arrays.

To access a component of an entity with id = 3 you would do this: world.storage["ComponentType"][3].

So, each loop of the game, these arrays would be fed to their respected systems ( movement(world.storage["Position"], world.storage["Velocity"]) ).

Now, I don't see why systems couldn't be implemented just as functions, as I showed. What optimizations can be made by using classes with data and methods (caching)?

Also, these systems would need to iterate over all the entities that exist, doesn't this make entity frameworks much slower than regular inheritance based engines? Why do some people "register" systems to the World cla