NpcAvatarFactory

class NpcAvatarFactory(allocator: ByteBufAllocator, extendedInfoFilter: ExtendedInfoFilter, extendedInfoWriter: List<NpcAvatarExtendedInfoWriter>, huffmanCodec: HuffmanCodecProvider, zoneIndexStorage: ZoneIndexStorage, npcInfoProtocolSupplier: DeferredNpcInfoProtocolSupplier)

NPC avatar factor is responsible for allocating new avatars for NPCs, or, if possible, re-using old ones that are no longer in use, to avoid generating mass amounts of garbage.

Parameters

allocator

the byte buffer allocator used to pre-compute bitcodes for this avatar.

extendedInfoFilter

the filter used to determine whether the given NPC can still have extended info blocks written to it, or if we have to utilize a fall-back and tell the client that despite extended info having been flagged, we cannot write it (by writing the flag itself as a zero, so the client reads no further information).

extendedInfoWriter

the client-specific extended info writers for NPC information.

huffmanCodec

the huffman codec is used to compress chat extended info. While NPCs do not currently have any such extended info blocks, the interface requires it be passed in, so we must still provide it.

zoneIndexStorage

the collection that keeps track of npc indices in various zones.

npcInfoProtocolSupplier

a supplier for the npc info protocol. This is a cheap hack to get around a circular dependency issue without rewriting a great deal of code.

Constructors

Link copied to clipboard
constructor(allocator: ByteBufAllocator, extendedInfoFilter: ExtendedInfoFilter, extendedInfoWriter: List<NpcAvatarExtendedInfoWriter>, huffmanCodec: HuffmanCodecProvider, zoneIndexStorage: ZoneIndexStorage, npcInfoProtocolSupplier: DeferredNpcInfoProtocolSupplier)

Functions

Link copied to clipboard
fun alloc(index: Int, id: Int, level: Int, x: Int, z: Int, spawnCycle: Int = 0, direction: Int = 0, priority: AvatarPriority = AvatarPriority.NORMAL, specific: Boolean = false): NpcAvatar

Allocates a new NPC avatar, or re-uses an older cached one if possible.

Link copied to clipboard
fun release(avatar: NpcAvatar)

Releases the avatar back into the repository to be used by other NPCs.