Example #1
0
        public Program()
        {
            Runtime.UpdateFrequency = UpdateFrequency.Update100;

            GridTerminalSystem.GetBlocksOfType <IMyTextPanel>(StatusMonitors, lcd => MyIni.HasSection(lcd.CustomData, "status_monitor") && lcd.IsSameConstructAs(Me));
            GridTerminalSystem.GetBlocksOfType <IMyBatteryBlock>(Batteries, battery => battery.IsSameConstructAs(Me));
            GridTerminalSystem.GetBlocksOfType <IMyGasTank>(FuelTanks, tank => BlockUtils.IsHydrogenTank(tank) && tank.IsSameConstructAs(Me));
            GridTerminalSystem.GetBlocksOfType <IMyGasTank>(OxygenTanks, tank => BlockUtils.IsOxygenTank(tank) && tank.IsSameConstructAs(Me));

            GridTerminalSystem.GetBlocksOfType <IMyGravityGenerator>(GravityGenerators, gravity => gravity.IsSameConstructAs(Me));
            GridTerminalSystem.GetBlocksOfType <IMyRefinery>(Refineries, refinery => refinery.IsSameConstructAs(Me));
            GridTerminalSystem.GetBlocksOfType <IMyAssembler>(Assemblers, assembler => assembler.IsSameConstructAs(Me));
            GridTerminalSystem.GetBlocksOfType <IMyGasGenerator>(GasGenerators, gasGenerator => gasGenerator.IsSameConstructAs(Me));
            GridTerminalSystem.GetBlocksOfType <IMyRadioAntenna>(Antennas, antenna => antenna.IsSameConstructAs(Me));
            GridTerminalSystem.GetBlocksOfType <IMyOreDetector>(OreDetectors, detector => detector.IsSameConstructAs(Me));
        }
            public int GetValue(ShipDisplayValue value)
            {
                switch (value)
                {
                case ShipDisplayValue.BatteryPercentRemaining:
                    return(BlockUtils.GetBatteryPercentRemaining(this.blocks.Cast <IMyBatteryBlock>().ToList()));

                case ShipDisplayValue.StorageCapacityUsed:
                    return(BlockUtils.GetStorageCapacityRemaining(this.blocks.Cast <IMyCargoContainer>().ToList(), Echo));

                case ShipDisplayValue.ThrustCapacityUsed:
                    return(BlockUtils.GetThrustCapacityRemaining(this.blocks.Cast <IMyThrust>().ToList(), ShipController, Echo));

                default:
                    return(0);
                }
            }
            private void GetRelevantBlocks()
            {
                List <IMyTerminalBlock> found = new List <IMyTerminalBlock>();

                switch (DisplayValue)
                {
                case ShipDisplayValue.BatteryPercentRemaining:
                    GridTerminalSystem.GetBlocksOfType <IMyBatteryBlock>(found, b => b.IsSameConstructAs(Me));
                    this.blocks = found;
                    break;

                case ShipDisplayValue.StorageCapacityUsed:
                    GridTerminalSystem.GetBlocksOfType <IMyCargoContainer>(found, b => b.IsSameConstructAs(Me));
                    this.blocks = found;
                    break;

                case ShipDisplayValue.ThrustCapacityUsed:
                    List <IMyThrust> thrusters = new List <IMyThrust>();
                    GridTerminalSystem.GetBlocksOfType <IMyThrust>(thrusters, b => b.IsSameConstructAs(Me));
                    thrusters   = BlockUtils.GetThrustersEmittingInDirection(thrusters, Base6Directions.Direction.Down);
                    this.blocks = thrusters.Cast <IMyTerminalBlock>().ToList();
                    break;
                }
            }
Example #4
0
        public void StopNextConsumer()
        {
            // Find the lowest priority list with blocks enabled
            List <IMyTerminalBlock> blocks = PowerPriorities.Reverse.Find(blockList => BlockUtils.CountEnabled(List <IMyTerminalBlock> blockList) > 0);

            // Turn off the first enabled block
            blocks.Find(block => block.Enabled).Enabled = false;
        }