benmoran56 / esper

An ECS (Entity Component System) for Python
MIT License
537 stars 67 forks source link

Change default first entity ID to 1 #68

Closed elistevens closed 2 years ago

elistevens commented 2 years ago

Prior to this change, to have a value that stores a component ID set to a non-value, we must either:

This change makes it so that we can use the naturally falsy 0 value for unset IDs.

benmoran56 commented 2 years ago

Thank you for the pull request!

This is a simple enough change, but a few of the unit tests will also need to be updated. I can have a look at those later today, but feel free to update the pull request yourself if you would like.

-Ben

elistevens commented 2 years ago

Hrm, I think that I'm wrong - entity1 in the test_delete_entity test is already 1.

I misunderstood the create_enitity function. Since it does self._next_entity_id += 1 before adding the entity, the first entity value is already 1.

Sorry for the noise! I should have run some tests on my end first.

benmoran56 commented 2 years ago

Ah, you're right. But no worries! I didn't realize it either, even after glancing at the unit tests.