Пример #1
0
        public override bool ConnectionAllowed(ref Vector3I otherBlockPos, ref Vector3I faceNormal, MyCubeBlockDefinition def)
        {
            if (MountPoints == null)
                return true;
            var otherPos = Position + faceNormal;
            var other = CubeGrid.GetCubeBlock(otherPos);
            MyBlockOrientation or;
            if (other != null)
                or = other.Orientation;
            else
                or = MyBlockOrientation.Identity;
            var position = Position;
            m_mpCache.Clear();
            if (other != null && other.FatBlock is MyFracturedBlock)
                m_mpCache.AddRange((other.FatBlock as MyFracturedBlock).MountPoints);
            else
            {
				if (other != null && other.FatBlock is MyCompoundCubeBlock)
				{
					var lst = new List<MyCubeBlockDefinition.MountPoint>();
					foreach (var b in (other.FatBlock as MyCompoundCubeBlock).GetBlocks())
					{
						var mountPoints = b.BlockDefinition.GetBuildProgressModelMountPoints(b.BuildLevelRatio);
						MyCubeGrid.TransformMountPoints(lst, b.BlockDefinition, mountPoints, ref b.Orientation);
						m_mpCache.AddRange(lst);
					}
				}
				else if(other != null)
				{
					var mountPoints = def.GetBuildProgressModelMountPoints(other.BuildLevelRatio);
					MyCubeGrid.TransformMountPoints(m_mpCache, def, mountPoints, ref or);
				}
            }
            return MyCubeGrid.CheckMountPointsForSide(MountPoints, ref SlimBlock.Orientation, ref position, BlockDefinition.Id, ref faceNormal, m_mpCache,
                ref or, ref otherPos, def.Id);
        }
        public static void DrawMountPoints(float cubeSize, MyCubeBlockDefinition def, ref MatrixD drawMatrix)
        {
            var mountPoints = def.GetBuildProgressModelMountPoints(1.0f);
            if (mountPoints == null)
                return;

            if (!MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AUTOGENERATE)
                DrawMountPoints(cubeSize, def, drawMatrix, mountPoints);
            else
            {   //Generate mount points from model collisions and draw them
                if (def.Model != null)
                {
                    int index = 0;
                    MyModel model = VRage.Game.Models.MyModels.GetModel(def.Model);

                    foreach (var shape in model.HavokCollisionShapes)
                    {
                        MyPhysicsDebugDraw.DrawCollisionShape(shape, drawMatrix, 0.2f, ref index);
                    }

                    var newMountPoints = AutogenerateMountpoints(model, cubeSize);

                    DrawMountPoints(cubeSize, def, drawMatrix, newMountPoints.ToArray());
                }
            }

            if (MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS_HELPERS)
                DrawMountPointsAxisHelpers(def, ref drawMatrix, cubeSize);

        }