示例#1
0
 public CraftingBenchWindow(ICraftingRepository craftingRepository, InventoryWindow inventory)
 {
     WindowAreas = new[]
     {
         new CraftingWindowArea(craftingRepository, CraftingOutputIndex, 3, 3),
         new WindowArea(MainIndex, 27, 9, 3), // Main inventory
         new WindowArea(HotbarIndex, 9, 9, 1) // Hotbar
     };
     if (inventory != null)
     {
         inventory.MainInventory.CopyTo(MainInventory);
         inventory.Hotbar.CopyTo(Hotbar);
     }
     foreach (var area in WindowAreas)
         area.WindowChange += (s, e) => OnWindowChange(new WindowChangeEventArgs(
                 (s as WindowArea).StartIndex + e.SlotIndex, e.Value));
     Copying = false;
     if (inventory != null)
     {
         inventory.WindowChange += (sender, e) =>
         {
             if (Copying)
                 return;
             if ((e.SlotIndex >= InventoryWindow.MainIndex && e.SlotIndex < InventoryWindow.MainIndex + inventory.MainInventory.Length)
             || (e.SlotIndex >= InventoryWindow.HotbarIndex && e.SlotIndex < InventoryWindow.HotbarIndex + inventory.Hotbar.Length))
             {
                 inventory.MainInventory.CopyTo(MainInventory);
                 inventory.Hotbar.CopyTo(Hotbar);
             }
         };
     }
 }
示例#2
0
 public CraftingBenchWindow(ICraftingRepository craftingRepository, InventoryWindow inventory)
 {
     WindowAreas = new[]
     {
         new CraftingWindowArea(craftingRepository, CraftingOutputIndex, 3, 3),
         new WindowArea(MainIndex, 27, 9, 3),     // Main inventory
         new WindowArea(HotbarIndex, 9, 9, 1)     // Hotbar
     };
     inventory.MainInventory.CopyTo(MainInventory);
     inventory.Hotbar.CopyTo(Hotbar);
     foreach (var area in WindowAreas)
     {
         area.WindowChange += (s, e) => OnWindowChange(new WindowChangeEventArgs(
                                                           (s as WindowArea).StartIndex + e.SlotIndex, e.Value));
     }
     Copying = false;
     inventory.WindowChange += (sender, e) =>
     {
         if (Copying)
         {
             return;
         }
         if ((e.SlotIndex >= InventoryWindow.MainIndex && e.SlotIndex < InventoryWindow.MainIndex + inventory.MainInventory.Length) ||
             (e.SlotIndex >= InventoryWindow.HotbarIndex && e.SlotIndex < InventoryWindow.HotbarIndex + inventory.Hotbar.Length))
         {
             inventory.MainInventory.CopyTo(MainInventory);
             inventory.Hotbar.CopyTo(Hotbar);
         }
     };
 }
示例#3
0
 public InventoryWindow(ICraftingRepository craftingRepository)
 {
     WindowAreas = new[]
         {
             new CraftingWindowArea(craftingRepository, CraftingOutputIndex),
             new ArmorWindowArea(ArmorIndex),
             new WindowArea(MainIndex, 27, 9, 3), // Main inventory
             new WindowArea(HotbarIndex, 9, 9, 1) // Hotbar
         };
     foreach (var area in WindowAreas)
         area.WindowChange += (s, e) => OnWindowChange(new WindowChangeEventArgs(
             (s as WindowArea).StartIndex + e.SlotIndex, e.Value));
 }
示例#4
0
 public InventoryWindow(ICraftingRepository craftingRepository)
 {
     WindowAreas = new[]
     {
         new CraftingWindowArea(craftingRepository, CraftingOutputIndex),
         new ArmorWindowArea(ArmorIndex),
         new WindowArea(MainIndex, 27, 9, 3),                 // Main inventory
         new WindowArea(HotbarIndex, 9, 9, 1)                 // Hotbar
     };
     foreach (var area in WindowAreas)
     {
         area.WindowChange += (s, e) => OnWindowChange(new WindowChangeEventArgs(
                                                           (s as WindowArea).StartIndex + e.SlotIndex, e.Value));
     }
 }
示例#5
0
 public CraftingWindowArea(ICraftingRepository repository, int startIndex, int width = 2, int height = 2)
     : base(startIndex, width * height + 1, width, height)
 {
     Repository    = repository;
     WindowChange += HandleWindowChange;
 }
示例#6
0
 public CraftingWindowArea(ICraftingRepository repository, int startIndex, int width = 2, int height = 2)
     : base(startIndex, width * height + 1, width, height)
 {
     Repository = repository;
     WindowChange += HandleWindowChange;
 }