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

Entity.Set performs no checks if components exists at all to be able to set it, even in debug mode. #174

Open
emelrad12 opened this issue Nov 19, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@emelrad12
Copy link
Contributor

Calling Entity.Set to set a component that doesn't exist on a said entity, causes directly memory corruption.
A suggestion would be to make it safe, but add a non safe version for performance.
As the vast majority of ecs code normally would not be affected by such change in performance just a small part of it, that is called very often, hence I would suggest making the default behavior safe.

@genaray genaray added the enhancement New feature or request label Nov 21, 2023
@metalgearsloth
Copy link
Contributor

In our game we have a method called Ensure(Entity) where it checks Has first which might be useful, so anyone that knows for sure the component exists can use Set or otherwise use the other method.

@immortius
Copy link

I think it would be particularly good to add more documentation on the unsafe methods on their assumptions. If trying to Set a component to an entity that lacks it will break it that should be documented. The worst ones are the ones that don't immediately crash, like Add for a component on an entity that already has it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

4 participants