NateTheGreatt/bitECS

String type?

Closed this issue · 1 comments

I've never worked with TypedArrays before so I may be coming at this from the wrong direction. How would I define a component with string types? For example, suppose I want to define a "Name" component that stores the name of the entity - how would I do that?

This is addressed in the FAQ

Strings are expensive and usually unnecessary to have the ECS handle. Instead, create a mapping of integers to strings, and store the integers in the component data as a reference to a string. This makes string serialization minimal and fast.

Another solution I use is an exported array indexed by entity ID that stores the values I need, if having a component is not strictly necessary.