internal void RemovePlayer(Player player) { if (player.Id != 0) { //first need to inform the room, if there is one, of the player's disconnect. //Otherwise a new player might obtain the id and send that to a new room before this message gets there player.DisconnectOnRoom(); //this will clean up the player whether or not they actually finished being added. lock (_players) { _players.Remove(player.Id); PlayerCount--; } Room.MovePlayerCount(this, player.CurrentRoomGuid, Guid.Empty); } //it is necessary that we still raise the event, in case users are doing something during verification try { PlayerRemoved?.Invoke(player); } catch (Exception e) { Debug.LogException(e); } }
private void RemovePlayer(Player player) { if (player.Id == 0) { return; } //first need to inform the room, if there is one, of the player's disconnect. //Otherwise a new player might obtain the id and send that to a new room before this message gets there player.DisconnectOnRoom(); //this will clean up the player whether or not they actually finished being added. lock (_players) _players.Remove(player.Id); Room.MovePlayerCount(this, player.CurrentRoomGuid, Guid.Empty); //todo: anything else? this is run on disconnect try { PlayerRemoved?.Invoke(player); } catch (Exception e) { Debug.LogException(e); } }
/// <summary> /// run a single step /// </summary> public void Update(float?newTime = null) { if (newTime == null) { Time.Update((float)_watch.Elapsed.TotalSeconds); } else { Time.Update(newTime.Value); } //TODO: call update on everything _keysToRemove.Clear(); for (int i = 0; i < _gameObjects.Capacity; i++) { GameObject gobj; if (_gameObjects.TryGetValue(i, out gobj)) { if (Object.IsNull(gobj)) { _gameObjects.Remove(i); } else { gobj.RunComponentUpdates(); } } } foreach (var go in _gameObjects) { if (go) { go.RunCoroutines(); } } foreach (var go in _gameObjects) { if (go) { go.RunComponentLateUpdates(); } } foreach (var go in _gameObjects) { if (go) { go.RunEndOfFrameCoroutines(); } } //clear out destroyed objects foreach (var key in _keysToRemove) { _gameObjects.Remove(key); } _keysToRemove.Clear(); }
public void RemoveAddTest() { var add = new MockObject(); for (int i = 0; i < 10; i++) { _target.Add(add); } _target.Remove(3); int expected = 3; int actual = _target.Add(add); Assert.AreEqual(expected, actual); _target.Remove(0); expected = 0; actual = _target.Add(add); Assert.AreEqual(expected, actual); //make sure out of bounds doesn't throw _target.Remove(int.MaxValue); }
internal void RemoveView(NetworkView view) { if (view.Manager == this) { _allViews.Remove(view.ViewID.guid); RecycleNetworkView(view); } }
async Task RemoveRegistration(Registration registration) { _registrationLookup.Remove(registration.UserId); _registrations.Remove(registration); foreach (var groupId in await _groupsClient.GetUsersGroups(registration.UserId)) { _registeredGroupMembersLookup[groupId].Remove(registration.EndPoint); } }
internal static void RemoveObject(GameObject gobj) { // if (gobj.Id == -1) { Debug.LogError("Attempted to remove a gameobject with an Id of -1. This happens only if the gameobject has not fully registered with the gamestate before being destroyed. This should never happen. Throwing."); throw new Exception("Attempted to remove a gameobject with an Id of -1. This would be due to a gameobject not fully registering itself with the gamestate before being destroyed. This should never happen"); } GameObjects.Remove(gobj.Id); }
internal static void RemoveView(NetworkView view) { lock (ViewsLock) { var findView = Views[view.viewID.guid]; if (findView != null) { if (findView == view) { Views.Remove(view.viewID.guid); } } } }
internal static void DestroyAllViews() { var cap = allViews.Capacity; for (int i = 0; i < cap; i++) { NetworkView view; if (allViews.TryGetValue(i, out view)) { Destroy(view.gameObject); } allViews.Remove(i); } }
/////////////////////////////////////////////////////////////////////// private static void UnsetTraceCategories( IEnumerable <string> categories ) { lock (syncRoot) /* TRANSACTIONAL */ { // // NOTE: If the dictionary of "allowed" trace categories has // not been created yet, do so now. // if (traceCategories == null) { traceCategories = new IntDictionary(); } // // NOTE: If there are no trace categories specified, the trace // category dictionary may be created; however, it will // not be removed from. // if (categories != null) { foreach (string category in categories) { // // NOTE: Skip null categories. // if (category == null) { continue; } // // NOTE: Remove the trace category. // traceCategories.Remove(category); } } } }
internal void UnsubscribeSynchronizedField(int fieldId) { FieldProcessors.Remove(fieldId); }
internal static void RemoveObject(GameObject gobj) { GameObjects.Remove(gobj.Id); }
public void IntDictionaryComparisonTest() { const int TestSize = 10000000; var intDic = new IntDictionary<MockObject>(32); var dic = new Dictionary<int, MockObject>(32); //jit shit. var add = new MockObject(); add.Id = intDic.Add(add); foreach (var kvp in intDic) { kvp.DoNothing(); } intDic.Remove(add.Id); add.Id = 0; dic.Add(add.Id, add); foreach (var kvp in dic) { kvp.Value.DoNothing(); } dic.Remove(add.Id); Stopwatch watch = new Stopwatch(); watch.Reset(); //the real tests watch.Start(); for (int i = 0; i < TestSize; i++) { var foo = new MockObject(); foo.Id = intDic.Add(foo); } watch.Stop(); Debug.WriteLine("IntDic add: {0}", watch.Elapsed); watch.Reset(); watch.Start(); for (int i = 0; i < TestSize; i++) { var foo = new MockObject(); foo.Id = i; dic.Add(i, foo); } watch.Stop(); Debug.WriteLine("Dic add: {0}", watch.Elapsed); watch.Reset(); watch.Start(); foreach (var kvp in intDic) { if (kvp != null) kvp.DoNothing(); } watch.Stop(); Debug.WriteLine("Intdic foreach: {0}", watch.Elapsed); watch.Reset(); watch.Start(); foreach (var kvp in dic) { kvp.Value.DoNothing(); } watch.Stop(); Debug.WriteLine("Dic foreach: {0}", watch.Elapsed); watch.Reset(); watch.Start(); for (int i = 0; i < intDic.Capacity; i++) { MockObject value; if (intDic.TryGetValue(i, out value)) value.DoNothing(); } watch.Stop(); Debug.WriteLine("Intdic for: {0}", watch.Elapsed); watch.Reset(); const int halfSize = TestSize / 2; watch.Start(); for (int i = 0; i < halfSize; i++) { intDic.Remove(i); } watch.Stop(); Debug.WriteLine("Intdic remove: {0}", watch.Elapsed); watch.Reset(); watch.Start(); for (int i = 0; i < halfSize; i++) { dic.Remove(i); } watch.Stop(); Debug.WriteLine("dic remove: {0}", watch.Elapsed); watch.Reset(); watch.Start(); foreach (var kvp in intDic) { if (kvp != null) kvp.DoNothing(); } watch.Stop(); Debug.WriteLine("intdic foreach after remove: {0}", watch.Elapsed); watch.Reset(); watch.Start(); foreach (var kvp in dic) { kvp.Value.DoNothing(); } watch.Stop(); Debug.WriteLine("dic foreach after remove: {0}", watch.Elapsed); watch.Reset(); }
internal void Remove(int value) { _ReplaceFieldValueIntToDocId.Remove(value); }
/// <summary> /// remove the network view. This does not verify that the object in the slot was the same thing. Use contains to check that. /// </summary> /// <param name="view"></param> internal void Remove(NetworkView view) { _networkViews.Remove(view.Id); }
public void IntDictionaryComparisonTest() { const int TestSize = 10000000; var intDic = new IntDictionary <MockObject>(32); var dic = new Dictionary <int, MockObject>(32); //jit shit. var add = new MockObject(); add.Id = intDic.Add(add); foreach (var kvp in intDic) { kvp.DoNothing(); } intDic.Remove(add.Id); add.Id = 0; dic.Add(add.Id, add); foreach (var kvp in dic) { kvp.Value.DoNothing(); } dic.Remove(add.Id); Stopwatch watch = new Stopwatch(); watch.Reset(); //the real tests watch.Start(); for (int i = 0; i < TestSize; i++) { var foo = new MockObject(); foo.Id = intDic.Add(foo); } watch.Stop(); Debug.WriteLine("IntDic add: {0}", watch.Elapsed); watch.Reset(); watch.Start(); for (int i = 0; i < TestSize; i++) { var foo = new MockObject(); foo.Id = i; dic.Add(i, foo); } watch.Stop(); Debug.WriteLine("Dic add: {0}", watch.Elapsed); watch.Reset(); watch.Start(); foreach (var kvp in intDic) { if (kvp != null) { kvp.DoNothing(); } } watch.Stop(); Debug.WriteLine("Intdic foreach: {0}", watch.Elapsed); watch.Reset(); watch.Start(); foreach (var kvp in dic) { kvp.Value.DoNothing(); } watch.Stop(); Debug.WriteLine("Dic foreach: {0}", watch.Elapsed); watch.Reset(); watch.Start(); for (int i = 0; i < intDic.Capacity; i++) { MockObject value; if (intDic.TryGetValue(i, out value)) { value.DoNothing(); } } watch.Stop(); Debug.WriteLine("Intdic for: {0}", watch.Elapsed); watch.Reset(); const int halfSize = TestSize / 2; watch.Start(); for (int i = 0; i < halfSize; i++) { intDic.Remove(i); } watch.Stop(); Debug.WriteLine("Intdic remove: {0}", watch.Elapsed); watch.Reset(); watch.Start(); for (int i = 0; i < halfSize; i++) { dic.Remove(i); } watch.Stop(); Debug.WriteLine("dic remove: {0}", watch.Elapsed); watch.Reset(); watch.Start(); foreach (var kvp in intDic) { if (kvp != null) { kvp.DoNothing(); } } watch.Stop(); Debug.WriteLine("intdic foreach after remove: {0}", watch.Elapsed); watch.Reset(); watch.Start(); foreach (var kvp in dic) { kvp.Value.DoNothing(); } watch.Stop(); Debug.WriteLine("dic foreach after remove: {0}", watch.Elapsed); watch.Reset(); }