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

TryGetArchetype uses reference equality instead of SequenceEquals #9

Closed
MindSwipe opened this issue Nov 15, 2022 · 3 comments · Fixed by #10
Closed

TryGetArchetype uses reference equality instead of SequenceEquals #9

MindSwipe opened this issue Nov 15, 2022 · 3 comments · Fixed by #10
Assignees
Labels
bug Something isn't working

Comments

@MindSwipe
Copy link
Contributor

In the World method TryGetArchetype(Type[], out Archetype) the backing PooledDictionary uses reference equality, which leads to unexpected behavior such as this:

var archTypes1 = new Type[] { typeof(Transform) };
var archTypes2 = new Type[] { typeof(Transform) };

var entity1 = world.Create(archTypes1);
var entity2 = world.Create(archTypes2);

Creating 2 Archetypes in the World as archTypes1 and archTypes2 don't reference the same instance of Type[].

The fix is quite easy, implement an IEqualityComparer<Type[]> that uses SequenceEquals and pass it to the PooledDictionary to use.

@genaray genaray self-assigned this Nov 15, 2022
@genaray genaray added the bug Something isn't working label Nov 15, 2022
@genaray
Copy link
Owner

genaray commented Nov 15, 2022

Thanks again ! Quite easy to miss such details. Happy that someone thinks of such things :)

On my way to fix that issue ^^

@MindSwipe
Copy link
Contributor Author

I already have a fix ready to go. The PR also includes an amended .gitignore from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore as many folders and files were automatically included on my end

@genaray
Copy link
Owner

genaray commented Nov 15, 2022

Thanks and great work :) I will quickly create a new hotfix release and nuget for it.

DrSmugleaf pushed a commit to DrSmugleaf/Arch that referenced this issue Nov 23, 2023
DrSmugleaf pushed a commit to DrSmugleaf/Arch that referenced this issue Nov 23, 2023
This reverts commit fc1744b, reversing
changes made to cd88c6b.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants