Skip to main content

NetworkEntityComponentController

A class in Root.Township, Alta.Networking.

Turns lists of components on or off depending on whether this is the server or a client, and whether the player entity is the local player or a remote one.

Constructors​

MemberWhat it is
NetworkEntityComponentController()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​

5 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 IInitializeAsRemotePlayer.InitializeAsRemotePlayer(PlayerController player)Turns on the remote behaviours and turns off the local ones.
private void SetBehavioursEnabled(NetworkEntity entity)After init, turns server behaviours on only on the server and client behaviours only on clients. Skipped in local test.
private void SetComponentsEnabled(IEnumerable<Behaviour> components, bool isEnabled)Sets enabled on each component in the list.