private void BroadcastSound(IMyCharacter character, PlayerNotice notice) { if (character == null || _alertAudio == null || _alertAudio.IsPlaying) { return; } _alertAudio.CustomVolume = MyAPIGateway.Session.Config.GameVolume * 0.6f; _alertAudio.CustomMaxDistance = (float?)ShieldSphere.Radius * 2; _alertAudio.Entity = (MyEntity)character; MySoundPair pair = null; switch (notice) { case PlayerNotice.EmitterInit: pair = _audioReInit; break; case PlayerNotice.FieldBlocked: pair = _audioSolidBody; break; case PlayerNotice.OverLoad: pair = _audioOverload; break; case PlayerNotice.EmpOverLoad: pair = _audioEmp; break; case PlayerNotice.Remodulate: pair = _audioRemod; break; case PlayerNotice.NoLos: pair = _audioLos; break; case PlayerNotice.NoPower: pair = _audioNoPower; break; } if (_alertAudio.Entity != null && pair != null) { _alertAudio.PlaySingleSound(pair, true); } }
private static void BroadcastSound(IMyCharacter character, PlayerNotice notice) { var soundEmitter = Session.Instance.AudioReady((MyEntity)character); if (soundEmitter == null) { return; } MySoundPair pair = null; switch (notice) { case PlayerNotice.EmitterInit: pair = new MySoundPair("Arc_reinitializing"); break; case PlayerNotice.FieldBlocked: pair = new MySoundPair("Arc_solidbody"); break; case PlayerNotice.OverLoad: pair = new MySoundPair("Arc_overloaded"); break; case PlayerNotice.EmpOverLoad: pair = new MySoundPair("Arc_EMP"); break; case PlayerNotice.Remodulate: pair = new MySoundPair("Arc_remodulating"); break; case PlayerNotice.NoLos: pair = new MySoundPair("Arc_noLOS"); break; case PlayerNotice.NoPower: pair = new MySoundPair("Arc_insufficientpower"); break; } if (soundEmitter.Entity != null && pair != null) { soundEmitter.PlaySingleSound(pair, true); } }
private void PlayerMessages(PlayerNotice notice) { double radius; if (notice == PlayerNotice.EmpOverLoad || notice == PlayerNotice.OverLoad) { radius = 500; } else { radius = ShieldSphere.Radius * 2; } var center = GridIsMobile ? MyGrid.PositionComp.WorldVolume.Center : OffsetEmitterWMatrix.Translation; var sphere = new BoundingSphereD(center, radius); var sendMessage = false; IMyPlayer targetPlayer = null; foreach (var player in Session.Instance.Players.Values) { if (player.IdentityId != MyAPIGateway.Session.Player.IdentityId) { continue; } if (!sphere.Intersects(player.Character.WorldVolume)) { continue; } var relation = MyAPIGateway.Session.Player.GetRelationTo(MyCube.OwnerId); if (relation == MyRelationsBetweenPlayerAndBlock.Neutral || relation == MyRelationsBetweenPlayerAndBlock.Enemies) { continue; } sendMessage = true; targetPlayer = player; break; } if (sendMessage && !DsSet.Settings.NoWarningSounds) { BroadcastSound(targetPlayer.Character, notice); } switch (notice) { case PlayerNotice.EmitterInit: if (sendMessage) { MyAPIGateway.Utilities.ShowNotification("[ " + MyGrid.DisplayName + " ]" + " -- shield is reinitializing and checking LOS, attempting startup in 30 seconds!", 4816); } break; case PlayerNotice.FieldBlocked: if (sendMessage) { MyAPIGateway.Utilities.ShowNotification("[ " + MyGrid.DisplayName + " ]" + "-- the shield's field cannot form when in contact with a solid body", 6720, "Blue"); } break; case PlayerNotice.OverLoad: if (sendMessage) { MyAPIGateway.Utilities.ShowNotification("[ " + MyGrid.DisplayName + " ]" + " -- shield has overloaded, restarting in 20 seconds!!", 8000, "Red"); } break; case PlayerNotice.EmpOverLoad: if (sendMessage) { MyAPIGateway.Utilities.ShowNotification("[ " + MyGrid.DisplayName + " ]" + " -- shield was EMPed, restarting in 60 seconds!!", 8000, "Red"); } break; case PlayerNotice.Remodulate: if (sendMessage) { MyAPIGateway.Utilities.ShowNotification("[ " + MyGrid.DisplayName + " ]" + " -- shield remodulating, restarting in 5 seconds.", 4800); } break; case PlayerNotice.NoLos: if (sendMessage) { MyAPIGateway.Utilities.ShowNotification("[ " + MyGrid.DisplayName + " ]" + " -- Emitter does not have line of sight, shield offline", 8000, "Red"); } break; case PlayerNotice.NoPower: if (sendMessage) { MyAPIGateway.Utilities.ShowNotification("[ " + MyGrid.DisplayName + " ]" + " -- Insufficient Power, shield is failing!", 5000, "Red"); } break; } if (Session.Enforced.Debug == 3) { Log.Line($"[PlayerMessages] Sending:{sendMessage} - rangeToClinetPlayer:{Vector3D.Distance(sphere.Center, MyAPIGateway.Session.Player.Character.WorldVolume.Center)}"); } }