public void UpdateSubscribings(HashSet <uint> newSubscribings) { if (!IsServer || ConnectionId < 0 || !Player.IsReady) { // This is not player's networked object return; } // Always add controlled network object to subscribe it LiteNetLibIdentity tempIdentity; newSubscribings.Add(ObjectId); foreach (uint oldSubscribing in Subscribings) { if (oldSubscribing == ObjectId) { continue; } if (!newSubscribings.Contains(oldSubscribing)) { Player.Unsubscribe(oldSubscribing); if (Manager.LogDebug) { Logging.Log(LogTag, $"Player: {ConnectionId} unsubscribe object ID: {oldSubscribing}."); } } } Subscribings.Clear(); foreach (uint newSubscribing in newSubscribings) { if (!Manager.Assets.TryGetSpawnedObject(newSubscribing, out tempIdentity) || tempIdentity.IsDestroyed) { continue; } Subscribings.Add(newSubscribing); Player.Subscribe(newSubscribing); if (Manager.LogDebug) { Logging.Log(LogTag, $"Player: {ConnectionId} subscribe object ID: {newSubscribing}."); } } }
public void RemoveSubscribing(uint subscribing) { Subscribings.Remove(subscribing); Player.Unsubscribe(subscribing); }