fix: MatchInterestManagement - use TryGetValue in OnDestroyed

This commit is contained in:
MrGadget 2022-11-29 06:16:53 -05:00
parent 186702f810
commit f67aa64d59

View File

@ -43,10 +43,12 @@ public override void OnSpawned(NetworkIdentity identity)
public override void OnDestroyed(NetworkIdentity identity) public override void OnDestroyed(NetworkIdentity identity)
{ {
lastObjectMatch.TryGetValue(identity, out Guid currentMatch); if (lastObjectMatch.TryGetValue(identity, out Guid currentMatch))
lastObjectMatch.Remove(identity); {
if (currentMatch != Guid.Empty && matchObjects.TryGetValue(currentMatch, out HashSet<NetworkIdentity> objects) && objects.Remove(identity)) lastObjectMatch.Remove(identity);
RebuildMatchObservers(currentMatch); if (currentMatch != Guid.Empty && matchObjects.TryGetValue(currentMatch, out HashSet<NetworkIdentity> objects) && objects.Remove(identity))
RebuildMatchObservers(currentMatch);
}
} }
// internal so we can update from tests // internal so we can update from tests