Files
Delta-v/Content.Shared/_DV/Footprints/EntitySystems/DecalScrubberSystem.cs
T
DisposableCrewmember42andpre-commit-ci[bot] 378cceb44f feat: Make footprints decals (#5226)
* feat(wip): footprints now decals instead of entities

* fix: apply proper offset to footprint decals

* refactor: basedecaloffset to readonly

* feat: add back dragging smears, also resolve conflicts

* refactor: rename dragging to beingDragged for clarity

* docs: properly document draggingdecals

* refactor: remove unused reagent code

* refactor: move under _DV

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* feat(wip): mops now able to remove decals

# Conflicts:
#	Content.Server/_DV/Footprints/Systems/PuddleFootPrintsSystem.cs

* fix: reset ColorQuantity if transparent prints

* feat: implement scrubbing

* refactor: remove unused import, ioc dependency

* feat: remove 5u water when scrubbing

* fix: remove unused attributes from protos

* docs: add summary to puddlefootprintscomp

* fix: colliding entity checked for flight, not the puddle

also minor refactor: renamed local variables/parameters of OnEndCollide for clarity

* style: remove newlines, redundant parens

* test: ensure FootPrints stepSize/dragSize are positive

* docs: add prediction todo

* feat: add bare footprints, restore sprite assignments

---------

Signed-off-by: DisposableCrewmember42 <disposablecrewmember42@proton.me>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-03-26 14:44:06 +01:00

83 lines
3.2 KiB
C#

using Content.Shared._DV.Footprints.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Decals;
using Content.Shared.DoAfter;
using Content.Shared.Interaction;
using Content.Shared.Popups;
using Robust.Shared.Audio.Systems;
namespace Content.Shared._DV.Footprints.EntitySystems;
public sealed class DecalScrubberSystem : EntitySystem
{
[Dependency] private readonly SharedDecalSystem _decal = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly EntityManager _entityManager = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedSolutionContainerSystem _solution = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DecalScrubberComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<DecalScrubberComponent, DecalScrubberDoAfterEvent>(OnDoAfter);
}
private void OnDoAfter(Entity<DecalScrubberComponent> ent, ref DecalScrubberDoAfterEvent args)
{
if (args.Cancelled
|| ent.Comp.LastClick is not { } loc
|| _transform.GetGrid(loc) is not { } grid
|| !TryComp<DecalGridComponent>(grid, out var decalGrid))
return;
if (ent.Comp.CleaningSolutionName is { } solutionName &&
_solution.TryGetSolution(ent.Owner, solutionName, out var solutionOpt) &&
solutionOpt is {} solutionEnt)
{
var solution = solutionEnt.Comp.Solution;
var toRemove = new ReagentQuantity(ent.Comp.CleaningReagent.Id, ent.Comp.CleaningReagentCost);
if (solution.GetReagentQuantity(toRemove.Reagent) <= ent.Comp.CleaningReagentCost)
{
_popup.PopupPredicted(Loc.GetString("decal-scrubber-dry-popup", ("user", args.User)), ent.Owner, args.User);
return;
}
_solution.RemoveReagent(solutionEnt, toRemove);
}
var decals = _decal.GetDecalsInRange(grid, loc.Position, ent.Comp.Radius, decal => decal.Cleanable);
foreach (var (id, _) in decals)
{
_decal.RemoveDecal(loc.EntityId, id, decalGrid);
}
_audio.PlayPredicted(ent.Comp.ScrubSound, loc, args.User);
}
private void OnAfterInteract(Entity<DecalScrubberComponent> ent, ref AfterInteractEvent args)
{
if (!args.CanReach || args.Handled || args.Target != null)
return;
ent.Comp.LastClick = args.ClickLocation;
var ev = new DecalScrubberDoAfterEvent();
var doArgs = new DoAfterArgs(_entityManager, args.User, ent.Comp.DoAfterLength, ev, ent.Owner)
{
BreakOnDamage = true,
BreakOnMove = true,
BreakOnWeightlessMove = true,
NeedHand = true,
};
if (_doAfter.TryStartDoAfter(doArgs))
_popup.PopupPredicted(Loc.GetString("decal-scrubber-popup", ("user", args.User)), ent.Owner, args.User);
}
}