Ejemplo n.º 1
0
        public void Dispense()
        {
            Point3 coordinates = m_componentBlockEntity.Coordinates;
            int    data        = Terrain.ExtractData(m_subsystemTerrain.Terrain.GetCellValue(coordinates.X, coordinates.Y, coordinates.Z));
            int    direction   = DispenserBlock.GetDirection(data);

            DispenserBlock.Mode mode = DispenserBlock.GetMode(data);
            int num = 0;
            int slotValue;

            while (true)
            {
                if (num < SlotsCount)
                {
                    slotValue = GetSlotValue(num);
                    int slotCount = GetSlotCount(num);
                    if (slotValue != 0 && slotCount > 0)
                    {
                        break;
                    }
                    num++;
                    continue;
                }
                return;
            }
            int num2 = RemoveSlotItems(num, 1);

            for (int i = 0; i < num2; i++)
            {
                DispenseItem(coordinates, direction, slotValue, mode);
            }
        }
Ejemplo n.º 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  = DispenserBlock.SetMode(data, DispenserBlock.Mode.Dispense);
                value = Terrain.ReplaceData(value, data);
                m_subsystemTerrain.ChangeCell(m_componentBlockEntity.Coordinates.X, m_componentBlockEntity.Coordinates.Y, m_componentBlockEntity.Coordinates.Z, value);
            }
            if (m_shootButton.IsClicked)
            {
                data  = DispenserBlock.SetMode(data, DispenserBlock.Mode.Shoot);
                value = Terrain.ReplaceData(value, data);
                m_subsystemTerrain.ChangeCell(m_componentBlockEntity.Coordinates.X, m_componentBlockEntity.Coordinates.Y, m_componentBlockEntity.Coordinates.Z, value);
            }
            if (m_acceptsDropsBox.IsClicked)
            {
                data  = DispenserBlock.SetAcceptsDrops(data, !DispenserBlock.GetAcceptsDrops(data));
                value = Terrain.ReplaceData(value, data);
                m_subsystemTerrain.ChangeCell(m_componentBlockEntity.Coordinates.X, m_componentBlockEntity.Coordinates.Y, m_componentBlockEntity.Coordinates.Z, value);
            }
            DispenserBlock.Mode mode = DispenserBlock.GetMode(data);
            m_dispenseButton.IsChecked  = (mode == DispenserBlock.Mode.Dispense);
            m_shootButton.IsChecked     = (mode == DispenserBlock.Mode.Shoot);
            m_acceptsDropsBox.IsChecked = DispenserBlock.GetAcceptsDrops(data);
            if (!m_componentDispenser.IsAddedToProject)
            {
                base.ParentWidget.Children.Remove(this);
            }
        }