Add ItemStatus for mopping (#13745)

* Add ItemStatus for mopping

Big QOL feature

* a
This commit is contained in:
metalgearsloth
2023-02-11 12:38:45 +11:00
committed by GitHub
parent 95e35b94b5
commit 2c751d5153
6 changed files with 138 additions and 4 deletions

View File

@@ -1,3 +1,4 @@
using System.Linq;
using Content.Server.Chemistry.Components.SolutionManager;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.DoAfter;
@@ -5,6 +6,7 @@ using Content.Server.Fluids.Components;
using Content.Server.Popups;
using Content.Shared.Chemistry.Components;
using Content.Shared.FixedPoint;
using Content.Shared.Fluids;
using Content.Shared.Interaction;
using Content.Shared.Tag;
using JetBrains.Annotations;
@@ -15,7 +17,7 @@ using Robust.Shared.Map;
namespace Content.Server.Fluids.EntitySystems;
[UsedImplicitly]
public sealed class MoppingSystem : EntitySystem
public sealed class MoppingSystem : SharedMoppingSystem
{
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly SpillableSystem _spillableSystem = default!;
@@ -30,11 +32,37 @@ public sealed class MoppingSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<AbsorbentComponent, ComponentInit>(OnAbsorbentInit);
SubscribeLocalEvent<AbsorbentComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<AbsorbentComponent, SolutionChangedEvent>(OnAbsorbentSolutionChange);
SubscribeLocalEvent<TransferCancelledEvent>(OnTransferCancelled);
SubscribeLocalEvent<TransferCompleteEvent>(OnTransferComplete);
}
private void OnAbsorbentInit(EntityUid uid, AbsorbentComponent component, ComponentInit args)
{
// TODO: I know dirty on init but no prediction moment.
UpdateAbsorbent(uid, component);
}
private void OnAbsorbentSolutionChange(EntityUid uid, AbsorbentComponent component, SolutionChangedEvent args)
{
UpdateAbsorbent(uid, component);
}
private void UpdateAbsorbent(EntityUid uid, AbsorbentComponent component)
{
if (!_solutionSystem.TryGetSolution(uid, AbsorbentComponent.SolutionName, out var solution))
return;
var oldProgress = component.Progress;
component.Progress = (float) (solution.Volume / solution.MaxVolume);
if (component.Progress.Equals(oldProgress))
return;
Dirty(component);
}
private void OnAfterInteract(EntityUid uid, AbsorbentComponent component, AfterInteractEvent args)
{
if (!args.CanReach || args.Handled)