Example #1
0
        public void Main(string argument, UpdateType updateSource)
        {
            if (_resourceTextPanel == null)
            {
                _resourceTextPanel = (IMyTextSurface)GridTerminalSystem.GetBlockWithName("资源统计面板");
            }
            var terminalBlocks = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlocks(terminalBlocks);
            terminalBlocks = terminalBlocks.Where(m => m.HasInventory).ToList();
            _resourceDetection.UpdateInventory(terminalBlocks);
            Color  lcdColor;
            string lcdText = _resourceDetection.GetText(out lcdColor);

            _resourceTextPanel.FontColor = lcdColor;
            _resourceTextPanel.WriteText(lcdText);
            var batteryBlocks = new List <IMyBatteryBlock>();

            GridTerminalSystem.GetBlocksOfType(batteryBlocks);
            List <IMyBatteryBlock> baseBatteryBlocks  = batteryBlocks.Where(m => m.CustomName.Equals(BaseBatteryName)).ToList();
            List <IMyBatteryBlock> otherBatteryBlocks = batteryBlocks.Where(m => !m.CustomName.Equals(BaseBatteryName)).ToList();

            if (_upTextPanel == null)
            {
                _upTextPanel = Me.GetSurface(0);
            }
            if (_downTextPanel == null)
            {
                _downTextPanel = Me.GetSurface(1);
            }
            if (_electricPowerDetection == null)
            {
                _electricPowerDetection = new ElectricPowerDetection();
            }
            _electricPowerDetection.Init(baseBatteryBlocks, otherBatteryBlocks);
            _electricPowerDetection.AutomaticManagement();
            terminalBlocks = new List <IMyTerminalBlock>();
            GridTerminalSystem.GetBlocksOfType <IMyCargoContainer>(terminalBlocks);
            if (_volumeDetection == null)
            {
                _volumeDetection = new VolumeDetection();
            }
            _volumeDetection.UpdateInfo(terminalBlocks);
            lcdText  = _electricPowerDetection.GetText();
            lcdText += _volumeDetection.GetText();
            _upTextPanel.WriteText(lcdText);
            lcdText = _electricPowerDetection.GetGuidText(out lcdColor);
            _downTextPanel.FontColor = lcdColor;
            _downTextPanel.WriteText(lcdText);
        }
Example #2
0
        public void Main(string argument, UpdateType updateSource)
        {
            if (_electricPowerDetection == null)
            {
                _electricPowerDetection = new ElectricPowerDetection();
            }
            if (_volumeDetection == null)
            {
                _volumeDetection = new VolumeDetection();
            }
            var batteryBlocks = new List <IMyBatteryBlock>();

            GridTerminalSystem.GetBlocksOfType(batteryBlocks);
            _electricPowerDetection.Init(batteryBlocks);
            var terminalBlocks = new List <IMyTerminalBlock>();
            var tempBlocks     = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlocksOfType <IMyShipDrill>(tempBlocks);
            terminalBlocks.AddRange(tempBlocks);
            GridTerminalSystem.GetBlocksOfType <IMyCockpit>(tempBlocks);
            terminalBlocks.AddRange(tempBlocks);
            GridTerminalSystem.GetBlocksOfType <IMyShipConnector>(tempBlocks);
            terminalBlocks.AddRange(tempBlocks);
            GridTerminalSystem.GetBlocksOfType <IMyCargoContainer>(tempBlocks);
            terminalBlocks.AddRange(tempBlocks);
            _volumeDetection.UpdateInfo(terminalBlocks);
            if (_cockpit1LeftLCDPanel == null || _cockpit2LeftLCDPanel == null)
            {
                var cockpit = (IMyCockpit)GridTerminalSystem.GetBlockWithName("主驾驶舱1");
                _cockpit1LeftLCDPanel = cockpit.GetSurface(1);
                cockpit = (IMyCockpit)GridTerminalSystem.GetBlockWithName("主驾驶舱2");
                _cockpit2LeftLCDPanel = cockpit.GetSurface(1);
            }
            string lcdText = _electricPowerDetection.GetText();

            lcdText += _volumeDetection.GetText();
            _cockpit1LeftLCDPanel.WriteText(lcdText);
            _cockpit2LeftLCDPanel.WriteText(lcdText);
        }
Example #3
0
        public void Main(string argument, UpdateType updateSource)
        {
            if (_electricPowerDetection == null)
            {
                _electricPowerDetection = new ElectricPowerDetection();
            }
            if (_resourceDetection == null)
            {
                _resourceDetection = new ResourceDetection(_resourceDictionary);
            }
            if (_volumeDetection == null)
            {
                _volumeDetection = new VolumeDetection();
            }
            var batteryBlocks = new List <IMyBatteryBlock>();

            GridTerminalSystem.GetBlocksOfType(batteryBlocks);
            _electricPowerDetection.Init(batteryBlocks);
            var terminalBlocks = new List <IMyTerminalBlock>();

            GridTerminalSystem.GetBlocksOfType <IMyCargoContainer>(terminalBlocks);
            _volumeDetection.UpdateInfo(terminalBlocks);
            if (_cockpitLeftLCDPanel == null || _cockpitRightLCDPanel == null)
            {
                var cockpit = (IMyCockpit)GridTerminalSystem.GetBlockWithName("主驾驶舱");
                _cockpitLeftLCDPanel  = cockpit.GetSurface(1);
                _cockpitRightLCDPanel = cockpit.GetSurface(2);
            }
            string lcdText = _electricPowerDetection.GetText();

            lcdText += _volumeDetection.GetText();
            _cockpitLeftLCDPanel.WriteText(lcdText);
            Color lcdFontColor;

            lcdText = _resourceDetection.GetText(out lcdFontColor);
            _cockpitRightLCDPanel.FontColor = lcdFontColor;
            _cockpitRightLCDPanel.WriteText(lcdText);
        }