protected override void DrawHud() { MyHud.BlockInfo.Visible = false; if (m_targetProjectionCube == null || m_targetProjectionGrid == null) { base.DrawHud(); return; } var block = m_targetProjectionGrid.GetCubeBlock(m_targetProjectionCube); if (block == null) { base.DrawHud(); return; } // Get first block from compound. if (MyFakes.ENABLE_COMPOUND_BLOCKS && block.FatBlock is MyCompoundCubeBlock) { MyCompoundCubeBlock compoundBlock = block.FatBlock as MyCompoundCubeBlock; if (compoundBlock.GetBlocksCount() > 0) { block = compoundBlock.GetBlocks().First(); } else { Debug.Assert(false); } } MyHud.BlockInfo.Visible = true; MyHud.BlockInfo.MissingComponentIndex = 0; MyHud.BlockInfo.BlockName = block.BlockDefinition.DisplayNameText; MyHud.BlockInfo.BlockIcons = block.BlockDefinition.Icons; MyHud.BlockInfo.BlockIntegrity = 0.01f; MyHud.BlockInfo.CriticalIntegrity = block.BlockDefinition.CriticalIntegrityRatio; MyHud.BlockInfo.CriticalComponentIndex = block.BlockDefinition.CriticalGroup; MyHud.BlockInfo.OwnershipIntegrity = block.BlockDefinition.OwnershipIntegrityRatio; //SetBlockComponents(MyHud.BlockInfo, block); MyHud.BlockInfo.Components.Clear(); for (int i = 0; i < block.ComponentStack.GroupCount; i++) { var info = block.ComponentStack.GetGroupInfo(i); var component = new MyHudBlockInfo.ComponentInfo(); component.DefinitionId = info.Component.Id; component.ComponentName = info.Component.DisplayNameText; component.Icons = info.Component.Icons; component.TotalCount = info.TotalCount; component.MountedCount = 0; component.StockpileCount = 0; MyHud.BlockInfo.Components.Add(component); } }
protected void SetBlockComponents(MyHudBlockInfo hudInfo, MySlimBlock block) { hudInfo.Components.Clear(); for (int i = 0; i < block.ComponentStack.GroupCount; i++) { var info = block.ComponentStack.GetGroupInfo(i); var component = new MyHudBlockInfo.ComponentInfo(); component.ComponentName = info.Component.DisplayNameText; component.Icon = info.Component.Icon; component.TotalCount = info.TotalCount; component.MountedCount = info.MountedCount; hudInfo.Components.Add(component); } if (!block.StockpileEmpty) { // For each component foreach (var comp in block.BlockDefinition.Components) { // Get amount in stockpile int amount = block.GetConstructionStockpileItemAmount(comp.Definition.Id); for (int i = 0; amount > 0 && i < hudInfo.Components.Count; i++) { if (block.ComponentStack.GetGroupInfo(i).Component == comp.Definition) { if (block.ComponentStack.IsFullyDismounted) { return; } // Distribute amount in stockpile from bottom to top var info = hudInfo.Components[i]; int space = info.TotalCount - info.MountedCount; int movedItems = Math.Min(space, amount); info.StockpileCount = movedItems; amount -= movedItems; hudInfo.Components[i] = info; } } Debug.Assert(!Sync.IsServer || amount == 0, "There's more items in stockpile than necessary"); } } }