Skip to content

Commit

Permalink
FUCKING ENTITYTEST
Browse files Browse the repository at this point in the history
  • Loading branch information
MilonPL committed Nov 23, 2024
1 parent a273f31 commit c59e49d
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions Content.Server/_EE/FootPrint/FootPrintsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
// using Content.Shared.Standing;
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.GameTicking; // DeltaV
using Content.Shared.GameTicking;
using Microsoft.EntityFrameworkCore.Migrations.Operations; // DeltaV
using Robust.Shared.Map;
using Robust.Shared.Map.Components; // DeltaV
using Robust.Shared.Random;
Expand Down Expand Up @@ -163,17 +164,35 @@ private void OnFootPrintInit(Entity<FootPrintComponent> ent, ref ComponentInit a
/// </summary>
private void OnFootPrintRemove(Entity<FootPrintComponent> ent, ref ComponentRemove args)
{
if (!TryGetTilePos(ent.Owner, out var tilePos))
return;
// Try to get tile pos if entity is still valid
Vector2i? tilePos = null;
if (!Deleted(ent) && !EntityManager.IsQueuedForDeletion(ent) && Transform(ent).ParentUid.IsValid())
{
TryGetTilePos(ent.Owner, out var pos);
tilePos = pos;
}

// If we couldn't get tile pos, search all tiles to find and remove this footprint
if (tilePos == null)
{
foreach (var (pos, prints) in _footprintsPerTile)
{
if (!prints.Contains(ent.Owner))
continue;

tilePos = pos;
break;
}
}

if (_footprintsPerTile.TryGetValue(tilePos, out var footprints))
// Clean up the footprint tracking if we found it
if (tilePos.HasValue && _footprintsPerTile.TryGetValue(tilePos.Value, out var footprints))
{
// Create a new queue without the removed footprint
var newQueue = new Queue<EntityUid>(footprints.Where(x => x != ent.Owner));
if (newQueue.Count > 0)
_footprintsPerTile[tilePos] = newQueue;
_footprintsPerTile[tilePos.Value] = newQueue;
else
_footprintsPerTile.Remove(tilePos);
_footprintsPerTile.Remove(tilePos.Value);
}
}

Expand Down

0 comments on commit c59e49d

Please sign in to comment.