WorldEntityInfo

The world entity info class tracks everything about the world entities that are near this player.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun backingBuffer(): ByteBuf

Returns the backing byte buffer for this world entity info instance.

Link copied to clipboard
fun clearEntities(worldId: Int)

Clears all the entities for the provided worldId. This function is only intended to be used together with the net.rsprot.protocol.game.outgoing.worldentity.ClearEntities packet. This packet should only be called before WorldEntityProtocol.update has been called, otherwise problems may arise.

Link copied to clipboard

Gets the indices of all the world entities that were added to high resolution in this cycle, allowing the server to allocate new player and npc info instances, and sync the state of the zones in those world entities.

Link copied to clipboard

Gets a list of all the world entity indices that are currently in high resolution, allowing for correct functionality for player and npc infos, as well as zone updates.

Link copied to clipboard

Gets the indices of all the world entities that were removed from the high resolution in this cycle, allowing the server to destroy the player and npc info instances corresponding to them, and to clear the zones that were being tracked due to it.

Link copied to clipboard
open override fun isDestroyed(): Boolean

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.

Link copied to clipboard
open override fun onAlloc(index: Int, oldSchoolClientType: OldSchoolClientType, newInstance: Boolean)

Invoked whenever a previously pooled object is re-allocated. This function will be responsible for restoring state to be equivalent to newly instantiated object.

Link copied to clipboard
open override fun onDealloc()

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'.

Link copied to clipboard

Resets any existing world entity state, as a clean state is required.

Link copied to clipboard

Resets the render coordinate. This function should be called when the player leaves one of the dynamic world entities and moves back onto the root world.

Link copied to clipboard
fun setRenderCoord(level: Int, x: Int, z: Int)

Sets the render coordinate of this player. This function should only be used when the player is inside one of the world entities. The value should correspond to the coordinate at which the world entity in which the player resides, in the root world - not in the instance land.

Link copied to clipboard

Turns the previously-computed world entity info into a packet instance which can be flushed to the client. If an exception was caught during the computation of this world entity info, it will be thrown in here, allowing the server to properly handle exceptions in a per-player perspective.

Link copied to clipboard
fun updateBuildArea(buildArea: BuildArea)
fun updateBuildArea(zoneX: Int, zoneZ: Int, widthInZones: Int = BuildArea.DEFAULT_BUILD_AREA_SIZE, heightInZones: Int = BuildArea.DEFAULT_BUILD_AREA_SIZE)

Updates the build area for this player. This should always perfectly correspond to the actual build area that is sent via REBUILD_NORMAL or REBUILD_REGION packets.

Link copied to clipboard
fun updateCoord(worldId: Int, level: Int, x: Int, z: Int)

Updates the current real absolute coordinate of the local player in the world.

Link copied to clipboard
fun updateRenderDistance(distance: Int)

Updates the render distance for this player, potentially allowing the world entities to be rendered from further away. All instances will however still be constrained to within the build area, in their entirety - if they cannot fulfill that constraint, they will not be put into high resolution view.