public void SetItemUnlocked(string itemId, bool unlocked) { if (unlocked && ItemUnlocked(itemId)) { return; } if (!unlocked && unlockablesMap.ContainsKey(itemId) && !ItemUnlocked(itemId)) { return; } var added = unlockablesMap.ContainsKey(itemId); unlockablesMap[itemId] = unlocked; OnItemUpdated?.Invoke(new UnlockableItemUpdatedArgs(itemId, unlocked, added)); }
public virtual void SetItemUnlocked(string itemId, bool unlocked) { if (string.IsNullOrEmpty(itemId)) { throw new ArgumentNullException(nameof(itemId), "Can't set unlock status of item with empty ID."); } if (unlocked && ItemUnlocked(itemId)) { return; } if (!unlocked && unlockablesMap.ContainsKey(itemId) && !ItemUnlocked(itemId)) { return; } var added = unlockablesMap.ContainsKey(itemId); unlockablesMap[itemId] = unlocked; OnItemUpdated?.Invoke(new UnlockableItemUpdatedArgs(itemId, unlocked, added)); }