Skip to content

Commit d0b5719

Browse files
jaglitegrannTwoTenPvP
authored andcommitted
fix: NetworkStart not called for respawned objects. (#227)
1 parent f59e691 commit d0b5719

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

MLAPI/Core/NetworkedBehaviour.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public NetworkedObject NetworkedObject
128128
public ulong OwnerClientId => NetworkedObject.OwnerClientId;
129129

130130
internal bool networkedStartInvoked = false;
131+
internal bool internalNetworkedStartInvoked = false;
131132
/// <summary>
132133
/// Gets called when message handlers are ready to be registered and the networking is setup
133134
/// </summary>

MLAPI/Core/NetworkedObject.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,14 +479,26 @@ internal void InvokeBehaviourOnGainedOwnership()
479479
}
480480
}
481481

482+
internal void ResetNetworkedStartInvoked()
483+
{
484+
for (int i = 0; i < childNetworkedBehaviours.Count; i++)
485+
{
486+
childNetworkedBehaviours[i].networkedStartInvoked = false;
487+
}
488+
}
489+
482490
internal void InvokeBehaviourNetworkSpawn(Stream stream)
483491
{
484492
for (int i = 0; i < childNetworkedBehaviours.Count; i++)
485493
{
486494
//We check if we are it's networkedObject owner incase a networkedObject exists as a child of our networkedObject.
487495
if(!childNetworkedBehaviours[i].networkedStartInvoked)
488496
{
489-
childNetworkedBehaviours[i].InternalNetworkStart();
497+
if(!childNetworkedBehaviours[i].internalNetworkedStartInvoked)
498+
{
499+
childNetworkedBehaviours[i].InternalNetworkStart();
500+
childNetworkedBehaviours[i].internalNetworkedStartInvoked = true;
501+
}
490502
childNetworkedBehaviours[i].NetworkStart(stream);
491503
childNetworkedBehaviours[i].networkedStartInvoked = true;
492504
}

MLAPI/Spawning/SpawnManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ internal static void SpawnNetworkedObjectLocally(NetworkedObject netObject, ulon
340340
}
341341
}
342342

343+
netObject.ResetNetworkedStartInvoked();
343344

344345
if (readPayload)
345346
{

0 commit comments

Comments
 (0)