Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Footprints Fixes #421

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions Content.Server/Chemistry/TileReactions/CleanTileReaction.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reaction;
Expand All @@ -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;

Expand Down Expand Up @@ -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);

Expand All @@ -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<SolutionComponent>? solution)
{
solution = default;
if (entMan.TryGetComponent<PuddleComponent>(entity, out var puddle) &&
solutionContainerSystem.TryGetSolution(entity, puddle.SolutionName, out var puddleSolution, out _))
{
solution = puddleSolution;
return true;
}

if (entMan.TryGetComponent<FootPrintComponent>(entity, out var footPrint) &&
solutionContainerSystem.TryGetSolution(entity, footPrint.SolutionName, out var footPrintSolution, out _))
{
solution = footPrintSolution;
return true;
}

return false;
}
}
16 changes: 11 additions & 5 deletions Content.Server/FootPrint/FootPrintsSystem.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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<TransformComponent> _transformQuery;
private EntityQuery<MobThresholdsComponent> _mobThresholdQuery;
Expand All @@ -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 <= .3f)
component.DNAs.Clear();

if (component.PrintsColor.A <= .2f
if (component.PrintsColor.A <= .3f // avoid creating footsteps that are invisible
|| TryComp<PhysicsComponent>(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 _))
Expand All @@ -66,17 +70,19 @@ 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<PuddleFootPrintsComponent>(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;

var entity = Spawn(component.StepProtoId, CalcCoords(gridUid, component, transform, dragging));
var footPrintComponent = EnsureComp<FootPrintComponent>(entity);

var forensics = EntityManager.EnsureComponent<ForensicsComponent>(entity);
forensics.DNAs.UnionWith(component.DNAs);
if (TryComp<ForensicsComponent>(uid, out var ownerForensics)) // Floof edit: transfer owner DNA into the footsteps
forensics.DNAs.UnionWith(ownerForensics.DNAs);

footPrintComponent.PrintOwner = uid;
Dirty(entity, footPrintComponent);
Expand Down
1 change: 1 addition & 0 deletions Content.Shared/Footprint/FootPrintsComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public sealed partial class FootPrintsComponent : Component
/// </summary>
public float ColorInterpolationFactor = 0.2f;

// Floof
[DataField]
public HashSet<string> DNAs = new();
}
Loading