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 FurnaceWindow(IEventScheduler scheduler, Coordinates3D coordinates, IItemRepository itemRepository, InventoryWindow inventory) { ItemRepository = itemRepository; EventScheduler = scheduler; Coordinates = coordinates; WindowAreas = new[] { new WindowArea(IngredientIndex, 1, 1, 1), new WindowArea(FuelIndex, 1, 1, 1), new WindowArea(OutputIndex, 1, 1, 1), new WindowArea(MainIndex, 27, 9, 3), new WindowArea(HotbarIndex, 9, 9, 1) }; 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 ChestWindow(InventoryWindow inventory, bool doubleChest = false) { DoubleChest = doubleChest; if (doubleChest) { WindowAreas = new[] { new WindowArea(ChestIndex, 54, 9, 3), // Chest new WindowArea(DoubleMainIndex, 27, 9, 3), // Main inventory new WindowArea(DoubleHotbarIndex, 9, 9, 1) // Hotbar }; } else { WindowAreas = new[] { new WindowArea(ChestIndex, 27, 9, 3), // Chest new WindowArea(MainIndex, 27, 9, 3), // Main inventory new WindowArea(HotbarIndex, 9, 9, 1) // Hotbar }; } inventory.MainInventory.CopyTo(MainInventory); inventory.Hotbar.CopyTo(Hotbar); 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); } }; foreach (var area in WindowAreas) { area.WindowChange += (s, e) => OnWindowChange(new WindowChangeEventArgs( (s as WindowArea).StartIndex + e.SlotIndex, e.Value)); } }
public RemoteClient(IMultiplayerServer server, IPacketReader packetReader, PacketHandler[] packetHandlers, Socket connection) { LoadedChunks = new List<Coordinates2D>(); Server = server; Inventory = new InventoryWindow(server.CraftingRepository); InventoryWindow.WindowChange += HandleWindowChange; SelectedSlot = InventoryWindow.HotbarIndex; CurrentWindow = InventoryWindow; ItemStaging = ItemStack.EmptyStack; KnownEntities = new List<IEntity>(); Disconnected = false; EnableLogging = server.EnableClientLogging; NextWindowID = 1; Connection = connection; SocketPool = new SocketAsyncEventArgsPool(100, 200, 65536); PacketReader = packetReader; PacketHandlers = packetHandlers; cancel = new CancellationTokenSource(); StartReceive(); }
public ChestWindow(InventoryWindow inventory, bool doubleChest = false) { DoubleChest = doubleChest; if (doubleChest) { WindowAreas = new[] { new WindowArea(ChestIndex, 54, 9, 3), // Chest new WindowArea(DoubleMainIndex, 27, 9, 3), // Main inventory new WindowArea(DoubleHotbarIndex, 9, 9, 1) // Hotbar }; } else { WindowAreas = new[] { new WindowArea(ChestIndex, 27, 9, 3), // Chest new WindowArea(MainIndex, 27, 9, 3), // Main inventory new WindowArea(HotbarIndex, 9, 9, 1) // Hotbar }; } inventory.MainInventory.CopyTo(MainInventory); inventory.Hotbar.CopyTo(Hotbar); 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); } }; foreach (var area in WindowAreas) area.WindowChange += (s, e) => OnWindowChange(new WindowChangeEventArgs( (s as WindowArea).StartIndex + e.SlotIndex, e.Value)); }
public MultiplayerClient(TrueCraftUser user) { User = user; Client = new TcpClient(); PacketReader = new PacketReader(); PacketReader.RegisterCorePackets(); PacketHandlers = new PacketHandler[0x100]; Handlers.PacketHandlers.RegisterHandlers(this); World = new ReadOnlyWorld(); Inventory = new InventoryWindow(null); var repo = new BlockRepository(); repo.DiscoverBlockProviders(); World.World.BlockRepository = repo; World.World.ChunkProvider = new EmptyGenerator(); Physics = new PhysicsEngine(World.World, repo); SocketPool = new SocketAsyncEventArgsPool(100, 200, 65536); connected = 0; cancel = new CancellationTokenSource(); Health = 20; var crafting = new CraftingRepository(); CraftingRepository = crafting; crafting.DiscoverRecipes(); }
public FurnaceWindow(IEventScheduler scheduler, Coordinates3D coordinates, IItemRepository itemRepository, InventoryWindow inventory) { ItemRepository = itemRepository; EventScheduler = scheduler; Coordinates = coordinates; WindowAreas = new[] { new WindowArea(IngredientIndex, 1, 1, 1), new WindowArea(FuelIndex, 1, 1, 1), new WindowArea(OutputIndex, 1, 1, 1), new WindowArea(MainIndex, 27, 9, 3), new WindowArea(HotbarIndex, 9, 9, 1) }; 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); } }; }