/// <summary> /// Unregisters a mod handler. /// </summary> /// <returns><c>true</c>, if mod handler was unregistered, <c>false</c> otherwise.</returns> /// <param name="modName">Mod Name.</param> public bool UnregisterModHandler(string modName) { var unregistered = false; lock (EventLock) { if (RegisteredRawMods.ContainsKey(modName)) { RegisteredRawMods.Remove(modName); unregistered = true; } if (RegisteredUpdateMods.ContainsKey(modName)) { RegisteredUpdateMods.Remove(modName); UpdateQueue.Remove(modName); unregistered = true; } if (RegisteredFixedUpdateMods.ContainsKey(modName)) { RegisteredFixedUpdateMods.Remove(modName); FixedUpdateQueue.Remove(modName); unregistered = true; } } return(unregistered); }
/// <inheritdoc /> public void RemoveChunk(ChunkCoordinates position, bool dispose = true) { BlockLightCalculations.Remove(position); if (Chunks.TryRemove(position, out var column)) { foreach (var blockEntity in column.GetBlockEntities) { World.EntityManager.RemoveBlockEntity( new BlockCoordinates((column.X << 4) + blockEntity.X, blockEntity.Y, (column.Z << 4) + blockEntity.Z)); } UpdateQueue.Remove(position); UpdateBorderQueue.Remove(position); if (dispose) { column.Dispose(); } } }
/// <summary> /// Removes all unsent update information of a removed entity from the update queue /// </summary> /// <param name="entityGuid">Guid of the removed entity/param> private void RemoveEntityFromQueue(Entity entity) { bool gotLock = false; try { QueueLock.Enter(ref gotLock); foreach (UpdateInfo entityUpdate in UpdateQueue) { if (entityUpdate.entityGuid.Equals(entity.Guid)) { UpdateQueue.Remove(entityUpdate); } } } finally { if (gotLock) { QueueLock.Exit(); } } }