示例#1
0
    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);
    }
示例#2
0
    private void AddSegmentRecursively(BoardOccupant _sourceOccupant)       //int _col,int _row, int _sideExiting) {
    // Create empty segment to populate, and add it to our list.
    {
        BeamSegment newSegment = new BeamSegment(this, _sourceOccupant);

        segments.Add(newSegment);
        int exitSide = _sourceOccupant.SideFacing;         // assume that we ALWAYS come OUT of any Occupant's SideFacing.

        //// HACK for chirality.
        //if (_sourceOccupant.ChirH < 0) {
        //    if (exitSide == Sides.L) { exitSide = Sides.R; }
        //    else if (exitSide == Sides.R) { exitSide = Sides.L; }
        //}
        //if (_sourceOccupant.ChirV < 0) {
        //    if (exitSide == Sides.B) { exitSide = Sides.T; }
        //    else if (exitSide == Sides.T) { exitSide = Sides.B; }
        //}
        AddSegmentSpaceRecursively(newSegment, exitSide);          // populate the segment (and maybe make more segments)!
    }