public void Execute(IConsoleShell shell, IPlayerSession?player, string[] args) { var gasId = -1; var gas = (Gas)(-1); if (args.Length < 3) { return; } if (!int.TryParse(args[0], out var id) || !(int.TryParse(args[1], out gasId) || Enum.TryParse(args[1], true, out gas)) || !float.TryParse(args[2], out var moles)) { return; } if (gas != (Gas)(-1)) { gasId = (int)gas; } var gridId = new GridId(id); var mapMan = IoCManager.Resolve <IMapManager>(); if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) { shell.SendText(player, "Invalid grid ID."); return; } var entMan = IoCManager.Resolve <IEntityManager>(); if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) { shell.SendText(player, "Failed to get grid entity."); return; } if (!grid.HasComponent <GridAtmosphereComponent>()) { shell.SendText(player, "Grid doesn't have an atmosphere."); return; } var gam = grid.GetComponent <GridAtmosphereComponent>(); foreach (var tile in gam) { if (gasId != -1) { tile.Air?.AdjustMoles(gasId, moles); gam.Invalidate(tile.GridIndices); continue; } tile.Air?.AdjustMoles(gas, moles); gam.Invalidate(tile.GridIndices); } }
public void Execute(IConsoleShell shell, IPlayerSession?player, 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) || !(AtmosCommandUtils.TryParseGasID(args[3], out var gasId)) || !float.TryParse(args[4], out var moles)) { return; } var gridId = new GridId(id); var mapMan = IoCManager.Resolve <IMapManager>(); if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) { shell.SendText(player, "Invalid grid ID."); return; } var entMan = IoCManager.Resolve <IEntityManager>(); if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) { shell.SendText(player, "Failed to get grid entity."); return; } if (!grid.HasComponent <GridAtmosphereComponent>()) { shell.SendText(player, "Grid doesn't have an atmosphere."); return; } var gam = grid.GetComponent <GridAtmosphereComponent>(); var indices = new Vector2i(x, y); var tile = gam.GetTile(indices); if (tile == null) { shell.SendText(player, "Invalid coordinates."); return; } if (tile.Air == null) { shell.SendText(player, "Can't add gas to that tile."); return; } tile.Air.AdjustMoles(gasId, moles); tile.Invalidate(); }
public void InvalidatePosition(GridId gridId, Vector2i pos) { if (!gridId.IsValid()) { return; } _atmosphereSystem.UpdateAdjacent(gridId, pos); _atmosphereSystem.InvalidateTile(gridId, pos); }
public void Execute(IConsoleShell shell, IPlayerSession?player, string[] args) { if (args.Length < 1) { return; } if (!int.TryParse(args[0], out var id)) { shell.SendText(player, "Not enough arguments!"); } var gridId = new GridId(id); var mapMan = IoCManager.Resolve <IMapManager>(); if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) { shell.SendText(player, "Invalid grid ID."); return; } var entMan = IoCManager.Resolve <IEntityManager>(); if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) { shell.SendText(player, "Failed to get grid entity."); return; } if (!grid.HasComponent <GridAtmosphereComponent>()) { shell.SendText(player, "Grid doesn't have an atmosphere."); return; } var gam = grid.GetComponent <GridAtmosphereComponent>(); var tiles = 0; var moles = 0f; foreach (var tile in gam) { if (tile.Air == null || tile.Air.Immutable) { continue; } tiles++; moles += tile.Air.TotalMoles; tile.Air.RemoveRatio(1f); gam.Invalidate(tile.GridIndices); } shell.SendText(player, $"Removed {moles} moles from {tiles} tiles."); }
public void InvalidatePosition(GridId gridId, Vector2i pos, bool fixVacuum = false) { if (!gridId.IsValid()) { return; } _atmosphereSystem.UpdateAdjacent(gridId, pos); _atmosphereSystem.InvalidateTile(gridId, pos); if (fixVacuum) { _atmosphereSystem.FixVacuum(gridId, pos); } }
public IGridAtmosphereComponent?GetGridAtmosphere(GridId gridId) { if (!gridId.IsValid()) { return(null); } if (!_mapManager.TryGetGrid(gridId, out var grid)) { return(null); } return(ComponentManager.TryGetComponent(grid.GridEntityId, out IGridAtmosphereComponent? gridAtmosphere) ? gridAtmosphere : null); }
public IGridAtmosphereComponent?GetGridAtmosphere(GridId gridId) { if (!gridId.IsValid()) { return(_spaceAtmos); } var grid = _mapManager.GetGrid(gridId); if (!EntityManager.TryGetEntity(grid.GridEntityId, out var gridEnt)) { return(_spaceAtmos); } return(gridEnt.TryGetComponent(out IGridAtmosphereComponent? atmos) ? atmos : _spaceAtmos); }
public void Execute(IConsoleShell shell, string argStr, string[] args) { if (args.Length < 3) { return; } if (!int.TryParse(args[0], out var id) || !(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 var gridComp)) { shell.WriteLine("Invalid grid ID."); return; } var entMan = IoCManager.Resolve <IEntityManager>(); if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) { shell.WriteLine("Failed to get grid entity."); return; } if (!grid.HasComponent <IGridAtmosphereComponent>()) { shell.WriteLine("Grid doesn't have an atmosphere."); return; } var gam = grid.GetComponent <IGridAtmosphereComponent>(); foreach (var tile in gam) { tile.Air?.AdjustMoles(gasId, moles); tile.Invalidate(); } }
public void Execute(IConsoleShell shell, string argStr, string[] args) { if (args.Length < 1) { shell.WriteLine(Help); 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)) { shell.WriteLine("Failed to get grid entity."); return; } if (entMan.HasComponent <IAtmosphereComponent>(gridComp.GridEntityId)) { shell.WriteLine("Grid already has an atmosphere."); return; } entMan.AddComponent <UnsimulatedGridAtmosphereComponent>(gridComp.GridEntityId); shell.WriteLine($"Added unsimulated atmosphere to grid {id}."); }
public void Execute(IConsoleShell shell, IPlayerSession?player, string[] args) { if (args.Length < 1) { shell.SendText(player, Help); return; } if (!int.TryParse(args[0], out var id)) { shell.SendText(player, $"{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.SendText(player, $"{gridId} is not a valid grid id."); return; } var entMan = IoCManager.Resolve <IEntityManager>(); if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) { shell.SendText(player, "Failed to get grid entity."); return; } if (grid.HasComponent <IGridAtmosphereComponent>()) { shell.SendText(player, "Grid already has an atmosphere."); return; } grid.AddComponent <UnsimulatedGridAtmosphereComponent>(); shell.SendText(player, $"Added unsimulated atmosphere to grid {id}."); }
public static TileRef?GetTileRef(this MapIndices mapIndices, GridId gridId) { if (!gridId.IsValid()) { return(null); } var mapManager = IoCManager.Resolve <IMapManager>(); if (!mapManager.TryGetGrid(gridId, out var grid)) { return(null); } if (!grid.TryGetTileRef(mapIndices, out var tile)) { return(null); } return(tile); }
private bool FindGasPortIn(GridId gridId, EntityCoordinates coordinates, [NotNullWhen(true)] out GasPortComponent?port) { port = null; if (!gridId.IsValid()) { return(false); } var grid = _mapManager.GetGrid(gridId); foreach (var entityUid in grid.GetLocal(coordinates)) { if (EntityManager.TryGetComponent <GasPortComponent>(entityUid, out port)) { return(true); } } return(false); }
public void Execute(IConsoleShell shell, string argStr, string[] args) { if (args.Length < 2) { return; } if (!int.TryParse(args[0], out var id) || !float.TryParse(args[1], out var temperature)) { return; } var gridId = new GridId(id); var mapMan = IoCManager.Resolve <IMapManager>(); if (temperature < Atmospherics.TCMB) { shell.WriteLine("Invalid temperature."); return; } if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) { shell.WriteLine("Invalid grid ID."); return; } var atmosphereSystem = EntitySystem.Get <AtmosphereSystem>(); var tiles = 0; foreach (var tile in atmosphereSystem.GetAllTileMixtures(gridId, true)) { tiles++; tile.Temperature = temperature; } shell.WriteLine($"Changed the temperature of {tiles} tiles."); }
public void Execute(IConsoleShell shell, string argStr, string[] args) { 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) || !float.TryParse(args[3], out var temperature)) { return; } var gridId = new GridId(id); var mapMan = IoCManager.Resolve <IMapManager>(); if (temperature < Atmospherics.TCMB) { shell.WriteLine("Invalid temperature."); return; } if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) { shell.WriteLine("Invalid grid ID."); return; } var entMan = IoCManager.Resolve <IEntityManager>(); if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) { shell.WriteLine("Failed to get grid entity."); return; } if (!grid.HasComponent <GridAtmosphereComponent>()) { shell.WriteLine("Grid doesn't have an atmosphere."); return; } var gam = grid.GetComponent <GridAtmosphereComponent>(); var indices = new Vector2i(x, y); var tile = gam.GetTile(indices); if (tile == null) { shell.WriteLine("Invalid coordinates."); return; } if (tile.Air == null) { shell.WriteLine("Can't change that tile's temperature."); return; } tile.Air.Temperature = temperature; tile.Invalidate(); }
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) || !float.TryParse(args[3], out var amount) || !bool.TryParse(args[4], out var ratio)) { return; } var gridId = new GridId(id); var mapMan = IoCManager.Resolve <IMapManager>(); if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) { shell.WriteLine("Invalid grid ID."); return; } var entMan = IoCManager.Resolve <IEntityManager>(); if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) { shell.WriteLine("Failed to get grid entity."); return; } if (!grid.HasComponent <GridAtmosphereComponent>()) { shell.WriteLine("Grid doesn't have an atmosphere."); return; } var gam = grid.GetComponent <GridAtmosphereComponent>(); var indices = new Vector2i(x, y); var tile = gam.GetTile(indices); if (tile == null) { shell.WriteLine("Invalid coordinates."); return; } if (tile.Air == null) { shell.WriteLine("Can't remove gas from that tile."); return; } if (ratio) { tile.Air.RemoveRatio(amount); } else { tile.Air.Remove(amount); } tile.Invalidate(); }
public static TileRef GetTileRef(this MapIndices mapIndices, GridId gridId, IMapManager?mapManager = null) { if (!gridId.IsValid()) { return(default);
/// <summary> /// Attempts to get the turf at map indices with grid id or null if no such turf is found. /// </summary> public static TileRef GetTileRef(this Vector2i vector2i, GridId gridId, IMapManager?mapManager = null) { if (!gridId.IsValid()) { return(default);
public void Execute(IConsoleShell shell, IPlayerSession?player, string[] args) { if (args.Length < 2) { return; } if (!int.TryParse(args[0], out var id) || !float.TryParse(args[1], out var temperature)) { return; } var gridId = new GridId(id); var mapMan = IoCManager.Resolve <IMapManager>(); if (temperature < Atmospherics.TCMB) { shell.SendText(player, "Invalid temperature."); return; } if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out var gridComp)) { shell.SendText(player, "Invalid grid ID."); return; } var entMan = IoCManager.Resolve <IEntityManager>(); if (!entMan.TryGetEntity(gridComp.GridEntityId, out var grid)) { shell.SendText(player, "Failed to get grid entity."); return; } if (!grid.HasComponent <GridAtmosphereComponent>()) { shell.SendText(player, "Grid doesn't have an atmosphere."); return; } var gam = grid.GetComponent <GridAtmosphereComponent>(); var tiles = 0; foreach (var tile in gam) { if (tile.Air == null) { continue; } tiles++; tile.Air.Temperature = temperature; gam.Invalidate(tile.GridIndices); } shell.SendText(player, $"Changed the temperature of {tiles} tiles."); }