コード例 #1
0
 /// <inheritdoc />
 public MutableCubieCube Clone()
 {
     return(new MutableCubieCube(CornerPositions.ToArray(), CornerOrientations.ToArray(), EdgePositions.ToArray(), EdgeOrientations.ToArray()));
 }
コード例 #2
0
ファイル: WorldScene.cs プロジェクト: ysj1995/Trinity
        public List <ConnectedSceneResult> ConnectedScenes()
        {
            var  scenesSharingCorners = Core.Scenes.CurrentWorldScenes.Where(s => s.CornerPositions.Any(pos => CornerPositions.Contains(pos)));
            var  output = new List <ConnectedSceneResult>();
            bool withinBounds;

            foreach (var other in scenesSharingCorners)
            {
                var onSouthEdge = other.NorthWest.X == SouthWest.X && other.NorthEast.X == SouthEast.X;
                withinBounds = other.Size.X < Size.X
                    ? other.NorthWest.Y >= SouthWest.Y && other.NorthEast.Y <= SouthEast.Y
                    : other.NorthWest.Y <= SouthWest.Y && other.NorthEast.Y >= SouthEast.Y;

                if (onSouthEdge && withinBounds)
                {
                    if (other.ExitDirections.HasFlag(SceneExitDirections.North) && ExitDirections.HasFlag(SceneExitDirections.South))
                    {
                        output.Add(new ConnectedSceneResult
                        {
                            Scene        = other,
                            Direction    = SceneExitDirections.South,
                            ExitPosition = ExitPositions[SceneExitDirections.South],
                            EdgePointA   = other.NorthWest,
                            EdgePointB   = other.NorthEast,
                        });
                    }
                    continue;
                }

                var onNorthEdge = other.SouthWest.X == NorthWest.X && other.SouthEast.X == NorthEast.X;
                withinBounds = other.Size.X < Size.X
                    ? other.SouthWest.Y >= NorthWest.Y && other.SouthEast.Y <= NorthEast.Y
                    : other.SouthWest.Y <= NorthWest.Y && other.SouthEast.Y >= NorthEast.Y;

                if (onNorthEdge && withinBounds)
                {
                    if (other.ExitDirections.HasFlag(SceneExitDirections.South) && ExitDirections.HasFlag(SceneExitDirections.North))
                    {
                        output.Add(new ConnectedSceneResult
                        {
                            Scene        = other,
                            Direction    = SceneExitDirections.North,
                            ExitPosition = ExitPositions[SceneExitDirections.North],
                            EdgePointA   = other.SouthEast,
                            EdgePointB   = other.SouthWest,
                        });
                    }
                    continue;
                }

                var onEastEdge = other.NorthWest.Y == NorthEast.Y && other.SouthWest.Y == SouthEast.Y;
                withinBounds = other.Size.X < Size.X
                    ? other.NorthWest.X >= NorthEast.X && other.SouthWest.X <= SouthEast.X
                    : other.NorthWest.X <= NorthEast.X && other.SouthWest.X >= SouthEast.X;

                if (onEastEdge && withinBounds)
                {
                    if (other.ExitDirections.HasFlag(SceneExitDirections.West) && ExitDirections.HasFlag(SceneExitDirections.East))
                    {
                        output.Add(new ConnectedSceneResult
                        {
                            Scene        = other,
                            Direction    = SceneExitDirections.East,
                            ExitPosition = ExitPositions[SceneExitDirections.East],
                            EdgePointA   = other.NorthWest,
                            EdgePointB   = other.SouthWest,
                        });
                    }
                    continue;
                }

                var onWestEdge = other.NorthEast.Y == NorthWest.Y && other.SouthEast.Y == SouthWest.Y;
                withinBounds = other.Size.X < Size.X
                    ? other.NorthEast.X >= NorthWest.X && other.SouthEast.X <= SouthWest.X
                    : other.NorthEast.X <= NorthWest.X && other.SouthEast.X >= SouthWest.X;

                if (onWestEdge && withinBounds)
                {
                    if (other.ExitDirections.HasFlag(SceneExitDirections.East) && ExitDirections.HasFlag(SceneExitDirections.West))
                    {
                        output.Add(new ConnectedSceneResult
                        {
                            Scene        = other,
                            Direction    = SceneExitDirections.West,
                            ExitPosition = ExitPositions[SceneExitDirections.West],
                            EdgePointA   = other.SouthEast,
                            EdgePointB   = other.NorthEast,
                        });
                    }
                }
            }

            return(output);
        }