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

World Destruction / Corruption via Destroyed World Reference #247

Open
Garrett-Ravatt opened this issue Nov 26, 2024 · 0 comments
Open

World Destruction / Corruption via Destroyed World Reference #247

Garrett-Ravatt opened this issue Nov 26, 2024 · 0 comments

Comments

@Garrett-Ravatt
Copy link

If a world is destroyed and then "destroyed" again after another world has replaced it (occupying the unused world ID), the second world won't actually be able to create entities anymore. It will track its size as if it can, and will create entity objects with the right ids and archetype, but the entities will be evaluated as null. Exceptions won't be thrown until the Entity is accessed in some way.

var worldA = World.Create(); // World A has ID 0 and size 0
worldA.Create(); // worldA is now size 1
World.Destroy(worldA); // world A is size 0

var worldB = World.Create(); // World B has ID 0 and size 0
var e0 = worldB.Create(0); // world B now has size 1
World.Destroy(worldA); // World B still appears to have size 1
var e1 = worldB.Create(0); // World B has size 2

e0.Get<int>(); // This causes a null reference exception
e1.Get<int>(); // This also causes a null reference exception
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

1 participant