public override bool GetShouldDrawThisFrame_Subclass()
        {
            if (!base.GetShouldDrawThisFrame_Subclass())
            {
                return(false);
            }

            GameEntity possibleEntity = ArcenExternalUIUtilities.GetEntityToUseForBuildMenu();

            if (possibleEntity == null)
            {
                return(false);
            }

            if (possibleEntity.PrimaryKeyID != this.EntityID ||
                possibleEntity.TypeData != this.EntityData)
            {
                this.EntityID   = possibleEntity.PrimaryKeyID;
                this.EntityData = possibleEntity.TypeData;
                this.EntityChangedSinceLastButtonSetUpdate_Queue         = true;
                this.EntityChangedSinceLastButtonSetUpdate_QueueControls = true;
                this.EntityChangedSinceLastButtonSetUpdate_Menu          = true;
            }

            if (LastEntityBuildQueueUpdateTimestamp < possibleEntity.TimeBuildQueueLastUpdated)
            {
                this.EntityChangedSinceLastButtonSetUpdate_Queue         = true;
                this.EntityChangedSinceLastButtonSetUpdate_QueueControls = true;
                LastEntityBuildQueueUpdateTimestamp = possibleEntity.TimeBuildQueueLastUpdated;
            }

            return(true);
        }
Exemple #2
0
 public override bool GetShouldBeHidden()
 {
     if (ArcenExternalUIUtilities.GetEntityToUseForBuildMenu() == null)
     {
         return(true);
     }
     return(false);
 }
        public override bool GetShouldDrawThisFrame_Subclass()
        {
            if (!base.GetShouldDrawThisFrame_Subclass())
            {
                return(false);
            }

            GameEntity entity = ArcenExternalUIUtilities.GetEntityToUseForBuildMenu();

            if (entity == null)
            {
                return(false);
            }

            return(true);
        }
            public void SetText(TextId textId, int NumericValue, string tooltip)
            {
                string suffix = ArcenExternalUIUtilities.GetRoundedNumberWithSuffix(ref NumericValue, false);

                ArcenDoubleCharacterBuffer buffer = SubTexts[(int)textId].Text.StartWritingToBuffer();

                buffer.Add(NumericValue);
                if (suffix.Length > 0)
                {
                    buffer.Add(suffix);
                }
                SubTexts[(int)textId].Text.FinishWritingToBuffer();
                SubTexts[(int)textId].Tooltip    = tooltip;
                LastTextIDWritten                = textId;
                LastWrittenWasImageInsteadOfText = false;
            }
