Skip to content

Commit

Permalink
Merge remote-tracking branch 'next-origin/master' into Upstream5
Browse files Browse the repository at this point in the history
  • Loading branch information
FireNameFN committed Jan 14, 2025
2 parents 07ecbef + 38e710f commit 9315850
Show file tree
Hide file tree
Showing 58 changed files with 428 additions and 610 deletions.
47 changes: 47 additions & 0 deletions Content.Client/_CorvaxNext/Footprints/FootprintSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Content.Shared._CorvaxNext.Footprints;
using Robust.Client.GameObjects;
using Robust.Shared.Utility;

namespace Content.Client._CorvaxNext.Footprints;

public sealed class FootprintSystem : EntitySystem
{
public override void Initialize()
{
SubscribeLocalEvent<FootprintComponent, ComponentStartup>(OnComponentStartup);
SubscribeNetworkEvent<FootprintChangedEvent>(OnFootprintChanged);
}

private void OnComponentStartup(Entity<FootprintComponent> entity, ref ComponentStartup e)
{
UpdateSprite(entity, entity);
}

private void OnFootprintChanged(FootprintChangedEvent e)
{
if (!TryGetEntity(e.Entity, out var entity))
return;

if (!TryComp<FootprintComponent>(entity, out var footprint))
return;

UpdateSprite(entity.Value, footprint);
}

private void UpdateSprite(EntityUid entity, FootprintComponent footprint)
{
if (!TryComp<SpriteComponent>(entity, out var sprite))
return;

for (var i = 0; i < footprint.Footprints.Count; i++)
{
if (!sprite.LayerExists(i, false))
sprite.AddBlankLayer(i);

sprite.LayerSetOffset(i, footprint.Footprints[i].Offset);
sprite.LayerSetRotation(i, footprint.Footprints[i].Rotation);
sprite.LayerSetColor(i, footprint.Footprints[i].Color);
sprite.LayerSetSprite(i, new SpriteSpecifier.Rsi(new("/Textures/_CorvaxNext/Effects/footprint.rsi"), footprint.Footprints[i].State));
}
}
}

This file was deleted.

7 changes: 7 additions & 0 deletions Content.Server/Chemistry/TileReactions/CleanTileReaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Robust.Shared.Map;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using System.Linq;
using Content.Shared._CorvaxNext.Footprints;
using Content.Server._CorvaxNext.Footprints;

namespace Content.Server.Chemistry.TileReactions;

Expand Down Expand Up @@ -57,6 +59,11 @@ IEntityManager entityManager

solutionContainerSystem.TryAddSolution(puddleSolution.Value, new Solution(ReplacementReagent, purgeable.Volume));

// Corvax-Next-Footprints-Start
if (entityManager.HasComponent<FootprintComponent>(entity))
entityManager.EventBus.RaiseLocalEvent(entity, new FootprintCleanEvent());
// Corvax-Next-Footprints-End

if (purgeable.Volume <= FixedPoint2.Zero)
break;
}
Expand Down
89 changes: 8 additions & 81 deletions Content.Server/Fluids/EntitySystems/AbsorbentSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Numerics;
using Content.Server._CorvaxNext.Footprints;
using Content.Server.Popups;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
Expand All @@ -13,7 +14,6 @@
using Robust.Shared.Map.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using Content.Shared._CorvaxNext.Footprints.Components;

namespace Content.Server.Fluids.EntitySystems;

Expand All @@ -29,9 +29,6 @@ public sealed class AbsorbentSystem : SharedAbsorbentSystem
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
[Dependency] private readonly UseDelaySystem _useDelay = default!;
[Dependency] private readonly MapSystem _mapSystem = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;

public const float FootprintAbsorptionRange = 0.25f; // Corvax-Next-Footprints

public override void Initialize()
{
Expand Down Expand Up @@ -115,18 +112,13 @@ public void Mop(EntityUid user, EntityUid target, EntityUid used, AbsorbentCompo
&& _useDelay.IsDelayed((used, useDelay)))
return;

// Corvax-Next-Footprints-Start
// Footsteps cleaning logic, try to grab from
if (TryFootprintInteract(user, used, target, component, useDelay, absorberSoln.Value))
return;

// If it's a puddle try to grab from
if (TryPuddleInteract(user, used, target, component, useDelay, absorberSoln.Value))
return;

// If it's refillable try to transfer
TryRefillableInteract(user, used, target, component, useDelay, absorberSoln.Value);
// Corvax-Next-Footprints-End
if (!TryPuddleInteract(user, used, target, component, useDelay, absorberSoln.Value))
{
// If it's refillable try to transfer
if (!TryRefillableInteract(user, used, target, component, useDelay, absorberSoln.Value))
return;
}
}

/// <summary>
Expand Down Expand Up @@ -331,73 +323,8 @@ private bool TryPuddleInteract(EntityUid user, EntityUid used, EntityUid target,

_melee.DoLunge(user, used, Angle.Zero, localPos, null, false);

return true;
}

