Revert "Remove references to obsolete GridId" (#11790)
This commit is contained in:
@@ -40,7 +40,7 @@ namespace Content.Server.Salvage
|
||||
private static readonly int SalvageLocationPlaceAttempts = 16;
|
||||
|
||||
// TODO: This is probably not compatible with multi-station
|
||||
private readonly Dictionary<EntityUid, SalvageGridState> _salvageGridStates = new();
|
||||
private readonly Dictionary<GridId, SalvageGridState> _salvageGridStates = new();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -66,9 +66,10 @@ namespace Content.Server.Salvage
|
||||
private void OnGridRemoval(GridRemovalEvent ev)
|
||||
{
|
||||
// If we ever want to give magnets names, and announce them individually, we would need to loop this, before removing it.
|
||||
if (_salvageGridStates.Remove(ev.EntityUid))
|
||||
if (_salvageGridStates.Remove(ev.GridId))
|
||||
{
|
||||
if (EntityManager.TryGetComponent<SalvageGridComponent>(ev.EntityUid, out var salvComp) && salvComp.SpawnerMagnet != null)
|
||||
var gridUid = _mapManager.GetGridEuid(ev.GridId);
|
||||
if (EntityManager.TryGetComponent<SalvageGridComponent>(gridUid, out var salvComp) && salvComp.SpawnerMagnet != null)
|
||||
Report(salvComp.SpawnerMagnet.Owner, salvComp.SpawnerMagnet.SalvageChannel, "salvage-system-announcement-spawn-magnet-lost");
|
||||
// For the very unlikely possibility that the salvage magnet was on a salvage, we will not return here
|
||||
}
|
||||
@@ -91,7 +92,7 @@ namespace Content.Server.Salvage
|
||||
if (component.MagnetState.StateType == MagnetStateType.Inactive) return;
|
||||
|
||||
var magnetTranform = EntityManager.GetComponent<TransformComponent>(component.Owner);
|
||||
if (!(magnetTranform.GridUid is EntityUid gridId) || !_salvageGridStates.TryGetValue(gridId, out var salvageGridState))
|
||||
if (!_salvageGridStates.TryGetValue(magnetTranform.GridID, out var salvageGridState))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -129,8 +130,8 @@ namespace Content.Server.Salvage
|
||||
args.PushMarkup(Loc.GetString("salvage-system-magnet-examined-cooling-down"));
|
||||
break;
|
||||
case MagnetStateType.Holding:
|
||||
var magnetTransform = EntityManager.GetComponent<TransformComponent>(component.Owner);
|
||||
if (magnetTransform.GridUid is EntityUid gridId && _salvageGridStates.TryGetValue(gridId, out var salvageGridState))
|
||||
var magnetTranform = EntityManager.GetComponent<TransformComponent>(component.Owner);
|
||||
if (_salvageGridStates.TryGetValue(magnetTranform.GridID, out var salvageGridState))
|
||||
{
|
||||
var remainingTime = component.MagnetState.Until - salvageGridState.CurrentTime;
|
||||
args.PushMarkup(Loc.GetString("salvage-system-magnet-examined-active", ("timeLeft", Math.Ceiling(remainingTime.TotalSeconds))));
|
||||
@@ -159,13 +160,12 @@ namespace Content.Server.Salvage
|
||||
{
|
||||
case MagnetStateType.Inactive:
|
||||
ShowPopup("salvage-system-report-activate-success", component, user);
|
||||
var magnetTranform = EntityManager.GetComponent<TransformComponent>(component.Owner);
|
||||
SalvageGridState? gridState;
|
||||
var magnetTransform = EntityManager.GetComponent<TransformComponent>(component.Owner);
|
||||
EntityUid gridId = magnetTransform.GridUid ?? throw new InvalidOperationException("Magnet had no grid associated");
|
||||
if (!_salvageGridStates.TryGetValue(gridId, out gridState))
|
||||
if (!_salvageGridStates.TryGetValue(magnetTranform.GridID, out gridState))
|
||||
{
|
||||
gridState = new SalvageGridState();
|
||||
_salvageGridStates[gridId] = gridState;
|
||||
_salvageGridStates[magnetTranform.GridID] = gridState;
|
||||
}
|
||||
gridState.ActiveMagnets.Add(component);
|
||||
component.MagnetState = new MagnetState(MagnetStateType.Attaching, gridState.CurrentTime + AttachingTime);
|
||||
@@ -227,7 +227,8 @@ namespace Content.Server.Salvage
|
||||
angle = Angle.Zero;
|
||||
var tsc = Transform(component.Owner);
|
||||
coords = new EntityCoordinates(component.Owner, component.Offset).ToMap(EntityManager);
|
||||
if (_mapManager.TryGetGrid(tsc.GridUid, out var magnetGrid))
|
||||
var grid = tsc.GridID;
|
||||
if (_mapManager.TryGetGrid(grid, out var magnetGrid))
|
||||
{
|
||||
angle = magnetGrid.WorldRotation;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user