Beispiel #1
0
        public void GetMissingComponents(Dictionary <string, int> addToDictionary, MyConstructionStockpile availableItems = null)
        {
            Dictionary <string, int> dictionary;
            string str2;
            int    topGroupIndex = this.m_topGroupIndex;

            MyCubeBlockDefinition.Component component = this.m_blockDefinition.Components[topGroupIndex];
            int num2 = this.m_topComponentIndex + 1;

            if (this.IsFullyDismounted)
            {
                num2--;
            }
            if (num2 < component.Count)
            {
                string subtypeName = component.Definition.Id.SubtypeName;
                if (!addToDictionary.ContainsKey(subtypeName))
                {
                    addToDictionary[subtypeName] = component.Count - num2;
                }
                else
                {
                    dictionary        = addToDictionary;
                    str2              = subtypeName;
                    dictionary[str2] += component.Count - num2;
                }
            }
            topGroupIndex++;
            while (topGroupIndex < this.m_blockDefinition.Components.Length)
            {
                component = this.m_blockDefinition.Components[topGroupIndex];
                string subtypeName = component.Definition.Id.SubtypeName;
                if (!addToDictionary.ContainsKey(subtypeName))
                {
                    addToDictionary[subtypeName] = component.Count;
                }
                else
                {
                    dictionary        = addToDictionary;
                    str2              = subtypeName;
                    dictionary[str2] += component.Count;
                }
                topGroupIndex++;
            }
            if (availableItems != null)
            {
                for (topGroupIndex = 0; topGroupIndex < addToDictionary.Keys.Count; topGroupIndex++)
                {
                    string subtypeName = addToDictionary.Keys.ElementAt <string>(topGroupIndex);
                    dictionary        = addToDictionary;
                    str2              = subtypeName;
                    dictionary[str2] -= availableItems.GetItemAmount(new MyDefinitionId(typeof(MyObjectBuilder_Component), subtypeName), MyItemFlags.None);
                    if (addToDictionary[subtypeName] <= 0)
                    {
                        addToDictionary.Remove(subtypeName);
                        topGroupIndex--;
                    }
                }
            }
        }
        public bool CanContinueBuild(MyInventory inventory, MyConstructionStockpile stockpile)
        {
            if (IsFullIntegrity)
            {
                return(false);
            }
            float topIntegrity = GetTopComponentIntegrity();

            if (topIntegrity < m_blockDefinition.Components[m_topGroupIndex].Definition.MaxIntegrity)
            {
                return(true);
            }

            int nextCompoGroup = m_topGroupIndex;

            if (m_topComponentIndex == m_blockDefinition.Components[nextCompoGroup].Count - 1)
            {
                nextCompoGroup++;
            }

            var componentDefinition = m_blockDefinition.Components[nextCompoGroup].Definition;

            if (stockpile != null && stockpile.GetItemAmount(componentDefinition.Id) > 0)
            {
                return(true);
            }

            if (inventory != null && inventory.GetItemAmount(componentDefinition.Id) > 0)
            {
                return(true);
            }
            return(false);
        }
        public void GetMissingComponents(Dictionary <string, int> addToDictionary, MyConstructionStockpile availableItems = null)
        {
            int index      = m_topGroupIndex;
            var component  = m_blockDefinition.Components[index];
            int mountCount = m_topComponentIndex + 1;

            if (IsFullyDismounted)
            {
                mountCount--;
            }
            if (mountCount < component.Count)
            {
                string subTypeId = component.Definition.Id.SubtypeName;
                if (addToDictionary.ContainsKey(subTypeId))
                {
                    addToDictionary[subTypeId] += component.Count - mountCount;
                }
                else
                {
                    addToDictionary[subTypeId] = component.Count - mountCount;
                }
            }
            index++;
            for (; index < m_blockDefinition.Components.Length; index++)
            {
                component = m_blockDefinition.Components[index];
                string subTypeId = component.Definition.Id.SubtypeName;
                if (addToDictionary.ContainsKey(subTypeId))
                {
                    addToDictionary[subTypeId] += component.Count;
                }
                else
                {
                    addToDictionary[subTypeId] = component.Count;
                }
            }
            if (availableItems != null)
            {
                for (index = 0; index < addToDictionary.Keys.Count; index++)
                {
                    string key = addToDictionary.Keys.ElementAt(index);
                    addToDictionary[key] -= availableItems.GetItemAmount(new MyDefinitionId(typeof(MyObjectBuilder_Component), key));
                    if (addToDictionary[key] <= 0)
                    {
                        addToDictionary.Remove(key);
                        index--;
                    }
                }
            }
        }
