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); } }
public override void OnHitByProjectile(CellFace cellFace, WorldItem worldItem) { if (worldItem.ToRemove) { return; } ComponentBlockEntity blockEntity = m_subsystemBlockEntities.GetBlockEntity(cellFace.X, cellFace.Y, cellFace.Z); if (blockEntity != null && DispenserBlock.GetAcceptsDrops(Terrain.ExtractData(m_subsystemTerrain.Terrain.GetCellValue(cellFace.X, cellFace.Y, cellFace.Z)))) { ComponentDispenser inventory = blockEntity.Entity.FindComponent <ComponentDispenser>(throwOnError: true); Pickable pickable = worldItem as Pickable; int num = pickable?.Count ?? 1; int num2 = ComponentInventoryBase.AcquireItems(inventory, worldItem.Value, num); if (num2 < num) { m_subsystemAudio.PlaySound("Audio/PickableCollected", 1f, 0f, worldItem.Position, 3f, autoDelay: true); } if (num2 <= 0) { worldItem.ToRemove = true; } else if (pickable != null) { pickable.Count = num2; } } }