Beispiel #1
0
 private bool CheckOrMountFirstComponent(MyConstructionStockpile stockpile = null)
 {
     if (this.Integrity <= 7.629511E-06f)
     {
         MyComponentDefinition definition = this.m_blockDefinition.Components[0].Definition;
         if ((stockpile != null) && !stockpile.RemoveItems(1, definition.Id, MyItemFlags.None))
         {
             return(false);
         }
         this.Integrity = 1.525902E-05f;
         this.UpdateBuildIntegrityUp();
     }
     return(true);
 }
        private bool CheckOrMountFirstComponent(MyConstructionStockpile stockpile = null)
        {
            if (Integrity > MOUNT_THRESHOLD / 2)
            {
                return(true);
            }
            var firstComponent = m_blockDefinition.Components[0].Definition;

            if (stockpile == null || stockpile.RemoveItems(1, firstComponent.Id))
            {
                Integrity = MOUNT_THRESHOLD;
                UpdateBuildIntegrityUp();
                return(true);
            }
            return(false);
        }
Beispiel #3
0
 private void IncreaseMountLevelInternal(float mountAmount, MyConstructionStockpile stockpile = null)
 {
     if (this.CheckOrMountFirstComponent(stockpile))
     {
         float topComponentIntegrity = this.GetTopComponentIntegrity();
         float maxIntegrity          = this.m_blockDefinition.Components[this.m_topGroupIndex].Definition.MaxIntegrity;
         int   topGroupIndex         = this.m_topGroupIndex;
         int   topComponentIndex     = this.m_topComponentIndex;
         while (mountAmount > 0f)
         {
             float num5 = maxIntegrity - topComponentIntegrity;
             if (mountAmount < num5)
             {
                 this.Integrity += mountAmount;
                 this.UpdateBuildIntegrityUp();
                 return;
             }
             this.Integrity += num5 + 1.525902E-05f;
             mountAmount    -= num5 + 1.525902E-05f;
             if ((topComponentIndex + 1) >= this.m_blockDefinition.Components[this.m_topGroupIndex].Count)
             {
                 topGroupIndex++;
                 topComponentIndex = 0;
             }
             if (topGroupIndex == this.m_blockDefinition.Components.Length)
             {
                 this.Integrity = this.MaxIntegrity;
                 this.UpdateBuildIntegrityUp();
                 return;
             }
             MyComponentDefinition definition = this.m_blockDefinition.Components[topGroupIndex].Definition;
             if ((stockpile != null) && !stockpile.RemoveItems(1, definition.Id, MyItemFlags.None))
             {
                 this.Integrity -= 1.525902E-05f;
                 this.UpdateBuildIntegrityUp();
                 return;
             }
             this.UpdateBuildIntegrityUp();
             this.SetTopIndex(topGroupIndex, topComponentIndex);
             topComponentIntegrity = 1.525902E-05f;
             maxIntegrity          = this.m_blockDefinition.Components[topGroupIndex].Definition.MaxIntegrity;
         }
     }
 }
        private void IncreaseMountLevelInternal(float mountAmount, MyConstructionStockpile stockpile = null)
        {
            Debug.Assert(BuildIntegrity >= Integrity, "Integrity of component stack is larger than build integrity");

            if (!CheckOrMountFirstComponent(stockpile))
            {
                return;
            }

            float topIntegrity     = GetTopComponentIntegrity();
            float maxCompIntegrity = m_blockDefinition.Components[m_topGroupIndex].Definition.MaxIntegrity;
            int   groupIndex       = (int)m_topGroupIndex;
            int   compIndex        = (int)m_topComponentIndex;

            while (mountAmount > 0)
            {
                float toBuild = maxCompIntegrity - topIntegrity;

                if (mountAmount < toBuild)
                {
                    Integrity += mountAmount;
                    UpdateBuildIntegrityUp();
                    break;
                }

                Integrity   += toBuild + MOUNT_THRESHOLD;
                mountAmount -= toBuild + MOUNT_THRESHOLD;

                ++compIndex;
                if (compIndex >= m_blockDefinition.Components[m_topGroupIndex].Count)
                {
                    ++groupIndex;
                    compIndex = 0;
                }
                // Fully built
                if (groupIndex == m_blockDefinition.Components.Length)
                {
                    Integrity = MaxIntegrity;
                    UpdateBuildIntegrityUp();
                    break;
                }
                // We don't have the next item
                var nextComponent = m_blockDefinition.Components[groupIndex].Definition;
                if (stockpile != null && !stockpile.RemoveItems(1, nextComponent.Id))
                {
                    Integrity -= MOUNT_THRESHOLD;
                    UpdateBuildIntegrityUp();
                    break;
                }
                else
                {
                    UpdateBuildIntegrityUp();
                }

                SetTopIndex(groupIndex, compIndex);
                topIntegrity     = MOUNT_THRESHOLD;
                maxCompIntegrity = m_blockDefinition.Components[groupIndex].Definition.MaxIntegrity;
            }

            return;
        }
        private void IncreaseMountLevelInternal(float mountAmount, MyConstructionStockpile stockpile = null)
        {
            Debug.Assert(BuildIntegrity >= Integrity, "Integrity of component stack is larger than build integrity");

            if (!CheckOrMountFirstComponent(stockpile))
            {
                return;
            }

            float topIntegrity = GetTopComponentIntegrity();
            float maxCompIntegrity = m_blockDefinition.Components[m_topGroupIndex].Definition.MaxIntegrity;
            int groupIndex = (int)m_topGroupIndex;
            int compIndex = (int)m_topComponentIndex;

            while (mountAmount > 0) {
                float toBuild = maxCompIntegrity - topIntegrity;

                if (mountAmount < toBuild)
                {
                    Integrity += mountAmount;
                    UpdateBuildIntegrityUp();
                    break;
                }

                Integrity += toBuild + MOUNT_THRESHOLD;
                mountAmount -= toBuild + MOUNT_THRESHOLD;

                ++compIndex;
                if (compIndex >= m_blockDefinition.Components[m_topGroupIndex].Count)
                {
                    ++groupIndex;
                    compIndex = 0;
                }
                // Fully built
                if (groupIndex == m_blockDefinition.Components.Length)
                {
                    Integrity = MaxIntegrity;
                    UpdateBuildIntegrityUp();
                    break;
                }
                // We don't have the next item
                var nextComponent = m_blockDefinition.Components[groupIndex].Definition;
                if (stockpile != null && !stockpile.RemoveItems(1, nextComponent.Id))
                {
                    Integrity -= MOUNT_THRESHOLD;
                    UpdateBuildIntegrityUp();
                    break;
                }
                else
                {
                    UpdateBuildIntegrityUp();
                }

                SetTopIndex(groupIndex, compIndex);
                topIntegrity = MOUNT_THRESHOLD;
                maxCompIntegrity = m_blockDefinition.Components[groupIndex].Definition.MaxIntegrity;
            }

            return;
        }
 private bool CheckOrMountFirstComponent(MyConstructionStockpile stockpile = null)
 {
     if (Integrity > MOUNT_THRESHOLD / 2)
     {
         return true;
     }
     var firstComponent = m_blockDefinition.Components[0].Definition;
     if (stockpile == null || stockpile.RemoveItems(1, firstComponent.Id))
     {
         Integrity = MOUNT_THRESHOLD;
         UpdateBuildIntegrityUp();
         return true;
     }
     return false;
 }