Exemple #5
0
        public static void WriteSquadAndShipCounts(ArcenDoubleCharacterBuffer Buffer, SideRelationship relationship)
        {
            Planet planet = Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed();

            if (planet == null)
            {
                return;
            }

            CombatSide localSide = planet.Combat.GetSideForWorldSide(World_AIW2.Instance.GetLocalPlayerSide());

            int  squadResult = 0;
            FInt strength    = FInt.Zero;

            localSide.DoForRelatedSides(relationship, delegate(CombatSide side)
            {
                if (relationship == SideRelationship.SidesIAmFriendlyTowards && side == localSide)
                {
                    return(DelReturn.Continue); // when counting "ally" units, don't count my own units
                }
                side.Entities.DoForEntities(GameEntityCategory.Ship, delegate(GameEntity ship)
                {
                    int shipCount = 1 + ship.GetCurrentExtraShipsInSquad();
                    strength     += ship.TypeData.BalanceStats.StrengthPerShip * shipCount;
                    strength     += ship.GetStrengthOfContentsIfAny();
                    squadResult++;
                    return(DelReturn.Continue);
                });
                return(DelReturn.Continue);
            });

            if (squadResult > 0)
            {
                int    strengthAsInt  = strength.IntValue;
                string strengthSuffix = ArcenExternalUIUtilities.GetRoundedNumberWithSuffix(ref strengthAsInt);
                Buffer
                .Add(squadResult)
                .Add(" squads (")
                .Add(strengthAsInt)
                .Add(strengthSuffix)
                .Add(" strength)")
                ;
            }
        }
        public static void HandleInner(Int32 Int1, string InputActionInternalName)
        {
            if (ArcenUI.CurrentlyShownWindowsWith_PreventsNormalInputHandlers.Count > 0)
            {
                return;
            }
            if (ArcenUI.Instance.ShowingConsole)
            {
                return;
            }
            switch (InputActionInternalName)
            {
                #region Development Tools
            case "DebugGenerateMap":
                if (World.Instance.IsLoaded)
                {
                    return;
                }
                ArcenSocket.Instance.Shutdown();
                Engine_AIW2.Instance.InnerDoStartNewWorldOKLogic();
                break;

            case "DebugSendNextWave":
            {
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                GameCommand command = GameCommand.Create(GameCommandType.Debug_SendNextWave);
                World_AIW2.Instance.QueueGameCommand(command, true);
            }
            break;

            case "DebugIncreaseAIP":
            {
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                GameCommand command = GameCommand.Create(GameCommandType.Debug_IncreaseAIP);
                World_AIW2.Instance.QueueGameCommand(command, true);
            }
            break;

            case "DebugGiveSomeMetal":
            {
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                GameCommand command = GameCommand.Create(GameCommandType.Debug_GiveMetal);
                World_AIW2.Instance.QueueGameCommand(command, true);
            }
            break;

            case "DebugGiveScience":
            {
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                GameCommand command = GameCommand.Create(GameCommandType.Debug_GiveScience);
                World_AIW2.Instance.QueueGameCommand(command, true);
            }
            break;

            case "DebugConnectToLocalServer":
                ArcenSocket.Instance.OpenAsClient(Window_MainMenu.Instance.TargetIP, (ushort)GameSettings.Current.GetInt(ArcenIntSetting_Universal.NetworkPort));
                break;

            case "ReloadExternalDefinitions":
                ArcenUI.Instance.Initialize(true);
                //Engine_Universal.OnReloadAllExternalDefinitions();
                break;

            case "ReloadExternalConstantsAndLanguageOnly":
                Engine_Universal.OnReloadExternalConstantsAndLanguageOnly();
                break;

                #endregion
            case "ToggleGalaxyMap":
                if (Engine_Universal.RunStatus == RunStatus.GameStart)
                {
                    return;
                }
                switch (Engine_AIW2.Instance.CurrentGameViewMode)
                {
                case GameViewMode.MainGameView:
                    Engine_AIW2.Instance.PresentationLayer.ReactToLeavingPlanetView(Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed());
                    Engine_AIW2.Instance.SetCurrentGameViewMode(GameViewMode.GalaxyMapView);
                    break;

                case GameViewMode.GalaxyMapView:
                    Engine_AIW2.Instance.SetCurrentGameViewMode(GameViewMode.MainGameView);
                    Engine_AIW2.Instance.PresentationLayer.ReactToEnteringPlanetView(Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed());
                    break;
                }
                break;

            case "TogglePause":
            {
                if (Engine_Universal.RunStatus == RunStatus.GameStart)
                {
                    return;
                }
                GameCommand command = GameCommand.Create(GameCommandType.TogglePause);
                World_AIW2.Instance.QueueGameCommand(command, true);
            }
            break;

            case "ScoutAll":
            {
                if (Engine_Universal.RunStatus == RunStatus.GameStart)
                {
                    return;
                }
                GameCommand command = GameCommand.Create(GameCommandType.Debug_RevealAll);
                World_AIW2.Instance.QueueGameCommand(command, true);
            }
            break;

            case "ScrapUnits":
            {
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                GameCommand command = GameCommand.Create(GameCommandType.ScrapUnits);
                Engine_AIW2.Instance.DoForSelected(SelectionCommandScope.CurrentPlanet_UnlessViewingGalaxy, delegate(GameEntity ship)
                    {
                        command.RelatedEntityIDs.Add(ship.PrimaryKeyID);
                        return(DelReturn.Continue);
                    });
                if (command.RelatedEntityIDs.Count > 0)
                {
                    World_AIW2.Instance.QueueGameCommand(command, true);
                }
            }
            break;

            case "ToggleFRD":
            {
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                GameCommand command = GameCommand.Create(GameCommandType.SetBehavior);
                command.SentWithToggleSet_SetOrdersForProducedUnits = Engine_AIW2.Instance.SettingOrdersForProducedUnits;
                bool foundSomeOff = false;
                Engine_AIW2.Instance.DoForSelected(SelectionCommandScope.CurrentPlanet_UnlessViewingGalaxy, delegate(GameEntity selected)
                    {
                        if (selected.EntitySpecificOrders.Behavior != EntityBehaviorType.Attacker)
                        {
                            foundSomeOff = true;
                        }
                        return(DelReturn.Continue);
                    });
                EntityBehaviorType targetType = EntityBehaviorType.Stationary;
                if (foundSomeOff)
                {
                    targetType = EntityBehaviorType.Attacker;
                }
                command.RelatedMagnitude = (int)targetType;
                Engine_AIW2.Instance.DoForSelected(SelectionCommandScope.CurrentPlanet_UnlessViewingGalaxy, delegate(GameEntity ship)
                    {
                        command.RelatedEntityIDs.Add(ship.PrimaryKeyID);
                        return(DelReturn.Continue);
                    });
                if (command.RelatedEntityIDs.Count > 0)
                {
                    World_AIW2.Instance.QueueGameCommand(command, true);
                }
            }
            break;

            case "ToggleSettingOrdersForProducedUnits":
                Engine_AIW2.Instance.SettingOrdersForProducedUnits = !Engine_AIW2.Instance.SettingOrdersForProducedUnits;
                break;

            case "ToggleCombatSideBooleanFlag":
            {
                Planet      planet  = Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed();
                CombatSide  side    = planet.Combat.GetSideForWorldSide(World_AIW2.Instance.GetLocalPlayerSide());
                GameCommand command = GameCommand.Create(GameCommandType.ChangeCombatSideBooleanFlag);
                command.RelatedSide                  = side.WorldSide;
                command.RelatedPlanetIndex           = planet.PlanetIndex;
                command.RelatedCombatSideBooleanFlag = (CombatSideBooleanFlag)Int1;
                command.RelatedBool                  = !side.BooleanFlags[command.RelatedCombatSideBooleanFlag];
                World_AIW2.Instance.QueueGameCommand(command, true);
            }
            break;

            case "SelectAllMobileMilitary":
            case "SelectController":
            case "SelectSpaceDock":
            {
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide();
                if (localSide == null)
                {
                    return;
                }
                Planet planet = Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed();
                if (planet == null)
                {
                    return;
                }
                EntityRollupType rollup   = EntityRollupType.None;
                MetalFlowPurpose flowType = MetalFlowPurpose.None;
                switch (InputActionInternalName)
                {
                case "SelectAllMobileMilitary":
                    rollup = EntityRollupType.MobileCombatants;
                    break;

                case "SelectController":
                    rollup = EntityRollupType.Controllers;
                    break;

                case "SelectSpaceDock":
                    rollup   = EntityRollupType.HasAnyMetalFlows;
                    flowType = MetalFlowPurpose.BuildingShipsInternally;
                    break;

                default:
                    return;
                }

                bool unselectingInstead = false;
                if (Engine_AIW2.Instance.PresentationLayer.GetAreInputFlagsActive(ArcenInputFlags.Additive))
                {
                }
                else if (Engine_AIW2.Instance.PresentationLayer.GetAreInputFlagsActive(ArcenInputFlags.Subtractive))
                {
                    unselectingInstead = true;
                }
                else
                {
                    Engine_AIW2.Instance.ClearSelection(SelectionCommandScope.CurrentPlanet_UnlessViewingGalaxy);
                }

                for (int i = 0; i < planet.Combat.Sides.Count; i++)
                {
                    CombatSide side = planet.Combat.Sides[i];
                    if (!side.WorldSide.ControlledByPlayerAccounts.Contains(PlayerAccount.Local.PlayerPrimaryKeyID))
                    {
                        continue;
                    }
                    side.Entities.DoForEntities(rollup, delegate(GameEntity entity)
                        {
                            if (flowType != MetalFlowPurpose.None &&
                                entity.TypeData.MetalFlows[flowType] == null)
                            {
                                return(DelReturn.Continue);
                            }
                            if (unselectingInstead)
                            {
                                entity.Unselect();
                            }
                            else
                            {
                                entity.Select();
                            }
                            return(DelReturn.Continue);
                        });
                }
            }
            break;

            case "IncreaseFrameSize":
            case "DecreaseFrameSize":
            {
                GameCommand command = GameCommand.Create(GameCommandType.ChangeFrameSize);
                command.RelatedMagnitude = 1;
                if (InputActionInternalName == "DecreaseFrameSize")
                {
                    command.RelatedMagnitude = -command.RelatedMagnitude;
                }
                World_AIW2.Instance.QueueGameCommand(command, true);
            }
            break;

            case "IncreaseFrameFrequency":
            case "DecreaseFrameFrequency":
            {
                GameCommand command = GameCommand.Create(GameCommandType.ChangeFrameFrequency);
                command.RelatedMagnitude = 1;
                if (InputActionInternalName == "DecreaseFrameFrequency")
                {
                    command.RelatedMagnitude = -command.RelatedMagnitude;
                }
                World_AIW2.Instance.QueueGameCommand(command, true);
            }
            break;

            case "ShowShipRanges_Selected":
                ArcenInput_AIW2.ShouldShowShipRanges_Selected = true;
                break;

            case "ShowShipRanges_Hovered":
                ArcenInput_AIW2.ShouldShowShipRanges_Hovered = true;
                break;

            case "ShowShipRanges_All":
                ArcenInput_AIW2.ShouldShowShipRanges_All = true;
                break;

            case "ShowShipOrders":
                ArcenInput_AIW2.ShouldShowShipOrders = true;
                break;

            case "SelectBuilder":
            {
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide();
                if (localSide == null)
                {
                    return;
                }
                Planet planet = Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed();
                if (planet == null)
                {
                    return;
                }

                GameEntity currentBuilder = null;
                if (Engine_AIW2.Instance.GetHasSelection(SelectionCommandScope.CurrentPlanet_UnlessViewingGalaxy))
                {
                    currentBuilder = ArcenExternalUIUtilities.GetEntityToUseForBuildMenu();
                    if (currentBuilder != null)
                    {
                        Engine_AIW2.Instance.ClearSelection(SelectionCommandScope.CurrentPlanet_UnlessViewingGalaxy);
                    }
                }

                Window_InGameBottomMenu.Instance.CloseAllExpansions();

                CombatSide side         = planet.Combat.GetSideForWorldSide(localSide);
                bool       foundCurrent = false;
                GameEntity newBuilder   = null;
                GameEntity firstBuilder = null;
                side.Entities.DoForEntities(GameEntityCategory.Ship, delegate(GameEntity entity)
                    {
                        if (entity.TypeData.BuildMenus == null || entity.TypeData.BuildMenus.Count <= 0)
                        {
                            return(DelReturn.Continue);
                        }
                        if (firstBuilder == null)
                        {
                            firstBuilder = entity;
                        }
                        if (entity == currentBuilder)
                        {
                            foundCurrent = true;
                        }
                        else if (foundCurrent)
                        {
                            newBuilder = entity;
                            return(DelReturn.Break);
                        }
                        return(DelReturn.Continue);
                    });
                if (newBuilder == null && firstBuilder != null)
                {
                    newBuilder = firstBuilder;
                }
                if (newBuilder != null)
                {
                    newBuilder.Select();
                    if (!Window_InGameBuildTabMenu.Instance.IsOpen)
                    {
                        Window_InGameCommandsMenu.bToggleBuildMenu.Instance.HandleClick();
                    }
                }
            }
            break;

            case "OpenTechMenu":
            case "ClearMenus":
                if (!World.Instance.IsLoaded)
                {
                    return;
                }
                ToggleableWindowController window;
                switch (InputActionInternalName)
                {
                case "OpenTechMenu":
                    window = Window_InGameTechTabMenu.Instance;
                    break;

                case "ClearMenus":
                    window = null;
                    break;

                default:
                    return;
                }
                bool closing = window == null || window.IsOpen;
                Engine_AIW2.Instance.ClearSelection(SelectionCommandScope.CurrentPlanet_UnlessViewingGalaxy);
                Window_InGameBottomMenu.Instance.CloseAllExpansions();
                if (!closing)
                {
                    Window_InGameBottomMenu.bToggleMasterMenu.Instance.HandleClick();

                    switch (InputActionInternalName)
                    {
                    case "OpenTechMenu":
                        Window_InGameMasterMenu.bToggleTechMenu.Instance.HandleClick();
                        break;

                    default:
                        return;
                    }
                }
                break;
            }
        }
            public override void UpdateContent(ArcenUIWrapperedUnityImage Image, ArcenUI_Image.SubImageGroup _SubImages, SubTextGroup _SubTexts)
            {
                this.SubImages = _SubImages;
                this.SubTexts  = _SubTexts;
                GameEntityTypeData typeData = this.TypeToBuild;

                if (typeData == null)
                {
                    return;
                }

                WorldSide localSide = World_AIW2.Instance.GetLocalPlayerSide();

                //Planet planet = Engine_AIW2.Instance.NonSim_GetPlanetBeingCurrentlyViewed();
                //CombatSide localCombatSide = planet.Combat.GetSideForWorldSide( localSide );

                if (GameEntity.CurrentlyHoveredOver != null)
                {
                    this.PanelMode = Mode.ActualUnit;
                }
                else if (Window_InGameTechTabMenu.Instance.IsOpen)
                {
                    this.PanelMode = Mode.Tech;
                }
                else if (Window_InGameBuildTabMenu.Instance.IsOpen)
                {
                    this.PanelMode = Mode.Build;
                }

                TextId.SubjectSummary.Set(typeData.Name, string.Empty);

                try
                {
                    int markLevel = typeData.Balance_MarkLevel == null ? 0 : typeData.Balance_MarkLevel.Ordinal;
                    if (markLevel <= 0)
                    {
                        ImageId.MarkLevel.Hide();
                    }
                    else
                    {
                        ImageId.MarkLevel.Set(Window_InGameOutlineSidebar.Sprite_MarkLevels[markLevel], string.Empty);
                    }

                    if (this.PanelMode == Mode.Tech && typeData.TechPrereq != null)
                    {
                        bool unlocked = localSide.GetHasResearched(typeData.TechPrereq);
                        ImageId.Locked.ChangeVisibility(!unlocked);
                        ImageId.Unlocked.ChangeVisibility(unlocked);
                        ImageId.Science.Show();
                        TextId.Science.Set(typeData.TechPrereq.ScienceCost, string.Empty);
                    }
                    else
                    {
                        ImageId.Locked.Hide();
                        ImageId.Unlocked.Hide();
                        ImageId.Science.Hide();
                        TextId.Science.Hide();
                    }

                    if (typeData.BalanceStats.SquadFuelConsumption > 0)
                    {
                        ImageId.Fuel.Show();
                        ImageId.Power.Hide();
                        TextId.FuelOrPower.Set(typeData.BalanceStats.SquadFuelConsumption, string.Empty);
                    }
                    else if (typeData.BalanceStats.SquadPowerConsumption > 0)
                    {
                        ImageId.Fuel.Hide();
                        ImageId.Power.Show();
                        TextId.FuelOrPower.Set(typeData.BalanceStats.SquadPowerConsumption, string.Empty);
                    }
                    else
                    {
                        ImageId.Fuel.Hide();
                        ImageId.Power.Hide();
                        TextId.FuelOrPower.Hide();
                    }

                    if (typeData.BalanceStats.SquadMetalCost > 0)
                    {
                        ImageId.Metal.Show();
                        TextId.Metal.Set(typeData.BalanceStats.SquadMetalCost, string.Empty);
                    }
                    else
                    {
                        ImageId.Metal.Hide();
                        TextId.Metal.Hide();
                    }

                    int cap = typeData.BalanceStats.SquadsPerCap;
                    if (cap <= 0)
                    {
                        ImageId.Cap.Hide();
                        TextId.Cap.Hide();
                    }
                    else
                    {
                        ImageId.Cap.Show();
                        TextId.Cap.Set(cap, string.Empty);
                    }

                    ImageId.Strength.Show();
                    TextId.Strength.Set(typeData.BalanceStats.StrengthPerSquad.IntValue, string.Empty);

                    SystemEntry.SubEntry mainOffensiveWeaponSystemSubEntry = null;
                    EntitySystemTypeData cloakSystem   = null;
                    EntitySystemTypeData tachyonSystem = null;
                    EntitySystemTypeData tractorSystem = null;
                    EntitySystemTypeData gravitySystem = null;
                    for (int i = 0; i < typeData.SystemEntries.Count; i++)
                    {
                        SystemEntry entry = typeData.SystemEntries[i];
                        if (entry.SubEntries.Count <= 0)
                        {
                            continue;
                        }
                        SystemEntry.SubEntry subEntry = entry.SubEntries[0];
                        if (mainOffensiveWeaponSystemSubEntry == null && subEntry.GetDPS() > 0)
                        {
                            mainOffensiveWeaponSystemSubEntry = subEntry;
                        }
                        EntitySystemTypeData systemData = subEntry.SystemData;
                        if (cloakSystem == null && subEntry.BalanceStats.SquadCloakingPoints > 0)
                        {
                            cloakSystem = systemData;
                        }
                        if (tachyonSystem == null && subEntry.BalanceStats.TachyonPoints > 0)
                        {
                            tachyonSystem = systemData;
                        }
                        if (tractorSystem == null && subEntry.BalanceStats.TractorPoints > 0)
                        {
                            tractorSystem = systemData;
                        }
                        if (gravitySystem == null && subEntry.BalanceStats.GravityPoints > 0)
                        {
                            gravitySystem = systemData;
                        }
                    }

                    if (mainOffensiveWeaponSystemSubEntry != null)
                    {
                        SystemEntry.SubEntry systemSubEntry = mainOffensiveWeaponSystemSubEntry;
                        EntitySystemTypeData systemData     = systemSubEntry.SystemData;
                        Balance_WeaponType   weaponData     = systemData.Balance_WeaponType;

                        ImageId.Attack.Set(systemData.Balance_WeaponType.CounterType);
                        TextId.Attack.Set(systemSubEntry.GetDPS().IntValue, systemData.Balance_WeaponType.CounterType.StatTooltip);
                        ImageId.Range.Set(weaponData.Range);
                        ImageId.EngineDamage.Set(weaponData.Balance_EngineDamageType);
                        ImageId.Paralysis.Set(weaponData.Balance_ParalysisClass);
                        ImageId.Ion.Set(weaponData.Balance_IonClass);
                        ImageId.Implosion.Set(weaponData.Balance_ImplosionClass);
                        ImageId.Nuclear.Set(systemData.Balance_NuclearClass);
                    }
                    else
                    {
                        ImageId.Attack.Hide();
                        TextId.Attack.Hide();
                        ImageId.Range.Hide();
                        ImageId.EngineDamage.Hide();
                        ImageId.Paralysis.Hide();
                        ImageId.Ion.Hide();
                        ImageId.Implosion.Hide();
                        ImageId.Nuclear.Hide();
                    }

                    ImageId.Defense.Set(typeData.Balance_Defense);

                    int        totalMaxHP = (typeData.BalanceStats.HullPoints + typeData.BalanceStats.ShieldPoints) * typeData.Balance_ShipsPerSquad;
                    GameEntity entity     = GameEntity.CurrentlyHoveredOver;
                    if (this.PanelMode == Mode.ActualUnit && entity != null && (entity.HullPointsLost > 0 || entity.ShieldPointsLost > 0 || entity.SquadShipsLost > 0 || entity.SelfBuildingMetalRemaining > 0))
                    {
                        float percent;
                        if (entity.SelfBuildingMetalRemaining <= 0)
                        {
                            int totalCurrentHP = (typeData.BalanceStats.HullPoints + typeData.BalanceStats.ShieldPoints) * (typeData.Balance_ShipsPerSquad - 1);
                            totalCurrentHP += (entity.GetCurrentHullPoints() + entity.GetCurrentShieldPoints());
                            percent         = ((float)totalCurrentHP / (float)totalMaxHP) * 100;
                        }
                        else
                        {
                            percent = (1f - ((float)entity.SelfBuildingMetalRemaining / (float)typeData.BalanceStats.SquadMetalCost)) * 100;
                        }
                        string percentMask;
                        if (entity.SelfBuildingMetalRemaining > 0 || entity.HasNotYetBeenFullyClaimed)
                        {
                            percentMask = "#,##0.0";
                        }
                        else
                        {
                            percentMask = "#,##0";
                        }
                        int    totalHPForDisplay        = totalMaxHP;
                        string suffix                   = ArcenExternalUIUtilities.GetRoundedNumberWithSuffix(ref totalHPForDisplay, true);
                        ArcenCharacterBuffer textBuffer = new ArcenCharacterBuffer();
                        textBuffer.Add(totalHPForDisplay.ToString("#,##0"));
                        textBuffer.Add(suffix);
                        textBuffer.Add(" (");
                        textBuffer.Add(percent.ToString(percentMask));
                        textBuffer.Add("%)");
                        string text = textBuffer.ToString();
                        TextId.Defense.Set(text, typeData.Balance_Defense.StatTooltip);
                    }
                    else
                    {
                        TextId.Defense.Set(totalMaxHP, typeData.Balance_Defense.StatTooltip);
                    }

                    ImageId.Speed.Set(typeData.Balance_Speed);
                    ImageId.EngineDamageResistance.Set(typeData.Balance_EngineHealthType);
                    ImageId.ParalysisResistance.Set(typeData.Balance_ParalysisResistance);
                    ImageId.IonResistance.Set(typeData.Balance_IonResistance);
                    ImageId.ImplosionResistance.Set(typeData.Balance_ImplosionResistance);
                    ImageId.NuclearResistance.Set(typeData.Balance_NuclearResistance);

                    ImageId.Cloak.Set(cloakSystem == null ? null : cloakSystem.Balance_CloakingType);
                    ImageId.Tachyon.Set(tachyonSystem == null ? null : tachyonSystem.Balance_TachyonType);
                    ImageId.Tractor.Set(tractorSystem == null ? null : tractorSystem.Balance_TractorType);
                    ImageId.TractorResistance.Set(typeData.Balance_TractorResistanceType);
                    ImageId.Gravity.Set(gravitySystem == null ? null : gravitySystem.Balance_GravityType);
                    ImageId.GravityResistance.Set(typeData.Balance_GravityResistanceType);

                    TextId.Description.Set(typeData.Description, string.Empty);
                }
                catch (Exception e)
                {
                    ArcenDebugging.ArcenDebugLog("Exception in UpdateContent after " + (LastWrittenWasImageInsteadOfText ? "image " + LastImageIDWritten : "text " + LastTextIDWritten) + ":" + e.ToString(), Verbosity.ShowAsError);
                }
            }