diff --git a/Content.Server/Administration/Systems/AdminVerbSystem.cs b/Content.Server/Administration/Systems/AdminVerbSystem.cs index 3a419b93f6..c7e23374a3 100644 --- a/Content.Server/Administration/Systems/AdminVerbSystem.cs +++ b/Content.Server/Administration/Systems/AdminVerbSystem.cs @@ -59,6 +59,7 @@ namespace Content.Server.Administration.Systems [Dependency] private readonly SharedMindSystem _mindSystem = default!; [Dependency] private readonly ToolshedManager _toolshed = default!; [Dependency] private readonly RejuvenateSystem _rejuvenate = default!; + [Dependency] private readonly SharedPopupSystem _popup = default!; private readonly Dictionary _openSolutionUis = new(); @@ -357,7 +358,8 @@ namespace Content.Server.Administration.Systems var message = ExamineSystemShared.InRangeUnOccluded(args.User, args.Target) ? Loc.GetString("in-range-unoccluded-verb-on-activate-not-occluded") : Loc.GetString("in-range-unoccluded-verb-on-activate-occluded"); - args.Target.PopupMessage(args.User, message); + + _popup.PopupEntity(message, args.Target, args.User); } }; args.Verbs.Add(verb); diff --git a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs index 2adec63db5..b2f62572bf 100644 --- a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs +++ b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs @@ -37,6 +37,7 @@ namespace Content.Server.Atmos.EntitySystems [Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly SharedPopupSystem _popup = default!; public const float MinimumFireStacks = -10f; public const float MaximumFireStacks = 20f; @@ -45,7 +46,7 @@ namespace Content.Server.Atmos.EntitySystems public const float MinIgnitionTemperature = 373.15f; public const string FlammableFixtureID = "flammable"; - private float _timer = 0f; + private float _timer; private Dictionary _fireEvents = new(); @@ -191,8 +192,7 @@ namespace Content.Server.Atmos.EntitySystems { var tempDelta = args.Temperature - MinIgnitionTemperature; - var maxTemp = 0f; - _fireEvents.TryGetValue(flammable, out maxTemp); + _fireEvents.TryGetValue(flammable, out var maxTemp); if (tempDelta > maxTemp) _fireEvents[flammable] = tempDelta; @@ -233,7 +233,7 @@ namespace Content.Server.Atmos.EntitySystems if (!flammable.OnFire || !flammable.CanExtinguish) return; - _adminLogger.Add(LogType.Flammable, $"{ToPrettyString(flammable.Owner):entity} stopped being on fire damage"); + _adminLogger.Add(LogType.Flammable, $"{ToPrettyString(uid):entity} stopped being on fire damage"); flammable.OnFire = false; flammable.FireStacks = 0; @@ -271,16 +271,16 @@ namespace Content.Server.Atmos.EntitySystems if (!Resolve(uid, ref flammable)) return; - if (!flammable.OnFire || !_actionBlockerSystem.CanInteract(flammable.Owner, null) || flammable.Resisting) + if (!flammable.OnFire || !_actionBlockerSystem.CanInteract(uid, null) || flammable.Resisting) return; flammable.Resisting = true; - flammable.Owner.PopupMessage(Loc.GetString("flammable-component-resist-message")); + _popup.PopupEntity(Loc.GetString("flammable-component-resist-message"), uid, uid); _stunSystem.TryParalyze(uid, TimeSpan.FromSeconds(2f), true); // TODO FLAMMABLE: Make this not use TimerComponent... - flammable.Owner.SpawnTimer(2000, () => + uid.SpawnTimer(2000, () => { flammable.Resisting = false; flammable.FireStacks -= 1f; @@ -329,7 +329,7 @@ namespace Content.Server.Atmos.EntitySystems continue; } - _alertsSystem.ShowAlert(uid, AlertType.Fire, null, null); + _alertsSystem.ShowAlert(uid, AlertType.Fire); if (flammable.FireStacks > 0) { diff --git a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs index e193de4b3d..e857b02b94 100644 --- a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs +++ b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs @@ -27,6 +27,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems [Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly NodeContainerSystem _nodeContainer = default!; + [Dependency] private readonly SharedPopupSystem _popup = default!; public override void Initialize() { @@ -49,14 +50,16 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems private void OnExamined(EntityUid uid, GasPressurePumpComponent pump, ExaminedEvent args) { - if (!EntityManager.GetComponent(pump.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status. + if (!EntityManager.GetComponent(uid).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status. return; if (Loc.TryGetString("gas-pressure-pump-system-examined", out var str, - ("statusColor", "lightblue"), // TODO: change with pressure? - ("pressure", pump.TargetPressure) - )) + ("statusColor", "lightblue"), // TODO: change with pressure? + ("pressure", pump.TargetPressure) + )) + { args.PushMarkup(str); + } } private void OnPumpUpdated(EntityUid uid, GasPressurePumpComponent pump, AtmosDeviceUpdateEvent args) @@ -66,7 +69,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems || !_nodeContainer.TryGetNode(nodeContainer, pump.InletName, out PipeNode? inlet) || !_nodeContainer.TryGetNode(nodeContainer, pump.OutletName, out PipeNode? outlet)) { - _ambientSoundSystem.SetAmbience(pump.Owner, false); + _ambientSoundSystem.SetAmbience(uid, false); return; } @@ -74,7 +77,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems if (outputStartingPressure >= pump.TargetPressure) { - _ambientSoundSystem.SetAmbience(pump.Owner, false); + _ambientSoundSystem.SetAmbience(uid, false); return; // No need to pump gas if target has been reached. } @@ -86,7 +89,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems var removed = inlet.Air.Remove(transferMoles); _atmosphereSystem.Merge(outlet.Air, removed); - _ambientSoundSystem.SetAmbience(pump.Owner, removed.TotalMoles > 0f); + _ambientSoundSystem.SetAmbience(uid, removed.TotalMoles > 0f); } } @@ -104,14 +107,14 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) return; - if (EntityManager.GetComponent(pump.Owner).Anchored) + if (Transform(uid).Anchored) { _userInterfaceSystem.TryOpen(uid, GasPressurePumpUiKey.Key, actor.PlayerSession); DirtyUI(uid, pump); } else { - args.User.PopupMessageCursor(Loc.GetString("comp-gas-pump-ui-needs-anchor")); + _popup.PopupCursor(Loc.GetString("comp-gas-pump-ui-needs-anchor"), args.User); } args.Handled = true; @@ -141,7 +144,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems return; _userInterfaceSystem.TrySetUiState(uid, GasPressurePumpUiKey.Key, - new GasPressurePumpBoundUserInterfaceState(EntityManager.GetComponent(pump.Owner).EntityName, pump.TargetPressure, pump.Enabled)); + new GasPressurePumpBoundUserInterfaceState(EntityManager.GetComponent(uid).EntityName, pump.TargetPressure, pump.Enabled)); } private void UpdateAppearance(EntityUid uid, GasPressurePumpComponent? pump = null, AppearanceComponent? appearance = null) diff --git a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs index 5b8035681e..19ad8175aa 100644 --- a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs +++ b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs @@ -9,9 +9,7 @@ using Content.Server.DeviceNetwork.Systems; using Content.Server.NodeContainer; using Content.Server.NodeContainer.EntitySystems; using Content.Server.NodeContainer.Nodes; -using Content.Shared.Atmos.Piping; using Content.Shared.Atmos.Piping.Binary.Components; -using Content.Shared.Atmos.Piping.Unary.Components; using Content.Shared.Atmos.Visuals; using Content.Shared.Audio; using Content.Shared.Database; @@ -34,6 +32,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly NodeContainerSystem _nodeContainer = default!; [Dependency] private readonly DeviceNetworkSystem _deviceNetwork = default!; + [Dependency] private readonly SharedPopupSystem _popup = default!; public override void Initialize() @@ -59,7 +58,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems private void OnExamined(EntityUid uid, GasVolumePumpComponent pump, ExaminedEvent args) { - if (!EntityManager.GetComponent(pump.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status. + if (!EntityManager.GetComponent(uid).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status. return; if (Loc.TryGetString("gas-volume-pump-system-examined", out var str, @@ -98,14 +97,14 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems { pump.Blocked = true; } - + if (previouslyBlocked != pump.Blocked) UpdateAppearance(uid, pump); if (pump.Blocked) return; // We multiply the transfer rate in L/s by the seconds passed since the last process to get the liters. - var removed = inlet.Air.RemoveVolume((float)(pump.TransferRate * args.dt)); + var removed = inlet.Air.RemoveVolume(pump.TransferRate * args.dt); // Some of the gas from the mixture leaks when overclocked. if (pump.Overclocked) @@ -141,14 +140,14 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) return; - if (EntityManager.GetComponent(pump.Owner).Anchored) + if (Transform(uid).Anchored) { _userInterfaceSystem.TryOpen(uid, GasVolumePumpUiKey.Key, actor.PlayerSession); DirtyUI(uid, pump); } else { - args.User.PopupMessageCursor(Loc.GetString("comp-gas-pump-ui-needs-anchor")); + _popup.PopupCursor(Loc.GetString("comp-gas-pump-ui-needs-anchor"), args.User); } args.Handled = true; @@ -177,7 +176,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems return; _userInterfaceSystem.TrySetUiState(uid, GasVolumePumpUiKey.Key, - new GasVolumePumpBoundUserInterfaceState(EntityManager.GetComponent(pump.Owner).EntityName, pump.TransferRate, pump.Enabled)); + new GasVolumePumpBoundUserInterfaceState(Name(uid), pump.TransferRate, pump.Enabled)); } private void UpdateAppearance(EntityUid uid, GasVolumePumpComponent? pump = null, AppearanceComponent? appearance = null) diff --git a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs index 0780ff035f..ce2213d535 100644 --- a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs +++ b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs @@ -26,6 +26,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems [Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly NodeContainerSystem _nodeContainer = default!; + [Dependency] private readonly SharedPopupSystem _popup = default!; public override void Initialize() { @@ -54,7 +55,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems if (!mixer.Enabled) { - _ambientSoundSystem.SetAmbience(mixer.Owner, false); + _ambientSoundSystem.SetAmbience(uid, false); return; } @@ -65,7 +66,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems || !_nodeContainer.TryGetNode(nodeContainer, mixer.InletTwoName, out PipeNode? inletTwo) || !_nodeContainer.TryGetNode(nodeContainer, mixer.OutletName, out PipeNode? outlet)) { - _ambientSoundSystem.SetAmbience(mixer.Owner, false); + _ambientSoundSystem.SetAmbience(uid, false); return; } @@ -103,7 +104,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems if (transferMolesOne <= 0 || transferMolesTwo <= 0) { - _ambientSoundSystem.SetAmbience(mixer.Owner, false); + _ambientSoundSystem.SetAmbience(uid, false); return; } @@ -133,7 +134,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems } if (transferred) - _ambientSoundSystem.SetAmbience(mixer.Owner, true); + _ambientSoundSystem.SetAmbience(uid, true); } private void OnMixerLeaveAtmosphere(EntityUid uid, GasMixerComponent mixer, AtmosDeviceDisabledEvent args) @@ -150,14 +151,14 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) return; - if (EntityManager.GetComponent(mixer.Owner).Anchored) + if (Transform(uid).Anchored) { _userInterfaceSystem.TryOpen(uid, GasMixerUiKey.Key, actor.PlayerSession); DirtyUI(uid, mixer); } else { - args.User.PopupMessageCursor(Loc.GetString("comp-gas-mixer-ui-needs-anchor")); + _popup.PopupCursor(Loc.GetString("comp-gas-mixer-ui-needs-anchor"), args.User); } args.Handled = true; @@ -169,7 +170,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems return; _userInterfaceSystem.TrySetUiState(uid, GasMixerUiKey.Key, - new GasMixerBoundUserInterfaceState(EntityManager.GetComponent(mixer.Owner).EntityName, mixer.TargetPressure, mixer.Enabled, mixer.InletOneConcentration)); + new GasMixerBoundUserInterfaceState(EntityManager.GetComponent(uid).EntityName, mixer.TargetPressure, mixer.Enabled, mixer.InletOneConcentration)); } private void UpdateAppearance(EntityUid uid, GasMixerComponent? mixer = null, AppearanceComponent? appearance = null) diff --git a/Content.Server/Botany/Systems/BotanySystem.Seed.cs b/Content.Server/Botany/Systems/BotanySystem.Seed.cs index 752d8e4004..02fb1060f3 100644 --- a/Content.Server/Botany/Systems/BotanySystem.Seed.cs +++ b/Content.Server/Botany/Systems/BotanySystem.Seed.cs @@ -9,6 +9,7 @@ using Content.Shared.Examine; using Content.Shared.Hands.EntitySystems; using Content.Shared.Physics; using Content.Shared.Popups; +using Content.Shared.Random; using Content.Shared.Random.Helpers; using Content.Shared.Slippery; using Content.Shared.StepTrigger.Components; @@ -34,6 +35,7 @@ public sealed partial class BotanySystem : EntitySystem [Dependency] private readonly MetaDataSystem _metaData = default!; [Dependency] private readonly FixtureSystem _fixtureSystem = default!; [Dependency] private readonly CollisionWakeSystem _colWakeSystem = default!; + [Dependency] private readonly RandomHelperSystem _randomHelper = default!; public override void Initialize() { @@ -160,7 +162,7 @@ public sealed partial class BotanySystem : EntitySystem var product = _robustRandom.Pick(proto.ProductPrototypes); var entity = Spawn(product, position); - entity.RandomOffset(0.25f); + _randomHelper.RandomOffset(entity, 0.25f); products.Add(entity); var produce = EnsureComp(entity); diff --git a/Content.Server/Botany/Systems/LogSystem.cs b/Content.Server/Botany/Systems/LogSystem.cs index e9ac926d8a..b6cb0dedaf 100644 --- a/Content.Server/Botany/Systems/LogSystem.cs +++ b/Content.Server/Botany/Systems/LogSystem.cs @@ -2,6 +2,7 @@ using Content.Server.Botany.Components; using Content.Server.Kitchen.Components; using Content.Shared.Hands.EntitySystems; using Content.Shared.Interaction; +using Content.Shared.Random; using Content.Shared.Random.Helpers; using Robust.Shared.Containers; @@ -11,6 +12,7 @@ public sealed class LogSystem : EntitySystem { [Dependency] private readonly SharedHandsSystem _handsSystem = default!; [Dependency] private readonly SharedContainerSystem _containerSystem = default!; + [Dependency] private readonly RandomHelperSystem _randomHelper = default!; public override void Initialize() { @@ -39,7 +41,7 @@ public sealed class LogSystem : EntitySystem var xform = Transform(plank); _containerSystem.AttachParentToContainerOrGrid(xform); xform.LocalRotation = 0; - plank.RandomOffset(0.25f); + _randomHelper.RandomOffset(plank, 0.25f); } } diff --git a/Content.Server/Botany/Systems/PlantHolderSystem.cs b/Content.Server/Botany/Systems/PlantHolderSystem.cs index 506b88f78b..c3d57c4ad8 100644 --- a/Content.Server/Botany/Systems/PlantHolderSystem.cs +++ b/Content.Server/Botany/Systems/PlantHolderSystem.cs @@ -15,7 +15,7 @@ using Content.Shared.Hands.Components; using Content.Shared.IdentityManagement; using Content.Shared.Interaction; using Content.Shared.Popups; -using Content.Shared.Random.Helpers; +using Content.Shared.Random; using Content.Shared.Tag; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -39,6 +39,7 @@ public sealed class PlantHolderSystem : EntitySystem [Dependency] private readonly SharedPointLightSystem _pointLight = default!; [Dependency] private readonly SolutionContainerSystem _solutionSystem = default!; [Dependency] private readonly TagSystem _tagSystem = default!; + [Dependency] private readonly RandomHelperSystem _randomHelper = default!; [Dependency] private readonly IRobustRandom _random = default!; @@ -253,7 +254,7 @@ public sealed class PlantHolderSystem : EntitySystem component.Seed.Unique = false; var seed = _botany.SpawnSeedPacket(component.Seed, Transform(args.User).Coordinates, args.User); - seed.RandomOffset(0.25f); + _randomHelper.RandomOffset(seed, 0.25f); var displayName = Loc.GetString(component.Seed.DisplayName); _popup.PopupCursor(Loc.GetString("plant-holder-component-take-sample-message", ("seedName", displayName)), args.User); diff --git a/Content.Server/Chat/SuicideSystem.cs b/Content.Server/Chat/SuicideSystem.cs index 2f6ac51d72..131d19c523 100644 --- a/Content.Server/Chat/SuicideSystem.cs +++ b/Content.Server/Chat/SuicideSystem.cs @@ -10,6 +10,7 @@ using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Systems; using Content.Shared.Popups; using Content.Shared.Tag; +using Robust.Shared.Player; using Robust.Shared.Prototypes; namespace Content.Server.Chat @@ -22,6 +23,7 @@ namespace Content.Server.Chat [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly TagSystem _tagSystem = default!; [Dependency] private readonly MobStateSystem _mobState = default!; + [Dependency] private readonly SharedPopupSystem _popup = default!; public bool Suicide(EntityUid victim) { @@ -67,10 +69,10 @@ namespace Content.Server.Chat return; var othersMessage = Loc.GetString("suicide-command-default-text-others", ("name", victim)); - victim.PopupMessageOtherClients(othersMessage); + _popup.PopupEntity(othersMessage, victim, Filter.PvsExcept(victim), true); var selfMessage = Loc.GetString("suicide-command-default-text-self"); - victim.PopupMessage(selfMessage); + _popup.PopupEntity(selfMessage, victim, victim); suicideEvent.SetHandled(SuicideKind.Bloodloss); } @@ -112,7 +114,7 @@ namespace Content.Server.Chat if (itemQuery.HasComponent(entity)) continue; - RaiseLocalEvent(entity, suicideEvent, false); + RaiseLocalEvent(entity, suicideEvent); if (suicideEvent.Handled) return true; @@ -129,7 +131,7 @@ namespace Content.Server.Chat if (!_prototypeManager.TryIndex(kind.ToString(), out var damagePrototype)) { const SuicideKind fallback = SuicideKind.Blunt; - Logger.Error($"{nameof(SuicideSystem)} could not find the damage type prototype associated with {kind}. Falling back to {fallback}"); + Log.Error($"{nameof(SuicideSystem)} could not find the damage type prototype associated with {kind}. Falling back to {fallback}"); damagePrototype = _prototypeManager.Index(fallback.ToString()); } const int lethalAmountOfDamage = 200; // TODO: Would be nice to get this number from somewhere else diff --git a/Content.Server/Coordinates/SpawnRandomOffsetSystem.cs b/Content.Server/Coordinates/SpawnRandomOffsetSystem.cs index f664ec1225..5643681f4e 100644 --- a/Content.Server/Coordinates/SpawnRandomOffsetSystem.cs +++ b/Content.Server/Coordinates/SpawnRandomOffsetSystem.cs @@ -1,9 +1,13 @@ +using Content.Shared.Random; using Content.Shared.Random.Helpers; +using Robust.Shared.Random; namespace Content.Server.Coordinates; public sealed class SpawnRandomOffsetSystem : EntitySystem { + [Dependency] private readonly RandomHelperSystem _randomHelper = default!; + public override void Initialize() { base.Initialize(); @@ -13,8 +17,7 @@ public sealed class SpawnRandomOffsetSystem : EntitySystem private void OnMapInit(EntityUid uid, SpawnRandomOffsetComponent component, MapInitEvent args) { - // TODO: Kill this extension with fire, thanks - uid.RandomOffset(component.Offset); + _randomHelper.RandomOffset(uid, component.Offset); EntityManager.RemoveComponentDeferred(uid, component); } } diff --git a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs index 2f34b4285d..d50ce8df1f 100644 --- a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs @@ -11,6 +11,7 @@ using Content.Shared.FixedPoint; using Content.Shared.Interaction; using Content.Shared.Kitchen; using Content.Shared.Popups; +using Content.Shared.Random; using Content.Shared.Random.Helpers; using Content.Shared.Stacks; using JetBrains.Annotations; @@ -33,6 +34,7 @@ namespace Content.Server.Kitchen.EntitySystems [Dependency] private readonly SharedAudioSystem _audioSystem = default!; [Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!; [Dependency] private readonly SharedContainerSystem _containerSystem = default!; + [Dependency] private readonly RandomHelperSystem _randomHelper = default!; public override void Initialize() { @@ -230,7 +232,7 @@ namespace Content.Server.Kitchen.EntitySystems foreach (var entity in inputContainer.ContainedEntities.ToList()) { inputContainer.Remove(entity); - entity.RandomOffset(0.4f); + _randomHelper.RandomOffset(entity, 0.4f); } UpdateUiState(uid); } @@ -245,7 +247,7 @@ namespace Content.Server.Kitchen.EntitySystems if (inputContainer.Remove(ent)) { - ent.RandomOffset(0.4f); + _randomHelper.RandomOffset(ent, 0.4f); ClickSound(uid, reagentGrinder); UpdateUiState(uid); } diff --git a/Content.Server/Popups/PopupExtensions.cs b/Content.Server/Popups/PopupExtensions.cs deleted file mode 100644 index 1419ef46fc..0000000000 --- a/Content.Server/Popups/PopupExtensions.cs +++ /dev/null @@ -1,53 +0,0 @@ -using Content.Shared.Popups; -using Robust.Server.Player; -using Robust.Shared.Player; - -namespace Content.Server.Popups -{ - public static class PopupExtensions - { - /// - /// Pops up a message for every player around to see, - /// except for itself. - /// - /// The entity on which to popup the message. - /// The message to show. - [Obsolete("Use PopupSystem.PopupEntity instead")] - public static void PopupMessageOtherClients(this EntityUid source, string message) - { - var viewers = Filter.Empty() - .AddPlayersByPvs(source) - .Recipients; - - foreach (var viewer in viewers) - { - if (viewer.AttachedEntity is not {Valid: true} viewerEntity || source == viewerEntity || viewer.AttachedEntity == null) - { - continue; - } - - source.PopupMessage(viewerEntity, message); - } - } - - /// - /// Pops up a message at the given entity's location for everyone, - /// including itself, to see. - /// - /// The entity above which to show the message. - /// The message to be seen. - /// - /// The instance of player manager to use, will be resolved automatically - /// if null. - /// - /// - /// The range in which to search for players, defaulting to one screen. - /// - [Obsolete("Use PopupSystem.PopupEntity instead")] - public static void PopupMessageEveryone(this EntityUid source, string message, IPlayerManager? playerManager = null, int range = 15) - { - source.PopupMessage(message); - source.PopupMessageOtherClients(message); - } - } -} diff --git a/Content.Server/Popups/PopupMsgCommand.cs b/Content.Server/Popups/PopupMsgCommand.cs deleted file mode 100644 index 8e4294c7fd..0000000000 --- a/Content.Server/Popups/PopupMsgCommand.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Content.Server.Administration; -using Content.Shared.Administration; -using Content.Shared.Popups; -using Robust.Shared.Console; - -namespace Content.Server.Popups -{ - [AdminCommand(AdminFlags.Debug)] - public sealed class PopupMsgCommand : IConsoleCommand - { - public string Command => "srvpopupmsg"; - public string Description => ""; - public string Help => ""; - - public void Execute(IConsoleShell shell, string argStr, string[] args) - { - var source = EntityUid.Parse(args[0]); - var viewer = EntityUid.Parse(args[1]); - var msg = args[2]; - - source.PopupMessage(viewer, msg); - } - } -} diff --git a/Content.Server/Popups/PopupSystem.cs b/Content.Server/Popups/PopupSystem.cs index 407d2c49aa..483d4f3d3f 100644 --- a/Content.Server/Popups/PopupSystem.cs +++ b/Content.Server/Popups/PopupSystem.cs @@ -12,6 +12,7 @@ namespace Content.Server.Popups { [Dependency] private readonly IPlayerManager _player = default!; [Dependency] private readonly IConfigurationManager _cfg = default!; + [Dependency] private readonly TransformSystem _xform = default!; public override void PopupCursor(string message, PopupType type = PopupType.Small) { @@ -36,7 +37,7 @@ namespace Content.Server.Popups public override void PopupCoordinates(string message, EntityCoordinates coordinates, PopupType type = PopupType.Small) { - var mapPos = coordinates.ToMap(EntityManager); + var mapPos = coordinates.ToMap(EntityManager, _xform); var filter = Filter.Empty().AddPlayersByPvs(mapPos, entManager: EntityManager, playerMan: _player, cfgMan: _cfg); RaiseNetworkEvent(new PopupCoordinatesEvent(message, type, GetNetCoordinates(coordinates)), filter); } diff --git a/Content.Server/Repairable/RepairableSystem.cs b/Content.Server/Repairable/RepairableSystem.cs index 8d9833a66f..486ac756e3 100644 --- a/Content.Server/Repairable/RepairableSystem.cs +++ b/Content.Server/Repairable/RepairableSystem.cs @@ -1,12 +1,10 @@ using Content.Server.Administration.Logs; using Content.Shared.Damage; using Content.Shared.Database; -using Content.Shared.DoAfter; using Content.Shared.Interaction; using Content.Shared.Popups; using Content.Shared.Repairable; using Content.Shared.Tools; -using Content.Shared.Tools.Components; namespace Content.Server.Repairable { @@ -14,6 +12,7 @@ namespace Content.Server.Repairable { [Dependency] private readonly SharedToolSystem _toolSystem = default!; [Dependency] private readonly DamageableSystem _damageableSystem = default!; + [Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly IAdminLogManager _adminLogger= default!; public override void Initialize() @@ -33,7 +32,7 @@ namespace Content.Server.Repairable if (component.Damage != null) { var damageChanged = _damageableSystem.TryChangeDamage(uid, component.Damage, true, false, origin: args.User); - _adminLogger.Add(LogType.Healed, $"{ToPrettyString(args.User):user} repaired {ToPrettyString(uid):target} by {damageChanged?.Total}"); + _adminLogger.Add(LogType.Healed, $"{ToPrettyString(args.User):user} repaired {ToPrettyString(uid):target} by {damageChanged?.GetTotal()}"); } else @@ -43,10 +42,10 @@ namespace Content.Server.Repairable _adminLogger.Add(LogType.Healed, $"{ToPrettyString(args.User):user} repaired {ToPrettyString(uid):target} back to full health"); } - uid.PopupMessage(args.User, - Loc.GetString("comp-repairable-repair", - ("target", uid), - ("tool", args.Used!))); + var str = Loc.GetString("comp-repairable-repair", + ("target", uid), + ("tool", args.Used!)); + _popup.PopupEntity(str, uid, args.User); } public async void Repair(EntityUid uid, RepairableComponent component, InteractUsingEvent args) diff --git a/Content.Server/Stunnable/Systems/StunbatonSystem.cs b/Content.Server/Stunnable/Systems/StunbatonSystem.cs index 7a801765d8..f4a7448fa2 100644 --- a/Content.Server/Stunnable/Systems/StunbatonSystem.cs +++ b/Content.Server/Stunnable/Systems/StunbatonSystem.cs @@ -11,6 +11,7 @@ using Content.Shared.Item; using Content.Shared.Popups; using Content.Shared.Stunnable; using Content.Shared.Toggleable; +using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.Player; @@ -21,6 +22,9 @@ namespace Content.Server.Stunnable.Systems [Dependency] private readonly SharedItemSystem _item = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly RiggableSystem _riggableSystem = default!; + [Dependency] private readonly SharedPopupSystem _popup = default!; + [Dependency] private readonly BatterySystem _battery = default!; + [Dependency] private readonly AudioSystem _audio = default!; public override void Initialize() { @@ -35,7 +39,7 @@ namespace Content.Server.Stunnable.Systems private void OnStaminaHitAttempt(EntityUid uid, StunbatonComponent component, ref StaminaDamageOnHitAttemptEvent args) { if (!component.Activated || - !TryComp(uid, out var battery) || !battery.TryUseCharge(component.EnergyPerUse)) + !TryComp(uid, out var battery) || !_battery.TryUseCharge(uid, component.EnergyPerUse, battery)) { args.Cancelled = true; return; @@ -43,7 +47,7 @@ namespace Content.Server.Stunnable.Systems if (battery.CurrentCharge < component.EnergyPerUse) { - SoundSystem.Play(component.SparksSound.GetSound(), Filter.Pvs(component.Owner, entityManager: EntityManager), uid, AudioHelpers.WithVariation(0.25f)); + _audio.PlayPvs(component.SparksSound, uid, AudioHelpers.WithVariation(0.25f)); TurnOff(uid, component); } } @@ -66,9 +70,11 @@ namespace Content.Server.Stunnable.Systems ? Loc.GetString("comp-stunbaton-examined-on") : Loc.GetString("comp-stunbaton-examined-off"); args.PushMarkup(msg); - if(TryComp(uid, out var battery)) + if (TryComp(uid, out var battery)) + { args.PushMarkup(Loc.GetString("stunbaton-component-on-examine-charge", ("charge", (int)((battery.CurrentCharge/battery.MaxCharge) * 100)))); + } } private void TurnOff(EntityUid uid, StunbatonComponent comp) @@ -76,17 +82,17 @@ namespace Content.Server.Stunnable.Systems if (!comp.Activated) return; - if (TryComp(comp.Owner, out var appearance) && - TryComp(comp.Owner, out var item)) + if (TryComp(uid, out var appearance) && + TryComp(uid, out var item)) { - _item.SetHeldPrefix(comp.Owner, "off", item); + _item.SetHeldPrefix(uid, "off", item); _appearance.SetData(uid, ToggleVisuals.Toggled, false, appearance); } - SoundSystem.Play(comp.SparksSound.GetSound(), Filter.Pvs(comp.Owner), comp.Owner, AudioHelpers.WithVariation(0.25f)); + _audio.PlayPvs(comp.SparksSound, uid, AudioHelpers.WithVariation(0.25f)); comp.Activated = false; - Dirty(comp); + Dirty(uid, comp); } private void TurnOn(EntityUid uid, StunbatonComponent comp, EntityUid user) @@ -95,12 +101,11 @@ namespace Content.Server.Stunnable.Systems if (comp.Activated) return; - var playerFilter = Filter.Pvs(comp.Owner, entityManager: EntityManager); - if (!TryComp(comp.Owner, out var battery) || battery.CurrentCharge < comp.EnergyPerUse) + if (!TryComp(uid, out var battery) || battery.CurrentCharge < comp.EnergyPerUse) { - SoundSystem.Play(comp.TurnOnFailSound.GetSound(), playerFilter, comp.Owner, AudioHelpers.WithVariation(0.25f)); - user.PopupMessage(Loc.GetString("stunbaton-component-low-charge")); + _audio.PlayPvs(comp.TurnOnFailSound, uid, AudioHelpers.WithVariation(0.25f)); + _popup.PopupEntity(Loc.GetString("stunbaton-component-low-charge"), user, user); return; } @@ -110,26 +115,27 @@ namespace Content.Server.Stunnable.Systems } - if (EntityManager.TryGetComponent(comp.Owner, out var appearance) && - EntityManager.TryGetComponent(comp.Owner, out var item)) + if (EntityManager.TryGetComponent(uid, out var appearance) && + EntityManager.TryGetComponent(uid, out var item)) { - _item.SetHeldPrefix(comp.Owner, "on", item); + _item.SetHeldPrefix(uid, "on", item); _appearance.SetData(uid, ToggleVisuals.Toggled, true, appearance); } - SoundSystem.Play(comp.SparksSound.GetSound(), playerFilter, comp.Owner, AudioHelpers.WithVariation(0.25f)); + _audio.PlayPvs(comp.SparksSound, uid, AudioHelpers.WithVariation(0.25f)); comp.Activated = true; - Dirty(comp); + Dirty(uid, comp); } // https://github.com/space-wizards/space-station-14/pull/17288#discussion_r1241213341 private void OnSolutionChange(EntityUid uid, StunbatonComponent component, SolutionChangedEvent args) { // Explode if baton is activated and rigged. - if (TryComp(uid, out var riggable)) - if (TryComp(uid, out var battery)) - if (component.Activated && riggable.IsRigged) - _riggableSystem.Explode(uid, battery); + if (!TryComp(uid, out var riggable) || !TryComp(uid, out var battery)) + return; + + if (component.Activated && riggable.IsRigged) + _riggableSystem.Explode(uid, battery); } private void SendPowerPulse(EntityUid target, EntityUid? user, EntityUid used) @@ -138,7 +144,7 @@ namespace Content.Server.Stunnable.Systems { Used = used, User = user - }, false); + }); } } } diff --git a/Content.Shared/Popups/SharedPopupExtensions.cs b/Content.Shared/Popups/SharedPopupExtensions.cs deleted file mode 100644 index 94305330ef..0000000000 --- a/Content.Shared/Popups/SharedPopupExtensions.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Robust.Shared.Map; -using Robust.Shared.Player; - -namespace Content.Shared.Popups -{ - public static class SharedPopupExtensions - { - /// - /// Pops up a message at the location of for - /// alone to see. - /// - /// The entity above which the message will appear. - /// The entity that will see the message. - /// The message to show. - [Obsolete("Use PopupSystem.PopupEntity instead.")] - public static void PopupMessage(this EntityUid source, EntityUid viewer, string message) - { - var popupSystem = EntitySystem.Get(); - - popupSystem.PopupEntity(message, source, viewer); - } - - /// - /// Pops up a message at the given entity's location for it alone to see. - /// - /// The entity that will see the message. - /// The message to be seen. - [Obsolete("Use PopupSystem.PopupEntity instead.")] - public static void PopupMessage(this EntityUid viewer, string message) - { - viewer.PopupMessage(viewer, message); - } - - /// - /// Makes a string of text float up from a client's cursor. - /// - /// - /// The client attached entity that the message is being sent to. - /// - /// Text contents of the message. - [Obsolete("Use PopupSystem.PopupCursor instead.")] - public static void PopupMessageCursor(this EntityUid viewer, string message) - { - var popupSystem = EntitySystem.Get(); - popupSystem.PopupCursor(message, viewer); - } - } -} diff --git a/Content.Shared/Random/Helpers/SharedEntityExtensions.cs b/Content.Shared/Random/Helpers/SharedEntityExtensions.cs deleted file mode 100644 index 5b12ffb94d..0000000000 --- a/Content.Shared/Random/Helpers/SharedEntityExtensions.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Numerics; -using Robust.Shared.Random; -using Robust.Shared.Utility; - -namespace Content.Shared.Random.Helpers -{ - public static class SharedEntityExtensions - { - public static void RandomOffset(this EntityUid entity, float minX, float maxX, float minY, float maxY) - { - DebugTools.AssertNotNull(entity); - DebugTools.Assert(minX <= maxX, $"Minimum X value ({minX}) must be smaller than or equal to the maximum X value ({maxX})"); - DebugTools.Assert(minY <= maxY, $"Minimum Y value ({minY}) must be smaller than or equal to the maximum Y value ({maxY})"); - - var random = IoCManager.Resolve(); - var randomX = random.NextFloat() * (maxX - minX) + minX; - var randomY = random.NextFloat() * (maxY - minY) + minY; - var offset = new Vector2(randomX, randomY); - - IoCManager.Resolve().GetComponent(entity).LocalPosition += offset; - } - - public static void RandomOffset(this EntityUid entity, float min, float max) - { - DebugTools.AssertNotNull(entity); - DebugTools.Assert(min <= max, $"Minimum value ({min}) must be smaller than or equal to the maximum value ({max})"); - - entity.RandomOffset(min, max, min, max); - } - - public static void RandomOffset(this EntityUid entity, float value) - { - value = Math.Abs(value); - entity.RandomOffset(-value, value); - } - } -} diff --git a/Content.Shared/Random/RandomHelperSystem.cs b/Content.Shared/Random/RandomHelperSystem.cs new file mode 100644 index 0000000000..66ebcc3f78 --- /dev/null +++ b/Content.Shared/Random/RandomHelperSystem.cs @@ -0,0 +1,35 @@ +using System.Numerics; +using Content.Shared.Random.Helpers; +using Robust.Shared.Random; +using Robust.Shared.Utility; + +namespace Content.Shared.Random; + +/// +/// System containing various content-related random helpers. +/// +public sealed class RandomHelperSystem : EntitySystem +{ + [Dependency] private readonly SharedTransformSystem _transform = default!; + [Dependency] private readonly IRobustRandom _random = default!; + + public void RandomOffset(EntityUid entity, float minX, float maxX, float minY, float maxY) + { + var randomX = _random.NextFloat() * (maxX - minX) + minX; + var randomY = _random.NextFloat() * (maxY - minY) + minY; + var offset = new Vector2(randomX, randomY); + + var xform = Transform(entity); + _transform.SetLocalPosition(xform, xform.LocalPosition + offset); + } + + public void RandomOffset(EntityUid entity, float min, float max) + { + RandomOffset(entity, min, max, min, max); + } + + public void RandomOffset(EntityUid entity, float value) + { + RandomOffset(entity, -value, value); + } +} diff --git a/SpaceStation14.sln.DotSettings b/SpaceStation14.sln.DotSettings index 57f0e3c4db..72e550ac6e 100644 --- a/SpaceStation14.sln.DotSettings +++ b/SpaceStation14.sln.DotSettings @@ -587,6 +587,7 @@ public sealed partial class $CLASS$ : Shared$CLASS$ { True True True + True True True True