Skip to content

Does Entity need to know all possible components? #295

Answered by hmans
JKarneeb asked this question in Q&A
Discussion options

You must be logged in to vote

So, one thing to remember is that there are many ways to actually compose the Entity type, instead of defining it monolithically. I've had projects where I did something like the following:

type IPosition {
  position: Vector3
}

type IHealth {
  health: { current: number, max: number }
}

type Entity = Partial<IPosition & IHealth & ...>

There are, of course, many variations on this.

In a similar vein, remember that Miniplex expects entities to be objects, but doesn't really care what these objects actually are. I've had at least one project where I actually implemented entities as class instances to explore this. It might feel far removed from typical ECS thinking, but I was enjoying it …

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@hamzakubba
Comment options

@hmans
Comment options

@JKarneeb
Comment options

@hmans
Comment options

Answer selected by JKarneeb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants