예제 #1
0
        public SnapCandidate Snap(UserCoordinates userCoordinates, FortressLayout layout)
        {
            var centerPoint       = userCoordinates.NearestHardpoint();
            var candidatePosition = Position.ThreeByThreeCenteredAt(centerPoint);

            bool isLegal   = false;
            var  isBlocked = layout.ComponentsByHardpoint(centerPoint)
                             .Any(c => c.ComponentType == FoundationComponentType.Floor);

            if (!isBlocked)
            {
                var neighbors             = GetNeighboringFoundations(candidatePosition, layout);
                var hasMisalignedNeighbor = neighbors.Any(
                    n => n.Position.OverlapWith(candidatePosition).Hardpoints.Count == 2);
                isLegal = !hasMisalignedNeighbor;
            }

            var candidate = new SnapCandidate()
            {
                Position    = candidatePosition,
                BoundingBox = new RectangleF(centerPoint.X - .1f, centerPoint.Y - .1f, .2f, .2f),
                IsLegal     = isLegal
            };

            return(candidate);
        }
예제 #2
0
        public SnapCandidate Snap(UserCoordinates userCoordinates, FortressLayout layout)
        {
            var hardpoint = userCoordinates.NearestHardpoint();
            var overlaps  = layout.ComponentsByHardpoint(hardpoint).ToList();

            var isLegal =
                overlaps.Any(c => c.ComponentType == FoundationComponentType.Floor) &&
                overlaps.All(c => c.ComponentType != FoundationComponentType.Pillar);

            var candidate = new SnapCandidate()
            {
                Position    = Position.OneByOneAt(hardpoint),
                BoundingBox = new RectangleF(hardpoint.X - .1f, hardpoint.Y - .1f, .2f, .2f),
                IsLegal     = isLegal
            };

            return(candidate);
        }