Remove Explicit GridId References (#8315)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -25,8 +25,8 @@ namespace Content.MapRenderer.Painters
|
||||
private readonly IEntityManager _sEntityManager;
|
||||
private readonly IMapManager _sMapManager;
|
||||
|
||||
private readonly ConcurrentDictionary<GridId, List<EntityData>> _entities;
|
||||
private readonly Dictionary<GridId, List<DecalData>> _decals;
|
||||
private readonly ConcurrentDictionary<EntityUid, List<EntityData>> _entities;
|
||||
private readonly Dictionary<EntityUid, List<DecalData>> _decals;
|
||||
|
||||
public GridPainter(ClientIntegrationInstance client, ServerIntegrationInstance server)
|
||||
{
|
||||
@@ -48,27 +48,27 @@ namespace Content.MapRenderer.Painters
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
|
||||
if (!_entities.TryGetValue(grid.Index, out var entities))
|
||||
if (!_entities.TryGetValue(grid.GridEntityId, out var entities))
|
||||
{
|
||||
Console.WriteLine($"No entities found on grid {grid.Index}");
|
||||
Console.WriteLine($"No entities found on grid {grid.GridEntityId}");
|
||||
return;
|
||||
}
|
||||
|
||||
// Decals are always painted before entities, and are also optional.
|
||||
if (_decals.TryGetValue(grid.Index, out var decals))
|
||||
if (_decals.TryGetValue(grid.GridEntityId, out var decals))
|
||||
_decalPainter.Run(gridCanvas, decals);
|
||||
|
||||
|
||||
_entityPainter.Run(gridCanvas, entities);
|
||||
Console.WriteLine($"{nameof(GridPainter)} painted grid {grid.Index} in {(int) stopwatch.Elapsed.TotalMilliseconds} ms");
|
||||
Console.WriteLine($"{nameof(GridPainter)} painted grid {grid.GridEntityId} in {(int) stopwatch.Elapsed.TotalMilliseconds} ms");
|
||||
}
|
||||
|
||||
private ConcurrentDictionary<GridId, List<EntityData>> GetEntities()
|
||||
private ConcurrentDictionary<EntityUid, List<EntityData>> GetEntities()
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
|
||||
var components = new ConcurrentDictionary<GridId, List<EntityData>>();
|
||||
var components = new ConcurrentDictionary<EntityUid, List<EntityData>>();
|
||||
|
||||
foreach (var entity in _sEntityManager.GetEntities())
|
||||
{
|
||||
@@ -90,14 +90,14 @@ namespace Content.MapRenderer.Painters
|
||||
}
|
||||
|
||||
var transform = _sEntityManager.GetComponent<TransformComponent>(entity);
|
||||
if (_cMapManager.TryGetGrid(transform.GridID, out var grid))
|
||||
if (_cMapManager.TryGetGrid(transform.GridEntityId, out var grid))
|
||||
{
|
||||
var position = transform.LocalPosition;
|
||||
|
||||
var (x, y) = TransformLocalPosition(position, grid);
|
||||
var data = new EntityData(sprite, x, y);
|
||||
|
||||
components.GetOrAdd(transform.GridID, _ => new List<EntityData>()).Add(data);
|
||||
components.GetOrAdd(transform.GridEntityId, _ => new List<EntityData>()).Add(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,12 +106,12 @@ namespace Content.MapRenderer.Painters
|
||||
return components;
|
||||
}
|
||||
|
||||
private Dictionary<GridId, List<DecalData>> GetDecals()
|
||||
private Dictionary<EntityUid, List<DecalData>> GetDecals()
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
|
||||
var decals = new Dictionary<GridId, List<DecalData>>();
|
||||
var decals = new Dictionary<EntityUid, List<DecalData>>();
|
||||
|
||||
foreach (var grid in _sMapManager.GetAllGrids())
|
||||
{
|
||||
@@ -126,7 +126,7 @@ namespace Content.MapRenderer.Painters
|
||||
foreach (var (_, decal) in list)
|
||||
{
|
||||
var (x, y) = TransformLocalPosition(decal.Coordinates, grid);
|
||||
decals.GetOrNew(grid.Index).Add(new DecalData(decal, x, y));
|
||||
decals.GetOrNew(grid.GridEntityId).Add(new DecalData(decal, x, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user