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); }