private void SendEntitySpeak(EntityUid source, string message, bool hideChat = false) { if (!_actionBlocker.CanSpeak(source)) { return; } message = TransformSpeech(source, message); (message, var channel) = GetRadioPrefix(source, message); if (channel != null) { _listener.PingListeners(source, message, channel); } var messageWrap = Loc.GetString("chat-manager-entity-say-wrap-message", ("entityName", Name(source))); SendInVoiceRange(ChatChannel.Local, message, messageWrap, source, hideChat); var ev = new EntitySpokeEvent(message); RaiseLocalEvent(source, ev); _adminLogger.Add(LogType.Chat, LogImpact.Low, $"Say from {ToPrettyString(source):user}: {message}"); }
public void EntitySay(IEntity source, string message) { if (!ActionBlockerSystem.CanSpeak(source)) { return; } // Get entity's PlayerSession IPlayerSession playerSession = source.GetComponent <IActorComponent>().playerSession; // Check if message exceeds the character limit if the sender is a player if (playerSession != null) { if (message.Length > MaxMessageLength) { DispatchServerMessage(playerSession, Loc.GetString(MaxLengthExceededMessage, MaxMessageLength)); return; } } var pos = source.Transform.GridPosition; var clients = _playerManager.GetPlayersInRange(pos, VoiceRange).Select(p => p.ConnectedClient); var msg = _netManager.CreateNetMessage <MsgChatMessage>(); msg.Channel = ChatChannel.Local; msg.Message = message; msg.MessageWrap = $"{source.Name} says, \"{{0}}\""; msg.SenderEntity = source.Uid; _netManager.ServerSendToMany(msg, clients.ToList()); var listeners = _entitySystemManager.GetEntitySystem <ListeningSystem>(); listeners.PingListeners(source, pos, message); }
public void DoInstantAction(InstantActionEventArgs args) { if (!ActionBlockerSystem.CanSpeak(args.Performer)) { return; } if (!args.Performer.TryGetComponent <HumanoidAppearanceComponent>(out var humanoid)) { return; } if (!args.Performer.TryGetComponent <SharedActionsComponent>(out var actions)) { return; } if (_random.Prob(.01f) && !string.IsNullOrWhiteSpace(_wilhelm)) { EntitySystem.Get <AudioSystem>().PlayFromEntity(_wilhelm, args.Performer, AudioParams.Default.WithVolume(Volume)); } else { switch (humanoid.Sex) { case Sex.Male: if (_male == null) { break; } EntitySystem.Get <AudioSystem>().PlayFromEntity(_random.Pick(_male), args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume)); break; case Sex.Female: if (_female == null) { break; } EntitySystem.Get <AudioSystem>().PlayFromEntity(_random.Pick(_female), args.Performer, AudioHelpers.WithVariation(Variation).WithVolume(Volume)); break; default: throw new ArgumentOutOfRangeException(); } } actions.Cooldown(args.ActionType, Cooldowns.SecondsFromNow(_cooldown)); }
public void EntitySay(IEntity source, string message) { if (!ActionBlockerSystem.CanSpeak(source)) { return; } // Check if message exceeds the character limit if the sender is a player if (source.TryGetComponent(out IActorComponent actor) && message.Length > MaxMessageLength) { var feedback = Loc.GetString(MaxLengthExceededMessage, MaxMessageLength); DispatchServerMessage(actor.playerSession, feedback); return; } foreach (var handler in _chatTransformHandlers) { //TODO: rather return a bool and use a out var? message = handler(source, message); } message = message.Trim(); var pos = source.Transform.Coordinates; var clients = _playerManager.GetPlayersInRange(pos, VoiceRange).Select(p => p.ConnectedClient); if (message.StartsWith(';')) { // Remove semicolon message = message.Substring(1).TrimStart(); // Capitalize first letter message = message[0].ToString().ToUpper() + message.Remove(0, 1); if (source.TryGetComponent(out InventoryComponent inventory) && inventory.TryGetSlotItem(EquipmentSlotDefines.Slots.EARS, out ItemComponent item) && item.Owner.TryGetComponent(out HeadsetComponent headset)) { headset.RadioRequested = true; } else { source.PopupMessage(Loc.GetString("You don't have a headset on!")); } }
public void EntitySay(IEntity source, string message) { if (!ActionBlockerSystem.CanSpeak(source)) { return; } var pos = source.Transform.GridPosition; var clients = _playerManager.GetPlayersInRange(pos, VoiceRange).Select(p => p.ConnectedClient); var msg = _netManager.CreateNetMessage <MsgChatMessage>(); msg.Channel = ChatChannel.Local; msg.Message = message; msg.MessageWrap = $"{source.Name} says, \"{{0}}\""; msg.SenderEntity = source.Uid; _netManager.ServerSendToMany(msg, clients.ToList()); }
public bool TryScream(EntityUid uid, VocalComponent?component = null) { if (!Resolve(uid, ref component, false)) { return(false); } if (!_blocker.CanSpeak(uid)) { return(false); } var sex = Sex.Male; //the default is male because requiring humanoid appearance for this is dogshit if (TryComp(uid, out HumanoidAppearanceComponent? humanoid)) { sex = humanoid.Sex; } if (_random.Prob(component.WilhelmProbability)) { SoundSystem.Play(component.Wilhelm.GetSound(), Filter.Pvs(uid), uid, component.AudioParams); return(true); } var scale = (float)_random.NextGaussian(1, VocalComponent.Variation); var pitchedParams = component.AudioParams.WithPitchScale(scale); switch (sex) { case Sex.Male: SoundSystem.Play(component.MaleScream.GetSound(), Filter.Pvs(uid), uid, pitchedParams); break; case Sex.Female: SoundSystem.Play(component.FemaleScream.GetSound(), Filter.Pvs(uid), uid, pitchedParams); break; default: throw new ArgumentOutOfRangeException(); } return(true); }
public void EntitySay(IEntity source, string message) { if (!ActionBlockerSystem.CanSpeak(source)) { return; } // Get entity's PlayerSession IPlayerSession playerSession = source.GetComponent <IActorComponent>().playerSession; // Check if message exceeds the character limit if the sender is a player if (playerSession != null) { if (message.Length > MaxMessageLength) { DispatchServerMessage(playerSession, Loc.GetString(MaxLengthExceededMessage, MaxMessageLength)); return; } } foreach (var handler in _chatTransformHandlers) { //TODO: rather return a bool and use a out var? message = handler(source, message); } // Ensure the first letter inside the message string is always a capital letter message = message[0].ToString().ToUpper() + message.Remove(0, 1); var pos = source.Transform.Coordinates; var clients = _playerManager.GetPlayersInRange(pos, VoiceRange).Select(p => p.ConnectedClient); var msg = _netManager.CreateNetMessage <MsgChatMessage>(); msg.Channel = ChatChannel.Local; msg.Message = message; msg.MessageWrap = $"{source.Name} says, \"{{0}}\""; msg.SenderEntity = source.Uid; _netManager.ServerSendToMany(msg, clients.ToList()); var listeners = _entitySystemManager.GetEntitySystem <ListeningSystem>(); listeners.PingListeners(source, pos, message); }
private void OnClientTypingChanged(TypingChangedEvent ev) { // make sure that this entity still exist if (!Exists(ev.Uid)) { Logger.Warning($"Client attached entity {ev.Uid} from TypingChangedEvent doesn't exist on server."); return; } // check if this entity can speak or emote if (!_actionBlocker.CanEmote(ev.Uid) && !_actionBlocker.CanSpeak(ev.Uid)) { // nah, make sure that typing indicator is disabled SetTypingIndicatorEnabled(ev.Uid, false); return; } SetTypingIndicatorEnabled(ev.Uid, ev.IsTyping); }
public bool TryScream(EntityUid uid, VocalComponent?component = null) { if (!Resolve(uid, ref component, false)) { return(false); } if (!_blocker.CanSpeak(uid)) { return(false); } // Currently this requires humanoid appearance & doesn't have any sort of fall-back or gender-neutral scream. if (!TryComp(uid, out HumanoidAppearanceComponent? humanoid)) { return(false); } if (_random.Prob(.01f)) { SoundSystem.Play(Filter.Pvs(uid), component.Wilhelm.GetSound(), uid, component.AudioParams); return(true); } var scale = (float)_random.NextGaussian(1, VocalComponent.Variation); var pitchedParams = component.AudioParams.WithPitchScale(scale); switch (humanoid.Sex) { case Sex.Male: SoundSystem.Play(Filter.Pvs(uid), component.MaleScream.GetSound(), uid, pitchedParams); break; case Sex.Female: SoundSystem.Play(Filter.Pvs(uid), component.FemaleScream.GetSound(), uid, pitchedParams); break; default: throw new ArgumentOutOfRangeException(); } return(true); }