namespace SPTarkov.Server.Core.Extensions { public static class DictionaryExtensions { /// /// Add a value by key to a dictionary, if the key doesn't exist, create it /// /// Dictionary key type /// Dictionary to add/update /// Key to update by /// Value to add to key public static void AddOrUpdate(this IDictionary dict, T key, double value) where T : notnull { if (!dict.TryAdd(key, value)) { dict[key] += value; } } /// /// Add a value by key to a dictionary, if the key doesn't exist, create it /// /// Dictionary key type /// Dictionary to add/update /// Key to update by /// Value to add to key public static void AddOrUpdate(this IDictionary dict, T key, int value) where T : notnull { if (!dict.TryAdd(key, value)) { dict[key] += value; } } } }