Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String type? #47

Closed
luetkemj opened this issue Sep 10, 2021 · 1 comment
Closed

String type? #47

luetkemj opened this issue Sep 10, 2021 · 1 comment

Comments

@luetkemj
Copy link

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?

@vegeta897
Copy link
Contributor

vegeta897 commented Sep 10, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants