mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 13:37:47 +03:00
Soapy Water & Edible Soap (#20364)
* soap reagent and soapy water * make soapy water recognizable * Fix tile cleaning bug CleanDecalsReaction was able to take more than the reactVolume it was given. * make soapy water an evaporating reagent * Tile reactions when mopping * Fix indescribably soap flavor * Adjust soap flavours Soap and soapy water now taste clean and syndie soap tastes like punishment. * Better soap numbers & DeleteOnSolutionEmpty * Changed TrashOnEmpty to TrashOnSolutionEmpty * Last TrashOnSolutionEmpty change * Fix merged code not compiling * Requested changes.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Fluids;
|
||||
using Content.Shared.Fluids.Components;
|
||||
@@ -9,6 +8,7 @@ using Content.Shared.Interaction;
|
||||
using Content.Shared.Timing;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace Content.Server.Fluids.EntitySystems;
|
||||
/// <inheritdoc/>
|
||||
public sealed class AbsorbentSystem : SharedAbsorbentSystem
|
||||
{
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||
[Dependency] private readonly AudioSystem _audio = default!;
|
||||
[Dependency] private readonly PopupSystem _popups = default!;
|
||||
@@ -55,13 +56,13 @@ public sealed class AbsorbentSystem : SharedAbsorbentSystem
|
||||
var oldProgress = component.Progress.ShallowClone();
|
||||
component.Progress.Clear();
|
||||
|
||||
var water = solution.GetTotalPrototypeQuantity(PuddleSystem.EvaporationReagent);
|
||||
var water = solution.GetTotalPrototypeQuantity(PuddleSystem.EvaporationReagents);
|
||||
if (water > FixedPoint2.Zero)
|
||||
{
|
||||
component.Progress[_prototype.Index<ReagentPrototype>(PuddleSystem.EvaporationReagent).SubstanceColor] = water.Float();
|
||||
component.Progress[solution.GetColorWithOnly(_prototype, PuddleSystem.EvaporationReagents)] = water.Float();
|
||||
}
|
||||
|
||||
var otherColor = solution.GetColorWithout(_prototype, PuddleSystem.EvaporationReagent);
|
||||
var otherColor = solution.GetColorWithout(_prototype, PuddleSystem.EvaporationReagents);
|
||||
var other = (solution.Volume - water).Float();
|
||||
|
||||
if (other > 0f)
|
||||
@@ -140,7 +141,7 @@ public sealed class AbsorbentSystem : SharedAbsorbentSystem
|
||||
// Remove the non-water reagents.
|
||||
// Remove water on target
|
||||
// Then do the transfer.
|
||||
var nonWater = absorberSoln.SplitSolutionWithout(component.PickupAmount, PuddleSystem.EvaporationReagent);
|
||||
var nonWater = absorberSoln.SplitSolutionWithout(component.PickupAmount, PuddleSystem.EvaporationReagents);
|
||||
_solutionContainerSystem.UpdateChemicals(used, absorberSoln, true);
|
||||
|
||||
if (nonWater.Volume == FixedPoint2.Zero && absorberSoln.AvailableVolume == FixedPoint2.Zero)
|
||||
@@ -153,18 +154,16 @@ public sealed class AbsorbentSystem : SharedAbsorbentSystem
|
||||
component.PickupAmount :
|
||||
absorberSoln.AvailableVolume;
|
||||
|
||||
var water = refillableSolution.RemoveReagent(PuddleSystem.EvaporationReagent, transferAmount);
|
||||
var water = refillableSolution.SplitSolutionWithOnly(transferAmount, PuddleSystem.EvaporationReagents);
|
||||
_solutionContainerSystem.UpdateChemicals(target, refillableSolution);
|
||||
|
||||
if (water == FixedPoint2.Zero && nonWater.Volume == FixedPoint2.Zero)
|
||||
if (water.Volume == FixedPoint2.Zero && nonWater.Volume == FixedPoint2.Zero)
|
||||
{
|
||||
_popups.PopupEntity(Loc.GetString("mopping-system-target-container-empty-water", ("target", target)), user, user);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (water > 0 && !_solutionContainerSystem.TryAddReagent(used, absorberSoln, PuddleSystem.EvaporationReagent, water,
|
||||
out _))
|
||||
|
||||
if (water.Volume > 0 && !_solutionContainerSystem.TryAddSolution(used, absorberSoln, water))
|
||||
{
|
||||
_popups.PopupEntity(Loc.GetString("mopping-system-full", ("used", used)), used, user);
|
||||
}
|
||||
@@ -217,18 +216,18 @@ public sealed class AbsorbentSystem : SharedAbsorbentSystem
|
||||
if (!TryComp(target, out PuddleComponent? puddle))
|
||||
return false;
|
||||
|
||||
if (!_solutionSystem.TryGetSolution(target, puddle.SolutionName, out var puddleSolution) || puddleSolution.Volume <= 0)
|
||||
if (!_solutionSystem.TryGetSolution(target, puddle.SolutionName, out var puddleSoln) || puddleSoln.Volume <= 0)
|
||||
return false;
|
||||
|
||||
// Check if the puddle has any non-evaporative reagents
|
||||
if (_puddleSystem.CanFullyEvaporate(puddleSolution))
|
||||
if (_puddleSystem.CanFullyEvaporate(puddleSoln))
|
||||
{
|
||||
_popups.PopupEntity(Loc.GetString("mopping-system-puddle-evaporate", ("target", target)), user, user);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if we have any evaporative reagents on our absorber to transfer
|
||||
var available = absorberSoln.GetTotalPrototypeQuantity(PuddleSystem.EvaporationReagent);
|
||||
var available = absorberSoln.GetTotalPrototypeQuantity(PuddleSystem.EvaporationReagents);
|
||||
|
||||
// No material
|
||||
if (available == FixedPoint2.Zero)
|
||||
@@ -240,14 +239,21 @@ public sealed class AbsorbentSystem : SharedAbsorbentSystem
|
||||
var transferMax = absorber.PickupAmount;
|
||||
var transferAmount = available > transferMax ? transferMax : available;
|
||||
|
||||
var split = puddleSolution.SplitSolutionWithout(transferAmount, PuddleSystem.EvaporationReagent);
|
||||
var puddleSplit = puddleSoln.SplitSolutionWithout(transferAmount, PuddleSystem.EvaporationReagents);
|
||||
var absorberSplit = absorberSoln.SplitSolutionWithOnly(puddleSplit.Volume, PuddleSystem.EvaporationReagents);
|
||||
|
||||
absorberSoln.RemoveReagent(PuddleSystem.EvaporationReagent, split.Volume);
|
||||
puddleSolution.AddReagent(PuddleSystem.EvaporationReagent, split.Volume);
|
||||
absorberSoln.AddSolution(split, _prototype);
|
||||
// Do tile reactions first
|
||||
var coordinates = Transform(target).Coordinates;
|
||||
if (_mapManager.TryGetGrid(coordinates.GetGridUid(EntityManager), out var mapGrid))
|
||||
{
|
||||
_puddleSystem.DoTileReactions(mapGrid.GetTileRef(coordinates), absorberSplit);
|
||||
}
|
||||
|
||||
puddleSoln.AddSolution(absorberSplit, _prototype);
|
||||
absorberSoln.AddSolution(puddleSplit, _prototype);
|
||||
|
||||
_solutionSystem.UpdateChemicals(used, absorberSoln);
|
||||
_solutionSystem.UpdateChemicals(target, puddleSolution);
|
||||
_solutionSystem.UpdateChemicals(target, puddleSoln);
|
||||
_audio.PlayPvs(absorber.PickupSound, target);
|
||||
_useDelay.BeginDelay(used);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user