mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkClient.BootstrapIdentity split into SetIdentityFlags and InvokeIdentityCallbacks
This commit is contained in:
parent
d27e08647a
commit
384e551245
@ -1353,16 +1353,23 @@ internal static void ChangeOwner(NetworkIdentity identity, ChangeOwnerMessage me
|
||||
}
|
||||
}
|
||||
|
||||
// bootstrap NetworkIdentity by initializing flags and invoking callbacks.
|
||||
// used to happen in multiple places, so let's have this in one function.
|
||||
static void BootstrapIdentity(NetworkIdentity identity)
|
||||
// set up NetworkIdentity flags on the client.
|
||||
// needs to be separate from invoking callbacks.
|
||||
// cleaner, and some places need to set flags first.
|
||||
static void SetIdentityFlags(NetworkIdentity identity)
|
||||
{
|
||||
// initialize flags before invoking callbacks.
|
||||
// this way isClient/isLocalPlayer is correct during callbacks.
|
||||
// fixes: https://github.com/MirrorNetworking/Mirror/issues/3362
|
||||
identity.isClient = true;
|
||||
identity.isLocalPlayer = localPlayer == identity;
|
||||
}
|
||||
|
||||
// invoke NetworkIdentity callbacks on the client.
|
||||
// needs to be separate from configuring flags.
|
||||
// cleaner, and some places need to set flags first.
|
||||
static void InvokeIdentityCallbacks(NetworkIdentity identity)
|
||||
{
|
||||
// invoke OnStartAuthority
|
||||
identity.NotifyAuthority();
|
||||
|
||||
@ -1372,11 +1379,19 @@ static void BootstrapIdentity(NetworkIdentity identity)
|
||||
// invoke OnStartLocalPlayer
|
||||
if (identity.isLocalPlayer)
|
||||
{
|
||||
// TODO move connection initialization to SetIdentityFlags?
|
||||
identity.connectionToServer = connection;
|
||||
identity.OnStartLocalPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
// configure flags & invoke callbacks
|
||||
static void BootstrapIdentity(NetworkIdentity identity)
|
||||
{
|
||||
SetIdentityFlags(identity);
|
||||
InvokeIdentityCallbacks(identity);
|
||||
}
|
||||
|
||||
// broadcast ///////////////////////////////////////////////////////////
|
||||
static void BroadcastTimeSnapshot()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user