public Player(GameSession session, Account account, PlayerDto dto) { Session = session; Account = account; _tutorialState = dto.TutorialState; _level = dto.Level; _totalExperience = (uint)dto.TotalExperience; _pen = (uint)dto.PEN; _ap = (uint)dto.AP; _coins1 = (uint)dto.Coins1; _coins2 = (uint)dto.Coins2; Settings = new PlayerSettingManager(this, dto); DenyManager = new DenyManager(this, dto); Mailbox = new Mailbox(this, dto); Inventory = new Inventory(this, dto); CharacterManager = new CharacterManager(this, dto); RoomInfo = new PlayerRoomInfo(); }
/// <summary> /// Saves all pending changes to the database /// </summary> public void Save() { using (var db = GameDatabase.Open()) { if (NeedsToSave) { db.Update(new PlayerDto { Id = (int)Account.Id, TutorialState = TutorialState, Level = Level, TotalExperience = (int)TotalExperience, PEN = (int)PEN, AP = (int)AP, Coins1 = (int)Coins1, Coins2 = (int)Coins2, CurrentCharacterSlot = CharacterManager.CurrentSlot }); NeedsToSave = false; } Settings.Save(db); Inventory.Save(db); CharacterManager.Save(db); LicenseManager.Save(db); DenyManager.Save(db); Mailbox.Save(db); DeathMatch.Save(db); TouchDown.Save(db); Chasser.Save(db); BattleRoyal.Save(db); CaptainMode.Save(db); Mission.Save(db); } }