Files
wwdpublic/Content.Server/FootPrint/PuddleFootPrintsSystem.cs
VMSolidus 8d59c57099 Footprints Performance Updates (#1439)
# Description

This is a port of https://github.com/Fansana/floofstation1/pull/445
Except I despise that this wasn't upstreamed so much that I didn't even
cherrypick it.

# Changelog

🆑
- add: Footprints are now cleaned in a small radius around the mouse
cursor when mopping them.

(cherry picked from commit 11678af96950f6af75f7effef40fc92a7af33350)
2025-01-14 01:31:23 +03:00

49 lines
2.0 KiB
C#

using Content.Shared.FootPrint;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.FixedPoint;
using Content.Shared.Fluids.Components;
using Content.Shared.Forensics;
using Robust.Shared.Physics.Events;
using Robust.Shared.Prototypes;
namespace Content.Server.FootPrint;
public sealed class PuddleFootPrintsSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PuddleFootPrintsComponent, EndCollideEvent>(OnStepTrigger);
}
private void OnStepTrigger(EntityUid uid, PuddleFootPrintsComponent component, ref EndCollideEvent args)
{
if (!TryComp<PuddleComponent>(uid, out var puddle) || !TryComp<FootPrintsComponent>(args.OtherEntity, out var tripper))
return;
// Transfer DNAs from the puddle to the tripper
if (TryComp<ForensicsComponent>(uid, out var puddleForensics))
{
tripper.DNAs.UnionWith(puddleForensics.DNAs);
if(TryComp<ForensicsComponent>(args.OtherEntity, out var tripperForensics))
tripperForensics.DNAs.UnionWith(puddleForensics.DNAs);
}
// Transfer reagents from the puddle to the tripper.
// Ideally it should be a two-way process, but that is too hard to simulate and will have very little effect outside of potassium-water spills.
var quantity = puddle.Solution?.Comp?.Solution?.Volume ?? 0;
var footprintsCapacity = tripper.ContainedSolution.AvailableVolume;
if (quantity <= 0 || footprintsCapacity <= 0)
return;
var transferAmount = FixedPoint2.Min(footprintsCapacity, quantity * component.SizeRatio);
var transferred = _solutionContainer.SplitSolution(puddle.Solution!.Value, transferAmount);
tripper.ContainedSolution.AddSolution(transferred, _protoMan);
}
}