From ebdcc0e81fa24711e6269330e733f07852f2f372 Mon Sep 17 00:00:00 2001 From: fox Date: Thu, 19 Dec 2024 23:19:27 +0300 Subject: [PATCH 1/2] All the fixes --- .../TileReactions/CleanTileReaction.cs | 35 ++++++++++++++++--- Content.Server/FootPrint/FootPrintsSystem.cs | 16 ++++++--- .../Footprint/FootPrintsComponent.cs | 1 + 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/Content.Server/Chemistry/TileReactions/CleanTileReaction.cs b/Content.Server/Chemistry/TileReactions/CleanTileReaction.cs index 3f5ae63c365..b7bfce9346d 100644 --- a/Content.Server/Chemistry/TileReactions/CleanTileReaction.cs +++ b/Content.Server/Chemistry/TileReactions/CleanTileReaction.cs @@ -1,3 +1,4 @@ +using System.Diagnostics.CodeAnalysis; using Content.Server.Chemistry.Containers.EntitySystems; using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Reaction; @@ -7,6 +8,9 @@ using Robust.Shared.Map; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using System.Linq; +using Content.Shared.Chemistry.EntitySystems; +using Content.Shared.FootPrint; + namespace Content.Server.Chemistry.TileReactions; @@ -42,11 +46,9 @@ FixedPoint2 ITileReaction.TileReact(TileRef tile, ReagentPrototype reagent, Fixe foreach (var entity in entities) { - if (!puddleQuery.TryGetComponent(entity, out var puddle) || - !solutionContainerSystem.TryGetSolution(entity, puddle.SolutionName, out var puddleSolution, out _)) - { + // Floof - separated this into a separate function to incroporate cleaning footprints + if (!TryGetCleanableSolution(entity, entMan, solutionContainerSystem, out var puddleSolution)) continue; - } var purgeable = solutionContainerSystem.SplitSolutionWithout(puddleSolution.Value, purgeAmount, ReplacementReagent, reagent.ID); @@ -60,4 +62,29 @@ FixedPoint2 ITileReaction.TileReact(TileRef tile, ReagentPrototype reagent, Fixe return (reactVolume / CleanAmountMultiplier - purgeAmount) * CleanAmountMultiplier; } + + // Floof + private bool TryGetCleanableSolution( + EntityUid entity, + IEntityManager entMan, + SharedSolutionContainerSystem solutionContainerSystem, + [NotNullWhen(true)] out Entity? solution) + { + solution = default; + if (entMan.TryGetComponent(entity, out var puddle) && + solutionContainerSystem.TryGetSolution(entity, puddle.SolutionName, out var puddleSolution, out _)) + { + solution = puddleSolution; + return true; + } + + if (entMan.TryGetComponent(entity, out var footPrint) && + solutionContainerSystem.TryGetSolution(entity, footPrint.SolutionName, out var footPrintSolution, out _)) + { + solution = footPrintSolution; + return true; + } + + return false; + } } diff --git a/Content.Server/FootPrint/FootPrintsSystem.cs b/Content.Server/FootPrint/FootPrintsSystem.cs index 8c5b7e2a3cc..a4828b43782 100644 --- a/Content.Server/FootPrint/FootPrintsSystem.cs +++ b/Content.Server/FootPrint/FootPrintsSystem.cs @@ -1,5 +1,6 @@ using System.Linq; using Content.Server.Atmos.Components; +using Content.Server.Gravity; using Content.Shared.Inventory; using Content.Shared.Mobs; using Content.Shared.Mobs.Components; @@ -9,6 +10,7 @@ using Content.Shared.Chemistry.EntitySystems; using Content.Shared.Forensics; using Robust.Shared.Map; +using Robust.Shared.Physics.Components; using Robust.Shared.Random; namespace Content.Server.FootPrint; @@ -22,7 +24,7 @@ public sealed class FootPrintsSystem : EntitySystem [Dependency] private readonly SharedSolutionContainerSystem _solution = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; - [Dependency] private readonly EntityLookupSystem _lookup = default!; + [Dependency] private readonly EntityLookupSystem _lookup = default!; // Floof private EntityQuery _transformQuery; private EntityQuery _mobThresholdQuery; @@ -49,10 +51,12 @@ private void OnStartupComponent(EntityUid uid, FootPrintsComponent component, Co private void OnMove(EntityUid uid, FootPrintsComponent component, ref MoveEvent args) { - if (component.PrintsColor.A <= .2f) // avoid creating footsteps that are invisible + // Floof: clear stored DNAs if footprints are now invisible + if (component.PrintsColor.A <= .2f) component.DNAs.Clear(); - if (component.PrintsColor.A <= .2f + if (component.PrintsColor.A <= .2f // avoid creating footsteps that are invisible + || TryComp(uid, out var physics) && physics.BodyStatus != BodyStatus.OnGround // Floof: do not create footprints if the entity is flying || !_transformQuery.TryComp(uid, out var transform) || !_mobThresholdQuery.TryComp(uid, out var mobThreshHolds) || !_map.TryFindGridAt(_transform.GetMapCoordinates((uid, transform)), out var gridUid, out _)) @@ -66,9 +70,10 @@ private void OnMove(EntityUid uid, FootPrintsComponent component, ref MoveEvent if (!(distance > stepSize)) return; + // Floof section var entities = _lookup.GetEntitiesIntersecting(uid, LookupFlags.All); foreach (var entityUid in entities.Where(entityUid => HasComp(entityUid))) - return; //are we on a puddle? we exit, ideally we would exchange liquid and DNA with the puddle but meh, too lazy to do that now. + return; // are we on a puddle? we exit, ideally we would exchange liquid and DNA with the puddle but meh, too lazy to do that now. component.RightStep = !component.RightStep; @@ -76,7 +81,8 @@ private void OnMove(EntityUid uid, FootPrintsComponent component, ref MoveEvent var footPrintComponent = EnsureComp(entity); var forensics = EntityManager.EnsureComponent(entity); - forensics.DNAs.UnionWith(component.DNAs); + if (TryComp(uid, out var ownerForensics)) // Floof edit: transfer owner DNA into the footsteps + forensics.DNAs.UnionWith(ownerForensics.DNAs); footPrintComponent.PrintOwner = uid; Dirty(entity, footPrintComponent); diff --git a/Content.Shared/Footprint/FootPrintsComponent.cs b/Content.Shared/Footprint/FootPrintsComponent.cs index 5de5d79abd5..ccdacff68cb 100644 --- a/Content.Shared/Footprint/FootPrintsComponent.cs +++ b/Content.Shared/Footprint/FootPrintsComponent.cs @@ -86,6 +86,7 @@ public sealed partial class FootPrintsComponent : Component /// public float ColorInterpolationFactor = 0.2f; + // Floof [DataField] public HashSet DNAs = new(); } From 94c759ab81de477c0cdcf7f5c9ee3f4203007bcb Mon Sep 17 00:00:00 2001 From: Mnemotechnican <69920617+Mnemotechnician@users.noreply.github.com> Date: Thu, 19 Dec 2024 23:25:47 +0300 Subject: [PATCH 2/2] Increase the footprint visibility threshold by 50% --- Content.Server/FootPrint/FootPrintsSystem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Server/FootPrint/FootPrintsSystem.cs b/Content.Server/FootPrint/FootPrintsSystem.cs index a4828b43782..e69e9bcf226 100644 --- a/Content.Server/FootPrint/FootPrintsSystem.cs +++ b/Content.Server/FootPrint/FootPrintsSystem.cs @@ -52,10 +52,10 @@ private void OnStartupComponent(EntityUid uid, FootPrintsComponent component, Co private void OnMove(EntityUid uid, FootPrintsComponent component, ref MoveEvent args) { // Floof: clear stored DNAs if footprints are now invisible - if (component.PrintsColor.A <= .2f) + if (component.PrintsColor.A <= .3f) component.DNAs.Clear(); - if (component.PrintsColor.A <= .2f // avoid creating footsteps that are invisible + if (component.PrintsColor.A <= .3f // avoid creating footsteps that are invisible || TryComp(uid, out var physics) && physics.BodyStatus != BodyStatus.OnGround // Floof: do not create footprints if the entity is flying || !_transformQuery.TryComp(uid, out var transform) || !_mobThresholdQuery.TryComp(uid, out var mobThreshHolds)