public void Execute(IConsoleShell shell, string argStr, string[] args)
        {
            if (args.Length < 3)
            {
                return;
            }
            if (!EntityUid.TryParse(args[0], out var gridId) ||
                !(AtmosCommandUtils.TryParseGasID(args[1], out var gasId)) ||
                !float.TryParse(args[2], out var moles))
            {
                return;
            }

            var mapMan = IoCManager.Resolve <IMapManager>();

            if (!gridId.IsValid() || !mapMan.TryGetGrid(gridId, out _))
            {
                shell.WriteLine("Invalid grid ID.");
                return;
            }

            var atmosphereSystem = EntitySystem.Get <AtmosphereSystem>();

            foreach (var tile in atmosphereSystem.GetAllTileMixtures(gridId, true))
            {
                tile.AdjustMoles(gasId, moles);
            }
        }
Esempio n. 2
0
        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) ||
                !(AtmosCommandUtils.TryParseGasID(args[3], out var gasId)) ||
                !float.TryParse(args[4], out var moles))
            {
                return;
            }

            var gridId = new GridId(id);

            var atmosphereSystem = EntitySystem.Get <AtmosphereSystem>();
            var indices          = new Vector2i(x, y);
            var tile             = atmosphereSystem.GetTileMixture(gridId, indices, true);

            if (tile == null)
            {
                shell.WriteLine("Invalid coordinates or tile.");
                return;
            }

            tile.AdjustMoles(gasId, moles);
        }
        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();
        }
Esempio n. 4
0
        public bool Execute(IDebugConsole console, params string[] args)
        {
            if (args.Length < 1)
            {
                console.AddLine(Help);
                return(false);
            }
            if (!Enum.TryParse <AtmosDebugOverlayMode>(args[0], out var xMode))
            {
                console.AddLine("Invalid mode");
                return(false);
            }
            int   xSpecificGas = 0;
            float xBase        = 0;
            float xScale       = Atmospherics.MolesCellStandard * 2;

            if (xMode == AtmosDebugOverlayMode.GasMoles)
            {
                if (args.Length != 2)
                {
                    console.AddLine("A target gas must be provided for this mode.");
                    return(false);
                }
                if (!AtmosCommandUtils.TryParseGasID(args[1], out xSpecificGas))
                {
                    console.AddLine("Gas ID not parsable or out of range.");
                    return(false);
                }
            }
            else
            {
                if (args.Length != 1)
                {
                    console.AddLine("No further information is required for this mode.");
                    return(false);
                }
                if (xMode == AtmosDebugOverlayMode.Temperature)
                {
                    // Red is 100C, Green is 20C, Blue is -60C
                    xBase  = Atmospherics.T20C + 80;
                    xScale = -160;
                }
            }
            var sys = EntitySystem.Get <AtmosDebugOverlaySystem>();

            sys.CfgMode        = xMode;
            sys.CfgSpecificGas = xSpecificGas;
            sys.CfgBase        = xBase;
            sys.CfgScale       = xScale;
            return(false);
        }
        public void Execute(IConsoleShell shell, IPlayerSession?player, 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.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)
            {
                tile.Air?.AdjustMoles(gasId, moles);
                gam.Invalidate(tile.GridIndices);
            }
        }
        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) ||
                !EntityUid.TryParse(args[2], out var euid) ||
                !(AtmosCommandUtils.TryParseGasID(args[3], out var gasId)) ||
                !float.TryParse(args[4], out var moles))
            {
                return;
            }

            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(euid, indices, true);

            if (tile == null)
            {
                shell.WriteLine("Invalid coordinates or tile.");
                return;
            }

            tile.AdjustMoles(gasId, moles);
        }