Files
tbd-station-14/Content.Server/Chemistry/EntitySystems/DeleteOnSolutionEmptySystem.cs
Psychpsyo 6a18bdc023 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.
2023-10-31 13:39:12 -07:00

39 lines
1.5 KiB
C#

using Content.Server.Chemistry.Components.DeleteOnSolutionEmptyComponent;
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.EntitySystems;
namespace Content.Server.Chemistry.EntitySystems.DeleteOnSolutionEmptySystem
{
public sealed class DeleteOnSolutionEmptySystem : EntitySystem
{
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DeleteOnSolutionEmptyComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<DeleteOnSolutionEmptyComponent, SolutionChangedEvent>(OnSolutionChange);
}
public void OnStartup(EntityUid uid, DeleteOnSolutionEmptyComponent component, ComponentStartup args)
{
CheckSolutions(uid, component);
}
public void OnSolutionChange(EntityUid uid, DeleteOnSolutionEmptyComponent component, SolutionChangedEvent args)
{
CheckSolutions(uid, component);
}
public void CheckSolutions(EntityUid uid, DeleteOnSolutionEmptyComponent component)
{
if (!EntityManager.HasComponent<SolutionContainerManagerComponent>(uid))
return;
if (_solutionContainerSystem.TryGetSolution(uid, component.Solution, out var solution))
if (solution.Volume <= 0)
EntityManager.QueueDeleteEntity(uid);
}
}
}