コード例 #1
0
        private bool WalkLine(Vector3I start, Vector3I end, IMyCubeGrid grid)
        {
            var it = new MathUtility.Vector3ILineIterator(start, end);

            while (it.IsValid())
            {
                IMySlimBlock block = grid.GetCubeBlock(it.Current);
                it.MoveNext();

                if (block == null)
                {
                    return(false);
                }

                if (!block.BlockDefinition.Id.SubtypeName.Contains("Shipyard"))
                {
                    return(false);
                }

                if (block.BuildPercent() < ((MyCubeBlockDefinition)block.BlockDefinition).CriticalIntegrityRatio)
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #2
0
        //    OBB corner structure
        //     ZMax    ZMin
        //    0----1  4----5
        //    |    |  |    |
        //    |    |  |    |
        //    3----2  7----6

        /// <summary>
        ///     Makes sure the shipyard has a complete frame made of shipyard conveyor blocks
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private bool IsFrameComplete(ShipyardItem item)
        {
            using (Profiler.Start(FullName, nameof(IsFrameComplete)))
            {
                var corners = new Vector3D[8];
                item.ShipyardBox.GetCorners(corners, 0);

                var gridCorners = new Vector3I[8];
                for (int i = 0; i < 8; i++)
                {
                    gridCorners[i] = ((IMyCubeGrid)item.YardEntity).WorldToGridInteger(corners[i]);
                }

                LinePair[] lines =
                {
                    new LinePair(0, 1),
                    new LinePair(0, 4),
                    new LinePair(1, 2),
                    new LinePair(1, 5),
                    new LinePair(2, 3),
                    new LinePair(2, 6),
                    new LinePair(3, 0),
                    new LinePair(3, 7),
                    new LinePair(4, 5),
                    new LinePair(5, 6),
                    new LinePair(6, 7),
                    new LinePair(7, 4),
                };

                var grid = (IMyCubeGrid)item.YardEntity;
                foreach (LinePair line in lines)
                {
                    var it = new MathUtility.Vector3ILineIterator(gridCorners[line.Start], gridCorners[line.End]);
                    while (it.IsValid())
                    {
                        IMySlimBlock block = grid.GetCubeBlock(it.Current);
                        it.MoveNext();
                        if (block == null)
                        {
                            return(false);
                        }

                        if (!block.BlockDefinition.Id.SubtypeName.Contains("Shipyard"))
                        {
                            return(false);
                        }

                        if (block.BuildPercent() < .8)
                        {
                            return(false);
                        }
                    }
                }

                return(true);
            }
        }