public override void VTSUpdate(double interpolationHd, float interpolationLd, float elapsedTime) { _listenerPosition = _cameraManager.ActiveCamera.WorldPosition.Value.AsVector3(); //Set current camera Position _soundEngine.SetListenerPosition(_listenerPosition, _cameraManager.ActiveCamera.LookAt.Value); //Update All sounds currently playing following new player position (For 3D Sounds) _soundEngine.Update3DSounds(); //Get current player chunk VisualChunk chunk; if (!_worldChunk.GetSafeChunk(MathHelper.Floor(_playerEntityManager.Player.Position.X), MathHelper.Floor(_playerEntityManager.Player.Position.Z), out chunk)) { return; } //Always active background music linked to player Mood + Time MoodSoundProcessing(_playerEntityManager.Player); //Activate Ambiant sounds following player positions, biomes, times, ... if (_biomesParams != null) { AmbiantSoundProcessing(chunk, _playerEntityManager.Player); } //Walking step sound processing WalkingSoundProcessing(); try { StaticEntitiesEmittedSoundProcessing(); } catch (InvalidOperationException x) { logger.Error("Error when processing static sounds: {0}", x.Message); } }
public void ReplaceBlocks(Vector3I[] position, byte[] blockId, BlockTag[] tags, bool isNetworkChange) { //Single block to change ============================================= if (blockId.Length == 1) { ThreadsManager.RunAsync(() => ReplaceBlockThreaded(position[0], blockId[0], isNetworkChange, tags != null ? tags[0] : null), singleConcurrencyRun: true); return; } //Multiple blocks to change ============================================= Dictionary <VisualChunk, List <TerraCubePositionTag> > blockPerChunk = new Dictionary <VisualChunk, List <TerraCubePositionTag> >(); List <TerraCubePositionTag> blockList; //Multiple block to changes at once //Split the various blocks by chunks for (int i = 0; i < blockId.Length; i++) { BlockTag tag = tags != null ? tags[i] : null; VisualChunk impactedChunk; if (_worldChunks.GetSafeChunk(position[i].X, position[i].Z, out impactedChunk)) { if (!blockPerChunk.TryGetValue(impactedChunk, out blockList)) { blockList = new List <TerraCubePositionTag>(); blockPerChunk[impactedChunk] = blockList; } blockList.Add(new TerraCubePositionTag(position[i], blockId[i], tag)); } } //Create a thread for working on the update per chunk ! foreach (var blocks in blockPerChunk) { ThreadsManager.RunAsync(() => ReplaceChunkBlocksThreaded(blocks.Key, blocks.Value, isNetworkChange), singleConcurrencyRun: true); } }