diff --git a/Utility Mods/MoA Fusion Systems/Data/ctf_score_background.sbc b/Utility Mods/MoA Fusion Systems/Data/HudTextures.sbc
similarity index 71%
rename from Utility Mods/MoA Fusion Systems/Data/ctf_score_background.sbc
rename to Utility Mods/MoA Fusion Systems/Data/HudTextures.sbc
index 0e6538197..dadd3556e 100644
--- a/Utility Mods/MoA Fusion Systems/Data/ctf_score_background.sbc
+++ b/Utility Mods/MoA Fusion Systems/Data/HudTextures.sbc
@@ -25,5 +25,17 @@
0.1
Textures\fusionBarBackground.dds
+
+
+ TransparentMaterialDefinition
+ HudBackground
+
+ false
+ 1
+ false
+ false
+ 0.1
+ Textures\HudBackground.dds
+
diff --git a/Utility Mods/MoA Fusion Systems/Data/Scripts/ModularAssemblies/HudHelpers/FusionWindow.cs b/Utility Mods/MoA Fusion Systems/Data/Scripts/ModularAssemblies/HudHelpers/FusionWindow.cs
new file mode 100644
index 000000000..8a8f76261
--- /dev/null
+++ b/Utility Mods/MoA Fusion Systems/Data/Scripts/ModularAssemblies/HudHelpers/FusionWindow.cs
@@ -0,0 +1,220 @@
+using Epstein_Fusion_DS.Communication;
+using Epstein_Fusion_DS.FusionParts;
+using Epstein_Fusion_DS.HeatParts;
+using RichHudFramework.UI;
+using RichHudFramework.UI.Rendering;
+using RichHudFramework.UI.Rendering.Client;
+using Sandbox.Game.Entities;
+using Sandbox.ModAPI;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using VRage.Game.Entity;
+using VRage.Game.ModAPI;
+using VRageMath;
+
+namespace Epstein_Fusion_DS.HudHelpers
+{
+ internal class FusionWindow : CamSpaceNode
+ {
+ private readonly TexturedBox _backgroundBox, _foregroundBox, _heatBox, _storBox;
+ private readonly Label _heatLabel, _storageLabel, _infoLabelLeft;
+
+ private readonly GlyphFormat _stdTextFormat = new GlyphFormat(color: HudConstants.HudTextColor, alignment: TextAlignment.Center, font: FontManager.GetFont("BI_Monospace"));
+ private readonly GlyphFormat _stdTextFormatInfo = new GlyphFormat(color: HudConstants.HudTextColor, textSize: 0.85f, alignment: TextAlignment.Left, font: FontManager.GetFont("BI_Monospace"));
+
+ public FusionWindow(HudParentBase parent) : base(parent)
+ {
+ RotationAxis = new Vector3(0, 1, 0);
+ RotationAngle = 0.25f;
+ TransformOffset = new Vector3D(-0.0675, -0.04, -0.05);
+
+ _backgroundBox = new TexturedBox(this)
+ {
+ Material = new Material("WhiteSquare", HudConstants.HudSize),
+ Size = HudConstants.HudSize,
+ Color = HudConstants.HudBackgroundColor,
+ IsMasking = true,
+ ZOffset = sbyte.MinValue,
+ Padding = Vector2.Zero,
+ };
+ _foregroundBox = new TexturedBox(this)
+ {
+ Material = new Material("HudBackground", new Vector2(400, 136)),
+ Size = HudConstants.HudSize,
+ ZOffset = sbyte.MaxValue,
+ };
+
+ _heatLabel = new Label(this)
+ {
+ Text = "00% HEAT",
+ Offset = new Vector2(0, 0),
+ Format = _stdTextFormat,
+ ZOffset = sbyte.MaxValue,
+ };
+ _storageLabel = new Label(this)
+ {
+ Text = "00% STOR",
+ Offset = new Vector2(0, -_backgroundBox.Size.Y/3),
+ Format = _stdTextFormat,
+ ZOffset = sbyte.MaxValue,
+ };
+
+ _infoLabelLeft = new Label(this)
+ {
+ Text = "100% INTEGRITY - ALL SYSTEMS NOMINAL",
+ Offset = new Vector2(0, _backgroundBox.Size.Y/3),
+ Format = _stdTextFormat,
+ ZOffset = sbyte.MaxValue,
+ };
+
+ _heatBox = new TexturedBox(_backgroundBox)
+ {
+ Material = new Material("WhiteSquare", new Vector2(384, 38) * HudConstants.HudSizeRatio),
+ Size = new Vector2(384, 38) * HudConstants.HudSizeRatio,
+ ParentAlignment = ParentAlignments.Left | ParentAlignments.Top | ParentAlignments.Inner,
+ Offset = new Vector2(8, -49) * HudConstants.HudSizeRatio,
+ ZOffset = 0,
+ Color = Color.Red,
+ };
+
+ _storBox = new TexturedBox(_backgroundBox)
+ {
+ Material = new Material("WhiteSquare", new Vector2(384, 38) * HudConstants.HudSizeRatio),
+ Size = new Vector2(384, 38) * HudConstants.HudSizeRatio,
+ ParentAlignment = ParentAlignments.Left | ParentAlignments.Top | ParentAlignments.Inner,
+ Offset = new Vector2(8, -95) * HudConstants.HudSizeRatio,
+ ZOffset = 0,
+ Color = Color.Orange,
+ };
+ }
+
+
+ private static ModularDefinitionApi ModularApi => Epstein_Fusion_DS.ModularDefinition.ModularApi;
+ private int _ticks = 0;
+ private bool _shouldHide;
+ private MyEntity3DSoundEmitter _soundEmitter = null;
+ private readonly MySoundPair _alertSound = new MySoundPair("ArcSoundBlockAlert2");
+
+ public void Update()
+ {
+ _ticks++;
+ var playerCockpit = MyAPIGateway.Session?.Player?.Controller?.ControlledEntity?.Entity as IMyShipController;
+
+ // Pulling the current HudState is SLOOOOWWWW, so we only pull it when tab is just pressed.
+ //if (MyAPIGateway.Input.IsNewKeyPressed(MyKeys.Tab))
+ // _shouldHide = MyAPIGateway.Session?.Config?.HudState != 1;
+
+ // Hide HUD element if the player isn't in a cockpit
+ if (playerCockpit == null || _shouldHide)
+ {
+ if (Visible) Visible = false;
+
+ if (_soundEmitter != null)
+ {
+ _soundEmitter.StopSound(true);
+ _soundEmitter = null;
+ }
+ return;
+ }
+
+ var playerGrid = playerCockpit.CubeGrid;
+
+ float totalFusionCapacity = 0;
+ float totalFusionGeneration = 0;
+ float totalFusionStored = 0;
+ float reactorIntegrity = 0;
+ int reactorCount = 0;
+
+ foreach (var system in SFusionManager.I.FusionSystems)
+ {
+ if (playerGrid != ModularApi.GetAssemblyGrid(system.Key))
+ continue;
+
+ totalFusionCapacity += system.Value.MaxPowerStored;
+ totalFusionGeneration += system.Value.PowerGeneration;
+ totalFusionStored += system.Value.PowerStored;
+ foreach (var reactor in system.Value.Reactors)
+ {
+ reactorIntegrity += reactor.Block.SlimBlock.Integrity/reactor.Block.SlimBlock.MaxIntegrity;
+ reactorCount++;
+ }
+ foreach (var thruster in system.Value.Thrusters)
+ {
+ reactorIntegrity += thruster.Block.SlimBlock.Integrity/thruster.Block.SlimBlock.MaxIntegrity;
+ reactorCount++;
+ }
+ }
+ reactorIntegrity /= reactorCount;
+
+ // Hide HUD element if the grid has no fusion systems (capacity is always >0 for a fusion system)
+ if (totalFusionCapacity == 0)
+ {
+ if (Visible) Visible = false;
+ return;
+ }
+
+ // Show otherwise
+ if (!Visible) Visible = true;
+
+ var heatPct = HeatManager.I.GetGridHeatLevel(playerGrid);
+
+ _heatBox.Width = 384 * HudConstants.HudSizeRatio.X * heatPct;
+ _heatBox.Color = new Color(heatPct, 1-heatPct, 0, 0.75f);
+
+ _storBox.Width = 384 * HudConstants.HudSizeRatio.X * (totalFusionStored / totalFusionCapacity);
+
+ _infoLabelLeft.Text = new RichText
+ {
+ {(reactorIntegrity*100).ToString("N0") + "%", _stdTextFormatInfo.WithColor(reactorIntegrity > 0.6 ? Color.White : Color.Red)},
+ {" INTEGRITY - ", _stdTextFormatInfo},
+ {GetNoticeText(heatPct, reactorIntegrity), GetNoticeFormat(heatPct, reactorIntegrity)},
+ };
+
+ _heatLabel.Text = $"{heatPct*100:N0}% HEAT";
+ _storageLabel.Text = $"{(totalFusionStored / totalFusionCapacity) * 100:N0}% STOR";
+
+ if (heatPct > 0.8f)
+ {
+ if (_soundEmitter == null)
+ {
+ _soundEmitter = new MyEntity3DSoundEmitter((MyEntity) playerCockpit.Entity)
+ {
+ CanPlayLoopSounds = true
+ };
+ _soundEmitter.PlaySound(_alertSound);
+ }
+ }
+ else
+ {
+ if (_soundEmitter != null)
+ {
+ _soundEmitter.StopSound(true);
+ _soundEmitter = null;
+ }
+ }
+ }
+
+ private string GetNoticeText(float heatPct, float integrityPct)
+ {
+ if (integrityPct < 0.1)
+ return "I DON'T WANT TO DIE.";
+ if (integrityPct < 0.5)
+ return "-!- REACTOR FAILURE -!-";
+ if (integrityPct < 0.6)
+ return "-!- SHUTDOWN IMMINENT -!-";
+ if (heatPct > 0.8)
+ return "! THERMAL DAMAGE !";
+ return "ALL SYSTEMS NOMINAL";
+ }
+
+ private GlyphFormat GetNoticeFormat(float heatPct, float integrityPct)
+ {
+ if (integrityPct < 0.6 || heatPct > 0.8)
+ return _stdTextFormatInfo.WithColor(Color.Red);
+ return _stdTextFormatInfo;
+ }
+ }
+}
diff --git a/Utility Mods/MoA Fusion Systems/Data/Scripts/ModularAssemblies/HudHelpers/HudConstants.cs b/Utility Mods/MoA Fusion Systems/Data/Scripts/ModularAssemblies/HudHelpers/HudConstants.cs
new file mode 100644
index 000000000..cab42a67e
--- /dev/null
+++ b/Utility Mods/MoA Fusion Systems/Data/Scripts/ModularAssemblies/HudHelpers/HudConstants.cs
@@ -0,0 +1,20 @@
+using RichHudFramework.UI.Rendering;
+using VRageMath;
+
+namespace Epstein_Fusion_DS.HudHelpers
+{
+ ///
+ /// HUD constants class for Fusion Systems
+ ///
+ public static class HudConstants
+ {
+ public static readonly Color HudBackgroundColor = new Color(255, 255, 255, 40);
+ public static readonly Color HudTextColor = Color.White;
+ public static Vector2 HudSize = new Vector2(300, 102);
+ public static Vector2 HudSizeRatio = HudSize / new Vector2(400, 136);
+
+ //public static Material BackgroundMaterial = new Material("HudBackground", new Vector2(435, 102));
+
+ //public static Vector2 HudAngle = new Vector2(
+ }
+}
diff --git a/Utility Mods/MoA Fusion Systems/Data/Scripts/ModularAssemblies/S_FusionPlayerHud.cs b/Utility Mods/MoA Fusion Systems/Data/Scripts/ModularAssemblies/S_FusionPlayerHud.cs
index e21fca76b..76f6d0a24 100644
--- a/Utility Mods/MoA Fusion Systems/Data/Scripts/ModularAssemblies/S_FusionPlayerHud.cs
+++ b/Utility Mods/MoA Fusion Systems/Data/Scripts/ModularAssemblies/S_FusionPlayerHud.cs
@@ -21,7 +21,7 @@ public class SFusionPlayerHud : MySessionComponentBase
public static SFusionPlayerHud I;
private int _ticks;
- private ConsumptionBar _consumptionBar;
+ private FusionWindow _fusionHud;
private static ModularDefinitionApi ModularApi => Epstein_Fusion_DS.ModularDefinition.ModularApi;
private static SFusionManager FusionManager => SFusionManager.I;
private static HeatManager HeatManager => HeatManager.I;
@@ -53,15 +53,17 @@ public override void UpdateAfterSimulation()
_ticks++;
try
{
- if (_consumptionBar == null && RichHudClient.Registered)
- _consumptionBar = new ConsumptionBar(HudMain.HighDpiRoot)
+ if (_fusionHud == null && RichHudClient.Registered)
+ {
+ _fusionHud = new FusionWindow(HudMain.HighDpiRoot)
{
Visible = true
- };
+ };
+ }
HeatManager.UpdateTick();
FusionManager.UpdateTick();
- _consumptionBar?.Update();
+ _fusionHud?.Update();
if (ModularApi.IsDebug())
{
diff --git a/Utility Mods/MoA Fusion Systems/Textures/HudBackground.dds b/Utility Mods/MoA Fusion Systems/Textures/HudBackground.dds
new file mode 100644
index 000000000..1e517cff8
Binary files /dev/null and b/Utility Mods/MoA Fusion Systems/Textures/HudBackground.dds differ
diff --git a/Utility Mods/MoA Fusion Systems/Textures/HudBackground.pdn b/Utility Mods/MoA Fusion Systems/Textures/HudBackground.pdn
new file mode 100644
index 000000000..5765d762b
Binary files /dev/null and b/Utility Mods/MoA Fusion Systems/Textures/HudBackground.pdn differ