Npc Info
An implementation of the npc info packet. This class is responsible for bringing together all the bits of the npc info protocol, including copying all the pre-built buffers that were made beforehand.
Functions
Appends the high resolution indices to the provided collection. This can be used to determine which NPCs the player is currently seeing in the client. Servers often rely on this metric to determine things such as aggression/hunt.
Gets the high resolution indices in a new arraylist of integers. The list is initialized to an initial capacity equal to the high resolution npc index count.
Whether this reference pooled object is destroyed. A destroyed object will not be returned back to the pool and instead will be left off for the garbage collector to clean up in due time. This condition is only hit when there was some error thrown during the processing of a given info object. In order to mitigate potential future problems that might continue to stem from re-using this object, we discard it altogether.
Invoked whenever a pooled object is no longer in use. This function is primarily used to clear out any sensitive information or potential memory leaks regarding byte buffers. This function should not fully reset objects, particularly primitives, as there is a chance a given pooled object never gets re-utilized and the garbage collector ends up picking it up. In such cases, it is more beneficial to do the resetting of properties during the onAlloc, to ensure no work is 'wasted'.
This function allocates a new clean world details object, as on reconnect, all existing npc info state is lost. This function should be called on the old npc info object whenever a reconnect occurs.
Resets the view distance back to a default value of 15 tile radius.
Sets the view distance, meaning how far the player can see NPCs.
Turns this npc info structure into a respective npc info packet, depending on the current known view distance.
Updates the build area for this NPC info. This will ensure that no NPCs outside of this box will be added to high resolution view.
Updates the coordinate of the local player, as this is necessary to know how far NPCs nearby are to the player, which allows us to remove NPCs that have gone too far out, and add NPCs that are within certain distance.