public void Inventory_EventTrigger(Client player, string eventName, params object[] args) { switch (eventName) { case "RequestInventory": { if (!Inventories.ContainsKey(player.handle)) { return; } player.sendInventory(); break; } case "ConsumeItem": { if (args.Length < 1 || !Inventories.ContainsKey(player.handle)) { return; } int idx = Convert.ToInt32(args[0]); player.useItem(idx); break; } case "DropItem": { if (args.Length < 3 || !Inventories.ContainsKey(player.handle)) { return; } int idx = Convert.ToInt32(args[0]); int amount = Convert.ToInt32(args[1]); Vector3 pos = (Vector3)args[2]; if (idx < 0 || idx >= Inventories[player.handle].Count) { return; } if (player.position.DistanceTo(pos) >= 3.0) { return; } if (Inventories[player.handle][idx].Item is IDroppable dropInfo) { Guid dropID; do { dropID = Guid.NewGuid(); } while (DroppedItems.ContainsKey(dropID)); DroppedItems.Add(dropID, new DroppedItem(dropID, Inventories[player.handle][idx].ID, dropInfo.DropModel, pos, amount)); player.removeItem(idx, amount); } break; } case "TakeItem": { if (args.Length < 1 || !Inventories.ContainsKey(player.handle)) { return; } Guid dropID = new Guid(args[0].ToString()); if (!DroppedItems.ContainsKey(dropID)) { return; } DroppedItem item = DroppedItems[dropID]; int added = player.giveItem(item.ID, item.Quantity); if (added > 0) { item.Quantity -= added; if (item.Quantity < 1) { item.Delete(); DroppedItems.Remove(dropID); } player.sendNotification("", $"+ {item.Name} x{added}."); } break; } } }