Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
        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;
            }
        }
Esempio n. 3
0
 protected internal virtual void OnWindowChange(WindowChangeEventArgs e)
 {
     if (WindowChange != null)
     {
         WindowChange(this, e);
     }
 }