Пример #1
0
        public override MyObjectBuilder_DefinitionBase GetObjectBuilder()
        {
            MyObjectBuilder_CubeBlockDefinition ob = (MyObjectBuilder_CubeBlockDefinition)base.GetObjectBuilder();

            ob.Size  = this.Size;
            ob.Model = this.Model;
            ob.UseModelIntersection = this.UseModelIntersection;
            ob.CubeSize             = this.CubeSize;
            ob.ModelOffset          = this.ModelOffset;
            ob.BlockTopology        = this.BlockTopology;
            ob.PhysicsOption        = this.PhysicsOption;
            ob.BlockPairName        = this.BlockPairName;
            ob.Center             = this.m_center;
            ob.MirroringX         = this.m_symmetryX;
            ob.MirroringY         = this.m_symmetryY;
            ob.MirroringZ         = this.m_symmetryZ;
            ob.DeformationRatio   = this.DeformationRatio;
            ob.EdgeType           = this.EdgeType;
            ob.AutorotateMode     = this.AutorotateMode;
            ob.MirroringBlock     = this.m_mirroringBlock;
            ob.MultiBlock         = this.MultiBlock;
            ob.GuiVisible         = this.GuiVisible;
            ob.Rotation           = this.Rotation;
            ob.Direction          = this.Direction;
            ob.Mirrored           = this.Mirrored;
            ob.BuildType          = this.BuildType;
            ob.GeneratedBlockType = this.GeneratedBlockType.ToString();
            ob.DamageEffectId     = this.DamageEffectID.HasValue ? this.DamageEffectID.Value : 0;
            ob.CompoundTemplates  = this.CompoundTemplates;
            ob.Icon = Icon;
            //ob.SubBlockDefinitions = SubBlockDefinitions;
            //ob.BlockVariants = BlockVariants;


            if (Components != null)
            {
                List <MyObjectBuilder_CubeBlockDefinition.CubeBlockComponent> compObs = new List <MyObjectBuilder_CubeBlockDefinition.CubeBlockComponent>();
                foreach (var comp in Components)
                {
                    var compOb = new MyObjectBuilder_CubeBlockDefinition.CubeBlockComponent();
                    compOb.Count   = (ushort)comp.Count;
                    compOb.Type    = comp.Definition.Id.TypeId;
                    compOb.Subtype = comp.Definition.Id.SubtypeName;
                    compObs.Add(compOb);
                }

                ob.Components = compObs.ToArray();
            }

            ob.CriticalComponent = new MyObjectBuilder_CubeBlockDefinition.CriticalPart()
            {
                Index   = 0,
                Subtype = ob.Components[0].Subtype,
                Type    = ob.Components[0].Type
            };

            List <MyObjectBuilder_CubeBlockDefinition.MountPoint> mountPoints = null;

            if (MountPoints != null)
            {
                mountPoints = new List <MyObjectBuilder_CubeBlockDefinition.MountPoint>();
                foreach (var mountPoint in MountPoints)
                {
                    MyObjectBuilder_CubeBlockDefinition.MountPoint mpOb = mountPoint.GetObjectBuilder(Size);
                    mountPoints.Add(mpOb);
                }

                ob.MountPoints = mountPoints.ToArray();
            }

            return(ob);
        }
        public override MyObjectBuilder_DefinitionBase GetObjectBuilder()
        {
            MyObjectBuilder_CubeBlockDefinition ob = (MyObjectBuilder_CubeBlockDefinition)base.GetObjectBuilder();

            ob.Size = this.Size;
            ob.Model = this.Model;
            ob.UseModelIntersection = this.UseModelIntersection;
            ob.CubeSize = this.CubeSize;
            ob.ModelOffset = this.ModelOffset;
            ob.BlockTopology = this.BlockTopology;
            ob.PhysicsOption = this.PhysicsOption;
            ob.BlockPairName = this.BlockPairName;
            ob.Center = this.m_center;
            ob.MirroringX = this.m_symmetryX;
            ob.MirroringY = this.m_symmetryY;
            ob.MirroringZ = this.m_symmetryZ;
            ob.DeformationRatio = this.DeformationRatio;
            ob.EdgeType = this.EdgeType;
            ob.AutorotateMode = this.AutorotateMode;
            ob.MirroringBlock = this.m_mirroringBlock;
            ob.MultiBlock = this.MultiBlock;
            ob.GuiVisible = this.GuiVisible;
            ob.Rotation = this.Rotation;
            ob.Direction = this.Direction;
            ob.Mirrored = this.Mirrored;
            ob.BuildType = this.BuildType.ToString();
            ob.BuildMaterial = this.BuildMaterial;
            ob.GeneratedBlockType = this.GeneratedBlockType.ToString();
            ob.DamageEffectId = this.DamageEffectID.HasValue ? this.DamageEffectID.Value : 0;
            ob.CompoundTemplates = this.CompoundTemplates;
            ob.Icon = Icon;
            ob.Points = this.Points;
            //ob.SubBlockDefinitions = SubBlockDefinitions;
            //ob.BlockVariants = BlockVariants;
            if (this.PhysicalMaterial != null)
            {
                ob.PhysicalMaterial = this.PhysicalMaterial.Id.SubtypeName;
            }
            ob.CompoundEnabled = this.CompoundEnabled;
            
            if (Components != null)
            {
                List<MyObjectBuilder_CubeBlockDefinition.CubeBlockComponent> compObs = new List<MyObjectBuilder_CubeBlockDefinition.CubeBlockComponent>();
                foreach (var comp in Components)
                {
                    var compOb = new MyObjectBuilder_CubeBlockDefinition.CubeBlockComponent();
                    compOb.Count = (ushort)comp.Count;
                    compOb.Type = comp.Definition.Id.TypeId;
                    compOb.Subtype = comp.Definition.Id.SubtypeName;
                    compObs.Add(compOb);
                }

                ob.Components = compObs.ToArray();
            }

            ob.CriticalComponent = new MyObjectBuilder_CubeBlockDefinition.CriticalPart()
            {
                Index = 0,
                Subtype = ob.Components[0].Subtype,
                Type = ob.Components[0].Type
            };

            List<MyObjectBuilder_CubeBlockDefinition.MountPoint> mountPoints = null;
            if (MountPoints != null)
            {
                mountPoints = new List<MyObjectBuilder_CubeBlockDefinition.MountPoint>(); 
                foreach (var mountPoint in MountPoints)
                {
                    MyObjectBuilder_CubeBlockDefinition.MountPoint mpOb = mountPoint.GetObjectBuilder(Size);
                    mountPoints.Add(mpOb);
                }

                ob.MountPoints = mountPoints.ToArray();
            }

            return ob;
        }