Skip to content

Conversation

@Princess-Cheeseballs
Copy link
Member

Noticed this while doing solutions refactor stuff, EnsureComp(ref Entity<T?>) can take a component as an argument, but if it's null, it will try to add a component without checking if one already exists.

So if for example, you had a method that took an Entity<T?> as an argument, which called EnsureComp(ref Entity<T?>) to ensure that the component always exists, but only passed an EntityUid to your method, despite the component existing, this method would try to add the component again without checking if it already existed.

This just changes the method so if you pass a null component, it runs the other EnsureComp method which helps remove code copypasting, and if you do pass a component, ensures it's not being deleted and adds it back if it is being deleted.

@PJB3005 PJB3005 added T: Bugfix Type: Bugs and/or bugfixes A: ECS Core functionality for the ECS labels Jan 31, 2026
@Tayrtahn Tayrtahn merged commit 5e160e2 into space-wizards:master Jan 31, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A: ECS Core functionality for the ECS T: Bugfix Type: Bugs and/or bugfixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants