public static void HandleItemGenericUnlock(WorldSession session, ClientItemGenericUnlock itemGenericUnlock) { Item item = session.Player.Inventory.GetItem(itemGenericUnlock.Location); if (item == null) { throw new InvalidPacketValueException(); } GenericUnlockEntryEntry entry = GameTableManager.Instance.GenericUnlockEntry.GetEntry(item.Entry.GenericUnlockSetId); if (entry == null) { throw new InvalidPacketValueException(); } // TODO: should some client error be shown for this? if (!session.GenericUnlockManager.IsUnlocked((GenericUnlockType)entry.GenericUnlockTypeEnum, entry.UnlockObject)) { return; } if (session.Player.Inventory.ItemUse(item)) { session.GenericUnlockManager.Unlock((ushort)entry.Id); } }
/// <summary> /// Create new <see cref="GenericUnlock"/> entry from supplied id. /// </summary> public void Unlock(ushort genericUnlockEntryId) { GenericUnlockEntryEntry entry = GameTableManager.Instance.GenericUnlockEntry.GetEntry(genericUnlockEntryId); if (entry == null) { SendUnlockResult(GenericUnlockResult.Invalid); return; } if (unlocks.ContainsKey(genericUnlockEntryId)) { SendUnlockResult(GenericUnlockResult.AlreadyUnlocked); return; } unlocks.Add(genericUnlockEntryId, new GenericUnlock(session.Account, entry)); SendUnlock(genericUnlockEntryId); SendUnlockResult(GenericUnlockResult.Unlocked); }
/// <summary> /// Create a new <see cref="CostumeUnlock"/> from supplied <see cref="GenericUnlockEntryEntry"/>. /// </summary> public GenericUnlock(AccountModel account, GenericUnlockEntryEntry entry) { Entry = entry; accountId = account.Id; isDirty = true; }
/// <summary> /// Create a new <see cref="CostumeUnlock"/> from existing <see cref="AccountGenericUnlockModel"/> database model. /// </summary> public GenericUnlock(AccountGenericUnlockModel model) { Entry = GameTableManager.Instance.GenericUnlockEntry.GetEntry(model.Entry); accountId = model.Id; }