JaimeGensler / thyseus

An archetypal Entity Component System, built entirely in Typescript
MIT License
74 stars 3 forks source link

[FEAT] Allow `Entity` objects to be dropped if no longer used #67

Closed JaimeGensler closed 6 months ago

JaimeGensler commented 11 months ago

Description

We hold onto Entity objects in the empty table (id 0). We ideally wouldn't do this to allow the objects to be reclaimed by the VM, and we don't recycle them anyway. They can be dropped once an entity has been spawned in their place, but if you spawn a bunch of entities and no longer need that many, you'll have an array of objects that will never be cleaned up.

Either Entity instances should be recycled (a breaking change), or we should allow them to be dropped.