Remove Explicit GridId References (#8315)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Server.Atmos.Commands
|
||||
{
|
||||
@@ -23,37 +22,29 @@ namespace Content.Server.Atmos.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(args[0], out var id))
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if(EntityUid.TryParse(args[0], out var euid))
|
||||
{
|
||||
shell.WriteLine($"{args[0]} is not a valid integer.");
|
||||
shell.WriteError($"Failed to parse euid '{args[0]}'.");
|
||||
return;
|
||||
}
|
||||
|
||||
var gridId = new GridId(id);
|
||||
|
||||
var mapMan = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
|
||||
if (!entMan.HasComponent<IMapGridComponent>(euid))
|
||||
{
|
||||
shell.WriteLine($"{gridId} is not a valid grid id.");
|
||||
shell.WriteError($"Euid '{euid}' does not exist or is not a grid.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_entities.EntityExists(gridComp.GridEntityId))
|
||||
{
|
||||
shell.WriteLine("Failed to get grid entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_entities.HasComponent<IAtmosphereComponent>(gridComp.GridEntityId))
|
||||
if (_entities.HasComponent<IAtmosphereComponent>(euid))
|
||||
{
|
||||
shell.WriteLine("Grid already has an atmosphere.");
|
||||
return;
|
||||
}
|
||||
|
||||
_entities.AddComponent<GridAtmosphereComponent>(gridComp.GridEntityId);
|
||||
_entities.AddComponent<GridAtmosphereComponent>(euid);
|
||||
|
||||
shell.WriteLine($"Added atmosphere to grid {id}.");
|
||||
shell.WriteLine($"Added atmosphere to grid {euid}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Atmos;
|
||||
@@ -12,22 +12,28 @@ namespace Content.Server.Atmos.Commands
|
||||
{
|
||||
public string Command => "addgas";
|
||||
public string Description => "Adds gas at a certain position.";
|
||||
public string Help => "addgas <X> <Y> <GridId> <Gas> <moles>";
|
||||
public string Help => "addgas <X> <Y> <GridEid> <Gas> <moles>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length < 5) return;
|
||||
|
||||
if(!int.TryParse(args[0], out var x)
|
||||
|| !int.TryParse(args[1], out var y)
|
||||
|| !int.TryParse(args[2], out var id)
|
||||
|| !EntityUid.TryParse(args[2], out var euid)
|
||||
|| !(AtmosCommandUtils.TryParseGasID(args[3], out var gasId))
|
||||
|| !float.TryParse(args[4], out var moles)) return;
|
||||
|
||||
var gridId = new GridId(id);
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entMan.HasComponent<IMapGridComponent>(euid))
|
||||
{
|
||||
shell.WriteError($"Euid '{euid}' does not exist or is not a grid.");
|
||||
return;
|
||||
}
|
||||
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
var indices = new Vector2i(x, y);
|
||||
var tile = atmosphereSystem.GetTileMixture(gridId, indices, true);
|
||||
var tile = atmosphereSystem.GetTileMixture(euid, indices, true);
|
||||
|
||||
if (tile == null)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.Components;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Server.Atmos.Commands
|
||||
{
|
||||
@@ -21,39 +20,29 @@ namespace Content.Server.Atmos.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(args[0], out var id))
|
||||
{
|
||||
shell.WriteLine($"{args[0]} is not a valid integer.");
|
||||
return;
|
||||
}
|
||||
|
||||
var gridId = new GridId(id);
|
||||
|
||||
var mapMan = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp))
|
||||
{
|
||||
shell.WriteLine($"{gridId} is not a valid grid id.");
|
||||
return;
|
||||
}
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (!entMan.EntityExists(gridComp.GridEntityId))
|
||||
if (EntityUid.TryParse(args[0], out var euid))
|
||||
{
|
||||
shell.WriteLine("Failed to get grid entity.");
|
||||
shell.WriteError($"Failed to parse euid '{args[0]}'.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (entMan.HasComponent<IAtmosphereComponent>(gridComp.GridEntityId))
|
||||
if (!entMan.HasComponent<IMapGridComponent>(euid))
|
||||
{
|
||||
shell.WriteError($"Euid '{euid}' does not exist or is not a grid.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (entMan.HasComponent<IAtmosphereComponent>(euid))
|
||||
{
|
||||
shell.WriteLine("Grid already has an atmosphere.");
|
||||
return;
|
||||
}
|
||||
|
||||
entMan.AddComponent<UnsimulatedGridAtmosphereComponent>(gridComp.GridEntityId);
|
||||
entMan.AddComponent<UnsimulatedGridAtmosphereComponent>(euid);
|
||||
|
||||
shell.WriteLine($"Added unsimulated atmosphere to grid {id}.");
|
||||
shell.WriteLine($"Added unsimulated atmosphere to grid {euid}.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Content.Server.Atmos.Commands
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
GridId gridId;
|
||||
EntityUid gridId;
|
||||
Gas? gas = null;
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
@@ -39,9 +39,9 @@ namespace Content.Server.Atmos.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = entMan.GetComponent<TransformComponent>(playerEntity).GridID;
|
||||
gridId = entMan.GetComponent<TransformComponent>(playerEntity).GridEntityId;
|
||||
|
||||
if (gridId == GridId.Invalid)
|
||||
if (gridId == EntityUid.Invalid)
|
||||
{
|
||||
shell.WriteLine("You aren't on a grid to delete gas from.");
|
||||
return;
|
||||
@@ -51,7 +51,7 @@ namespace Content.Server.Atmos.Commands
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (!int.TryParse(args[0], out var number))
|
||||
if (!EntityUid.TryParse(args[0], out var number))
|
||||
{
|
||||
// Argument is a gas
|
||||
if (player == null)
|
||||
@@ -66,9 +66,9 @@ namespace Content.Server.Atmos.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = entMan.GetComponent<TransformComponent>(playerEntity).GridID;
|
||||
gridId = entMan.GetComponent<TransformComponent>(playerEntity).GridEntityId;
|
||||
|
||||
if (gridId == GridId.Invalid)
|
||||
if (gridId == EntityUid.Invalid)
|
||||
{
|
||||
shell.WriteLine("You aren't on a grid to delete gas from.");
|
||||
return;
|
||||
@@ -85,27 +85,20 @@ namespace Content.Server.Atmos.Commands
|
||||
}
|
||||
|
||||
// Argument is a grid
|
||||
gridId = new GridId(number);
|
||||
|
||||
if (gridId == GridId.Invalid)
|
||||
{
|
||||
shell.WriteLine($"{gridId} is not a valid grid id.");
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = number;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
if (!int.TryParse(args[0], out var first))
|
||||
if (!EntityUid.TryParse(args[0], out var first))
|
||||
{
|
||||
shell.WriteLine($"{args[0]} is not a valid integer for a grid id.");
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = new GridId(first);
|
||||
gridId = first;
|
||||
|
||||
if (gridId == GridId.Invalid)
|
||||
if (gridId == EntityUid.Invalid)
|
||||
{
|
||||
shell.WriteLine($"{gridId} is not a valid grid id.");
|
||||
return;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Atmos;
|
||||
@@ -12,17 +12,15 @@ namespace Content.Server.Atmos.Commands
|
||||
{
|
||||
public string Command => "fillgas";
|
||||
public string Description => "Adds gas to all tiles in a grid.";
|
||||
public string Help => "fillgas <GridId> <Gas> <moles>";
|
||||
public string Help => "fillgas <GridEid> <Gas> <moles>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length < 3) return;
|
||||
if(!int.TryParse(args[0], out var id)
|
||||
if(!EntityUid.TryParse(args[0], out var gridId)
|
||||
|| !(AtmosCommandUtils.TryParseGasID(args[1], out var gasId))
|
||||
|| !float.TryParse(args[2], out var moles)) return;
|
||||
|
||||
var gridId = new GridId(id);
|
||||
|
||||
var mapMan = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out _))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
@@ -18,15 +18,13 @@ namespace Content.Server.Atmos.Commands
|
||||
if (args.Length < 5) return;
|
||||
if(!int.TryParse(args[0], out var x)
|
||||
|| !int.TryParse(args[1], out var y)
|
||||
|| !int.TryParse(args[2], out var id)
|
||||
|| !EntityUid.TryParse(args[2], out var id)
|
||||
|| !float.TryParse(args[3], out var amount)
|
||||
|| !bool.TryParse(args[4], out var ratio)) return;
|
||||
|
||||
var gridId = new GridId(id);
|
||||
|
||||
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
|
||||
var indices = new Vector2i(x, y);
|
||||
var tile = atmosphereSystem.GetTileMixture(gridId, indices, true);
|
||||
var tile = atmosphereSystem.GetTileMixture(id, indices, true);
|
||||
|
||||
if (tile == null)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Atmos;
|
||||
@@ -17,11 +17,9 @@ namespace Content.Server.Atmos.Commands
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length < 2) return;
|
||||
if(!int.TryParse(args[0], out var id)
|
||||
if(!EntityUid.TryParse(args[0], out var gridId)
|
||||
|| !float.TryParse(args[1], out var temperature)) return;
|
||||
|
||||
var gridId = new GridId(id);
|
||||
|
||||
var mapMan = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
if (temperature < Atmospherics.TCMB)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Atmos;
|
||||
@@ -19,11 +19,9 @@ namespace Content.Server.Atmos.Commands
|
||||
if (args.Length < 4) return;
|
||||
if(!int.TryParse(args[0], out var x)
|
||||
|| !int.TryParse(args[1], out var y)
|
||||
|| !int.TryParse(args[2], out var id)
|
||||
|| !EntityUid.TryParse(args[2], out var gridId)
|
||||
|| !float.TryParse(args[3], out var temperature)) return;
|
||||
|
||||
var gridId = new GridId(id);
|
||||
|
||||
if (temperature < Atmospherics.TCMB)
|
||||
{
|
||||
shell.WriteLine("Invalid temperature.");
|
||||
|
||||
Reference in New Issue
Block a user