コード例 #1
0
        private void AppendingCustomInfo(IMyTerminalBlock block, StringBuilder stringBuilder)
        {
            try
            {
                LastCustomInfoUpdate = _tick;
                var secToFull     = 0;
                var shieldPercent = !DsState.State.Online ? 0f : 100f;

                if (DsState.State.Charge < ShieldMaxCharge)
                {
                    shieldPercent = DsState.State.Charge / ShieldMaxCharge * 100;
                }
                if (ShieldChargeRate > 0)
                {
                    var toMax = ShieldMaxCharge - DsState.State.Charge;
                    var secs  = toMax / ShieldChargeRate;
                    if (secs.Equals(1))
                    {
                        secToFull = 0;
                    }
                    else
                    {
                        secToFull = (int)secs;
                    }
                }

                var shieldPowerNeeds = _powerNeeded;
                var powerUsage       = shieldPowerNeeds;
                var initStage        = 1;
                var validEmitterId   = DsState.State.ActiveEmitterId != 0;
                if (WarmedUp)
                {
                    initStage = 4;
                }
                else if (Warming)
                {
                    initStage = 3;
                }
                else if (_allInited)
                {
                    initStage = 2;
                }
                const string maxString = " MaxHp: ";
                var          hpValue   = (ShieldMaxCharge * ConvToHp);


                var status = GetShieldStatus();
                if (status == "[Shield Up]" || status == "[Shield Down]" || status == "[Shield Offline]")
                {
                    stringBuilder.Append(status + maxString + hpValue.ToString("N0") +
                                         "\n" +
                                         "\n[Shield HP__]: " + (DsState.State.Charge * ConvToHp).ToString("N0") + " (" + shieldPercent.ToString("0") + "%)" +
                                         "\n[HP Per Sec_]: " + (ShieldChargeRate * ConvToHp).ToString("N0") +
                                         "\n[Damage In__]: " + _damageReadOut.ToString("N0") +
                                         "\n[Charge Rate]: " + ShieldChargeRate.ToString("0.0") + " Mw" +
                                         "\n[Full Charge_]: " + secToFull.ToString("N0") + "s" +
                                         "\n[Over Heated]: " + DsState.State.Heat.ToString("0") + "%" +
                                         "\n[Maintenance]: " + _shieldMaintaintPower.ToString("0.0") + " Mw" +
                                         "\n[Shield Power]: " + ShieldCurrentPower.ToString("0.0") + " Mw" +
                                         "\n[Power Use]: " + powerUsage.ToString("0.0") + " (" + GridMaxPower.ToString("0.0") + ")Mw");
                }
                else
                {
                    stringBuilder.Append("Shield Status " + status +
                                         "\n" +
                                         "\n[Init Stage]: " + initStage + " of 4" +
                                         "\n[Emitter Ok]: " + validEmitterId +
                                         "\n[HP Stored]: " + (DsState.State.Charge * ConvToHp).ToString("N0") + " (" + shieldPercent.ToString("0") + "%)" +
                                         "\n[Shield Mode]: " + ShieldMode +
                                         "\n[Emitter LoS]: " + (DsState.State.EmitterLos) +
                                         "\n[Last Woken]: " + LastWokenTick + "/" + _tick +
                                         "\n[Waking Up]: " + DsState.State.Waking +
                                         "\n[Grid Owns Controller]: " + DsState.State.IsOwner +
                                         "\n[In Grid's Faction]: " + DsState.State.InFaction);
                }
            }
            catch (Exception ex) { Log.Line($"Exception in Controller AppendingCustomInfo: {ex}"); }
        }
