示例#1
0
 private void GenerateNeededParts(bool Set)
 {
     Sprung1 = m_rp.GetSprung(false);
     Sprung1.Rotate270();
     Sprung2 = m_rp.GetSprung(false);
     Sprung2.MirrorX();
     Sprung2.Rotate90();
     Straight1 = m_rp.GetStraight(0);
     Straight2 = m_rp.GetStraight(1);
     Cross     = m_rp.GetCrossing();
     FlipFlop  = m_rp.GetFlipFlop(!Set);
     Lazy      = m_rp.GetLazy(!Set);
     Lazy.Rotate270();
     Curve1 = m_rp.GetCurve(0);
     Curve2 = m_rp.GetCurve(1);
     Curve3 = m_rp.GetCurve(2);
 }
示例#2
0
        private void SetSubroutine(int States)
        {
            RailParts rp   = new RailParts();
            MyPGM     Lazy = rp.GetLazy(false);

            Lazy.MirrorX();
            Lazy.Rotate90();
            MyPGM Sprung1 = rp.GetSprung(false);

            Sprung1.MirrorY();
            MyPGM Sprung2 = rp.GetSprung(false);

            Sprung2.Rotate180();
            int[] SubConn = null;

            MyPGM Begins = GetSubroutineConn(States, ref SubConn);

            bool OneCurveSet = false;

            // Paint Subroutine
            for (int i = SubConn.Length; i > 0; i--)
            {
                if (SubConn[i - 1] > 1)
                {
                    if (OneCurveSet)
                    {
                        SetField(Lazy, 1 + ReadWriteHead.XRailsCnt + i - 1, 0);
                    }
                    else
                    {
                        SetField(rp.GetCurve(2), 1 + ReadWriteHead.XRailsCnt + i - 1, 0);
                    }
                    OneCurveSet = true;
                }
                else
                {
                    if (OneCurveSet)
                    {
                        SetField(rp.GetStraight(1), 1 + ReadWriteHead.XRailsCnt + i - 1, 0);
                    }
                }
            }
            // Paint Connections
            int XStartPos = ReadWriteHead.XRailsCnt + 1;
            int YStartPos = 1;

            for (int i = 0; i < Begins.YSize; i++)
            {
                for (int j = 0; j < Begins.XSize; j++)
                {
                    int Val = Begins.GetValue(j, i);
                    if (Val == 1)
                    {
                        SetField(rp.GetStraight(0), XStartPos + j, YStartPos + i);
                    }
                    else if (Val == 2)
                    {
                        SetField(Sprung1, XStartPos + j, YStartPos + i);
                    }
                    else if (Val == 3)
                    {
                        SetField(rp.GetCurve(2), XStartPos + j, YStartPos + i);
                    }
                    else if (Val == 4)
                    {
                        SetField(rp.GetCrossing(), XStartPos + j, YStartPos + i);
                    }
                    else if (Val == 5)
                    {
                        SetField(Sprung2, XStartPos + j, YStartPos + i);
                    }
                    else if (Val == 6)
                    {
                        SetField(rp.GetStraight(1), XStartPos + j, YStartPos + i);
                    }
                }
            }
            int LastPos = Begins.YSize - 1;

            for (int i = 0; i < Begins.XSize; i++)
            {
                if (Begins.GetValue(i, LastPos) > 0)
                {
                    m_Connected[i] = 1;
                }
                else
                {
                    m_Connected[i] = 0;
                }
            }
        }