Esempio n. 1
0
    public void TryRefreshConnectors()
    {
        List <Tuple <MachineConnector, MachineConnector> > lostConnections = new List <Tuple <MachineConnector, MachineConnector> >();

        foreach (MachineConnector m in _outputs)
        {
            if (m._conveyor != null)
            {
                lostConnections.Add(new Tuple <MachineConnector, MachineConnector>(m._conveyor._output, m._conveyor._input));
                MachineManager.DisconnectMachines(m._conveyor);
            }
        }

        foreach (MachineConnector m in _inputs)
        {
            if (m._conveyor != null)
            {
                lostConnections.Add(new Tuple <MachineConnector, MachineConnector>(m._conveyor._output, m._conveyor._input));
                MachineManager.DisconnectMachines(m._conveyor);
            }
        }

        foreach (Tuple <MachineConnector, MachineConnector> c in lostConnections)
        {
            MachineManager.ConnectMachines(c.Item1, c.Item2);
        }

        MachineManager.UpdateRecipes();
    }
        public void UpdateDesiredProductionSpeedTestOutputStorageLimited()
        {
            Reset();
            List <Machine> machines = new List <Machine>();

            Machine m1 = CreateMachine(0, 1);

            m1._maximumItemsPerSecond = Single.PositiveInfinity;
            m1._storageCapacity       = 1000;
            m1._itemsInStorage        = 1000;
            m1._storageMode           = Machine.StorageModes.Out;

            Machine m2 = CreateMachine(1, 0);

            m2._maximumItemsPerSecond = 5;
            m2._storageCapacity       = 1000;
            m2._itemsInStorage        = 997;
            m2._storageMode           = Machine.StorageModes.In;

            MachineManager.ConnectMachines(m1, 0, m2, 0);

            Assert.AreEqual(m1._itemsPerSecondToOutputs, 3);
            Assert.AreEqual(m1._itemsPerSecondToStorage, -3);

            Assert.AreEqual(m2._itemsPerSecondToOutputs, 0);
            Assert.AreEqual(m2._itemsPerSecondToStorage, 3);
        }
        public void UpdateDesiredProductionSpeedTestThreeMachinesWithMiddleStorageOutputDisabled()
        {
            Reset();
            List <Machine> machines = new List <Machine>();

            Machine m1 = CreateMachine(0, 1);

            m1._maximumItemsPerSecond = 5;

            Machine m2 = CreateMachine(1, 1);

            m2._maximumItemsPerSecond = 3;
            m2._storageCapacity       = 1000;
            m2._itemsInStorage        = 1000;
            m2._maximumItemsPerSecond = 1000;

            Machine m3 = CreateMachine(1, 0);

            m3._maximumItemsPerSecond = 4;
            m3._storageCapacity       = 1000;
            m3._storageMode           = Machine.StorageModes.In;

            MachineManager.ConnectMachines(m1, 0, m2, 0);
            MachineManager.ConnectMachines(m2, 0, m3, 0);

            Assert.AreEqual(m1._itemsPerSecondToOutputs, 3);
            Assert.AreEqual(m1._itemsPerSecondToStorage, 0);

            Assert.AreEqual(m2._itemsPerSecondToOutputs, 3);
            Assert.AreEqual(m2._itemsPerSecondToStorage, 0);

            Assert.AreEqual(m3._itemsPerSecondToOutputs, 0);
            Assert.AreEqual(m3._itemsPerSecondToStorage, 3);
        }
        public void UpdateDesiredProductionSpeedTestUnconnectedInput()
        {
            Reset();
            List <Machine> machines = new List <Machine>();

            Machine m1 = CreateMachine(1, 1);

            m1._maximumItemsPerSecond = 3;

            Machine m2 = CreateMachine(1, 0);

            m2._maximumItemsPerSecond = 5;
            m2._storageCapacity       = 1000;
            m2._storageMode           = Machine.StorageModes.In;

            MachineManager.ConnectMachines(m1, 0, m2, 0);

            Assert.AreEqual(m1._itemsPerSecondToOutputs, 0);
            Assert.AreEqual(m1._itemsPerSecondToStorage, 0);

            Assert.AreEqual(m2._itemsPerSecondToOutputs, 0);
            Assert.AreEqual(m2._itemsPerSecondToStorage, 0);
        }
Esempio n. 5
0
    private void OnEnable()
    {
        Machine m0 = CreateMachine(0, 1);

        m0._maximumItemsPerSecond = System.Single.PositiveInfinity;
        m0.SetTile(new Point(0, 4));
        m0._storageMode             = Machine.StorageModes.Out;
        m0._storageCapacity         = System.Single.PositiveInfinity;
        m0._itemsInStorage          = System.Single.PositiveInfinity;
        m0._itemInStorage           = new Item();
        m0._itemInStorage._baseItem = BaseItems.MixedOre;

        Machine m1 = CreateMachine(1, 2);

        m1._maximumItemsPerSecond = 10;
        m1.SetTile(new Point(4, 4));
        m1._addedProperty = Properties.Centrifuged;

        Machine m2 = CreateMachine(1, 1);

        m2._maximumItemsPerSecond = 2;
        m2.SetTile(new Point(12, 0));
        m2._addedProperty = Properties.Heated;

        Machine m3 = CreateMachine(1, 2);

        m3._maximumItemsPerSecond = 7;
        m3.SetTile(new Point(12, 8));
        m3._addedProperty = Properties.Heated;
        m3.SetRotation(Rotation.CW180);

        Machine m4 = CreateMachine(2, 1);

        m4._maximumItemsPerSecond = 2;
        m4.SetTile(new Point(20, 0));
        m4._addedProperty = Properties.Heated;

        Machine m5 = CreateMachine(1, 1);

        m5._maximumItemsPerSecond = 5;
        m5.SetTile(new Point(20, 12));
        m5._addedProperty = Properties.Stretched;

        Machine m6 = CreateMachine(1, 1);

        m6._maximumItemsPerSecond = 6;
        m6.SetTile(new Point(28, 12));
        m6._addedProperty = Properties.Cut;

        Machine m7 = CreateMachine(1, 0);

        m7.SetTile(new Point(24, 0));
        m7._maximumItemsPerSecond = 1e6f;
        m7._storageCapacity       = System.Single.PositiveInfinity;
        m7._storageMode           = Machine.StorageModes.In;

        Machine m8 = CreateMachine(1, 0);

        m8.SetTile(new Point(32, 12));
        m8._maximumItemsPerSecond = 1e6f;
        m8._storageCapacity       = System.Single.PositiveInfinity;
        m8._storageMode           = Machine.StorageModes.In;

        MachineManager.ConnectMachines(m0._outputs[0], m1._inputs[0]);
        MachineManager.ConnectMachines(m1._outputs[0], m2._inputs[0]);
        MachineManager.ConnectMachines(m1._outputs[1], m3._inputs[0]);
        MachineManager.ConnectMachines(m2._outputs[0], m4._inputs[0]);
        MachineManager.ConnectMachines(m3._outputs[0], m4._inputs[1]);
        MachineManager.ConnectMachines(m3._outputs[1], m5._inputs[0]);
        MachineManager.ConnectMachines(m5._outputs[0], m6._inputs[0]);
        MachineManager.ConnectMachines(m4._outputs[0], m7._inputs[0]);
        MachineManager.ConnectMachines(m6._outputs[0], m8._inputs[0]);

        MachineManager.UpdateRecipes();
    }