Remove Explicit GridId References (#8315)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Acruid
2022-06-11 18:54:41 -07:00
committed by GitHub
parent 846321cebb
commit 4f9be42f40
131 changed files with 531 additions and 588 deletions

View File

@@ -1,4 +1,4 @@
using Content.Server.Audio;
using Content.Server.Audio;
using Content.Server.Power.Components;
using Content.Shared.Gravity;
using Content.Shared.Interaction;
@@ -187,8 +187,8 @@ namespace Content.Server.Gravity.EntitySystems
private void UpdateGravityActive(GravityGeneratorComponent grav, bool shake)
{
var gridId = EntityManager.GetComponent<TransformComponent>(grav.Owner).GridID;
if (gridId == GridId.Invalid)
var gridId = EntityManager.GetComponent<TransformComponent>(grav.Owner).GridEntityId;
if (gridId == EntityUid.Invalid)
return;
var grid = _mapManager.GetGrid(gridId);

View File

@@ -18,7 +18,7 @@ namespace Content.Server.Gravity.EntitySystems
[Dependency] private readonly CameraRecoilSystem _cameraRecoil = default!;
private Dictionary<GridId, uint> _gridsToShake = new();
private Dictionary<EntityUid, uint> _gridsToShake = new();
private const float GravityKick = 100.0f;
private const uint ShakeTimes = 10;
@@ -44,7 +44,7 @@ namespace Content.Server.Gravity.EntitySystems
}
}
public void ShakeGrid(GridId gridId, GravityComponent comp)
public void ShakeGrid(EntityUid gridId, GravityComponent comp)
{
_gridsToShake[gridId] = ShakeTimes;
@@ -58,7 +58,7 @@ namespace Content.Server.Gravity.EntitySystems
{
// I have to copy this because C# doesn't allow changing collections while they're
// getting enumerated.
var gridsToShake = new Dictionary<GridId, uint>(_gridsToShake);
var gridsToShake = new Dictionary<EntityUid, uint>(_gridsToShake);
foreach (var gridId in _gridsToShake.Keys)
{
if (_gridsToShake[gridId] == 0)
@@ -73,12 +73,12 @@ namespace Content.Server.Gravity.EntitySystems
_gridsToShake = gridsToShake;
}
private void ShakeGrid(GridId gridId)
private void ShakeGrid(EntityUid gridId)
{
foreach (var player in _playerManager.Sessions)
{
if (player.AttachedEntity is not {Valid: true} attached
|| EntityManager.GetComponent<TransformComponent>(attached).GridID != gridId
|| EntityManager.GetComponent<TransformComponent>(attached).GridEntityId != gridId
|| !EntityManager.HasComponent<CameraRecoilComponent>(attached))
{
continue;

View File

@@ -16,12 +16,12 @@ namespace Content.Server.Gravity.EntitySystems
private void HandleGravityInitialize(EntityUid uid, GravityComponent component, ComponentInit args)
{
// Incase there's already a generator on the grid we'll just set it now.
var gridId = EntityManager.GetComponent<TransformComponent>(component.Owner).GridID;
var gridId = EntityManager.GetComponent<TransformComponent>(component.Owner).GridEntityId;
GravityChangedMessage message;
foreach (var generator in EntityManager.EntityQuery<GravityGeneratorComponent>())
{
if (EntityManager.GetComponent<TransformComponent>(generator.Owner).GridID == gridId && generator.GravityActive)
if (EntityManager.GetComponent<TransformComponent>(generator.Owner).GridEntityId == gridId && generator.GravityActive)
{
component.Enabled = true;
message = new GravityChangedMessage(gridId, true);
@@ -45,7 +45,7 @@ namespace Content.Server.Gravity.EntitySystems
if (comp.Enabled) return;
comp.Enabled = true;
var gridId = EntityManager.GetComponent<TransformComponent>(comp.Owner).GridID;
var gridId = EntityManager.GetComponent<TransformComponent>(comp.Owner).GridEntityId;
var message = new GravityChangedMessage(gridId, true);
RaiseLocalEvent(message);
}
@@ -55,7 +55,7 @@ namespace Content.Server.Gravity.EntitySystems
if (!comp.Enabled) return;
comp.Enabled = false;
var gridId = EntityManager.GetComponent<TransformComponent>(comp.Owner).GridID;
var gridId = EntityManager.GetComponent<TransformComponent>(comp.Owner).GridEntityId;
var message = new GravityChangedMessage(gridId, false);
RaiseLocalEvent(message);
}

View File

@@ -14,7 +14,7 @@ namespace Content.Server.Gravity.EntitySystems
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly AlertsSystem _alertsSystem = default!;
private readonly Dictionary<GridId, List<AlertsComponent>> _alerts = new();
private readonly Dictionary<EntityUid, List<AlertsComponent>> _alerts = new();
public override void Initialize()
{
@@ -34,11 +34,11 @@ namespace Content.Server.Gravity.EntitySystems
public void AddAlert(AlertsComponent status)
{
var xform = Transform(status.Owner);
var alerts = _alerts.GetOrNew(xform.GridID);
var alerts = _alerts.GetOrNew(xform.GridEntityId);
alerts.Add(status);
if (_mapManager.TryGetGrid(xform.GridID, out var grid))
if (_mapManager.TryGetGrid(xform.GridEntityId, out var grid))
{
if (EntityManager.GetComponent<GravityComponent>(grid.GridEntityId).Enabled)
{
@@ -53,7 +53,7 @@ namespace Content.Server.Gravity.EntitySystems
public void RemoveAlert(AlertsComponent status)
{
var grid = EntityManager.GetComponent<TransformComponent>(status.Owner).GridID;
var grid = EntityManager.GetComponent<TransformComponent>(status.Owner).GridEntityId;
if (!_alerts.TryGetValue(grid, out var statuses))
{
return;
@@ -101,7 +101,7 @@ namespace Content.Server.Gravity.EntitySystems
if (ev.OldParent is {Valid: true} old &&
EntityManager.TryGetComponent(old, out IMapGridComponent? mapGrid))
{
var oldGrid = mapGrid.GridIndex;
var oldGrid = mapGrid.Owner;
if (_alerts.TryGetValue(oldGrid, out var oldStatuses))
{
@@ -109,7 +109,7 @@ namespace Content.Server.Gravity.EntitySystems
}
}
var newGrid = ev.Transform.GridID;
var newGrid = ev.Transform.GridEntityId;
var newStatuses = _alerts.GetOrNew(newGrid);
newStatuses.Add(status);