Kill SharedEntityExtensions and all popup extensions (#20909)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -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<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;
|
||||
@@ -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<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)
|
||||
@@ -76,17 +82,17 @@ namespace Content.Server.Stunnable.Systems
|
||||
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)
|
||||
@@ -95,12 +101,11 @@ namespace Content.Server.Stunnable.Systems
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -110,26 +115,27 @@ namespace Content.Server.Stunnable.Systems
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
@@ -138,7 +144,7 @@ namespace Content.Server.Stunnable.Systems
|
||||
{
|
||||
Used = used,
|
||||
User = user
|
||||
}, false);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user