示例#1
0
        public void Dispense()
        {
            Point3 coordinates = m_componentBlockEntity.Coordinates;
            int    data        = Terrain.ExtractData(Utils.Terrain.GetCellValue(coordinates.X, coordinates.Y, coordinates.Z));
            int    direction   = FourDirectionalBlock.GetDirection(Utils.Terrain.GetCellValue(coordinates.X, coordinates.Y, coordinates.Z));

            Driller(coordinates, direction);
            int num = 0;
            int slotValue;

            while (true)
            {
                if (num >= SlotsCount - 1)
                {
                    return;
                }
                slotValue = GetSlotValue(num);
                int slotCount = GetSlotCount(num);
                if (slotValue != 0 && slotCount > 0)
                {
                    break;
                }
                num++;
            }
            MachineMode mode = DrillerBlock.GetMode(data);

            if (mode == MachineMode.Shoot)
            {
                int num2 = RemoveSlotItems(num, 1);
                for (int i = 0; i < num2; i++)
                {
                    DispenseItem(coordinates, direction, slotValue, mode);
                }
            }
        }
示例#2
0
        public override void Update()
        {
            int value = m_subsystemTerrain.Terrain.GetCellValue(m_componentBlockEntity.Coordinates.X, m_componentBlockEntity.Coordinates.Y, m_componentBlockEntity.Coordinates.Z);
            int data  = Terrain.ExtractData(value);

            if (m_dispenseButton.IsClicked)
            {
                data = DrillerBlock.SetMode(data, MachineMode.Dispense);
                m_subsystemTerrain.ChangeCell(m_componentBlockEntity.Coordinates.X, m_componentBlockEntity.Coordinates.Y, m_componentBlockEntity.Coordinates.Z, Terrain.ReplaceData(value, data));
            }
            if (m_shootButton.IsClicked)
            {
                data = DrillerBlock.SetMode(data, MachineMode.Shoot);
                m_subsystemTerrain.ChangeCell(m_componentBlockEntity.Coordinates.X, m_componentBlockEntity.Coordinates.Y, m_componentBlockEntity.Coordinates.Z, Terrain.ReplaceData(value, data));
            }
            if (m_acceptsDropsBox.IsClicked)
            {
                data = SixDirectionalBlock.SetAcceptsDrops(data, !SixDirectionalBlock.GetAcceptsDrops(data));
                m_subsystemTerrain.ChangeCell(m_componentBlockEntity.Coordinates.X, m_componentBlockEntity.Coordinates.Y, m_componentBlockEntity.Coordinates.Z, Terrain.ReplaceData(value, data));
            }
            var mode = DrillerBlock.GetMode(data);

            m_dispenseButton.IsChecked  = mode == MachineMode.Dispense;
            m_shootButton.IsChecked     = mode == MachineMode.Shoot;
            m_acceptsDropsBox.IsChecked = SixDirectionalBlock.GetAcceptsDrops(data);
            if (!m_componentDispenser.IsAddedToProject)
            {
                ParentWidget.Children.Remove(this);
            }
        }