mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-25 01:27:06 +03:00
* fix * fix * fix * fix * fix * Fix Bug with Opening Storage Containers (#1292) <!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Fixes the bug with opening storage containers while there's already one opened. --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 - fix: Fixed the bug with opening storage containers while there's already one open. (cherry picked from commit b0407604ced2859ccbdc417345dadc29656f71f0) * Automatic Changelog Update (#1292) (cherry picked from commit 9a40c3783eb0d0e622badc2febcaf0794f6f8ddd) * possible test fix * possible test fix * fix --------- Co-authored-by: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> Co-authored-by: SimpleStation Changelogs <simplestation14@users.noreply.github.com>
55 lines
2.5 KiB
C#
55 lines
2.5 KiB
C#
using System.Linq;
|
|
using Content.Server.Fluids.EntitySystems;
|
|
using Content.Shared.FootPrint;
|
|
using Content.Shared.Chemistry.Components.SolutionManager;
|
|
using Content.Shared.Chemistry.EntitySystems;
|
|
using Content.Shared.Fluids;
|
|
using Content.Shared.Fluids.Components;
|
|
using Content.Shared.Maps;
|
|
using Robust.Shared.Physics.Events;
|
|
|
|
namespace Content.Server.FootPrint;
|
|
|
|
public sealed class PuddleFootPrintsSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = 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<AppearanceComponent>(uid, out var appearance)
|
|
|| !TryComp<PuddleComponent>(uid, out var puddle)
|
|
|| !TryComp<FootPrintsComponent>(args.OtherEntity, out var tripper)
|
|
|| !TryComp<SolutionContainerManagerComponent>(uid, out var solutionManager)
|
|
|| !_solutionContainer.ResolveSolution((uid, solutionManager), puddle.SolutionName, ref puddle.Solution, out var solutions))
|
|
return;
|
|
|
|
var totalSolutionQuantity = solutions.Contents.Sum(sol => (float) sol.Quantity);
|
|
var waterQuantity = (from sol in solutions.Contents where sol.Reagent.Prototype == "Water" select (float) sol.Quantity).FirstOrDefault();
|
|
|
|
if (waterQuantity / (totalSolutionQuantity / 100f) > component.OffPercent || solutions.Contents.Count <= 0)
|
|
return;
|
|
|
|
tripper.ReagentToTransfer =
|
|
solutions.Contents.Aggregate((l, r) => l.Quantity > r.Quantity ? l : r).Reagent.Prototype;
|
|
|
|
if (_appearance.TryGetData(uid, PuddleVisuals.SolutionColor, out var color, appearance)
|
|
&& _appearance.TryGetData(uid, PuddleVisuals.CurrentVolume, out var volume, appearance))
|
|
AddColor((Color) color, (float) volume * component.SizeRatio, tripper);
|
|
|
|
_solutionContainer.RemoveEachReagent(puddle.Solution.Value, 1);
|
|
}
|
|
|
|
private void AddColor(Color col, float quantity, FootPrintsComponent component)
|
|
{
|
|
component.PrintsColor = component.ColorQuantity == 0f ? col : Color.InterpolateBetween(component.PrintsColor, col, component.ColorInterpolationFactor);
|
|
component.ColorQuantity += quantity;
|
|
}
|
|
}
|