diff --git a/Content.Server/Chat/ChatCommands.cs b/Content.Server/Chat/ChatCommands.cs index c5f194d429..9450fa45fc 100644 --- a/Content.Server/Chat/ChatCommands.cs +++ b/Content.Server/Chat/ChatCommands.cs @@ -5,9 +5,11 @@ using Content.Server.GameObjects.Components.Items.Storage; using Content.Server.GameObjects.Components.Observer; using Content.Server.Interfaces.Chat; using Content.Server.Interfaces.GameObjects; +using Content.Server.Interfaces; using Content.Server.Observer; using Content.Server.Players; using Content.Shared.GameObjects.Components.Damage; +using Content.Shared.Interfaces; using Robust.Server.Interfaces.Console; using Robust.Server.Interfaces.Player; using Robust.Shared.Enums; @@ -116,6 +118,9 @@ namespace Content.Server.Chat internal class SuicideCommand : IClientCommand { + [Dependency] private readonly IPlayerManager _playerManager = default!; + [Dependency] private readonly IServerNotifyManager _notifyManager = default!; + public string Command => "suicide"; public string Description => "Commits suicide"; @@ -186,12 +191,29 @@ namespace Content.Server.Chat } } // Default suicide, bite your tongue - chat.EntityMe(owner, Loc.GetString("is attempting to bite {0:their} own tongue, looks like {0:theyre} trying to commit suicide!", owner)); //TODO: theyre macro + PopupMessageOtherClientsInRange(owner, Loc.GetString("{0:theName} is attempting to bite {0:their} own tongue!", owner), 15); + _notifyManager.PopupMessage(owner, owner, Loc.GetString("You attempt to bite your own tongue!")); dmgComponent.ChangeDamage(DamageType.Piercing, 500, true, owner); // Prevent the player from returning to the body. Yes, this is an ugly hack. var ghost = new Ghost(){CanReturn = false}; ghost.Execute(shell, player, Array.Empty()); } + private void PopupMessageOtherClientsInRange(IEntity source, string message, int maxReceiveDistance) + { + var viewers = _playerManager.GetPlayersInRange(source.Transform.GridPosition, maxReceiveDistance); + + foreach (var viewer in viewers) + { + var viewerEntity = viewer.AttachedEntity; + + if (viewerEntity == null || source == viewerEntity) + { + continue; + } + + source.PopupMessage(viewer.AttachedEntity, message); + } + } } } diff --git a/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs b/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs index 7f37eef2e5..5a5228cdbd 100644 --- a/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs @@ -8,12 +8,16 @@ using Content.Server.GameObjects.EntitySystems; using Content.Server.Interfaces; using Content.Server.Interfaces.Chat; using Content.Server.Interfaces.GameObjects; +using Content.Server.GameObjects.EntitySystems.DoAfter; using Content.Shared.Chemistry; using Content.Shared.GameObjects; using Content.Shared.GameObjects.Components.Interactable; using Content.Shared.Interfaces.GameObjects.Components; +using Content.Shared.Interfaces; using Robust.Server.GameObjects; +using Robust.Server.Interfaces.Player; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Systems; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; @@ -31,6 +35,7 @@ namespace Content.Server.GameObjects.Components.Interactable { [Dependency] private readonly IEntitySystemManager _entitySystemManager = default!; [Dependency] private readonly IServerNotifyManager _notifyManager = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; public override string Name => "Welder"; public override uint? NetID => ContentNetIDs.WELDER; @@ -256,11 +261,13 @@ namespace Content.Server.GameObjects.Components.Interactable if (TryWeld(5, victim, silent: true)) { PlaySoundCollection(WeldSoundCollection); - chat.EntityMe(victim, Loc.GetString("welds {0:their} every orifice closed! It looks like {0:theyre} trying to commit suicide!", victim)); + PopupMessageOtherClientsInRange(victim, Loc.GetString("{0:theName} welds {0:their} every orifice closed! It looks like {0:theyre} trying to commit suicide!", victim), 15); + _notifyManager.PopupMessage(victim, victim, Loc.GetString("You weld your every orifice closed!")); return SuicideKind.Heat; } - chat.EntityMe(victim, Loc.GetString("bashes {0:themselves} with the {1}!", victim, Owner.Name)); + PopupMessageOtherClientsInRange(victim, Loc.GetString("{0:theName} bashes themselves with the unlit welding torch!", victim), 15); + _notifyManager.PopupMessage(victim, victim, Loc.GetString("You bash yourself with the unlit welding torch!")); return SuicideKind.Blunt; } @@ -268,5 +275,22 @@ namespace Content.Server.GameObjects.Components.Interactable { Dirty(); } + + private void PopupMessageOtherClientsInRange(IEntity source, string message, int maxReceiveDistance) + { + var viewers = _playerManager.GetPlayersInRange(source.Transform.GridPosition, maxReceiveDistance); + + foreach (var viewer in viewers) + { + var viewerEntity = viewer.AttachedEntity; + + if (viewerEntity == null || source == viewerEntity) + { + continue; + } + + source.PopupMessage(viewer.AttachedEntity, message); + } + } } } diff --git a/Content.Server/GameObjects/Components/Kitchen/MicrowaveComponent.cs b/Content.Server/GameObjects/Components/Kitchen/MicrowaveComponent.cs index 21ef4a521a..e3ba2687b3 100644 --- a/Content.Server/GameObjects/Components/Kitchen/MicrowaveComponent.cs +++ b/Content.Server/GameObjects/Components/Kitchen/MicrowaveComponent.cs @@ -27,6 +27,7 @@ using Robust.Server.GameObjects.Components.Container; using Robust.Server.GameObjects.Components.UserInterface; using Robust.Server.GameObjects.EntitySystems; using Robust.Server.Interfaces.GameObjects; +using Robust.Server.Interfaces.Player; using Robust.Shared.Audio; using Robust.Shared.GameObjects.Systems; using Content.Shared.GameObjects.Components.Body; @@ -44,8 +45,9 @@ namespace Content.Server.GameObjects.Components.Kitchen [Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] private readonly RecipeManager _recipeManager = default!; [Dependency] private readonly IServerNotifyManager _notifyManager = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; -#region YAMLSERIALIZE + #region YAMLSERIALIZE private int _cookTimeDefault; private int _cookTimeMultiplier; //For upgrades and stuff I guess? private string _badRecipeName = ""; @@ -498,12 +500,29 @@ namespace Content.Server.GameObjects.Components.Kitchen headCount++; } } - chat.EntityMe(victim, Loc.GetPluralString("is trying to cook {0:their} head!", "is trying to cook {0:their} heads!", headCount, victim)); + PopupMessageOtherClientsInRange(victim, Loc.GetString("{0:theName} is trying to cook {0:their} head!", victim), 15); + _notifyManager.PopupMessage(victim, victim, Loc.GetString("You cook your head!")); _currentCookTimerTime = 10; ClickSound(); _uiDirty = true; wzhzhzh(); return SuicideKind.Heat; } + private void PopupMessageOtherClientsInRange(IEntity source, string message, int maxReceiveDistance) + { + var viewers = _playerManager.GetPlayersInRange(source.Transform.GridPosition, maxReceiveDistance); + + foreach (var viewer in viewers) + { + var viewerEntity = viewer.AttachedEntity; + + if (viewerEntity == null || source == viewerEntity) + { + continue; + } + + source.PopupMessage(viewer.AttachedEntity, message); + } + } } }