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.
|
// set up NetworkIdentity flags on the client.
|
||||||
// used to happen in multiple places, so let's have this in one function.
|
// needs to be separate from invoking callbacks.
|
||||||
static void BootstrapIdentity(NetworkIdentity identity)
|
// cleaner, and some places need to set flags first.
|
||||||
|
static void SetIdentityFlags(NetworkIdentity identity)
|
||||||
{
|
{
|
||||||
// initialize flags before invoking callbacks.
|
// initialize flags before invoking callbacks.
|
||||||
// this way isClient/isLocalPlayer is correct during callbacks.
|
// this way isClient/isLocalPlayer is correct during callbacks.
|
||||||
// fixes: https://github.com/MirrorNetworking/Mirror/issues/3362
|
// fixes: https://github.com/MirrorNetworking/Mirror/issues/3362
|
||||||
identity.isClient = true;
|
identity.isClient = true;
|
||||||
identity.isLocalPlayer = localPlayer == identity;
|
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
|
// invoke OnStartAuthority
|
||||||
identity.NotifyAuthority();
|
identity.NotifyAuthority();
|
||||||
|
|
||||||
@ -1372,11 +1379,19 @@ static void BootstrapIdentity(NetworkIdentity identity)
|
|||||||
// invoke OnStartLocalPlayer
|
// invoke OnStartLocalPlayer
|
||||||
if (identity.isLocalPlayer)
|
if (identity.isLocalPlayer)
|
||||||
{
|
{
|
||||||
|
// TODO move connection initialization to SetIdentityFlags?
|
||||||
identity.connectionToServer = connection;
|
identity.connectionToServer = connection;
|
||||||
identity.OnStartLocalPlayer();
|
identity.OnStartLocalPlayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// configure flags & invoke callbacks
|
||||||
|
static void BootstrapIdentity(NetworkIdentity identity)
|
||||||
|
{
|
||||||
|
SetIdentityFlags(identity);
|
||||||
|
InvokeIdentityCallbacks(identity);
|
||||||
|
}
|
||||||
|
|
||||||
// broadcast ///////////////////////////////////////////////////////////
|
// broadcast ///////////////////////////////////////////////////////////
|
||||||
static void BroadcastTimeSnapshot()
|
static void BroadcastTimeSnapshot()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user