/// <summary>
	    /// Computes number of groups that have enough energy to work.
	    /// </summary>
	    public void UpdateHud(MyHudSinkGroupInfo info)
	    {
		    bool isWorking = true;
		    int workingGroupCount = 0;
		    int i = 0;
		    int typeIndex;
            if (!TryGetTypeIndex(ElectricityId, out typeIndex))
                return;
			for (; i < m_dataPerType[typeIndex].SinkDataByPriority.Length; ++i)
		    {
			    if (isWorking &&
					m_dataPerType[typeIndex].SinkDataByPriority[i].RemainingAvailableResource < m_dataPerType[typeIndex].SinkDataByPriority[i].RequiredInput &&
					!m_dataPerType[typeIndex].SinkDataByPriority[i].IsAdaptible)
				    isWorking = false;

			    if (isWorking)
				    ++workingGroupCount;

				info.SetGroupDeficit(i, Math.Max(m_dataPerType[typeIndex].SinkDataByPriority[i].RequiredInput - m_dataPerType[typeIndex].SinkDataByPriority[i].RemainingAvailableResource, 0.0f));
		    }

		    info.WorkingGroupCount = workingGroupCount;
	    }
예제 #2
0
 private void DrawPowerGroupInfo(MyHudSinkGroupInfo info)
 {
     var fsRect = MyGuiManager.GetSafeFullscreenRectangle();
     float namesOffset = -0.25f / (fsRect.Width / (float)fsRect.Height);
     var posValuesBase = new Vector2(0.985f, 0.65f); // coordinates in SafeFullscreenRectangle, but DrawString works with SafeGuiRectangle.
     var posNamesBase = new Vector2(posValuesBase.X + namesOffset, posValuesBase.Y);
     var posValues = ConvertHudToNormalizedGuiPosition(ref posValuesBase);
     var posNames = ConvertHudToNormalizedGuiPosition(ref posNamesBase);
     info.Data.DrawBottomUp(posNames, posValues, m_textScale);
 }