NpcAvatarTracker

A class that allows us to check which players are currently observing each NPC. Servers sometimes rely on checking the players that currently observe a NPC when determining things like aggression. This implementation makes migrating to RSProt easier.

We additionally use this class to track dormant NPCs, allowing us to skip computations for NPCs that do not have any players observing them, which lets us skip potentially thousands of calculations each cycle.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
inner class AvatarSet : Set<Int>

A Set implementation to provide easy access over all the player avatars observing this NPC. Note that only a single instance per NPC is ever created, meaning this should not be stored for long-term use. The iterator of this set will throw a concurrent modification exception if it is accessed across multiple game cycles.

Functions

Link copied to clipboard
fun add(index: Int)

Adds the player with the specified index to this bit set if it doesn't already exist.

Link copied to clipboard

Returns the cached avatar set of all the indices of player avatars that this NPC avatar is being observed by.

Link copied to clipboard

Gets the current number of players observing this avatar.

Link copied to clipboard

Checks whether this NPC avatar has any players currently observing it.

Link copied to clipboard
fun remove(index: Int)

Removes a player with the specified index from this bit set if it exists.

Link copied to clipboard
fun reset()

Resets all the tracking metrics for this avatar tracker.

Link copied to clipboard
open override fun toString(): String