Skip to main content
replaced http://gamedev.stackexchange.com/ with https://gamedev.stackexchange.com/
Source Link

Your implementation is a bit off of the other Entity-Component systems I've seen. I recommend taking a look at EntityX. It should give a good idea of what a working implementation looks like.

You could also read these which may help:

Role of systems in entity systems architectureRole of systems in entity systems architecture

Component - Game Programming Patterns

Understanding Component-Entity-Systems

As for some specific code critiques:

  • Using templates to manage your component types, not an enum. This will make for cleaner code. I'd only use an enum (or any numerical type or string) if you were implementing scripting or any runtime-based component system, but that's a whole different issue. Templates just offer better type safety.
  • Using std::unique_ptr instead of std::shared_ptr. If you're making copies of entites for whatever reason, you don't want them to share a pointer to the same component. If you're not copying them, you're wasting performance.
  • Using an ID for an entity and a central system (that holds components tied to a specific ID) instead of Entity objects that hold the components themselves.

Your implementation is a bit off of the other Entity-Component systems I've seen. I recommend taking a look at EntityX. It should give a good idea of what a working implementation looks like.

You could also read these which may help:

Role of systems in entity systems architecture

Component - Game Programming Patterns

Understanding Component-Entity-Systems

As for some specific code critiques:

  • Using templates to manage your component types, not an enum. This will make for cleaner code. I'd only use an enum (or any numerical type or string) if you were implementing scripting or any runtime-based component system, but that's a whole different issue. Templates just offer better type safety.
  • Using std::unique_ptr instead of std::shared_ptr. If you're making copies of entites for whatever reason, you don't want them to share a pointer to the same component. If you're not copying them, you're wasting performance.
  • Using an ID for an entity and a central system (that holds components tied to a specific ID) instead of Entity objects that hold the components themselves.

Your implementation is a bit off of the other Entity-Component systems I've seen. I recommend taking a look at EntityX. It should give a good idea of what a working implementation looks like.

You could also read these which may help:

Role of systems in entity systems architecture

Component - Game Programming Patterns

Understanding Component-Entity-Systems

As for some specific code critiques:

  • Using templates to manage your component types, not an enum. This will make for cleaner code. I'd only use an enum (or any numerical type or string) if you were implementing scripting or any runtime-based component system, but that's a whole different issue. Templates just offer better type safety.
  • Using std::unique_ptr instead of std::shared_ptr. If you're making copies of entites for whatever reason, you don't want them to share a pointer to the same component. If you're not copying them, you're wasting performance.
  • Using an ID for an entity and a central system (that holds components tied to a specific ID) instead of Entity objects that hold the components themselves.
added 160 characters in body
Source Link
LiquidFeline
  • 1.4k
  • 2
  • 13
  • 32

Your implementation is a bit off of the other Entity-Component systems I've seen. I recommend taking a look at EntityX. It should give a good idea of what a working implementation looks like.

You could also read these which may help:

Role of systems in entity systems architecture

Component - Game Programming Patterns

Understanding Component-Entity-Systems

As for some specific code critiques, I recommend:

  • Using templates to manage your component types, not an enum. This will make for cleaner code. I'd only use an enum (or any numerical type or string) if you were implementing scripting or any runtime-based component system, but that's a whole different issue. Templates just offer better type safety.
  • Using std::unique_ptr instead of std::shared_ptr. If you're making copies of entites for whatever reason, you don't want them to share a pointer to the same component. If you're not copying them, you're wasting performance.
  • Using an ID for an entity and a central system (that holds components tied to a specific ID) instead of Entity objects that hold the components themselves.

Your implementation is a bit off of the other Entity-Component systems I've seen. I recommend taking a look at EntityX. It should give a good idea of what a working implementation looks like.

You could also read these which may help:

Role of systems in entity systems architecture

Component - Game Programming Patterns

As for some specific code critiques, I recommend:

  • Using templates to manage your component types, not an enum. This will make for cleaner code. I'd only use an enum (or any numerical type or string) if you were implementing scripting or any runtime-based component system, but that's a whole different issue. Templates just offer better type safety.
  • Using std::unique_ptr instead of std::shared_ptr. If you're making copies of entites for whatever reason, you don't want them to share a pointer to the same component. If you're not copying them, you're wasting performance.

Your implementation is a bit off of the other Entity-Component systems I've seen. I recommend taking a look at EntityX. It should give a good idea of what a working implementation looks like.

You could also read these which may help:

Role of systems in entity systems architecture

Component - Game Programming Patterns

Understanding Component-Entity-Systems

As for some specific code critiques:

  • Using templates to manage your component types, not an enum. This will make for cleaner code. I'd only use an enum (or any numerical type or string) if you were implementing scripting or any runtime-based component system, but that's a whole different issue. Templates just offer better type safety.
  • Using std::unique_ptr instead of std::shared_ptr. If you're making copies of entites for whatever reason, you don't want them to share a pointer to the same component. If you're not copying them, you're wasting performance.
  • Using an ID for an entity and a central system (that holds components tied to a specific ID) instead of Entity objects that hold the components themselves.
Source Link
LiquidFeline
  • 1.4k
  • 2
  • 13
  • 32

Your implementation is a bit off of the other Entity-Component systems I've seen. I recommend taking a look at EntityX. It should give a good idea of what a working implementation looks like.

You could also read these which may help:

Role of systems in entity systems architecture

Component - Game Programming Patterns

As for some specific code critiques, I recommend:

  • Using templates to manage your component types, not an enum. This will make for cleaner code. I'd only use an enum (or any numerical type or string) if you were implementing scripting or any runtime-based component system, but that's a whole different issue. Templates just offer better type safety.
  • Using std::unique_ptr instead of std::shared_ptr. If you're making copies of entites for whatever reason, you don't want them to share a pointer to the same component. If you're not copying them, you're wasting performance.