protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            MyObjectBuilder_ContainerTypeDefinition definition = builder as MyObjectBuilder_ContainerTypeDefinition;

            CountMin = definition.CountMin;
            CountMax = definition.CountMax;
            ItemsCumulativeFrequency = 0.0f;

            int i = 0;

            Items           = new ContainerTypeItem[definition.Items.Length];
            m_itemSelection = new bool[definition.Items.Length];
            foreach (var itemBuilder in definition.Items)
            {
                ContainerTypeItem item = new ContainerTypeItem();
                item.AmountMax    = MyFixedPoint.DeserializeStringSafe(itemBuilder.AmountMax);
                item.AmountMin    = MyFixedPoint.DeserializeStringSafe(itemBuilder.AmountMin);
                item.Frequency    = Math.Max(itemBuilder.Frequency, 0.0f);
                item.DefinitionId = itemBuilder.Id;

                ItemsCumulativeFrequency += item.Frequency;

                Items[i]           = item;
                m_itemSelection[i] = false;
                ++i;
            }

            m_tempCumulativeFreq = ItemsCumulativeFrequency;
        }
Exemple #2
0
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);
            MyObjectBuilder_ContainerTypeDefinition definition = builder as MyObjectBuilder_ContainerTypeDefinition;

            this.CountMin = definition.CountMin;
            this.CountMax = definition.CountMax;
            this.ItemsCumulativeFrequency = 0f;
            int index = 0;

            this.Items           = new ContainerTypeItem[definition.Items.Length];
            this.m_itemSelection = new bool[definition.Items.Length];
            foreach (MyObjectBuilder_ContainerTypeDefinition.ContainerTypeItem item in definition.Items)
            {
                ContainerTypeItem item2 = new ContainerTypeItem {
                    AmountMax    = MyFixedPoint.DeserializeStringSafe(item.AmountMax),
                    AmountMin    = MyFixedPoint.DeserializeStringSafe(item.AmountMin),
                    Frequency    = Math.Max(item.Frequency, 0f),
                    DefinitionId = item.Id
                };
                this.ItemsCumulativeFrequency += item2.Frequency;
                this.Items[index]              = item2;
                this.m_itemSelection[index]    = false;
                index++;
            }
            this.m_tempCumulativeFreq = this.ItemsCumulativeFrequency;
        }