Skip to main content

ChunkPlayerManager

A class in Root.Township, Alta.Chunks.

Server: the players that have a chunk loaded. Each Chunk has one as Players, and the chunk loads or unloads when the first player is added or the last removed.

Constructors​

MemberWhat it is
ChunkPlayerManager(Chunk chunk)Creates a ChunkPlayerManager from chunk.

Fields​

MemberWhat it is
protected HashSet<Player> playersThe set of players, compared as Unity objects.

Properties​

MemberWhat it is
Chunk Chunk { get; }The chunk these players have loaded.
int Count { get; }How many players have the chunk loaded.
IEnumerable<Player> Items { get; }The players that have the chunk loaded.

Events​

MemberWhat it is
event Action FirstItemAddedFired when the first player is added.
event Action<Player> ItemAddedFired with each player added.
event Action<Player> ItemRemovedFired with each player removed.
event Action LastItemRemovedFired when the last player is removed.

Methods​

MemberWhat it is
bool Add(Player player)Marks the chunk as loaded for the player and adds them. Returns false if the player already had it in LoadedChunks.
bool Remove(Player player)Removes the chunk from the player's LoadedChunks and removes them. Returns false if the player didn't have it loaded.
void RemoveAll()Removes every player.
2 private and internal methods
MemberWhat it is
private void OnItemAdded(Player player)Fires FirstItemAdded if this is the first player, then ItemAdded.
private void OnItemRemoved(Player player)Fires ItemRemoved, then LastItemRemoved if no players are left.

Used in​

Members of other types that take, return or hold a ChunkPlayerManager: