Revert 'Revert 'Solution Entities'' (#23168)
This commit is contained in:
@@ -5,6 +5,7 @@ using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.Atmos.Piping.Unary.EntitySystems;
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Server.Chemistry.Containers.EntitySystems;
|
||||
using Content.Server.Medical.Components;
|
||||
using Content.Server.NodeContainer;
|
||||
using Content.Server.NodeContainer.EntitySystems;
|
||||
@@ -16,7 +17,6 @@ using Content.Server.UserInterface;
|
||||
using Content.Shared.Chemistry;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Components.SolutionManager;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.Climbing.Systems;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
@@ -28,7 +28,6 @@ using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Medical.Cryogenics;
|
||||
using Content.Shared.MedicalScanner;
|
||||
using Content.Shared.Tools;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -36,7 +35,7 @@ using SharedToolSystem = Content.Shared.Tools.Systems.SharedToolSystem;
|
||||
|
||||
namespace Content.Server.Medical;
|
||||
|
||||
public sealed partial class CryoPodSystem: SharedCryoPodSystem
|
||||
public sealed partial class CryoPodSystem : SharedCryoPodSystem
|
||||
{
|
||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||
[Dependency] private readonly GasCanisterSystem _gasCanisterSystem = default!;
|
||||
@@ -105,14 +104,15 @@ public sealed partial class CryoPodSystem: SharedCryoPodSystem
|
||||
&& fitsInDispenserQuery.TryGetComponent(container, out var fitsInDispenserComponent)
|
||||
&& solutionContainerManagerQuery.TryGetComponent(container,
|
||||
out var solutionContainerManagerComponent)
|
||||
&& _solutionContainerSystem.TryGetFitsInDispenser(container.Value, out var containerSolution, dispenserFits: fitsInDispenserComponent, solutionManager: solutionContainerManagerComponent))
|
||||
&& _solutionContainerSystem.TryGetFitsInDispenser((container.Value, fitsInDispenserComponent, solutionContainerManagerComponent),
|
||||
out var containerSolution, out _))
|
||||
{
|
||||
if (!bloodStreamQuery.TryGetComponent(patient, out var bloodstream))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var solutionToInject = _solutionContainerSystem.SplitSolution(container.Value, containerSolution, cryoPod.BeakerTransferAmount);
|
||||
var solutionToInject = _solutionContainerSystem.SplitSolution(containerSolution.Value, cryoPod.BeakerTransferAmount);
|
||||
_bloodstreamSystem.TryAddToChemicals(patient.Value, solutionToInject, bloodstream);
|
||||
_reactiveSystem.DoEntityReaction(patient.Value, solutionToInject, ReactionMethod.Injection);
|
||||
}
|
||||
@@ -123,7 +123,7 @@ public sealed partial class CryoPodSystem: SharedCryoPodSystem
|
||||
{
|
||||
if (!Resolve(uid, ref cryoPodComponent))
|
||||
return null;
|
||||
if (cryoPodComponent.BodyContainer.ContainedEntity is not {Valid: true} contained)
|
||||
if (cryoPodComponent.BodyContainer.ContainedEntity is not { Valid: true } contained)
|
||||
return null;
|
||||
base.EjectBody(uid, cryoPodComponent);
|
||||
_climbSystem.ForciblySetClimbing(contained, uid);
|
||||
@@ -132,12 +132,12 @@ public sealed partial class CryoPodSystem: SharedCryoPodSystem
|
||||
|
||||
#region Interaction
|
||||
|
||||
private void HandleDragDropOn(EntityUid uid, CryoPodComponent cryoPodComponent, ref DragDropTargetEvent args)
|
||||
private void HandleDragDropOn(Entity<CryoPodComponent> entity, ref DragDropTargetEvent args)
|
||||
{
|
||||
if (cryoPodComponent.BodyContainer.ContainedEntity != null)
|
||||
if (entity.Comp.BodyContainer.ContainedEntity != null)
|
||||
return;
|
||||
|
||||
var doAfterArgs = new DoAfterArgs(EntityManager, args.User, cryoPodComponent.EntryDelay, new CryoPodDragFinished(), uid, target: args.Dragged, used: uid)
|
||||
var doAfterArgs = new DoAfterArgs(EntityManager, args.User, entity.Comp.EntryDelay, new CryoPodDragFinished(), entity, target: args.Dragged, used: entity)
|
||||
{
|
||||
BreakOnDamage = true,
|
||||
BreakOnTargetMove = true,
|
||||
@@ -148,61 +148,65 @@ public sealed partial class CryoPodSystem: SharedCryoPodSystem
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnDragFinished(EntityUid uid, CryoPodComponent component, CryoPodDragFinished args)
|
||||
private void OnDragFinished(Entity<CryoPodComponent> entity, ref CryoPodDragFinished args)
|
||||
{
|
||||
if (args.Cancelled || args.Handled || args.Args.Target == null)
|
||||
return;
|
||||
|
||||
if (InsertBody(uid, args.Args.Target.Value, component))
|
||||
if (InsertBody(entity.Owner, args.Args.Target.Value, entity.Comp))
|
||||
{
|
||||
if (!TryComp(uid, out CryoPodAirComponent? cryoPodAir))
|
||||
if (!TryComp(entity.Owner, out CryoPodAirComponent? cryoPodAir))
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Medium,
|
||||
$"{ToPrettyString(args.User)} inserted {ToPrettyString(args.Args.Target.Value)} into {ToPrettyString(uid)}");
|
||||
$"{ToPrettyString(args.User)} inserted {ToPrettyString(args.Args.Target.Value)} into {ToPrettyString(entity.Owner)}");
|
||||
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Medium,
|
||||
$"{ToPrettyString(args.User)} inserted {ToPrettyString(args.Args.Target.Value)} into {ToPrettyString(uid)} which contains gas: {cryoPodAir!.Air.ToPrettyString():gasMix}");
|
||||
$"{ToPrettyString(args.User)} inserted {ToPrettyString(args.Args.Target.Value)} into {ToPrettyString(entity.Owner)} which contains gas: {cryoPodAir!.Air.ToPrettyString():gasMix}");
|
||||
}
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnActivateUIAttempt(EntityUid uid, CryoPodComponent cryoPodComponent, ActivatableUIOpenAttemptEvent args)
|
||||
private void OnActivateUIAttempt(Entity<CryoPodComponent> entity, ref ActivatableUIOpenAttemptEvent args)
|
||||
{
|
||||
if (args.Cancelled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var containedEntity = cryoPodComponent.BodyContainer.ContainedEntity;
|
||||
if (containedEntity == null || containedEntity == args.User || !HasComp<ActiveCryoPodComponent>(uid))
|
||||
var containedEntity = entity.Comp.BodyContainer.ContainedEntity;
|
||||
if (containedEntity == null || containedEntity == args.User || !HasComp<ActiveCryoPodComponent>(entity))
|
||||
{
|
||||
args.Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnActivateUI(EntityUid uid, CryoPodComponent cryoPodComponent, AfterActivatableUIOpenEvent args)
|
||||
private void OnActivateUI(Entity<CryoPodComponent> entity, ref AfterActivatableUIOpenEvent args)
|
||||
{
|
||||
TryComp<TemperatureComponent>(cryoPodComponent.BodyContainer.ContainedEntity, out var temp);
|
||||
TryComp<BloodstreamComponent>(cryoPodComponent.BodyContainer.ContainedEntity, out var bloodstream);
|
||||
TryComp<TemperatureComponent>(entity.Comp.BodyContainer.ContainedEntity, out var temp);
|
||||
TryComp<BloodstreamComponent>(entity.Comp.BodyContainer.ContainedEntity, out var bloodstream);
|
||||
|
||||
_userInterfaceSystem.TrySendUiMessage(
|
||||
uid,
|
||||
entity.Owner,
|
||||
HealthAnalyzerUiKey.Key,
|
||||
new HealthAnalyzerScannedUserMessage(GetNetEntity(cryoPodComponent.BodyContainer.ContainedEntity),
|
||||
temp?.CurrentTemperature ?? 0, bloodstream != null ? bloodstream.BloodSolution.FillFraction : 0));
|
||||
new HealthAnalyzerScannedUserMessage(GetNetEntity(entity.Comp.BodyContainer.ContainedEntity),
|
||||
temp?.CurrentTemperature ?? 0,
|
||||
(bloodstream != null && _solutionContainerSystem.ResolveSolution(entity.Owner, bloodstream.BloodSolutionName, ref bloodstream.BloodSolution, out var bloodSolution))
|
||||
? bloodSolution.FillFraction
|
||||
: 0
|
||||
));
|
||||
}
|
||||
|
||||
private void OnInteractUsing(EntityUid uid, CryoPodComponent cryoPodComponent, InteractUsingEvent args)
|
||||
private void OnInteractUsing(Entity<CryoPodComponent> entity, ref InteractUsingEvent args)
|
||||
{
|
||||
if (args.Handled || !cryoPodComponent.Locked || cryoPodComponent.BodyContainer.ContainedEntity == null)
|
||||
if (args.Handled || !entity.Comp.Locked || entity.Comp.BodyContainer.ContainedEntity == null)
|
||||
return;
|
||||
|
||||
args.Handled = _toolSystem.UseTool(args.Used, args.User, uid, cryoPodComponent.PryDelay, "Prying", new CryoPodPryFinished());
|
||||
args.Handled = _toolSystem.UseTool(args.Used, args.User, entity.Owner, entity.Comp.PryDelay, "Prying", new CryoPodPryFinished());
|
||||
}
|
||||
|
||||
private void OnExamined(EntityUid uid, CryoPodComponent component, ExaminedEvent args)
|
||||
private void OnExamined(Entity<CryoPodComponent> entity, ref ExaminedEvent args)
|
||||
{
|
||||
var container = _itemSlotsSystem.GetItemOrNull(uid, component.SolutionContainerName);
|
||||
if (args.IsInDetailsRange && container != null && _solutionContainerSystem.TryGetFitsInDispenser(container.Value, out var containerSolution))
|
||||
var container = _itemSlotsSystem.GetItemOrNull(entity.Owner, entity.Comp.SolutionContainerName);
|
||||
if (args.IsInDetailsRange && container != null && _solutionContainerSystem.TryGetFitsInDispenser(container.Value, out _, out var containerSolution))
|
||||
{
|
||||
args.PushMarkup(Loc.GetString("cryo-pod-examine", ("beaker", Name(container.Value))));
|
||||
if (containerSolution.Volume == 0)
|
||||
@@ -212,64 +216,63 @@ public sealed partial class CryoPodSystem: SharedCryoPodSystem
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPowerChanged(EntityUid uid, CryoPodComponent component, ref PowerChangedEvent args)
|
||||
private void OnPowerChanged(Entity<CryoPodComponent> entity, ref PowerChangedEvent args)
|
||||
{
|
||||
// Needed to avoid adding/removing components on a deleted entity
|
||||
if (Terminating(uid))
|
||||
if (Terminating(entity))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Powered)
|
||||
{
|
||||
EnsureComp<ActiveCryoPodComponent>(uid);
|
||||
EnsureComp<ActiveCryoPodComponent>(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemComp<ActiveCryoPodComponent>(uid);
|
||||
_uiSystem.TryCloseAll(uid, HealthAnalyzerUiKey.Key);
|
||||
RemComp<ActiveCryoPodComponent>(entity);
|
||||
_uiSystem.TryCloseAll(entity.Owner, HealthAnalyzerUiKey.Key);
|
||||
}
|
||||
UpdateAppearance(uid, component);
|
||||
UpdateAppearance(entity.Owner, entity.Comp);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Atmos handler
|
||||
|
||||
private void OnCryoPodUpdateAtmosphere(EntityUid uid, CryoPodComponent cryoPod, ref AtmosDeviceUpdateEvent args)
|
||||
private void OnCryoPodUpdateAtmosphere(Entity<CryoPodComponent> entity, ref AtmosDeviceUpdateEvent args)
|
||||
{
|
||||
if (!TryComp(uid, out NodeContainerComponent? nodeContainer))
|
||||
if (!TryComp(entity, out NodeContainerComponent? nodeContainer))
|
||||
return;
|
||||
|
||||
if (!_nodeContainer.TryGetNode(nodeContainer, cryoPod.PortName, out PortablePipeNode? portNode))
|
||||
if (!_nodeContainer.TryGetNode(nodeContainer, entity.Comp.PortName, out PortablePipeNode? portNode))
|
||||
return;
|
||||
|
||||
if (!TryComp(uid, out CryoPodAirComponent? cryoPodAir))
|
||||
if (!TryComp(entity, out CryoPodAirComponent? cryoPodAir))
|
||||
return;
|
||||
|
||||
_atmosphereSystem.React(cryoPodAir.Air, portNode);
|
||||
|
||||
if (portNode.NodeGroup is PipeNet {NodeCount: > 1} net)
|
||||
if (portNode.NodeGroup is PipeNet { NodeCount: > 1 } net)
|
||||
{
|
||||
_gasCanisterSystem.MixContainerWithPipeNet(cryoPodAir.Air, net.Air);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGasAnalyzed(EntityUid uid, CryoPodComponent component, GasAnalyzerScanEvent args)
|
||||
private void OnGasAnalyzed(Entity<CryoPodComponent> entity, ref GasAnalyzerScanEvent args)
|
||||
{
|
||||
if (!TryComp(uid, out CryoPodAirComponent? cryoPodAir))
|
||||
if (!TryComp(entity, out CryoPodAirComponent? cryoPodAir))
|
||||
return;
|
||||
|
||||
var gasMixDict = new Dictionary<string, GasMixture?> { { Name(uid), cryoPodAir.Air } };
|
||||
var gasMixDict = new Dictionary<string, GasMixture?> { { Name(entity.Owner), cryoPodAir.Air } };
|
||||
// If it's connected to a port, include the port side
|
||||
if (TryComp(uid, out NodeContainerComponent? nodeContainer))
|
||||
if (TryComp(entity, out NodeContainerComponent? nodeContainer))
|
||||
{
|
||||
if (_nodeContainer.TryGetNode(nodeContainer, component.PortName, out PipeNode? port))
|
||||
gasMixDict.Add(component.PortName, port.Air);
|
||||
if (_nodeContainer.TryGetNode(nodeContainer, entity.Comp.PortName, out PipeNode? port))
|
||||
gasMixDict.Add(entity.Comp.PortName, port.Air);
|
||||
}
|
||||
args.GasMixtures = gasMixDict;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user