public void Buy(RealmTime time, BuyPacket pkt) { SellableObject obj = Owner.GetEntity(pkt.ObjectId) as SellableObject; if (obj != null) { obj.Buy(this); } }
void Init(ClientProcessor psr) { this.psr = psr; this.acc = psr.Account; List<IntPoint> vaultChestPosition = new List<IntPoint>(); IntPoint spawn = new IntPoint(0, 0); int w = Map.Width; int h = Map.Height; for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) { var tile = Map[x, y]; if (tile.Region == TileRegion.Spawn) spawn = new IntPoint(x, y); else if (tile.Region == TileRegion.Vault) vaultChestPosition.Add(new IntPoint(x, y)); } vaultChestPosition.Sort((x, y) => Comparer<int>.Default.Compare( (x.X - spawn.X) * (x.X - spawn.X) + (x.Y - spawn.Y) * (x.Y - spawn.Y), (y.X - spawn.X) * (y.X - spawn.X) + (y.Y - spawn.Y) * (y.Y - spawn.Y))); var chests = psr.Account.Vault.Chests; for (int i = 0; i < chests.Count; i++) { Container con = new Container(0x0504, null, false); var inv = chests[i].Items.Select(_ => _ == -1 ? null : (XmlDatas.ItemDescs.ContainsKey((short)_) ? XmlDatas.ItemDescs[(short)_] : null)).ToArray(); for (int j = 0; j < 8; j++) con.Inventory[j] = inv[j]; con.Move(vaultChestPosition[0].X + 0.5f, vaultChestPosition[0].Y + 0.5f); //if getting debugger error here, check database to see if someones account has an extra vault. Delete the line. EnterWorld(con); vaultChestPosition.RemoveAt(0); vaultChests[new Tuple<Container, VaultChest>(con, chests[i])] = con.UpdateCount; } foreach (var i in vaultChestPosition) { SellableObject x = new SellableObject(0x0505); x.Move(i.X + 0.5f, i.Y + 0.5f); EnterWorld(x); } }