Remove implicit GridId conversions (#8975)

This commit is contained in:
Leon Friedrich
2022-06-29 00:56:02 +12:00
committed by GitHub
parent 7a14c6f331
commit c13c0b8b0b
13 changed files with 33 additions and 35 deletions

View File

@@ -48,9 +48,9 @@ namespace Content.Client.Atmos.EntitySystems
private void OnGridRemoved(GridRemovalEvent ev) private void OnGridRemoved(GridRemovalEvent ev)
{ {
if (_tileData.ContainsKey(ev.GridId)) if (_tileData.ContainsKey(ev.EntityUid))
{ {
_tileData.Remove(ev.GridId); _tileData.Remove(ev.EntityUid);
} }
} }

View File

@@ -123,10 +123,7 @@ namespace Content.Client.Atmos.EntitySystems
private void OnGridRemoved(GridRemovalEvent ev) private void OnGridRemoved(GridRemovalEvent ev)
{ {
if (_tileData.ContainsKey(ev.GridId)) _tileData.Remove(ev.EntityUid);
{
_tileData.Remove(ev.GridId);
}
} }
public bool HasData(EntityUid gridId) public bool HasData(EntityUid gridId)

View File

@@ -40,14 +40,14 @@ namespace Content.Client.Decals
private void OnGridRemoval(GridRemovalEvent ev) private void OnGridRemoval(GridRemovalEvent ev)
{ {
DecalRenderIndex.Remove(ev.GridId); DecalRenderIndex.Remove(ev.EntityUid);
DecalZIndexIndex.Remove(ev.GridId); DecalZIndexIndex.Remove(ev.EntityUid);
} }
private void OnGridInitialize(GridInitializeEvent ev) private void OnGridInitialize(GridInitializeEvent ev)
{ {
DecalRenderIndex[ev.GridId] = new(); DecalRenderIndex[ev.EntityUid] = new();
DecalZIndexIndex[ev.GridId] = new(); DecalZIndexIndex[ev.EntityUid] = new();
} }
public override void Shutdown() public override void Shutdown()

View File

@@ -187,7 +187,7 @@ public sealed class RadarControl : Control
foreach (var grid in _mapManager.FindGridsIntersecting(mapPosition.MapId, foreach (var grid in _mapManager.FindGridsIntersecting(mapPosition.MapId,
new Box2(mapPosition.Position - RadarRange, mapPosition.Position + RadarRange))) new Box2(mapPosition.Position - RadarRange, mapPosition.Position + RadarRange)))
{ {
if (grid.Index == ourGridId) continue; if (grid.GridEntityId == ourGridId) continue;
var gridBody = bodyQuery.GetComponent(grid.GridEntityId); var gridBody = bodyQuery.GetComponent(grid.GridEntityId);
if (gridBody.Mass < 10f) if (gridBody.Mass < 10f)

View File

@@ -27,7 +27,7 @@ namespace Content.IntegrationTests.Tests
{ {
// TODO: Properly find the "main" station grid. // TODO: Properly find the "main" station grid.
var grid0 = mapManager.GetAllGrids().First(); var grid0 = mapManager.GetAllGrids().First();
mapLoader.SaveBlueprint(grid0.Index, "save load save 1.yml"); mapLoader.SaveBlueprint(grid0.GridEntityId, "save load save 1.yml");
var mapId = mapManager.CreateMap(); var mapId = mapManager.CreateMap();
var grid = mapLoader.LoadBlueprint(mapId, "save load save 1.yml").gridId; var grid = mapLoader.LoadBlueprint(mapId, "save load save 1.yml").gridId;
mapLoader.SaveBlueprint(grid!.Value, "save load save 2.yml"); mapLoader.SaveBlueprint(grid!.Value, "save load save 2.yml");

View File

@@ -97,7 +97,7 @@ namespace Content.Server.AI.Pathfinding.Accessible
private void GridRemoved(GridRemovalEvent ev) private void GridRemoved(GridRemovalEvent ev)
{ {
_regions.Remove(ev.GridId); _regions.Remove(ev.EntityUid);
} }
public override void Update(float frameTime) public override void Update(float frameTime)

View File

@@ -47,7 +47,7 @@ namespace Content.Server.AI.Pathfinding.Pathfinders
return null; return null;
} }
if (_entityManager.Deleted(_pathfindingArgs.Start.GridIndex)) if (_entityManager.Deleted(_pathfindingArgs.Start.GridUid))
return null; return null;
var frontier = new PriorityQueue<ValueTuple<float, PathfindingNode>>(new PathfindingComparer()); var frontier = new PriorityQueue<ValueTuple<float, PathfindingNode>>(new PathfindingComparer());

View File

@@ -71,7 +71,7 @@ namespace Content.Server.Atmos.EntitySystems
private void OnAirtightReAnchor(EntityUid uid, AirtightComponent airtight, ref ReAnchorEvent args) private void OnAirtightReAnchor(EntityUid uid, AirtightComponent airtight, ref ReAnchorEvent args)
{ {
foreach (var gridId in new[] { args.OldGrid, args.GridId }) foreach (var gridId in new[] { args.OldGrid, args.Grid })
{ {
// Update and invalidate new position. // Update and invalidate new position.
airtight.LastPosition = (gridId, args.TilePos); airtight.LastPosition = (gridId, args.TilePos);

View File

@@ -109,10 +109,7 @@ namespace Content.Server.Atmos.EntitySystems
private void OnGridRemoved(GridRemovalEvent ev) private void OnGridRemoved(GridRemovalEvent ev)
{ {
if (_overlay.ContainsKey(ev.GridId)) _overlay.Remove(ev.EntityUid);
{
_overlay.Remove(ev.GridId);
}
} }
private void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e) private void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e)

View File

@@ -21,7 +21,7 @@ public sealed partial class ExplosionSystem : EntitySystem
var grid = _mapManager.GetGrid(ev.GridId); var grid = _mapManager.GetGrid(ev.GridId);
Dictionary<Vector2i, NeighborFlag> edges = new(); Dictionary<Vector2i, NeighborFlag> edges = new();
_gridEdges[ev.GridId] = edges; _gridEdges[ev.EntityUid] = edges;
foreach (var tileRef in grid.GetAllTiles()) foreach (var tileRef in grid.GetAllTiles())
{ {
@@ -32,8 +32,8 @@ public sealed partial class ExplosionSystem : EntitySystem
private void OnGridRemoved(GridRemovalEvent ev) private void OnGridRemoved(GridRemovalEvent ev)
{ {
_airtightMap.Remove(ev.GridId); _airtightMap.Remove(ev.EntityUid);
_gridEdges.Remove(ev.GridId); _gridEdges.Remove(ev.EntityUid);
} }
/// <summary> /// <summary>

View File

@@ -1,4 +1,4 @@
using System.Linq; using System.Linq;
using Content.Server.CharacterAppearance.Components; using Content.Server.CharacterAppearance.Components;
using Content.Server.Chat.Managers; using Content.Server.Chat.Managers;
using Content.Server.GameTicking.Rules.Configurations; using Content.Server.GameTicking.Rules.Configurations;
@@ -209,12 +209,12 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
minRadius = MathF.Max(aabb.Value.Width, aabb.Value.Height); minRadius = MathF.Max(aabb.Value.Width, aabb.Value.Height);
} }
var (_, gridId) = _mapLoader.LoadBlueprint(GameTicker.DefaultMap, map, new MapLoadOptions var (_, gridUid) = _mapLoader.LoadBlueprint(GameTicker.DefaultMap, map, new MapLoadOptions
{ {
Offset = center + MathF.Max(minRadius, minRadius) + 1000f, Offset = center + MathF.Max(minRadius, minRadius) + 1000f,
}); });
if (!gridId.HasValue) if (!gridUid.HasValue)
{ {
Logger.ErrorS("NUKEOPS", $"Gridid was null when loading \"{map}\", aborting."); Logger.ErrorS("NUKEOPS", $"Gridid was null when loading \"{map}\", aborting.");
foreach (var session in operatives) foreach (var session in operatives)
@@ -224,7 +224,6 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
return; return;
} }
var gridUid = _mapManager.GetGridEuid(gridId.Value);
// TODO: Loot table or something // TODO: Loot table or something
var commanderGear = _prototypeManager.Index<StartingGearPrototype>("SyndicateCommanderGearFull"); var commanderGear = _prototypeManager.Index<StartingGearPrototype>("SyndicateCommanderGearFull");
var starterGear = _prototypeManager.Index<StartingGearPrototype>("SyndicateOperativeGearFull"); var starterGear = _prototypeManager.Index<StartingGearPrototype>("SyndicateOperativeGearFull");
@@ -244,7 +243,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem
if (spawns.Count == 0) if (spawns.Count == 0)
{ {
spawns.Add(EntityManager.GetComponent<TransformComponent>(gridUid).Coordinates); spawns.Add(EntityManager.GetComponent<TransformComponent>(gridUid.Value).Coordinates);
Logger.WarningS("nukies", $"Fell back to default spawn for nukies!"); Logger.WarningS("nukies", $"Fell back to default spawn for nukies!");
} }

View File

@@ -1,4 +1,4 @@
using System.Linq; using System.Linq;
using Content.Server.Cargo.Systems; using Content.Server.Cargo.Systems;
using Content.Server.Chat.Managers; using Content.Server.Chat.Managers;
using Content.Server.GameTicking.Rules.Configurations; using Content.Server.GameTicking.Rules.Configurations;
@@ -171,7 +171,7 @@ public sealed class PiratesRuleSystem : GameRuleSystem
return; return;
} }
_pirateShip = _mapManager.GetGridEuid(gridId.Value); _pirateShip = gridId.Value;
// TODO: Loot table or something // TODO: Loot table or something
var pirateGear = _prototypeManager.Index<StartingGearPrototype>("PirateGear"); // YARRR var pirateGear = _prototypeManager.Index<StartingGearPrototype>("PirateGear"); // YARRR

View File

@@ -190,8 +190,14 @@ namespace Content.Server.Salvage
return; return;
} }
if (salvageTransform.GridUid == null)
{
Logger.ErrorS("salvage", "Salvage entity has no associated grid?");
return;
}
var parentTransform = salvageTransform.Parent!; var parentTransform = salvageTransform.Parent!;
foreach (var player in Filter.Empty().AddInGrid(salvageTransform.GridID, EntityManager).Recipients) foreach (var player in Filter.Empty().AddInGrid(salvageTransform.GridUid.Value, EntityManager).Recipients)
{ {
if (player.AttachedEntity.HasValue) if (player.AttachedEntity.HasValue)
{ {
@@ -277,18 +283,17 @@ namespace Content.Server.Salvage
Offset = spl.Position Offset = spl.Position
}; };
var (_, gridId) = _mapLoader.LoadBlueprint(spl.MapId, map.MapPath.ToString(), opts); var (_, salvageEntityId) = _mapLoader.LoadBlueprint(spl.MapId, map.MapPath.ToString(), opts);
if (gridId == null) if (salvageEntityId == null)
{ {
Report(component.Owner, "salvage-system-announcement-spawn-debris-disintegrated"); Report(component.Owner, "salvage-system-announcement-spawn-debris-disintegrated");
return false; return false;
} }
var salvageEntityId = _mapManager.GetGridEuid(gridId.Value);
component.AttachedEntity = salvageEntityId; component.AttachedEntity = salvageEntityId;
var gridcomp = EntityManager.EnsureComponent<SalvageGridComponent>(salvageEntityId); var gridcomp = EntityManager.EnsureComponent<SalvageGridComponent>(salvageEntityId.Value);
gridcomp.SpawnerMagnet = component; gridcomp.SpawnerMagnet = component;
var pulledTransform = EntityManager.GetComponent<TransformComponent>(salvageEntityId); var pulledTransform = EntityManager.GetComponent<TransformComponent>(salvageEntityId.Value);
pulledTransform.WorldRotation = spAngle; pulledTransform.WorldRotation = spAngle;
Report(component.Owner, "salvage-system-announcement-arrived", ("timeLeft", HoldTime.TotalSeconds)); Report(component.Owner, "salvage-system-announcement-arrived", ("timeLeft", HoldTime.TotalSeconds));