public void UpdateBlockInfo(Sandbox.ModAPI.IMyTerminalBlock block, StringBuilder info) { info.Clear(); info.AppendLine(" "); IMyCubeBlock cubeBlock = Entity as IMyCubeBlock; IMyGridTerminalSystem tsystem = MyAPIGateway.TerminalActionsHelper.GetTerminalSystemForGrid(cubeBlock.CubeGrid as IMyCubeGrid); if (tsystem != null) { List <IMyTerminalBlock> shieldsConnected = new List <IMyTerminalBlock> (); tsystem.GetBlocksOfType <IMyRefinery> (shieldsConnected, EnergyShieldsCore.shieldFilter); float shipCurrentShieldPoints = 0f; float shipMaximumShieldPoints = 0f; foreach (var shield in shieldsConnected) { ShieldGeneratorGameLogic generatorLogic = ((IMyTerminalBlock)shield).GameLogic.GetAs <ShieldGeneratorGameLogic> (); shipCurrentShieldPoints += generatorLogic.m_currentShieldPoints; shipMaximumShieldPoints += generatorLogic.m_maximumShieldPoints; } info.Append("Ship Shield: "); MyValueFormatter.AppendGenericInBestUnit(shipCurrentShieldPoints, info); info.Append("Pt/"); MyValueFormatter.AppendGenericInBestUnit(shipMaximumShieldPoints, info); info.Append("Pt\n"); } info.Append("Local Shield: "); MyValueFormatter.AppendGenericInBestUnit(m_currentShieldPoints, info); info.Append("Pt/"); MyValueFormatter.AppendGenericInBestUnit(m_maximumShieldPoints, info); info.Append("Pt\n"); info.Append("Recharge: "); MyValueFormatter.AppendGenericInBestUnit(m_pointsToRecharge * 60, info); info.Append("Pt/s "); if (EnergyShieldsCore.Config.AlternativeRechargeMode.Enable && (m_ticksUntilRecharge > 0)) { info.Append("(" + (int)Math.Ceiling(m_ticksUntilRecharge / 60d) + "s)\n"); } else { info.Append("\n"); } info.Append("Effectivity: "); MyValueFormatter.AppendWorkInBestUnit(m_currentPowerConsumption, info); info.Append("/"); MyValueFormatter.AppendWorkInBestUnit(m_setPowerConsumption, info); info.Append(" (" + (m_rechargeMultiplier * 100).ToString("N") + "%)"); }
private void printShieldStatus() { try { if (MyAPIGateway.Multiplayer.IsServer) { if (Entity.InScene) { Sandbox.ModAPI.IMyFunctionalBlock funcBlock = Entity as Sandbox.ModAPI.IMyFunctionalBlock; if (funcBlock.CustomName.Contains(":")) { String name = funcBlock.CustomName; long gridID = funcBlock.CubeGrid.EntityId; int index = name.IndexOf(':'); if ((index + 1) < name.Length) { name = name.Remove(index + 1); } IMyGridTerminalSystem tsystem = MyAPIGateway.TerminalActionsHelper.GetTerminalSystemForGrid(funcBlock.CubeGrid as IMyCubeGrid); List <IMyTerminalBlock> shieldsConnected = new List <IMyTerminalBlock>(); if (tsystem != null) { tsystem.GetBlocksOfType <Sandbox.ModAPI.Ingame.IMyRefinery>(shieldsConnected, EnergyShieldsCore.shieldFilter); float shipCurrentShieldPoints = 0f; float shipMaximumShieldPoints = 0f; foreach (var shield in shieldsConnected) { ShieldGeneratorGameLogic generatorLogic = ((IMyTerminalBlock)shield).GameLogic.GetAs <ShieldGeneratorGameLogic>(); shipCurrentShieldPoints += generatorLogic.m_currentShieldPoints; shipMaximumShieldPoints += generatorLogic.m_maximumShieldPoints; } name = name + " (" + Math.Round(shipCurrentShieldPoints) + "/" + Math.Round(shipMaximumShieldPoints) + ")"; funcBlock.SetCustomName(name); } else { name = name + " (" + Math.Round(m_currentShieldPoints) + "/" + Math.Round(m_maximumShieldPoints) + ")"; funcBlock.SetCustomName(name); } } } } } catch (Exception e) { } }
public void UpdateBlockInfo(Sandbox.ModAPI.IMyTerminalBlock block, StringBuilder info) { try { if (block == null) { return; } if (info == null) { return; } info.Clear(); info.AppendLine(" "); IMyGridTerminalSystem tsystem = null; if (block.CubeGrid != null) { tsystem = MyAPIGateway.TerminalActionsHelper.GetTerminalSystemForGrid(block.CubeGrid); } if (tsystem != null) { List <IMyTerminalBlock> shieldsConnected = new List <IMyTerminalBlock>(); tsystem.GetBlocksOfType <IMyRefinery>(shieldsConnected, EnergyShieldsCore.shieldFilter); float shipCurrentShieldPoints = 0f; float shipMaximumShieldPoints = 0f; foreach (var shield in shieldsConnected) { if (shield == null) { continue; } ShieldGeneratorGameLogic generatorLogic = null; if (EnergyShieldsCore.shieldGenerators.TryGetValue(shield.EntityId, out generatorLogic)) { shipCurrentShieldPoints += generatorLogic.m_currentShieldPoints; shipMaximumShieldPoints += generatorLogic.m_maximumShieldPoints; } } info.Append("总护盾: "); MyValueFormatter.AppendGenericInBestUnit(shipCurrentShieldPoints, info); info.Append("Pt/"); MyValueFormatter.AppendGenericInBestUnit(shipMaximumShieldPoints, info); info.Append("Pt\n"); } info.Append("此护盾: "); MyValueFormatter.AppendGenericInBestUnit(m_currentShieldPoints, info); info.Append("Pt/"); MyValueFormatter.AppendGenericInBestUnit(m_maximumShieldPoints, info); info.Append("Pt\n"); info.Append("充能: "); MyValueFormatter.AppendGenericInBestUnit(m_pointsToRecharge * 60, info); info.Append("Pt/s "); if (EnergyShieldsCore.Config.AlternativeRechargeMode.Enable && (m_ticksUntilRecharge > 0)) { info.Append("(" + (int)Math.Ceiling(m_ticksUntilRecharge / 60d) + "s)\n"); } else { info.Append("\n"); } info.Append("有效性: "); MyValueFormatter.AppendWorkInBestUnit(m_currentPowerConsumption, info); info.Append("/"); MyValueFormatter.AppendWorkInBestUnit(m_setPowerConsumption, info); info.Append(" (" + (m_rechargeMultiplier * 100).ToString("N") + "%)"); } catch (Exception e) { } }