Esempio n. 1
0
        private static void ConvertAllShapesToFractureComponentShapeBuilder(HkdBreakableShape shape, ref Matrix shapeRotation, MyBlockOrientation blockOrientation, HashSet <string> names, MyObjectBuilder_FractureComponentCubeBlock fractureComponentBuilder)
        {
            var name = shape.Name;

            if (names.Contains(name))
            {
                MyBlockOrientation shapeOrientation = new MyBlockOrientation(ref shapeRotation);
                if (shapeOrientation == blockOrientation)
                {
                    MyObjectBuilder_FractureComponentCubeBlock.FracturedShape builderShape = new MyObjectBuilder_FractureComponentBase.FracturedShape();
                    builderShape.Name  = name;
                    builderShape.Fixed = MyDestructionHelper.IsFixed(shape);

                    fractureComponentBuilder.Shapes.Add(builderShape);
                }
            }

            if (shape.GetChildrenCount() > 0)
            {
                List <HkdShapeInstanceInfo> children = new List <HkdShapeInstanceInfo>();
                shape.GetChildren(children);
                foreach (var child in children)
                {
                    var childShapeRotation = child.GetTransform();
                    ConvertAllShapesToFractureComponentShapeBuilder(child.Shape, ref childShapeRotation, blockOrientation, names, fractureComponentBuilder);
                }
            }
        }
        private static void ConvertAllShapesToFractureComponentShapeBuilder(HkdBreakableShape shape, ref Matrix shapeRotation, MyBlockOrientation blockOrientation,
                                                                            HashSet <Tuple <string, float> > namesAndBuildProgress, MyObjectBuilder_FractureComponentCubeBlock fractureComponentBuilder, out float buildProgress)
        {
            buildProgress = 1f;

            var name = shape.Name;
            Tuple <string, float> foundTuple = null;

            foreach (var tuple in namesAndBuildProgress)
            {
                if (tuple.Item1 == name)
                {
                    foundTuple = tuple;
                    break;
                }
            }

            if (foundTuple != null)
            {
                MyBlockOrientation shapeOrientation = new MyBlockOrientation(ref shapeRotation);
                if (shapeOrientation == blockOrientation)
                {
                    MyObjectBuilder_FractureComponentCubeBlock.FracturedShape builderShape = new MyObjectBuilder_FractureComponentBase.FracturedShape();
                    builderShape.Name  = name;
                    builderShape.Fixed = MyDestructionHelper.IsFixed(shape);

                    fractureComponentBuilder.Shapes.Add(builderShape);
                    buildProgress = foundTuple.Item2;
                }
            }

            if (shape.GetChildrenCount() > 0)
            {
                List <HkdShapeInstanceInfo> children = new List <HkdShapeInstanceInfo>();
                shape.GetChildren(children);
                foreach (var child in children)
                {
                    var   childShapeRotation = child.GetTransform();
                    float localBuildProgress;
                    ConvertAllShapesToFractureComponentShapeBuilder(child.Shape, ref childShapeRotation, blockOrientation, namesAndBuildProgress,
                                                                    fractureComponentBuilder, out localBuildProgress);

                    if (foundTuple == null)
                    {
                        buildProgress = localBuildProgress;
                    }
                }
            }
        }
Esempio n. 3
0
        private static void ConvertAllShapesToFractureComponentShapeBuilder(HkdBreakableShape shape, ref Matrix shapeRotation, MyBlockOrientation blockOrientation, HashSet <Tuple <string, float> > namesAndBuildProgress, MyObjectBuilder_FractureComponentCubeBlock fractureComponentBuilder, out float buildProgress)
        {
            buildProgress = 1f;
            string name = shape.Name;
            Tuple <string, float> tuple = null;

            foreach (Tuple <string, float> tuple2 in namesAndBuildProgress)
            {
                if (tuple2.Item1 == name)
                {
                    tuple = tuple2;
                    break;
                }
            }
            if ((tuple != null) && (new MyBlockOrientation(ref shapeRotation) == blockOrientation))
            {
                MyObjectBuilder_FractureComponentBase.FracturedShape item = new MyObjectBuilder_FractureComponentBase.FracturedShape {
                    Name  = name,
                    Fixed = MyDestructionHelper.IsFixed(shape)
                };
                fractureComponentBuilder.Shapes.Add(item);
                buildProgress = tuple.Item2;
            }
            if (shape.GetChildrenCount() > 0)
            {
                List <HkdShapeInstanceInfo> list = new List <HkdShapeInstanceInfo>();
                shape.GetChildren(list);
                foreach (HkdShapeInstanceInfo info in list)
                {
                    float  num;
                    Matrix transform = info.GetTransform();
                    ConvertAllShapesToFractureComponentShapeBuilder(info.Shape, ref transform, blockOrientation, namesAndBuildProgress, fractureComponentBuilder, out num);
                    if (tuple == null)
                    {
                        buildProgress = num;
                    }
                }
            }
        }