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

I Need a SortedMutableEntityBag #156

Closed
AnderWoche opened this issue Sep 5, 2024 · 5 comments
Closed

I Need a SortedMutableEntityBag #156

AnderWoche opened this issue Sep 5, 2024 · 5 comments
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@AnderWoche
Copy link

AnderWoche commented Sep 5, 2024

Lets make MutableEntityBag open so i can override it and make my SortedMutableEntityBag

Important is how entities are delete: i need this way:

i want to override minusAssign

operator fun minusAssign(entity: Entity) {
        for (i in 0 until size) {
            if (values[i] == entity) {
                size--
                System.arraycopy(values, i + 1, values, i, size - i)
                values[size] = Entity.NONE
                return
            }
        }
    }
@Quillraven
Copy link
Owner

Hi,
I don't have time for this at the moment but feel free to open a PR for it. Making the bag open will not do any harm 😉

What exactly is your entity removal doing? Doing an array copy every time you remove an entity feels highly inefficient?

@AnderWoche
Copy link
Author

I implemented it this way because I needed the same behavior as with an arrayList.

I didn't use a normal ArrayList because I wanted to use the EntityBag interface so that I could use the entities from the families without having to do any conversions beforehand.

I will sit down and try to make a pull request.

@AnderWoche
Copy link
Author

AnderWoche commented Sep 5, 2024

I have a small question,
Why is everything in just one file?
Is it more performant?

would it be bad if I put MutableEntityBag in an extra file?

Ohh .wait....

@Quillraven
Copy link
Owner

I don't think that this has anything to do with performance. It is just my personal preference that I group things that belong together in one file. However, if a file gets to big I split it up like I did it recently with world and world configuration if I remember correctly.

But feel free to extract the interface into a separate file. It has a lot of methods and might be better to move it into a separate file.

Btw, if you have time, can you also add the single() method please? I just discovered that method a few days ago and it is a cleaner version of first in some scenarios.

@Quillraven Quillraven added enhancement New feature or request help wanted Extra attention is needed labels Sep 5, 2024
@Quillraven Quillraven added this to the 2.10 milestone Sep 5, 2024
AnderWoche added a commit to AnderWoche/Fleks that referenced this issue Sep 8, 2024
@Quillraven
Copy link
Owner

refer to the PR. If you have further questions/feedback then please let me know :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants