private void AddSegmentSpaceRecursively(BeamSegment _segment, int exitSide) { // Do we have too many segments? Okay, stop; we're probably caught in an infinite-Beam Portal mirroring situation. if (NumSegments > 10) { return; } // Are we not allowed to EXIT this space? Then stop here. if (!BoardUtils.CanBeamExitSpace(GetSpace(_segment.LastColRow), exitSide)) { return; } // What space will we add it to? TranslationInfo ti = BoardUtils.GetTranslationInfo(mySource.BoardRef, _segment.LastColRow, exitSide); BoardSpace spaceToAddBeam = BoardUtils.GetSpace(BoardRef, ti.to); // If we can't ENTER the next space, then stop. :) int nextSideIn = MathUtils.GetSide(ti.dirIn); if (!BoardUtils.CanBeamEnterSpace(spaceToAddBeam, nextSideIn)) { return; } // Otherwise, add this space to the segment! _segment.AddSpace(spaceToAddBeam); // How is the beam exiting?? int endSideExiting = spaceToAddBeam.GetSideBeamExits(nextSideIn); // keep updaing endSideExiting (until we hit the end). // Otherwise, keep going! Add again! AddSegmentSpaceRecursively(_segment, endSideExiting); }