Пример #1
0
        public AssemblyArea(SolverComponent parent, ProgramWriter writer, IEnumerable <Molecule> products)
            : base(parent, writer, parent.OutputPosition)
        {
            Width      = products.Max(p => p.Width);
            HasTriplex = products.Any(p => p.HasTriplex);

            CreateBonders();
            CreateArms();
            CreateTracks();
        }
Пример #2
0
        public SingleAtomInput(SolverComponent parent, ProgramWriter writer, Vector2 position, Molecule molecule, int direction, Instruction instruction)
            : base(parent, writer, position, molecule)
        {
            if (molecule.Atoms.Count() > 1)
            {
                throw new ArgumentException("SingleAtomInput can't handle molecules with multiple atoms.");
            }

            Element       = molecule.Atoms.First().Element;
            m_instruction = instruction;

            CreateObjects(molecule, direction, instruction);
        }
Пример #3
0
        public OutputArea(SolverComponent parent, ProgramWriter writer, IEnumerable <Molecule> products)
            : base(parent, writer, parent.OutputPosition)
        {
            m_products = products;

            CreateOutputs();

            var armPos = new Vector2(-1, 1);

            m_outputArm = new Arm(this, armPos, Direction.SE, MechanismType.Arm1);

            new Track(this, armPos, Direction.NE, m_outputs.Values.Max(o => o.DropPosition));
        }
Пример #4
0
        public MultiAtomInput(SolverComponent parent, ProgramWriter writer, Vector2 position, Molecule molecule)
            : base(parent, writer, position, molecule)
        {
            m_extractAtomsCoroutine = new LoopingCoroutine <Element>(ExtractAtoms);

            // The atoms need to be moved at least 3 spaces to fully unbond them
            m_unbondWidth = Math.Max(3, Molecule.Width);

            var reagentPos = new Vector2(-Molecule.Width * 2 - m_unbondWidth - 2, -molecule.Height + 1);

            new Reagent(this, reagentPos.Add(molecule.Origin), molecule.Rotation, molecule.ID);

            var armPos = AddArms(reagentPos);

            AddTracks(armPos);
            AddGlyphs();
        }
Пример #5
0
        public LinearMoleculeInput(SolverComponent parent, ProgramWriter writer, Vector2 position, Molecule molecule)
            : base(parent, writer, position, molecule)
        {
            Molecule = molecule;
            if (molecule.Height != 1)
            {
                throw new ArgumentException(Invariant($"Molecule must have height 1. Specified height: {molecule.Height}."), "molecule");
            }

            m_extractAtomsCoroutine = new LoopingCoroutine <Element>(ExtractAtoms);

            var reagentPos = new Vector2(-Molecule.Width - 2, 1);

            new Reagent(this, reagentPos.Add(molecule.Origin), molecule.Rotation, molecule.ID);
            m_grabArm   = new Arm(this, reagentPos.Add(0, 1), Direction.SW, MechanismType.Piston);
            m_outputArm = new Arm(this, new Vector2(-3, 3), Direction.SW, MechanismType.Arm1, extension: 3);

            new Track(this, m_grabArm.Position, Direction.E, Molecule.Width - 1);
            new Glyph(this, new Vector2(-4, 0), Direction.E, GlyphType.Unbonding);
        }
Пример #6
0
        public AtomConveyor(SolverComponent parent, ProgramWriter writer, Vector2 position, int height)
            : base(parent, writer, position)
        {
            if (height % 2 > 0)
            {
                throw new ArgumentException("Height must be a multitple of two.", "height");
            }

            Height = height;

            for (int y = Height - 2; y >= 2; y -= 2)
            {
                m_downArms.Add(new Arm(this, new Vector2(2, y), Direction.NW, MechanismType.Arm1, extension: 2));
            }

            // This arm has to be in a different spot and direction to avoid atoms hitting it when moving East
            m_cornerArm = new Arm(this, new Vector2(-2, 2), Direction.E, MechanismType.Arm1, extension: 2);

            for (int i = 1; i <= 2; i++)
            {
                m_acrossArms.Add(new Arm(this, new Vector2(i * 2, -2), Direction.NW, MechanismType.Arm1, extension: 2));
            }
        }
Пример #7
0
 protected SolverComponent(SolverComponent parent, ProgramWriter writer, Vector2 position)
     : base(parent, position, 0)
 {
     Writer = writer;
 }
Пример #8
0
 protected MoleculeInput(SolverComponent parent, ProgramWriter writer, Vector2 position, Molecule molecule)
     : base(parent, writer, position)
 {
     Molecule = molecule;
 }