private void SaveItemToDB(DBGameAccount dbGameAccount, DBToon dbToon, EquipmentSlotId slotId, Item item) { if (item == null) return; if (item.DBInventory == null) item.DBInventory = new DBInventory(); item.DBInventory.DBGameAccount = dbGameAccount; item.DBInventory.DBToon = dbToon; item.DBInventory.LocationX = item.InventoryLocation.X; item.DBInventory.LocationY = item.InventoryLocation.Y; item.DBInventory.EquipmentSlot = (int)slotId; ItemGenerator.SaveToDB(item); item.DBInventory.DBItemInstance = item.DBItemInstance; DBSessions.AccountSession.SaveOrUpdate(item.DBInventory); }
public static GameAccount CreateGameAccount(Account account) { var newDBGameAccount = new DBGameAccount { DBAccount = DBSessions.AccountSession.Get<DBAccount>(account.PersistentID) }; DBSessions.AccountSession.SaveOrUpdate(newDBGameAccount); DBSessions.AccountSession.Flush(); return GetGameAccountByDBGameAccount(newDBGameAccount); }
public GameAccount(DBGameAccount dbGameAccount) : base(dbGameAccount.Id) { DBGameAccount = dbGameAccount; DBGameAccount.LastOnline = (long)DateTime.Now.ToExtendedEpoch(); SetField(); }
public static GameAccount GetGameAccountByDBGameAccount(DBGameAccount dbGameAccount) { if (!LoadedGameAccounts.Any(acc => acc.DBGameAccount.Id == dbGameAccount.Id)) LoadedGameAccounts.Add(new GameAccount(dbGameAccount)); return LoadedGameAccounts.Single(acc => acc.DBGameAccount.Id == dbGameAccount.Id); }