public static TronicSequence StartFromProxy(N8BlockFactory Blocks = null, string name = "Proxy")
        {
            TronicSequence ts = new TronicSequence(Blocks);
            ts.Proxy(name);

            return ts;
        }
        public static TronicSequence StartFromButton(N8BlockFactory Blocks = null, int type = 1, string name = "Button")
        {
            TronicSequence ts = new TronicSequence(Blocks);
            ts.Button(type, name);

            return ts;
        }
        public static TronicSequence StartFromKeyboard(N8BlockFactory Blocks = null, DataNodeOut DataOut = null, string name = "Keyboard")
        {
            TronicSequence ts = new TronicSequence(Blocks);
            //I just learned about the null coalsece operator! it is awesome.
            ts.Keyboard(DataOut ?? ts.NewDataBlock().Out, name);

            if (!ts.data.Contains(DataOut.Parent))
            {
                ts.data.Add(DataOut.Parent);
            }

            return ts;
        }
        private static void FleeTronics(N8BlockFactory LevelBlocks, List<FlowTronic> alerts, bool rotate = true, bool AttachLevelBlocks = false, string password = null)
        {
            Quaternion UpsideDown = new Quaternion(new Vector3D(1, 0, 0), 180);

            FlowTronic InitTronic;
            if (password == null)
            {
                InitTronic = LevelBlocks.Keyboard("Set Cell Password");
                InitTronic.position = new Vector3D(30, -30, 5);
            }
            else
            {
                InitTronic = LevelBlocks.Button(1, "Setup Reciever");
            }

            TronicSequence Reciever = new TronicSequence(InitTronic);

            DataBlock Channel = Reciever.NewDataBlock("Channel", "1025");
            DataBlock UsernameRec = Reciever.NewDataBlock("Recieved Username");
            DataBlock MessageRec = Reciever.NewDataBlock("Recieved Message");

            DataBlock UsernameStore = Reciever.NewDataBlock("Stored Username", "Tacroy");
            //Not used atm
            //DataBlock AlternateUsernameStore = Reciever.NewDataBlock("Alternate Username", "nobody");
            DataBlock Password = Reciever.NewDataBlock("Password", password ?? "");
            if (password == null)
            {
                InitTronic.DataOutA(Password.Out);
            }

            Reciever.RadioReciever(Channel.In, UsernameRec.Out, MessageRec.Out);

            TronicSequence PasswordTest = new TronicSequence();

            PasswordTest.IfEqual(Password.In, MessageRec.In, "PasswordCheck");

            TronicSequence NameTest = new TronicSequence();

            NameTest.IfEqual(UsernameRec.In, UsernameStore.In, "NameCheck");

            TronicSequence FlipFlop = TronicsTesting.Ringbuffer(new List<string>(new string[] { "0", "1" }));
            DataBlock ControlBit = FlipFlop.data[FlipFlop.data.Count - 1];
            DataBlock ReturnPos = Reciever.NewDataBlock("Return Position", "v0,0,0");

            Reciever.Append(NameTest)
                    .Append(PasswordTest)
                    .Append(FlipFlop)
                    .Mover(ReturnPos.In, ReturnPos.Out, "Return Mover")
                    .RadioTransmit(Channel.In, ControlBit.In, "Yeller");

            TronicSequence RandomBottomVector = TronicsTesting.RandomXYVectorGenerator(-1000, 1000, -1000);
            TronicSequence RandomTopVector = TronicsTesting.RandomXYVectorGenerator(-2000, 2000, 2000);
            DataBlock RandVectTop = RandomTopVector.data[RandomTopVector.data.Count - 1];
            DataBlock RandVectBottom = RandomBottomVector.data[RandomBottomVector.data.Count - 1];

            Random rand = new Random();

            Vector3D AttachOffset = rand.NextVector(new Vector3D(60,60,0), new Vector3D(-60,-60,0));

            foreach (FlowTronic alert in alerts)
            {
                alert.position += AttachOffset;
                RandomTopVector.GetFirst().FlowInFrom(alert);
            }

            N8Block TronicAttach = LevelBlocks.GenerateBlock("letter.period", "Attach Point");
            TronicAttach.position = -AttachOffset;
            TronicAttach.position.Z = 500;

            TronicSequence MovementLogic = new TronicSequence();
            MovementLogic.Append(RandomTopVector);

            MovementLogic.IfGreater(ControlBit.In, null, "Control");

            if (rotate)
            {
                TronicSequence ProxyRotor = new TronicSequence();
                DataBlock Quantity = ProxyRotor.NewDataBlock("Amount", "q0,0,1,0");
                DataBlock Current = ProxyRotor.NewDataBlock("Current", "q1,0,0,0");

                ProxyRotor.Multiply(Quantity.In, Current.In, Current.Out, "Unit step")
                          .Rotor(Current.In, null, "Rotate1");
                MovementLogic.Append(ProxyRotor);
            }
            //Mega and vacubombs take 15 seconds to explode, regular 10. Add 2 seconds up in the sky for a buffer.
            //Also keep in mind that because we fly up then delay, once we're up there we're a random sky mover so that should be safe enough.
            DataBlock DelayTime = MovementLogic.NewDataBlock("Delay", "17");
            MovementLogic.Mover(RandVectTop.In, null, "Flee Mover 1")
                         .Delay(DelayTime.In)
                         .Append(RandomBottomVector)
                         .Mover(RandVectBottom.In, null, "Flee Mover 2");

            MovementLogic.GetCurrent().Item1.FlowOutTo((FlowTronic)Reciever.tronics.Tronics.Last());

            MovementLogic.LayoutDense(AttachOffset);
            Reciever.LayoutDense(AttachOffset);

            //Attach everything
            Reciever.AttachAllNonPositional(TronicAttach, false);
            MovementLogic.AttachAllNonPositional(TronicAttach, false);

            foreach (N8Tronic t in alerts)
            {
                TronicAttach.AttachToMe(t);
            }

            LevelBlocks.CopyFromDestructive(MovementLogic.tronics);
            LevelBlocks.CopyFromDestructive(Reciever.tronics);

            if (AttachLevelBlocks)
            {
                foreach (N8Block b in from N8Block t in LevelBlocks.Blocks where t.name != "Attach Point" select t)
                {
                    b.position += AttachOffset;
                    TronicAttach.AttachToMe(b);
                }
            }

            N8Tronic RetMover = (from N8Tronic t in LevelBlocks.Tronics where t.name == "Return Mover" select t).First();
            N8Tronic FleeMover1 = (from N8Tronic t in LevelBlocks.Tronics where t.name == "Flee Mover 1" select t).First();
            N8Tronic FleeMover2 = (from N8Tronic t in LevelBlocks.Tronics where t.name == "Flee Mover 2" select t).First();

            RetMover.position.Z = -1000;
            FleeMover1.position.Z = 0;
            FleeMover1.position.X = -30;
            FleeMover2.position.Z = 0;
            FleeMover2.position.X = 30;
            RetMover.Detach();
            FleeMover1.Detach();
            FleeMover2.Detach();

            if (rotate)
            {
                N8Tronic Rotor = (from N8Tronic t in LevelBlocks.Tronics where t.name == "Rotate1" select t).First();
                TronicAttach.AttachToMe(Rotor);
            }

            Console.WriteLine("Total block count: " + (LevelBlocks.Blocks.Count + LevelBlocks.Tronics.Count));
        }
        public static TronicSequence StartFromReciever(DataNodeIn Channel, DataNodeOut Username, DataNodeOut Message, N8BlockFactory Blocks = null, string name = "Reciever")
        {
            TronicSequence ts = new TronicSequence(Blocks);
            ts.Button(1, "Reciever Setup")
              .RadioReciever(Channel, Username, Message, name);

            return ts;
        }
 internal void ElseInternal(TronicSequence ElseBranch)
 {
     var LastBranch = Branches.Pop();
     ElseBranch.GetFirst().FlowInFrom(LastBranch.Item1, LastBranch.Item2);
 }
        public TronicSequence IfNotEqual(DataNodeIn DataInA, DataNodeIn DataInB, string name = "IfNotEquals", TronicSequence Else = null)
        {
            CheckCanAppend();

            FlowTronic NextTronic = tronics.IfEqual(name);

            NextTronic.DataInA(DataInA);
            NextTronic.DataInB(DataInB);

            if (Else != null)
            {
                NextTronic.FlowOutTo(Else.GetFirst(), NodeType.FlowOutA);
                this.tronics.CopyFromDestructive(Else.tronics);
                this.sequence.AddRange(Else.sequence);
            }

            Append(NextTronic, NextTronic.GetNode(NodeType.FlowOutB));
            NoteBranch(NodeType.FlowOutA);

            return this;
        }
 public TronicSequence FlowOutTo(TronicSequence other, NodeType Out = NodeType.FlowOutA)
 {
     other.GetFirst().FlowInFrom(this.CurrentTronic, this.CurrentOut);
     return this;
 }
 public TronicSequence AppendCopy(TronicSequence other)
 {
     return this.Append(Utilities.DeepClone(other));
 }
        public TronicSequence Append(TronicSequence other)
        {
            if (this.CurrentTronic != null)
            {
                other.GetFirst().FlowInFrom(this.CurrentTronic, CurrentOut);
            }
            Tuple<FlowTronic, Node> temp = other.GetCurrent();

            this.CurrentTronic = temp.Item1;
            this.CurrentOut = temp.Item2;

            this.sequence.AddRange(other.sequence);
            this.data.AddRange(other.data);

            this.tronics.CopyFromDestructive(other.tronics);
            return this;
        }