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 partial class DeleteOnSolutionEmptySystem : EntitySystem { [Dependency] private SharedSolutionContainerSystem _solutionContainerSystem = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnStartup); SubscribeLocalEvent(OnSolutionChange); } public void OnStartup(Entity entity, ref ComponentStartup args) { CheckSolutions(entity); } public void OnSolutionChange(Entity entity, ref SolutionChangedEvent args) { var solution = args.Solution.Comp.Solution; if (args.Solution.Comp.Id != entity.Comp.Solution) return; if (solution.Volume <= 0) QueueDel(entity); } public void CheckSolutions(Entity entity) { if (!_solutionContainerSystem.TryGetSolution(entity.Owner, entity.Comp.Solution, out _, out var solution)) return; if (solution.Volume <= 0) QueueDel(entity); } } }