Beispiel #4
0
 public bool CanContinueBuild(MyInventoryBase inventory, MyConstructionStockpile stockpile)
 {
     if (this.IsFullIntegrity)
     {
         return(false);
     }
     if (this.GetTopComponentIntegrity() >= this.m_blockDefinition.Components[this.m_topGroupIndex].Definition.MaxIntegrity)
     {
         int topGroupIndex = this.m_topGroupIndex;
         if (this.m_topComponentIndex == (this.m_blockDefinition.Components[topGroupIndex].Count - 1))
         {
             topGroupIndex++;
         }
         MyComponentDefinition definition = this.m_blockDefinition.Components[topGroupIndex].Definition;
         if ((stockpile == null) || (stockpile.GetItemAmount(definition.Id, MyItemFlags.None) <= 0))
         {
             return((inventory != null) && (MyCubeBuilder.BuildComponent.GetItemAmountCombined(inventory, definition.Id) > 0));
         }
     }
     return(true);
 }
 public void GetMissingComponents(Dictionary<string, int> addToDictionary, MyConstructionStockpile availableItems = null)
 {
     int index = m_topGroupIndex;
     var component = m_blockDefinition.Components[index];
     int mountCount = m_topComponentIndex + 1;
     if (IsFullyDismounted)
         mountCount--;
     if (mountCount < component.Count)
     {
         string subTypeId = component.Definition.Id.SubtypeName;
         if (addToDictionary.ContainsKey(subTypeId))
             addToDictionary[subTypeId] += component.Count - mountCount;
         else
             addToDictionary[subTypeId] = component.Count - mountCount;
     }
     index++;
     for (; index < m_blockDefinition.Components.Length; index++)
     {
         component = m_blockDefinition.Components[index];
         string subTypeId = component.Definition.Id.SubtypeName;
         if (addToDictionary.ContainsKey(subTypeId))
             addToDictionary[subTypeId] += component.Count;
         else
             addToDictionary[subTypeId] = component.Count;
     }
     if (availableItems != null)
         for (index = 0; index < addToDictionary.Keys.Count; index++ )
         {
             string key = addToDictionary.Keys.ElementAt(index);
             addToDictionary[key] -= availableItems.GetItemAmount(new MyDefinitionId(typeof(MyObjectBuilder_Component), key));
             if (addToDictionary[key] <= 0)
             {
                 addToDictionary.Remove(key);
                 index--;
             }
         }
 }
        public bool CanContinueBuild(MyInventory inventory, MyConstructionStockpile stockpile)
        {
            if (IsFullIntegrity)
                return false;
            float topIntegrity = GetTopComponentIntegrity();
            if (topIntegrity < m_blockDefinition.Components[m_topGroupIndex].Definition.MaxIntegrity)
                return true;

            int nextCompoGroup = m_topGroupIndex;
            if (m_topComponentIndex == m_blockDefinition.Components[nextCompoGroup].Count - 1)
            {
                nextCompoGroup++;
            }

            var componentDefinition = m_blockDefinition.Components[nextCompoGroup].Definition;
            if (stockpile != null && stockpile.GetItemAmount(componentDefinition.Id) > 0)
            {
                return true;
            }

            if (inventory != null && inventory.GetItemAmount(componentDefinition.Id) > 0)
            {
                return true;
            }
            return false;
        }