PlayerManager()

Keeps track of all active players in game

new PlayerManager()

Listens to Events:
  • PlayerManager#event:save
  • PlayerManager#event:updateTick
Properties:
Name Type Description
players Map
events EventManager

Player events

loader EntityLoader

Extends

  • EventEmitter

Methods

addListener(behaviorName, listener)

Parameters:
Name Type Description
behaviorName string
listener function

addPlayer(player)

Parameters:
Name Type Description
player Player

exists(name) → {boolean}

Parameters:
Name Type Description
name string
Returns:
boolean

filter(fn) → {array}

Parameters:
Name Type Description
fn function

Filter function

Returns:
array

getBroadcastTargets() → {Array.<Character>}

Used by Broadcaster

Returns:
Array.<Character>

getPlayer(name) → {Player}

Parameters:
Name Type Description
name string
Returns:
Player

getPlayersAsArray() → {array}

Returns:
array

keyify(player) → {string}

Turn player into a key used by this class's map

Parameters:
Name Type Description
player Player
Returns:
string

async loadPlayer(state, account, username, force) → {Player}

Load a player for an account

Parameters:
Name Type Description
state GameState
account Account
username string
force boolean

true to force reload from storage

Returns:
Player

removePlayer(player, killSocket)

Remove the player from the game. WARNING: You must manually save the player first as this will modify serializable properties

Parameters:
Name Type Default Description
player Player
killSocket boolean false

true to also force close the player's socket

async save()

Save a player

Fires:

async saveAll()

Fires:

setLoader(loader)

Set the entity loader from which players are loaded

Parameters:
Name Type Description
loader EntityLoader

tickAll()

Fires: