fix: Network Id Zero
This commit is contained in:
parent
d011bf9a7a
commit
150deaa618
|
@ -124,10 +124,26 @@ public abstract class NetworkBase : BehaviourOverride, INetworkCommunicator
|
|||
}
|
||||
|
||||
private void OnNetworkEntityCollected(BehaviourCollector<INetworkEntity> sender, INetworkEntity behaviourCollected)
|
||||
=> networkEntities.Add(behaviourCollected.NetworkId, behaviourCollected);
|
||||
{
|
||||
if (behaviourCollected.NetworkId != 0)
|
||||
networkEntities.Add(behaviourCollected.NetworkId, behaviourCollected);
|
||||
|
||||
behaviourCollected.OnNetworkIdChanged += OnNetworkIdChanged;
|
||||
}
|
||||
|
||||
private void OnNetworkIdChanged(INetworkEntity sender, uint previousId)
|
||||
{
|
||||
if (networkEntities.TryGetValue(previousId, out INetworkEntity? networkEntity) && sender == networkEntity)
|
||||
networkEntities.Remove(previousId);
|
||||
|
||||
networkEntities.Add(sender.NetworkId, sender);
|
||||
}
|
||||
|
||||
private void OnNetworkEntityRemoved(BehaviourCollector<INetworkEntity> sender, INetworkEntity behaviourRemoved)
|
||||
=> networkEntities.Remove(behaviourRemoved.NetworkId);
|
||||
{
|
||||
networkEntities.Remove(behaviourRemoved.NetworkId);
|
||||
behaviourRemoved.OnNetworkIdChanged -= OnNetworkIdChanged;
|
||||
}
|
||||
|
||||
private void NetworkReceiveEvent(NetPeer peer, NetPacketReader reader, byte channel, DeliveryMethod deliveryMethod)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue