Skip to content

Commit

Permalink
Fix entities getting shuffled in the map renderer (#20100)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrSmugleaf authored Sep 13, 2023
1 parent 89b670d commit 5c15f52
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions Content.MapRenderer/Painters/GridPainter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Maths;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using SixLabors.ImageSharp;
Expand All @@ -23,7 +22,6 @@ public sealed class GridPainter
private readonly DecalPainter _decalPainter;

private readonly IEntityManager _cEntityManager;
private readonly IMapManager _cMapManager;

private readonly IEntityManager _sEntityManager;
private readonly IMapManager _sMapManager;
Expand All @@ -37,7 +35,6 @@ public GridPainter(ClientIntegrationInstance client, ServerIntegrationInstance s
_decalPainter = new DecalPainter(client, server);

_cEntityManager = client.ResolveDependency<IEntityManager>();
_cMapManager = client.ResolveDependency<IMapManager>();

_sEntityManager = server.ResolveDependency<IEntityManager>();
_sMapManager = server.ResolveDependency<IMapManager>();
Expand Down Expand Up @@ -73,26 +70,27 @@ private ConcurrentDictionary<EntityUid, List<EntityData>> GetEntities()

var components = new ConcurrentDictionary<EntityUid, List<EntityData>>();

foreach (var entity in _sEntityManager.GetEntities())
foreach (var serverEntity in _sEntityManager.GetEntities())
{
if (!_cEntityManager.TryGetComponent(entity, out SpriteComponent? sprite))
var clientEntity = _cEntityManager.GetEntity(_sEntityManager.GetNetEntity(serverEntity));
if (!_cEntityManager.TryGetComponent(clientEntity, out SpriteComponent? sprite))
{
continue;
}

var prototype = _sEntityManager.GetComponent<MetaDataComponent>(entity).EntityPrototype;
var prototype = _sEntityManager.GetComponent<MetaDataComponent>(serverEntity).EntityPrototype;
if (prototype == null)
{
continue;
}

var transform = _sEntityManager.GetComponent<TransformComponent>(entity);
var transform = _sEntityManager.GetComponent<TransformComponent>(serverEntity);
if (_sMapManager.TryGetGrid(transform.GridUid, out var grid))
{
var position = transform.LocalPosition;

var (x, y) = TransformLocalPosition(position, grid);
var data = new EntityData(entity, sprite, x, y);
var data = new EntityData(serverEntity, sprite, x, y);

components.GetOrAdd(transform.GridUid.Value, _ => new List<EntityData>()).Add(data);
}
Expand Down

0 comments on commit 5c15f52

Please sign in to comment.