private SetLocalPlayer ( short localPlayerControllerId ) : void | ||
localPlayerControllerId | short | |
return | void |
internal void SetLocalPlayer(short localPlayerControllerId)
{
this.m_IsLocalPlayer = true;
this.m_PlayerId = localPlayerControllerId;
bool hasAuthority = this.m_HasAuthority;
if (this.localPlayerAuthority)
{
this.m_HasAuthority = true;
}
for (int i = 0; i < this.m_NetworkBehaviours.Length; i++)
{
NetworkBehaviour behaviour = this.m_NetworkBehaviours[i];
behaviour.OnStartLocalPlayer();
if (this.localPlayerAuthority && !hasAuthority)
{
behaviour.OnStartAuthority();
}
}
}
static void CheckForOwner(NetworkIdentity uv) { for (int i = 0; i < s_PendingOwnerIds.Count; i++) { var pendingOwner = s_PendingOwnerIds[i]; if (pendingOwner.netId == uv.netId) { // found owner, turn into a local player // Set isLocalPlayer to true on this NetworkIdentity and trigger OnStartLocalPlayer in all scripts on the same GO uv.SetConnectionToServer(s_ReadyConnection); uv.SetLocalPlayer(pendingOwner.playerControllerId); if (LogFilter.logDev) { Debug.Log("ClientScene::OnOwnerMessage - player=" + uv.gameObject.name); } if (s_ReadyConnection.connectionId < 0) { if (LogFilter.logError) { Debug.LogError("Owner message received on a local client."); } return; } InternalAddPlayer(uv, pendingOwner.playerControllerId); s_PendingOwnerIds.RemoveAt(i); break; } } }