public static void LoadDefinition(this MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition, DictionaryReader <MyDefinitionId, int> materials, bool merge = true) { InitBlockInfo(blockInfo, definition); foreach (var material in materials) { var componentDefinition = MyDefinitionManager.Static.GetComponentDefinition(material.Key); var info = new MyHudBlockInfo.ComponentInfo(); if (componentDefinition == null) { MyPhysicalItemDefinition physicalDefinition = null; if (!MyDefinitionManager.Static.TryGetPhysicalItemDefinition(material.Key, out physicalDefinition)) { continue; } info.ComponentName = physicalDefinition.DisplayNameText; info.Icon = physicalDefinition.Icon; info.DefinitionId = physicalDefinition.Id; info.TotalCount = 1; } else { info.DefinitionId = componentDefinition.Id; info.ComponentName = componentDefinition.DisplayNameText; info.Icon = componentDefinition.Icon; info.TotalCount = material.Value; } blockInfo.Components.Add(info); } if (merge) { MergeSameComponents(blockInfo); } }
public static void LoadDefinition(this MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition, DictionaryReader<MyDefinitionId, int> materials, bool merge = true) { InitBlockInfo(blockInfo, definition); foreach (var material in materials) { var componentDefinition = MyDefinitionManager.Static.GetComponentDefinition(material.Key); var info = new MyHudBlockInfo.ComponentInfo(); if (componentDefinition == null) { MyPhysicalItemDefinition physicalDefinition = null; if (!MyDefinitionManager.Static.TryGetPhysicalItemDefinition(material.Key, out physicalDefinition)) continue; info.ComponentName = physicalDefinition.DisplayNameText; info.Icon = physicalDefinition.Icon; info.DefinitionId = physicalDefinition.Id; info.TotalCount = 1; } else { info.DefinitionId = componentDefinition.Id; info.ComponentName = componentDefinition.DisplayNameText; info.Icon = componentDefinition.Icon; info.TotalCount = material.Value; } blockInfo.Components.Add(info); } if (merge) MergeSameComponents(blockInfo, definition); }
public static void AddComponentsForBlock(this MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition) { for (int i = 0; i < definition.Components.Length; ++i) { var comp = definition.Components[i]; var info = new MyHudBlockInfo.ComponentInfo(); info.DefinitionId = comp.Definition.Id; info.ComponentName = comp.Definition.DisplayNameText; info.Icon = comp.Definition.Icon; info.TotalCount = comp.Count; blockInfo.Components.Add(info); } }
private static void AddComponentsForBlock(MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition) { for (int i = 0; i < definition.Components.Length; ++i) { var comp = definition.Components[i]; var info = new MyHudBlockInfo.ComponentInfo(); info.DefinitionId = comp.Definition.Id; info.ComponentName = comp.Definition.DisplayNameText; info.Icon = comp.Definition.Icon; info.TotalCount = comp.Count; blockInfo.Components.Add(info); } }
public static void LoadDefinition(this MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition, DictionaryReader<MyDefinitionId, int> materials, bool merge = true) { InitBlockInfo(blockInfo, definition); foreach (var material in materials) { var componentDefinition = MyDefinitionManager.Static.GetComponentDefinition(material.Key); var info = new MyHudBlockInfo.ComponentInfo(); info.DefinitionId = componentDefinition.Id; info.ComponentName = componentDefinition.DisplayNameText; info.Icon = componentDefinition.Icon; info.TotalCount = material.Value; blockInfo.Components.Add(info); } if (merge) MergeSameComponents(blockInfo, definition); }
public static void LoadDefinition(this MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition, DictionaryReader <MyDefinitionId, int> materials, bool merge = true) { InitBlockInfo(blockInfo, definition); foreach (var material in materials) { var componentDefinition = MyDefinitionManager.Static.GetComponentDefinition(material.Key); var info = new MyHudBlockInfo.ComponentInfo(); info.DefinitionId = componentDefinition.Id; info.ComponentName = componentDefinition.DisplayNameText; info.Icon = componentDefinition.Icon; info.TotalCount = material.Value; blockInfo.Components.Add(info); } if (merge) { MergeSameComponents(blockInfo, definition); } }
public static void LoadDefinition(this MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition, bool merge = true) { blockInfo.BlockName = definition.DisplayNameText; blockInfo.BlockIcon = definition.Icon; blockInfo.BlockIntegrity = 0; blockInfo.CriticalComponentIndex = -1; blockInfo.CriticalIntegrity = 0; blockInfo.OwnershipIntegrity = 0; blockInfo.MissingComponentIndex = -1; blockInfo.Components.Clear(); for (int i = 0; i < definition.Components.Length; ++i) { var comp = definition.Components[i]; var info = new MyHudBlockInfo.ComponentInfo(); info.ComponentName = comp.Definition.DisplayNameText; info.Icon = comp.Definition.Icon; info.TotalCount = comp.Count; blockInfo.Components.Add(info); } // Merge same components if (merge) { for (int i = definition.Components.Length - 1; i >= 0; i--) { for (int j = i - 1; j >= 0; j--) { if (definition.Components[i].Definition == definition.Components[j].Definition) { var info = blockInfo.Components[j]; info.TotalCount += blockInfo.Components[i].TotalCount; blockInfo.Components[j] = info; blockInfo.Components.RemoveAt(i); break; } } } } }
public static void LoadDefinition(this MyHudBlockInfo blockInfo, MyCubeBlockDefinition definition, bool merge = true) { blockInfo.BlockName = definition.DisplayNameText; blockInfo.BlockIcon = definition.Icon; blockInfo.BlockIntegrity = 0; blockInfo.CriticalComponentIndex = -1; blockInfo.CriticalIntegrity = 0; blockInfo.OwnershipIntegrity = 0; blockInfo.MissingComponentIndex = -1; blockInfo.Components.Clear(); for (int i = 0; i < definition.Components.Length; ++i) { var comp = definition.Components[i]; var info = new MyHudBlockInfo.ComponentInfo(); info.ComponentName = comp.Definition.DisplayNameText; info.Icon = comp.Definition.Icon; info.TotalCount = comp.Count; blockInfo.Components.Add(info); } // Merge same components if (merge) { for (int i = definition.Components.Length - 1; i >= 0; i--) { for (int j = i - 1; j >= 0; j--) { if (definition.Components[i].Definition == definition.Components[j].Definition) { var info = blockInfo.Components[j]; info.TotalCount += blockInfo.Components[i].TotalCount; blockInfo.Components[j] = info; blockInfo.Components.RemoveAt(i); break; } } } } }
private static void AddBlockComponent(MyHudBlockInfo hudInfo, MyComponentStack.GroupInfo groupInfo, MyInventoryBase availableInventory) { var componentInfo = new MyHudBlockInfo.ComponentInfo(); componentInfo.DefinitionId = groupInfo.Component.Id; componentInfo.ComponentName = groupInfo.Component.DisplayNameText; componentInfo.Icons = groupInfo.Component.Icons; componentInfo.TotalCount = groupInfo.TotalCount; componentInfo.MountedCount = groupInfo.MountedCount; if (availableInventory != null) componentInfo.AvailableAmount = (int)MyCubeBuilder.BuildComponent.GetItemAmountCombined(availableInventory, groupInfo.Component.Id); hudInfo.Components.Add(componentInfo); }
public static void SetBlockComponents(MyHudBlockInfo hudInfo, MySlimBlock block, MyInventoryBase availableInventory = null) { hudInfo.Components.Clear(); for (int i = 0; i < block.ComponentStack.GroupCount; i++) { var groupInfo = block.ComponentStack.GetGroupInfo(i); var componentInfo = new MyHudBlockInfo.ComponentInfo(); componentInfo.DefinitionId = groupInfo.Component.Id; componentInfo.ComponentName = groupInfo.Component.DisplayNameText; componentInfo.Icon = groupInfo.Component.Icon; componentInfo.TotalCount = groupInfo.TotalCount; componentInfo.MountedCount = groupInfo.MountedCount; if (availableInventory != null) componentInfo.AvailableAmount = (int)availableInventory.GetItemAmount(groupInfo.Component.Id); hudInfo.Components.Add(componentInfo); } 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; } } } } }
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); } }