Closed jpw1991 closed 1 year ago
Not at all insane! And this feels like a problem with an elegant solution. Like, each ItemDrop could do a search for the nearest neckro and tell the neckro to pick it up if the neckro doesn't have any goals or if it's closer than the neckro's current goal.
Not at all insane! And this feels like a problem with an elegant solution. Like, each ItemDrop could do a search for the nearest neckro and tell the neckro to pick it up if the neckro doesn't have any goals or if it's closer than the neckro's current goal.
I think that having each ItemDrop search for a Neckro would be insanely inefficient because it'd add overhead even when Neckros aren't around, and there'd be potentially hundreds of items searching for necks. Having the Neckros search for items is better because it'd be more efficient due to less objects searching.
But maybe you know something I don't? or I understood wrongly. Not sure
I gave your idea more thought, and I think it could work like the following:
Yeah that should work and also be pretty efficient
Looks like you're right! I underestimated how many ItemDrops there were. I was thinking there'd often be fewer ItemDrops than neckros, but a quick look tells me that's not true.
All right, a neckro-out search makes sense.
The fastest thing to do is probably what you originally said, just to have each neckro "claim" the item it's going towards, which removes it from the list of items other neckros can look at. The Dictionary you originally described doesn't have to contain every item as a key; items should be added as keys once a neckro claims it.
I was... going for perfect, and what we want is fast and "good enough", which is its own type of perfect.
I guess it doesn't have to be a dictionary, then. Just a "claimed" list.
I was... going for perfect, and what we want is fast and "good enough", which is its own type of perfect.
Very true haha
Would you like to do this one, or should I?
Please do!
Alright. This is ready to test
Description
I've noticed that sometimes multiple Neckros attempt to get the same item. This gave me an insane idea.
Imagine if the Neckros all saw what every other Neckros sees and knows which one of them is pursuing an item? They could then organise themselves far better. If a Neckro knows that his buddy is already getting the Greydwarf Eye, then he can instead go and grab the Resin.
Is the feature related to a problem?
Yes. Seeing multiple Neckros run for the same object.
Solutions
Maybe something like a static dictionary (key: GameObject, value: Neckro) of GameObjects and their corresponding Neckro. Neckros check the static dictionary for valueless keys and if one is found, it puts itself there. When the item gets picked up, the Neckro deletes it from the dictionary and looks again. If the dictionary ever becomes empty, all Neckros perform a little scan in their area and add to the dictionary.