/// <summary> Registers model id. </summary> public void Register(long id) { if (_renderMode == RenderMode.Scene) { _localIds.Add(id); } }
/// <summary> ///Add 的测试 ///</summary> public void AddTestHelper <KeyT>() { SafeHashSet <KeyT> target = new SafeHashSet <KeyT>(); // TODO: 初始化为适当的值 KeyT key = default(KeyT); // TODO: 初始化为适当的值 target.Add(key); Assert.Inconclusive("无法验证不返回值的方法。"); }
/// <summary> Register element with given id inside to prevent multiple loading. </summary> /// <remarks> /// Mostly used for objects which cross tile borders, but their geometry is /// not clipped (buildings one of examples) /// </remarks> public void Register(long id) { if (IsDisposed) { return; } _localIds.Add(id); GlobalIds.Add(id); }
public void SafeHashSet依照加入指定元素_集合中已經包含該元素故加入失敗_SafeHashSet應包含該元素並應回傳False() { var safeHashSet = new SafeHashSet <int> { 0, 1, 2, 3, 4, 5 }; const int element = 3; var result = safeHashSet.Add(element); result.Should().Be(false); var isContain = safeHashSet.Contains(element); isContain.Should().Be(true); }
public void SafeHashSet依照加入指定元素_加入成功_SafeHashSet應包含該元素並回傳True() { var safeHashSet = new SafeHashSet <int> { 0, 1, 2, 3, 4, 5 }; const int element = 10; var result = safeHashSet.Add(element); result.Should().Be(true); var isContain = safeHashSet.Contains(element); isContain.Should().Be(true); }
public void 繞行SafeHashSet操作集合_不同執行緒同時對SafeHashSet操作新增與刪除_不應擲出例外() { var safeHashSet = new SafeHashSet <int> { 1, 2, 3, 4, 5 }; Task.Run(() => { while (true) { safeHashSet.Add(0); } }); Task.Run(() => { while (true) { safeHashSet.Remove(0); } }); Task.Run(() => { while (true) { safeHashSet.Clear(); } }); Task.Run(() => { while (true) { safeHashSet.IntersectWith(Enumerable.Range(0, 3)); } }); Task.Run(() => { while (true) { safeHashSet.UnionWith(Enumerable.Range(0, 3)); } }); Action action = () => IterateCollection(safeHashSet).Wait(); action.Should().NotThrow(); }
// NOTE: jh 2010.10.01 // When we move to .NET 4.0 we'll have a proper ISet interface. Until // then, this factory method doesn't really make much sense. /* * protected virtual ISet instantiateSet() * { * return new HashSet(); * } */ /// <summary> /// Check the entry against the set of entries not included in the /// index and update the set if necessary. /// </summary> /// <param name="entry"> /// The entry to be checked. /// </param> /// <param name="excluded"> /// True if the insert or update of the entry into the index caused /// an exception. /// </param> protected void UpdateExcludedKeys(ICacheEntry entry, bool excluded) { SafeHashSet setExcluded = m_keysExcluded; if (excluded || !(setExcluded.Count == 0)) { Object key = entry.Key; if (excluded) { setExcluded.Add(key); } else { setExcluded.Remove(key); } } }
public void Listen(Action action, object owner = null) => listeners.Add(new WeakAction(action, owner));
/// <summary> Register element with given id inside to prevent multiple loading. </summary> public void Register(long id) { _localIds.Add(id); GlobalIds.Add(id); }
/// <summary> /// /// </summary> /// <param name="dt"></param> public virtual void OnUpdate(object sender, ProcessSliceEventArgs eventArgs) { if (m_isInWorld == false) { return; } uint uiUpdateCount = 0; MemoryPacket memoryPacket = new MemoryPacket(); // 把自己改变得值广播到附近 this.BroadcastValueUpdate(); // 开始更新道具 // 开始更新 新的游戏道具 if (m_NewItems.Count > 0) { WowItem[] newItemArray = m_NewItems.ToArrayAndClear(); foreach (var newItem in newItemArray) { //item.OnInsert(); newItem.ObjectCreationUpdate(memoryPacket, true); //obj.m_isInWorld = true; } uiUpdateCount += (uint)newItemArray.Length; } // 结束更新 新的游戏道具 // 开始跟新 存在的游戏道具 WowItem[] ownedItemArray = m_OwnedItemsRequiringUpdates.ToArrayAndClear(); foreach (var ownedItem in ownedItemArray) { ownedItem.BroadcastValueUpdate(); } // 结束跟新 存在的游戏道具 // 检测 if ((eventArgs.UpdateTime - m_PreUpdateTime) < ProcessServer.WowZoneCluster.World.UpdateWorldSpeed && uiUpdateCount > 0) { // 仅仅更新道具,就发送数据 然后退出 // 完成更新 this.AddUpdateData(memoryPacket, uiUpdateCount); this.SendUpdates(); return; } // 如果还需要更新人物等。。。 HashSet <WorldEntity> newWorldEntity = new HashSet <WorldEntity>(); // 获取附近的对象 IEnumerable <WorldEntity> nearbyWorldEntity = this.GetAllEntitysInRange(WowCharacter.BROAD_CAST_RANGE); // 排除已存在的对象 newWorldEntity.AddRange(nearbyWorldEntity); newWorldEntity.ExceptWith(m_KnownEntity); newWorldEntity.Remove(this); // 开始更新 新的游戏物体 foreach (WorldEntity entity in newWorldEntity) { WowCharacter wowCharacter = entity as WowCharacter; if (wowCharacter != null) { m_KnownCharacters.Add(wowCharacter); } IWowUpdate wowUpdate = entity.GetComponent <IWowUpdate>(WowUpdate.WOW_UPDATE_COMPONENT_ID); if (wowUpdate != null) { wowUpdate.ObjectCreationUpdate(memoryPacket, false); } //OnEncountered( obj ); } uiUpdateCount += (uint)newWorldEntity.Count; // 结束更新 新的游戏物体 // 获取已不再附近的对象 HashSet <WorldEntity> outOfRangeWorldEntity = new HashSet <WorldEntity>(); // 排除已不存在的对象 outOfRangeWorldEntity.AddRange(m_KnownEntity); outOfRangeWorldEntity.ExceptWith(nearbyWorldEntity); foreach (WorldEntity entity in outOfRangeWorldEntity) { WowCharacter wowCharacter = entity as WowCharacter; if (wowCharacter != null) { m_KnownCharacters.Remove(wowCharacter); } // m_outOfRange.Add(obj.EntityId); //OnOutOfRange( obj ); } // 添加现在已存在附近的游戏物体 m_KnownEntity.Clear(); m_KnownEntity.AddRange(nearbyWorldEntity); // 完成更新 if (uiUpdateCount > 0) { this.AddUpdateData(memoryPacket, uiUpdateCount); this.SendUpdates(); } foreach (var entity in outOfRangeWorldEntity) { // send the destroy packet IWowUpdate wowUpdate = entity.GetComponent <IWowUpdate>(WowUpdate.WOW_UPDATE_COMPONENT_ID); if (wowUpdate != null) { wowUpdate.SendDestroyToPlayer(this); } } m_PreUpdateTime = eventArgs.UpdateTime; }