//Handle Entity HealthState change private void EntityHealthStateChanged(object sender, EntityHealthStateChangeEventArgs e) { //Check if the entity entered the Dead state switch (e.NewState) { case DynamicEntityHealthState.Normal: if (e.PreviousState == DynamicEntityHealthState.Dead) { //Force a refresh of voxel body UpdateEntityVoxelBody(e.DynamicEntity.DynamicId, null); } break; case DynamicEntityHealthState.Drowning: break; case DynamicEntityHealthState.Dead: //Force a refresh of voxel body UpdateEntityVoxelBody(e.DynamicEntity.DynamicId, null); //Play dead sound only if player not active player if (!IsLocalPlayer(e.DynamicEntity.DynamicId)) { _soundEngine.StartPlay3D("Dying", 1.0f, e.DynamicEntity.Position.AsVector3()); } break; default: break; } }
private byte PlayWalkingSound(byte cubeId, DynamicEntitySoundTrack entityTrack) { List <SoundMetaData> sounds; byte soundIndex = 0; // play a water sound if (_stepsSounds.TryGetValue(cubeId, out sounds)) { // choose another sound to avoid playing the same sound one after another while (sounds.Count > 1 && entityTrack.LastSound == soundIndex) { soundIndex = (byte)_rnd.Next(0, sounds.Count); } if (entityTrack.isLocalSound) { _soundEngine.StartPlay2D(sounds[soundIndex].Alias, SourceCategory.FX); } else { _soundEngine.StartPlay3D(sounds[soundIndex].Alias, new Vector3((float)entityTrack.Entity.Position.X, (float)entityTrack.Entity.Position.Y, (float)entityTrack.Entity.Position.Z), SourceCategory.FX); } } return(soundIndex); }