decline-cookies / anvil-unity-dots

Unity DOTS and ECS specific additions and extensions to Anvil
MIT License
4 stars 1 forks source link

Hotfix - Double PopulateOnEntity #281

Closed jkeon closed 11 months ago

jkeon commented 11 months ago

Removing IEntitySpawnDefinitionExtension as it doesn't provide any value any more.

What is the current behaviour?

When using the IEntitySpawnDefinitionExtension.CreateAndPopulate methods, it would first call SpawnDeferredEntity and then PopulateOnEntity.

However, SpawnDeferredEntity already calls PopulateOnEntity so we end up calling PopulateOnEntity twice.

Normally for set operations, this is fine but not very performant.

But the danger lies in adding to a dynamic buffer where you will now get two adds instead of one.

What is the new behaviour?

Removing the second PopulateOnEntity call is easy enough in CreateAndPopulate but then CreateAndPopulate is just a proxy for SpawnDeferredEntity.

Instead we can just delete this class and callers can call entitySpawner.SpawnDeferredEntity(definition) directly.

What issues does this resolve?

What PRs does this depend on?

Does this introduce a breaking change?