Skip to main content

PlayerComponentController

A class in Root.Township, Alta.Networking.

Turns lists of components on or off for a player entity: server-only, client-only, and local player versus remote player. Starts every player as remote until it becomes the local player.

Constructors​

MemberWhat it is
PlayerComponentController()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

4 private and internal fields
MemberWhat it is
private List<Behaviour> clientBehavioursComponents enabled only on clients.
private List<Behaviour> localBehavioursComponents enabled only for the local player.
private List<Behaviour> remoteBehavioursComponents enabled only for remote players.
private List<Behaviour> serverBehavioursComponents enabled only on the server.

Methods​

4 private and internal methods
MemberWhat it is
private void Awake()Hooks up to the entity's InitializationFinished event.
private void IInitializeAsLocalPlayer.InitializeAsLocalPlayer(PlayerController player)Turns on the local behaviours and turns off the remote ones.
private void SetBehavioursEnabled(NetworkEntity entity)After init, sets server and client behaviours by side (skipped in local test), then turns local off and remote on.
private void SetComponentsEnabled(IEnumerable<Behaviour> components, bool isEnabled)Sets enabled on each component in the list.