* 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>
72 lines
2.7 KiB
C#
72 lines
2.7 KiB
C#
using Content.Shared.Chemistry.Components;
|
|
using Content.Shared.DragDrop;
|
|
using Content.Shared.FixedPoint;
|
|
using Content.Shared.Fluids;
|
|
|
|
namespace Content.Server.Fluids.EntitySystems;
|
|
|
|
public sealed partial class PuddleSystem
|
|
{
|
|
private void InitializeTransfers()
|
|
{
|
|
SubscribeLocalEvent<RefillableSolutionComponent, DragDropDraggedEvent>(OnRefillableDragged);
|
|
}
|
|
|
|
private void OnRefillableDragged(Entity<RefillableSolutionComponent> entity, ref DragDropDraggedEvent args)
|
|
{
|
|
if (!_solutionContainerSystem.TryGetSolution(entity.Owner, entity.Comp.Solution, out var soln, out var solution) || solution.Volume == FixedPoint2.Zero)
|
|
{
|
|
_popups.PopupEntity(Loc.GetString("mopping-system-empty", ("used", entity.Owner)), entity, args.User);
|
|
return;
|
|
}
|
|
|
|
// Dump reagents into DumpableSolution
|
|
if (TryComp<DumpableSolutionComponent>(args.Target, out var dump))
|
|
{
|
|
if (!_solutionContainerSystem.TryGetDumpableSolution((args.Target, dump, null), out var dumpableSoln, out var dumpableSolution))
|
|
return;
|
|
|
|
bool success = true;
|
|
if (dump.Unlimited)
|
|
{
|
|
var split = _solutionContainerSystem.SplitSolution(soln.Value, solution.Volume);
|
|
dumpableSolution.AddSolution(split, _prototypeManager);
|
|
}
|
|
else
|
|
{
|
|
var split = _solutionContainerSystem.SplitSolution(soln.Value, dumpableSolution.AvailableVolume);
|
|
success = _solutionContainerSystem.TryAddSolution(dumpableSoln.Value, split);
|
|
}
|
|
|
|
if (success)
|
|
{
|
|
_audio.PlayPvs(AbsorbentComponent.DefaultTransferSound, args.Target);
|
|
}
|
|
else
|
|
{
|
|
_popups.PopupEntity(Loc.GetString("mopping-system-full", ("used", args.Target)), args.Target, args.User);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
// Take reagents from target
|
|
if (!TryComp<DrainableSolutionComponent>(args.Target, out var drainable))
|
|
{
|
|
if (!_solutionContainerSystem.TryGetDrainableSolution((args.Target, drainable, null), out var drainableSolution, out _))
|
|
return;
|
|
|
|
var split = _solutionContainerSystem.SplitSolution(drainableSolution.Value, solution.AvailableVolume);
|
|
|
|
if (_solutionContainerSystem.TryAddSolution(soln.Value, split))
|
|
{
|
|
_audio.PlayPvs(AbsorbentComponent.DefaultTransferSound, entity);
|
|
}
|
|
else
|
|
{
|
|
_popups.PopupEntity(Loc.GetString("mopping-system-full", ("used", entity.Owner)), entity, args.User);
|
|
}
|
|
}
|
|
}
|
|
}
|