public virtual ItemStack this[int index] { get { foreach (var area in WindowAreas) { if (index >= area.StartIndex && index < area.StartIndex + area.Length) { return(area[index - area.StartIndex]); } } throw new IndexOutOfRangeException(); } set { foreach (var area in WindowAreas) { if (index >= area.StartIndex && index < area.StartIndex + area.Length) { var eventArgs = new WindowChangeEventArgs(index, value); OnWindowChange(eventArgs); if (!eventArgs.Handled) { area[index - area.StartIndex] = value; } return; } } throw new IndexOutOfRangeException(); } }
private void HandleWindowChange(object sender, WindowChangeEventArgs e) { if (Repository == null) { return; } var current = Repository.GetRecipe(Bench); if (e.SlotIndex == CraftingOutput) { if (e.Value.Empty && current != null) // Item picked up { RemoveItemFromOutput(current); current = Repository.GetRecipe(Bench); } } if (current == null) { Items[CraftingOutput] = ItemStack.EmptyStack; } else { Items[CraftingOutput] = current.Output; } }
protected internal virtual void OnWindowChange(WindowChangeEventArgs e) { if (WindowChange != null) { WindowChange(this, e); } }