Add ItemStatus for mopping (#13745)
* Add ItemStatus for mopping Big QOL feature * a
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
using Content.Server.Fluids.EntitySystems;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server.Fluids.Components;
|
||||
|
||||
/// <summary>
|
||||
/// For entities that can clean up puddles
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(MoppingSystem))]
|
||||
public sealed class AbsorbentComponent : Component
|
||||
{
|
||||
public const string SolutionName = "absorbed";
|
||||
|
||||
[DataField("pickupAmount")]
|
||||
public FixedPoint2 PickupAmount = FixedPoint2.New(10);
|
||||
|
||||
/// <summary>
|
||||
/// When using this tool on an empty floor tile, leave this much reagent as a new puddle.
|
||||
/// </summary>
|
||||
[DataField("residueAmount")]
|
||||
public FixedPoint2 ResidueAmount = FixedPoint2.New(10); // Should be higher than MopLowerLimit
|
||||
|
||||
/// <summary>
|
||||
/// To leave behind a wet floor, this tool will be unable to take from puddles with a volume less than this
|
||||
/// amount. This limit is ignored if the target puddle does not evaporate.
|
||||
/// </summary>
|
||||
[DataField("lowerLimit")]
|
||||
public FixedPoint2 LowerLimit = FixedPoint2.New(5);
|
||||
|
||||
[DataField("pickupSound")]
|
||||
public SoundSpecifier PickupSound = new SoundPathSpecifier("/Audio/Effects/Fluids/slosh.ogg");
|
||||
|
||||
[DataField("transferSound")]
|
||||
public SoundSpecifier TransferSound = new SoundPathSpecifier("/Audio/Effects/Fluids/watersplash.ogg");
|
||||
|
||||
/// <summary>
|
||||
/// Quantity of reagent that this mop can pick up per second. Determines the length of the do-after.
|
||||
/// </summary>
|
||||
[DataField("speed")] public float Speed = 10;
|
||||
|
||||
/// <summary>
|
||||
/// How many entities can this tool interact with at once?
|
||||
/// </summary>
|
||||
[DataField("maxEntities")]
|
||||
public int MaxInteractingEntities = 1;
|
||||
|
||||
/// <summary>
|
||||
/// What entities is this tool interacting with right now?
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public HashSet<EntityUid> InteractingEntities = new();
|
||||
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user