Revert "Solution Entities" (#23160)

Revert "Solution Entities (#21916)"

This reverts commit d75e743dd7.
This commit is contained in:
Emisse
2023-12-28 20:45:42 -07:00
committed by GitHub
parent c2c76c2035
commit 938d6d9945
180 changed files with 2959 additions and 3543 deletions

View File

@@ -1,7 +1,8 @@
using System.Linq;
using Content.Server.Administration.Logs;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Explosion.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Database;
using Content.Shared.Examine;
using Content.Shared.Payload.Components;
@@ -9,15 +10,14 @@ using Content.Shared.Tag;
using Robust.Shared.Containers;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Utility;
using System.Linq;
namespace Content.Server.Payload.EntitySystems;
public sealed class PayloadSystem : EntitySystem
{
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly SolutionContainerSystem _solutionSystem = default!;
[Dependency] private readonly IAdminLogManager _adminLogger= default!;
[Dependency] private readonly IComponentFactory _componentFactory = default!;
[Dependency] private readonly ISerializationManager _serializationManager = default!;
@@ -33,7 +33,7 @@ public sealed class PayloadSystem : EntitySystem
SubscribeLocalEvent<ChemicalPayloadComponent, TriggerEvent>(HandleChemicalPayloadTrigger);
}
public IEnumerable<EntityUid> GetAllPayloads(EntityUid uid, ContainerManagerComponent? contMan = null)
public IEnumerable<EntityUid> GetAllPayloads(EntityUid uid, ContainerManagerComponent? contMan=null)
{
if (!Resolve(uid, ref contMan, false))
yield break;
@@ -98,7 +98,7 @@ public sealed class PayloadSystem : EntitySystem
var temp = (object) component;
_serializationManager.CopyTo(data.Component, ref temp);
EntityManager.AddComponent(uid, (Component) temp!);
EntityManager.AddComponent(uid, (Component)temp!);
trigger.GrantedComponents.Add(registration.Type);
}
@@ -137,14 +137,14 @@ public sealed class PayloadSystem : EntitySystem
}
}
private void HandleChemicalPayloadTrigger(Entity<ChemicalPayloadComponent> entity, ref TriggerEvent args)
private void HandleChemicalPayloadTrigger(EntityUid uid, ChemicalPayloadComponent component, TriggerEvent args)
{
if (entity.Comp.BeakerSlotA.Item is not EntityUid beakerA
|| entity.Comp.BeakerSlotB.Item is not EntityUid beakerB
if (component.BeakerSlotA.Item is not EntityUid beakerA
|| component.BeakerSlotB.Item is not EntityUid beakerB
|| !TryComp(beakerA, out FitsInDispenserComponent? compA)
|| !TryComp(beakerB, out FitsInDispenserComponent? compB)
|| !_solutionContainerSystem.TryGetSolution(beakerA, compA.Solution, out var solnA, out var solutionA)
|| !_solutionContainerSystem.TryGetSolution(beakerB, compB.Solution, out var solnB, out var solutionB)
|| !_solutionSystem.TryGetSolution(beakerA, compA.Solution, out var solutionA)
|| !_solutionSystem.TryGetSolution(beakerB, compB.Solution, out var solutionB)
|| solutionA.Volume == 0
|| solutionB.Volume == 0)
{
@@ -155,17 +155,17 @@ public sealed class PayloadSystem : EntitySystem
var solStringB = SolutionContainerSystem.ToPrettyString(solutionB);
_adminLogger.Add(LogType.ChemicalReaction,
$"Chemical bomb payload {ToPrettyString(entity.Owner):payload} at {Transform(entity.Owner).MapPosition:location} is combining two solutions: {solStringA:solutionA} and {solStringB:solutionB}");
$"Chemical bomb payload {ToPrettyString(uid):payload} at {Transform(uid).MapPosition:location} is combining two solutions: {solStringA:solutionA} and {solStringB:solutionB}");
solutionA.MaxVolume += solutionB.MaxVolume;
_solutionContainerSystem.TryAddSolution(solnA.Value, solutionB);
_solutionContainerSystem.RemoveAllSolution(solnB.Value);
_solutionSystem.TryAddSolution(beakerA, solutionA, solutionB);
_solutionSystem.RemoveAllSolution(beakerB, solutionB);
// The grenade might be a dud. Redistribute solution:
var tmpSol = _solutionContainerSystem.SplitSolution(solnA.Value, solutionA.Volume * solutionB.MaxVolume / solutionA.MaxVolume);
_solutionContainerSystem.TryAddSolution(solnB.Value, tmpSol);
var tmpSol = _solutionSystem.SplitSolution(beakerA, solutionA, solutionA.Volume * solutionB.MaxVolume / solutionA.MaxVolume);
_solutionSystem.TryAddSolution(beakerB, solutionB, tmpSol);
solutionA.MaxVolume -= solutionB.MaxVolume;
_solutionContainerSystem.UpdateChemicals(solnA.Value);
_solutionSystem.UpdateChemicals(beakerA, solutionA, false);
args.Handled = true;
}