Skip to content

Fix World.TryGet(Entity, ComponentType) returning corrupted data - #320

Open
armadavalor wants to merge 1 commit into
genaray:masterfrom
armadavalor:fix/tryget-componenttype-304
Open

armadavalor wants to merge 1 commit into
genaray:masterfrom
armadavalor:fix/tryget-componenttype-304

Conversation

@armadavalor

Copy link
Copy Markdown

The non-generic World.TryGet(Entity, ComponentType, out object?) reinterpreted the component array as object[]. For struct components the array is a typed struct array, so the read returned garbage (and crashed the test host with a fatal error for a Transform struct). World.Get(Entity, ComponentType) already goes through Array.GetValue; TryGet now does the same.

Added TryGetByComponentType to WorldTest, which aborted the test run before the change. The full Arch.Tests suite passes (143/143, net8.0).

Closes #304

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

Successfully merging this pull request may close these issues.

world.TryGet with ComponentType overload outs corrupted data

1 participant