[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<ICommonSession, EditSolutionsEui> _openSolutionUis = new();
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);
[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;
public const float MinIgnitionTemperature = 373.15f;
public const string FlammableFixtureID = "flammable";
- private float _timer = 0f;
+ private float _timer;
private Dictionary<FlammableComponent, float> _fireEvents = new();
{
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;
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;
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;
continue;
}
- _alertsSystem.ShowAlert(uid, AlertType.Fire, null, null);
+ _alertsSystem.ShowAlert(uid, AlertType.Fire);
if (flammable.FireStacks > 0)
{
[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()
{
private void OnExamined(EntityUid uid, GasPressurePumpComponent pump, ExaminedEvent args)
{
- if (!EntityManager.GetComponent<TransformComponent>(pump.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
+ if (!EntityManager.GetComponent<TransformComponent>(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)
|| !_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;
}
if (outputStartingPressure >= pump.TargetPressure)
{
- _ambientSoundSystem.SetAmbience(pump.Owner, false);
+ _ambientSoundSystem.SetAmbience(uid, false);
return; // No need to pump gas if target has been reached.
}
var removed = inlet.Air.Remove(transferMoles);
_atmosphereSystem.Merge(outlet.Air, removed);
- _ambientSoundSystem.SetAmbience(pump.Owner, removed.TotalMoles > 0f);
+ _ambientSoundSystem.SetAmbience(uid, removed.TotalMoles > 0f);
}
}
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;
- if (EntityManager.GetComponent<TransformComponent>(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;
return;
_userInterfaceSystem.TrySetUiState(uid, GasPressurePumpUiKey.Key,
- new GasPressurePumpBoundUserInterfaceState(EntityManager.GetComponent<MetaDataComponent>(pump.Owner).EntityName, pump.TargetPressure, pump.Enabled));
+ new GasPressurePumpBoundUserInterfaceState(EntityManager.GetComponent<MetaDataComponent>(uid).EntityName, pump.TargetPressure, pump.Enabled));
}
private void UpdateAppearance(EntityUid uid, GasPressurePumpComponent? pump = null, AppearanceComponent? appearance = null)
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;
[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()
private void OnExamined(EntityUid uid, GasVolumePumpComponent pump, ExaminedEvent args)
{
- if (!EntityManager.GetComponent<TransformComponent>(pump.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
+ if (!EntityManager.GetComponent<TransformComponent>(uid).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status.
return;
if (Loc.TryGetString("gas-volume-pump-system-examined", out var str,
{
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)
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;
- if (EntityManager.GetComponent<TransformComponent>(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;
return;
_userInterfaceSystem.TrySetUiState(uid, GasVolumePumpUiKey.Key,
- new GasVolumePumpBoundUserInterfaceState(EntityManager.GetComponent<MetaDataComponent>(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)
[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()
{
if (!mixer.Enabled)
{
- _ambientSoundSystem.SetAmbience(mixer.Owner, false);
+ _ambientSoundSystem.SetAmbience(uid, false);
return;
}
|| !_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;
}
if (transferMolesOne <= 0 || transferMolesTwo <= 0)
{
- _ambientSoundSystem.SetAmbience(mixer.Owner, false);
+ _ambientSoundSystem.SetAmbience(uid, false);
return;
}
}
if (transferred)
- _ambientSoundSystem.SetAmbience(mixer.Owner, true);
+ _ambientSoundSystem.SetAmbience(uid, true);
}
private void OnMixerLeaveAtmosphere(EntityUid uid, GasMixerComponent mixer, AtmosDeviceDisabledEvent args)
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;
- if (EntityManager.GetComponent<TransformComponent>(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;
return;
_userInterfaceSystem.TrySetUiState(uid, GasMixerUiKey.Key,
- new GasMixerBoundUserInterfaceState(EntityManager.GetComponent<MetaDataComponent>(mixer.Owner).EntityName, mixer.TargetPressure, mixer.Enabled, mixer.InletOneConcentration));
+ new GasMixerBoundUserInterfaceState(EntityManager.GetComponent<MetaDataComponent>(uid).EntityName, mixer.TargetPressure, mixer.Enabled, mixer.InletOneConcentration));
}
private void UpdateAppearance(EntityUid uid, GasMixerComponent? mixer = null, AppearanceComponent? appearance = null)
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;
[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()
{
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<ProduceComponent>(entity);
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;
{
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
+ [Dependency] private readonly RandomHelperSystem _randomHelper = default!;
public override void Initialize()
{
var xform = Transform(plank);
_containerSystem.AttachParentToContainerOrGrid(xform);
xform.LocalRotation = 0;
- plank.RandomOffset(0.25f);
+ _randomHelper.RandomOffset(plank, 0.25f);
}
}
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;
[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!;
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);
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
[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)
{
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);
}
if (itemQuery.HasComponent(entity))
continue;
- RaiseLocalEvent(entity, suicideEvent, false);
+ RaiseLocalEvent(entity, suicideEvent);
if (suicideEvent.Handled)
return true;
if (!_prototypeManager.TryIndex<DamageTypePrototype>(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<DamageTypePrototype>(fallback.ToString());
}
const int lethalAmountOfDamage = 200; // TODO: Would be nice to get this number from somewhere else
+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();
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);
}
}
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;
[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()
{
foreach (var entity in inputContainer.ContainedEntities.ToList())
{
inputContainer.Remove(entity);
- entity.RandomOffset(0.4f);
+ _randomHelper.RandomOffset(entity, 0.4f);
}
UpdateUiState(uid);
}
if (inputContainer.Remove(ent))
{
- ent.RandomOffset(0.4f);
+ _randomHelper.RandomOffset(ent, 0.4f);
ClickSound(uid, reagentGrinder);
UpdateUiState(uid);
}
+++ /dev/null
-using Content.Shared.Popups;
-using Robust.Server.Player;
-using Robust.Shared.Player;
-
-namespace Content.Server.Popups
-{
- public static class PopupExtensions
- {
- /// <summary>
- /// Pops up a message for every player around <see cref="source"/> to see,
- /// except for <see cref="source"/> itself.
- /// </summary>
- /// <param name="source">The entity on which to popup the message.</param>
- /// <param name="message">The message to show.</param>
- [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);
- }
- }
-
- /// <summary>
- /// Pops up a message at the given entity's location for everyone,
- /// including itself, to see.
- /// </summary>
- /// <param name="source">The entity above which to show the message.</param>
- /// <param name="message">The message to be seen.</param>
- /// <param name="playerManager">
- /// The instance of player manager to use, will be resolved automatically
- /// if null.
- /// </param>
- /// <param name="range">
- /// The range in which to search for players, defaulting to one screen.
- /// </param>
- [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);
- }
- }
-}
+++ /dev/null
-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);
- }
- }
-}
{
[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)
{
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);
}
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
{
{
[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()
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
_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)
using Content.Shared.Popups;
using Content.Shared.Stunnable;
using Content.Shared.Toggleable;
+using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Player;
[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()
{
private void OnStaminaHitAttempt(EntityUid uid, StunbatonComponent component, ref StaminaDamageOnHitAttemptEvent args)
{
if (!component.Activated ||
- !TryComp<BatteryComponent>(uid, out var battery) || !battery.TryUseCharge(component.EnergyPerUse))
+ !TryComp<BatteryComponent>(uid, out var battery) || !_battery.TryUseCharge(uid, component.EnergyPerUse, battery))
{
args.Cancelled = true;
return;
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);
}
}
? Loc.GetString("comp-stunbaton-examined-on")
: Loc.GetString("comp-stunbaton-examined-off");
args.PushMarkup(msg);
- if(TryComp<BatteryComponent>(uid, out var battery))
+ if (TryComp<BatteryComponent>(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)
if (!comp.Activated)
return;
- if (TryComp<AppearanceComponent>(comp.Owner, out var appearance) &&
- TryComp<ItemComponent>(comp.Owner, out var item))
+ if (TryComp<AppearanceComponent>(uid, out var appearance) &&
+ TryComp<ItemComponent>(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)
if (comp.Activated)
return;
- var playerFilter = Filter.Pvs(comp.Owner, entityManager: EntityManager);
- if (!TryComp<BatteryComponent>(comp.Owner, out var battery) || battery.CurrentCharge < comp.EnergyPerUse)
+ if (!TryComp<BatteryComponent>(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;
}
}
- if (EntityManager.TryGetComponent<AppearanceComponent>(comp.Owner, out var appearance) &&
- EntityManager.TryGetComponent<ItemComponent>(comp.Owner, out var item))
+ if (EntityManager.TryGetComponent<AppearanceComponent>(uid, out var appearance) &&
+ EntityManager.TryGetComponent<ItemComponent>(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<RiggableComponent>(uid, out var riggable))
- if (TryComp<BatteryComponent>(uid, out var battery))
- if (component.Activated && riggable.IsRigged)
- _riggableSystem.Explode(uid, battery);
+ if (!TryComp<RiggableComponent>(uid, out var riggable) || !TryComp<BatteryComponent>(uid, out var battery))
+ return;
+
+ if (component.Activated && riggable.IsRigged)
+ _riggableSystem.Explode(uid, battery);
}
private void SendPowerPulse(EntityUid target, EntityUid? user, EntityUid used)
{
Used = used,
User = user
- }, false);
+ });
}
}
}
+++ /dev/null
-using Robust.Shared.Map;
-using Robust.Shared.Player;
-
-namespace Content.Shared.Popups
-{
- public static class SharedPopupExtensions
- {
- /// <summary>
- /// Pops up a message at the location of <see cref="source"/> for
- /// <see cref="viewer"/> alone to see.
- /// </summary>
- /// <param name="source">The entity above which the message will appear.</param>
- /// <param name="viewer">The entity that will see the message.</param>
- /// <param name="message">The message to show.</param>
- [Obsolete("Use PopupSystem.PopupEntity instead.")]
- public static void PopupMessage(this EntityUid source, EntityUid viewer, string message)
- {
- var popupSystem = EntitySystem.Get<SharedPopupSystem>();
-
- popupSystem.PopupEntity(message, source, viewer);
- }
-
- /// <summary>
- /// Pops up a message at the given entity's location for it alone to see.
- /// </summary>
- /// <param name="viewer">The entity that will see the message.</param>
- /// <param name="message">The message to be seen.</param>
- [Obsolete("Use PopupSystem.PopupEntity instead.")]
- public static void PopupMessage(this EntityUid viewer, string message)
- {
- viewer.PopupMessage(viewer, message);
- }
-
- /// <summary>
- /// Makes a string of text float up from a client's cursor.
- /// </summary>
- /// <param name="viewer">
- /// The client attached entity that the message is being sent to.
- /// </param>
- /// <param name="message">Text contents of the message.</param>
- [Obsolete("Use PopupSystem.PopupCursor instead.")]
- public static void PopupMessageCursor(this EntityUid viewer, string message)
- {
- var popupSystem = EntitySystem.Get<SharedPopupSystem>();
- popupSystem.PopupCursor(message, viewer);
- }
- }
-}
+++ /dev/null
-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<IRobustRandom>();
- var randomX = random.NextFloat() * (maxX - minX) + minX;
- var randomY = random.NextFloat() * (maxY - minY) + minY;
- var offset = new Vector2(randomX, randomY);
-
- IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(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);
- }
- }
-}
--- /dev/null
+using System.Numerics;
+using Content.Shared.Random.Helpers;
+using Robust.Shared.Random;
+using Robust.Shared.Utility;
+
+namespace Content.Shared.Random;
+
+/// <summary>
+/// System containing various content-related random helpers.
+/// </summary>
+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);
+ }
+}
<s:Boolean x:Key="/Default/UserDictionary/Words/=Deadminned/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dentification/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Diethylamine/@EntryIndexedValue">True</s:Boolean>
+ <s:Boolean x:Key="/Default/UserDictionary/Words/=doafter/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Drainable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=euid/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Firelock/@EntryIndexedValue">True</s:Boolean>