Esempio n. 1
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);
        }