コード例 #2
0
        private void AppendingCustomInfo(IMyTerminalBlock block, StringBuilder stringBuilder)
        {
            try
            {
                LastCustomInfoUpdate = _tick;
                var secToFull     = 0;
                var shieldPercent = !DsState.State.Online ? 0f : 100f;

                if (DsState.State.Charge < ShieldMaxCharge)
                {
                    shieldPercent = DsState.State.Charge / ShieldMaxCharge * 100;
                }

                if (ShieldChargeRate > 0)
                {
                    var toMax = ShieldMaxCharge - DsState.State.Charge;
                    var secs  = toMax / ShieldChargeRate;

                    if (secs.Equals(1))
                    {
                        secToFull = 0;
                    }
                    else
                    {
                        secToFull = (int)secs;
                    }
                }

                var shieldPowerNeeds = _powerNeeded;
                var powerUsage       = shieldPowerNeeds;
                var initStage        = 1;
                var validEmitterId   = DsState.State.ActiveEmitterId != 0;
                if (WarmedUp)
                {
                    initStage = 4;
                }
                else if (Warming)
                {
                    initStage = 3;
                }
                else if (_allInited)
                {
                    initStage = 2;
                }

                var maxString = _shieldCapped ? CapString : MaxString;
                var hpValue   = (ShieldMaxCharge * ConvToHp);


                var status = GetShieldStatus();
                if (status == "[Shield Up]" || status == "[Shield Down]" || status == "[Shield Offline]")
                {
                    var redirectedSides = ShuntedSideCount();
                    var bonusAmount     = redirectedSides * 20;
                    stringBuilder.Append(Localization.GetText($"InfoShieldStatus{status}") + maxString + hpValue.ToString("N0") +
                                         $"\n{Localization.GetText("InfoShield[Shield HP__]")}: " + (DsState.State.Charge * ConvToHp).ToString("N0") + " (" + shieldPercent.ToString("0") + "%)" +
                                         $"\n{Localization.GetText("InfoShield[HP Per Sec_]")}: " + (ShieldChargeRate * ConvToHp).ToString("N0") +
                                         $"\n{Localization.GetText("InfoShield[Damage In__]")}: " + _damageReadOut.ToString("N0") +
                                         $"\n{Localization.GetText("InfoShield[Charge Rate]")}: " + ShieldChargeRate.ToString("0.0") + " Mw" +
                                         $"\n{Localization.GetText("InfoShield[Full Charge_]")}: " + secToFull.ToString("N0") + "s" +
                                         $"\n{Localization.GetText("InfoShield[Over Heated]")}: " + DsState.State.Heat.ToString("0") + "%" +
                                         $"\n{Localization.GetText("InfoShield[Shunted Sides]")}: " + redirectedSides.ToString("0") + " (" + bonusAmount + "%)" +
                                         $"\n{Localization.GetText("InfoShield[Maintenance]")}: " + _shieldMaintaintPower.ToString("0.0") + " Mw" +
                                         $"\n{Localization.GetText("InfoShield[Shield Power]")}: " + ShieldCurrentPower.ToString("0.0") + " Mw" +
                                         $"\n{Localization.GetText("InfoShield[Power Use]")}: " + powerUsage.ToString("0.0") + " (" + GridMaxPower.ToString("0.0") + ")Mw" +
                                         $"\n{Localization.GetText("InfoShield[Power Density]")}: " + DsState.State.PowerDensity +
                                         $"\n{Localization.GetText("InfoShield[Block Density]")}: " + DsState.State.BlockDensity +
                                         $"\n{Localization.GetText("InfoShield[Density Total]")}: " + DsState.State.CapModifier);
                }
                else
                {
                    stringBuilder.Append($"{Localization.GetText("InfoShieldStatus")} " + Localization.GetText($"InfoShieldStatus{status}") +
                                         "\n" +
                                         $"\n{Localization.GetText("InfoShield[Init Stage]")}: " + initStage + " of 4" +
                                         $"\n{Localization.GetText("InfoShield[Emitter Ok]")}: " + validEmitterId +
                                         $"\n{Localization.GetText("InfoShield[HP Stored]")}: " + (DsState.State.Charge * ConvToHp).ToString("N0") + " (" + shieldPercent.ToString("0") + "%)" +
                                         $"\n{Localization.GetText("InfoShield[Shield Mode]")}: " + ShieldMode +
                                         $"\n{Localization.GetText("InfoShield[Emitter LoS]")}: " + (DsState.State.EmitterLos) +
                                         $"\n{Localization.GetText("InfoShield[Last Woken]")}: " + LastWokenTick + "/" + _tick +
                                         $"\n{Localization.GetText("InfoShield[Waking Up]")}: " + DsState.State.Waking +
                                         $"\n{Localization.GetText("InfoShield[Grid Owns Controller]")}: " + DsState.State.IsOwner +
                                         $"\n{Localization.GetText("InfoShield[In Grid's Faction]")}: " + DsState.State.InFaction);
                }
            }
            catch (Exception ex) { Log.Line($"Exception in Controller AppendingCustomInfo: {ex}"); }
        }