Solution Entities (#21916)
* Creates Content.Shared.Chemistry.Solutions Copies Solution class to new namespace Obsoletes old Solution class * Switches over to the Solutions.Solution Solution * Creates Content.Shared.Chemistry.Containers Copies relevant components/systems to the new namespace Obsoletes old versions * Switches over to the Containers.XYZ namespace * Creates SolutionSystem and obsoletes old SolutionContainerSystem methods * Start using SolutionSystem for Solution manipulation * EnumerateSolutions * Move TryGetMixableSolution * Move EnsureSolution to Server * Create Solution Entities * Stop using obsolete solution system methods * Fix prototype component tests * Add using ..Audio.Systems; back * Wrap solution container slots in ContainerSlots * Actually add the slot to the solution container map * Dirty SolutionContainerComponent when ensuring solutions * Revert namespace changes * Remerge SolutionSystem and SolutionContainerSystem * SolutionContainerManagerComponent refactor * Avoid wrapping necessary code in DebugTools.Assert as it is removed when compiling for release * Readd examine reagent sorting * Fix errors * Poke tests * Fix solution names not being applied * Fix WoolyComponent including statement * Fix merge skew * Fix compile errors * Make reactions use solntities * Reindent solution class namespace * Field attribute changes * AutoGenerateComponentState for SolutionContainerComponent * SolutionContainerComponent -> ContainedSolutionComponent * ref ReactionAttemptEvent * Denetwork preinit solutions * Misc 1 * Nullable TryGetSolution out vars * Cache associated solutions * Fix merge skew * Use explicit regions in SharedSolutionContainerSystem.Capabilities * Add debug assert * Use explicit regions in SharedSolutionContainerSystem.Relay + ref SolutionContainerChangedEvent * ContainedSolutionComponent.Name -> ContainedSolutionComponent.ContainerName * SolutionComponent doc comments * Implicit DataField names and property purge * ReagentEffect DataField names * Local variables for readability * Sort using statements + Entity<T> event handlers * Fix compile erros * Fix compile errors --------- Co-authored-by: ElectroJr <leonsfriedrich@gmail.com>
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
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;
|
||||
@@ -10,14 +9,15 @@ 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 _solutionSystem = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger= default!;
|
||||
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = 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(EntityUid uid, ChemicalPayloadComponent component, TriggerEvent args)
|
||||
private void HandleChemicalPayloadTrigger(Entity<ChemicalPayloadComponent> entity, ref TriggerEvent args)
|
||||
{
|
||||
if (component.BeakerSlotA.Item is not EntityUid beakerA
|
||||
|| component.BeakerSlotB.Item is not EntityUid beakerB
|
||||
if (entity.Comp.BeakerSlotA.Item is not EntityUid beakerA
|
||||
|| entity.Comp.BeakerSlotB.Item is not EntityUid beakerB
|
||||
|| !TryComp(beakerA, out FitsInDispenserComponent? compA)
|
||||
|| !TryComp(beakerB, out FitsInDispenserComponent? compB)
|
||||
|| !_solutionSystem.TryGetSolution(beakerA, compA.Solution, out var solutionA)
|
||||
|| !_solutionSystem.TryGetSolution(beakerB, compB.Solution, out var solutionB)
|
||||
|| !_solutionContainerSystem.TryGetSolution(beakerA, compA.Solution, out var solnA, out var solutionA)
|
||||
|| !_solutionContainerSystem.TryGetSolution(beakerB, compB.Solution, out var solnB, 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(uid):payload} at {Transform(uid).MapPosition:location} is combining two solutions: {solStringA:solutionA} and {solStringB:solutionB}");
|
||||
$"Chemical bomb payload {ToPrettyString(entity.Owner):payload} at {Transform(entity.Owner).MapPosition:location} is combining two solutions: {solStringA:solutionA} and {solStringB:solutionB}");
|
||||
|
||||
solutionA.MaxVolume += solutionB.MaxVolume;
|
||||
_solutionSystem.TryAddSolution(beakerA, solutionA, solutionB);
|
||||
_solutionSystem.RemoveAllSolution(beakerB, solutionB);
|
||||
_solutionContainerSystem.TryAddSolution(solnA.Value, solutionB);
|
||||
_solutionContainerSystem.RemoveAllSolution(solnB.Value);
|
||||
|
||||
// The grenade might be a dud. Redistribute solution:
|
||||
var tmpSol = _solutionSystem.SplitSolution(beakerA, solutionA, solutionA.Volume * solutionB.MaxVolume / solutionA.MaxVolume);
|
||||
_solutionSystem.TryAddSolution(beakerB, solutionB, tmpSol);
|
||||
var tmpSol = _solutionContainerSystem.SplitSolution(solnA.Value, solutionA.Volume * solutionB.MaxVolume / solutionA.MaxVolume);
|
||||
_solutionContainerSystem.TryAddSolution(solnB.Value, tmpSol);
|
||||
solutionA.MaxVolume -= solutionB.MaxVolume;
|
||||
_solutionSystem.UpdateChemicals(beakerA, solutionA, false);
|
||||
_solutionContainerSystem.UpdateChemicals(solnA.Value);
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user