Kill SharedEntityExtensions and all popup extensions (#20909)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Kara
2023-10-15 22:56:09 -07:00
committed by GitHub
parent 00e274ea38
commit 77964d4a6b
20 changed files with 135 additions and 238 deletions

View File

@@ -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<FlammableComponent, float> _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)
{

View File

@@ -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<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)
@@ -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<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;
@@ -141,7 +144,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
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)

View File

@@ -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<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,
@@ -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<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;
@@ -177,7 +176,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems
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)

View File

@@ -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<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;
@@ -169,7 +170,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
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)