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); } }; } }
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); } }; }
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)); }
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)); } }
public CraftingWindowArea(ICraftingRepository repository, int startIndex, int width = 2, int height = 2) : base(startIndex, width * height + 1, width, height) { Repository = repository; WindowChange += HandleWindowChange; }