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

            var ob = builder as MyObjectBuilder_FloraElementDefinition;

            AppliedGroups = new Dictionary <string, MyGroupedIds>();
            if (ob.AppliedGroups != null)
            {
                var          groups     = MyDefinitionManager.Static.GetGroupedIds("EnvGroups");
                MyGroupedIds groupedIds = null;
                foreach (var group in ob.AppliedGroups)
                {
                    if (groups.TryGetValue(group, out groupedIds))
                    {
                        AppliedGroups.Add(group, groupedIds);
                    }
                }
            }

            GrowthSteps = new List <GrowthStep>();
            if (ob.GrowthSteps != null)
            {
                foreach (var element in ob.GrowthSteps)
                {
                    GrowthSteps.Add(new GrowthStep(element.GroupInsId, element.Percent));
                }
            }

            if (ob.GatheredItem != null)
            {
                GatheredItemDefinition = ob.GatheredItem.Id;
                GatheredAmount         = ob.GatheredItem.Amount;
                IsGatherable           = true;
            }
            else
            {
                GatheredItemDefinition = new MyDefinitionId();
                GatheredAmount         = -1;
                IsGatherable           = false;
            }

            Regrowable        = ob.Regrowable;
            GrowTime          = ob.GrowTime;
            GatherableStep    = ob.GatherableStep;
            PostGatherStep    = ob.PostGatherStep;
            SpawnProbability  = ob.SpawnProbability;
            AreaTransformType = ob.AreaTransformType;
            DecayTime         = ob.DecayTime;
        }
示例#2
0
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);
            MyObjectBuilder_FloraElementDefinition definition = builder as MyObjectBuilder_FloraElementDefinition;

            this.AppliedGroups = new Dictionary <string, MyGroupedIds>();
            if (definition.AppliedGroups != null)
            {
                DictionaryValuesReader <string, MyGroupedIds> groupedIds = MyDefinitionManager.Static.GetGroupedIds("EnvGroups");
                MyGroupedIds result = null;
                foreach (string str in definition.AppliedGroups)
                {
                    if (groupedIds.TryGetValue(str, out result))
                    {
                        this.AppliedGroups.Add(str, result);
                    }
                }
            }
            this.GrowthSteps = new List <GrowthStep>();
            if (definition.GrowthSteps != null)
            {
                foreach (MyObjectBuilder_FloraElementDefinition.GrowthStep step in definition.GrowthSteps)
                {
                    this.GrowthSteps.Add(new GrowthStep(step.GroupInsId, step.Percent));
                }
            }
            if (definition.GatheredItem != null)
            {
                this.GatheredItemDefinition = definition.GatheredItem.Id;
                this.GatheredAmount         = definition.GatheredItem.Amount;
                this.IsGatherable           = true;
            }
            else
            {
                this.GatheredItemDefinition = new MyDefinitionId();
                this.GatheredAmount         = -1f;
                this.IsGatherable           = false;
            }
            this.Regrowable        = definition.Regrowable;
            this.GrowTime          = definition.GrowTime;
            this.GatherableStep    = definition.GatherableStep;
            this.PostGatherStep    = definition.PostGatherStep;
            this.SpawnProbability  = definition.SpawnProbability;
            this.AreaTransformType = definition.AreaTransformType;
            this.DecayTime         = definition.DecayTime;
        }