// Corvax-Next-Footprints-Start
private bool TryFootprintInteract(EntityUid user, EntityUid used, EntityUid target, AbsorbentComponent absorber, UseDelayComponent? useDelay, Entity<SolutionComponent> absorberSoln)
{
if (!HasComp<FootprintComponent>(target)) // Perform a check if it was a footprint that was clicked on
return false;

var soundPlayed = false;

var footPrints = new HashSet<Entity<FootprintComponent>>();
_lookup.GetEntitiesInRange(Transform(target).Coordinates, FootprintAbsorptionRange, footPrints, LookupFlags.Dynamic | LookupFlags.Uncontained);

foreach (var (footstepUid, comp) in footPrints)
{
if (!_solutionContainerSystem.ResolveSolution(footstepUid, comp.SolutionName, ref comp.Solution, out var targetStepSolution) || targetStepSolution.Volume <= 0)
continue;

if (_puddleSystem.CanFullyEvaporate(targetStepSolution))
continue; // no spam

var absorberSolution = absorberSoln.Comp.Solution;
var available = absorberSolution.GetTotalPrototypeQuantity(SharedPuddleSystem.EvaporationReagents);

// No material
if (available == FixedPoint2.Zero)
{
_popups.PopupEntity(Loc.GetString("mopping-system-no-water", ("used", used)), user, user);
return true;
}

var transferMax = absorber.PickupAmount;
var transferAmount = FixedPoint2.Min(transferMax, available);

var puddleSplit = targetStepSolution.SplitSolutionWithout(transferAmount, SharedPuddleSystem.EvaporationReagents);
var absorberSplit = absorberSolution.SplitSolutionWithOnly(puddleSplit.Volume, SharedPuddleSystem.EvaporationReagents);

var transform = Transform(target);
var gridUid = transform.GridUid;
if (TryComp<MapGridComponent>(gridUid, out var mapGrid))
{
var tileRef = _mapSystem.GetTileRef(gridUid.Value, mapGrid, transform.Coordinates);
_puddleSystem.DoTileReactions(tileRef, absorberSplit);
}

_solutionContainerSystem.AddSolution(comp.Solution.Value, absorberSplit);
_solutionContainerSystem.AddSolution(absorberSoln, puddleSplit);

if (!soundPlayed)
{
soundPlayed = true; // to prevent sound spam
_audio.PlayPvs(absorber.PickupSound, target);
}

if (useDelay is not null)
_useDelay.TryResetDelay((used, useDelay));
}

var userXform = Transform(user);
var targetPos = _transform.GetWorldPosition(target);
var localPos = Vector2.Transform(targetPos, _transform.GetInvWorldMatrix(userXform));
localPos = userXform.LocalRotation.RotateVec(localPos);

_melee.DoLunge(user, used, Angle.Zero, localPos, null, false);
RaiseLocalEvent(target, new FootprintCleanEvent()); // Corvax-Next-Footprints

return true;
}
// Corvax-Next-Footprints-End
}
15 changes: 14 additions & 1 deletion Content.Server/Fluids/EntitySystems/PuddleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Server.DoAfter;
using Content.Server.Fluids.Components;
using Content.Server.Spreader;
using Content.Shared._CorvaxNext.Footprints;
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Components.SolutionManager;
Expand Down Expand Up @@ -424,7 +425,7 @@ private void UpdateSlip(EntityUid entityUid, PuddleComponent component, Solution
private void UpdateSlow(EntityUid uid, Solution solution, PuddleComponent component) // Corvax-Next-Footprints
{
// Corvax-Next-Footprints-Start
if (!component.ViscosityAffectsMovement)
if (!component.AffectsMovement)
return;
// Corvax-Next-Footprints-End

Expand Down Expand Up @@ -674,6 +675,7 @@ public override bool TrySpillAt(TileRef tileRef, Solution solution, out EntityUi
var anchored = _map.GetAnchoredEntitiesEnumerator(gridId, mapGrid, tileRef.GridIndices);
var puddleQuery = GetEntityQuery<PuddleComponent>();
var sparklesQuery = GetEntityQuery<EvaporationSparkleComponent>();
var footprintQuery = GetEntityQuery<FootprintComponent>(); // Corvax-Next-Footprints

while (anchored.MoveNext(out var ent))
{
Expand All @@ -687,6 +689,11 @@ public override bool TrySpillAt(TileRef tileRef, Solution solution, out EntityUi
if (!puddleQuery.TryGetComponent(ent, out var puddle))
continue;

// Corvax-Next-Footprints-Start
if (footprintQuery.HasComp(ent))
continue;
// Corvax-Next-Footprints-End

if (TryAddSolution(ent.Value, solution, sound, puddleComponent: puddle))
{
EnsureComp<ActiveEdgeSpreaderComponent>(ent.Value);
Expand Down Expand Up @@ -735,12 +742,18 @@ public bool TryGetPuddle(TileRef tile, out EntityUid puddleUid)

var anc = _map.GetAnchoredEntitiesEnumerator(tile.GridUid, grid, tile.GridIndices);
var puddleQuery = GetEntityQuery<PuddleComponent>();
var footprintQuery = GetEntityQuery<FootprintComponent>(); // Corvax-Next-Footprints

while (anc.MoveNext(out var ent))
{
if (!puddleQuery.HasComponent(ent.Value))
continue;

// Corvax-Next-Footprints-Start
if (footprintQuery.HasComponent(ent.Value))
continue;
// Corvax-Next-Footprints-End

puddleUid = ent.Value;
return true;
}
Expand Down
Loading

0 comments on commit 9315850

Please sign in to comment.