public Cooldown GetCooldown(CooldownType type, uint id) { string key = type.ToString() + id; Cooldown cool; cooldownDict.TryGetValue(key, out cool); return(cool); }
public void DeleteCooldown(CooldownType type, uint id) { string key = type.ToString() + id; Cooldown cool; cooldownDict.TryGetValue(key, out cool); if (cool != null) { cool.Dispose(); } cooldownDict.Remove(key); }
/// <summary> /// Sets or updates a cooldown for a user. /// </summary> public void SetCooldown(CooldownType type, string name, TimeSpan duration) { DateTime expiresOn = DateTime.UtcNow.Add(duration); string id = $"{type.ToString().ToLower()}:{name}"; if (type.EqualsAny(CooldownType.Command, CooldownType.Global, CooldownType.Notify)) { if (!InternalCooldowns.TryAdd(id, expiresOn)) { InternalCooldowns[id] = expiresOn; } } if (type == CooldownType.Claimable) { Claimable info = Engine.GetClaimable(name); if (Cooldowns.ContainsKey(id)) { // if you can set a claimable cooldown. bool canUpdate = (Cooldowns[id] - DateTime.UtcNow) <= TimeSpan.Zero; if (canUpdate) { // Set up/update the streak stats if ((DateTime.UtcNow - Cooldowns[id]) >= info.Preservation) // if the streak will reset. { SetStat(info.StreakId, 1); } else { UpdateStat(info.StreakId, 1); } Cooldowns[id] = DateTime.UtcNow.Add(info.Cooldown); // set new expiration. } } else { SetStat(info.StreakId, 1); Cooldowns[id] = DateTime.UtcNow.Add(info.Cooldown); } } if (type == CooldownType.Item) { if (!Cooldowns.TryAdd(id, expiresOn)) { Cooldowns[id] = expiresOn; } } }
public void AddCooldown(CooldownType type, uint id, float cdTime) { Cooldown cool = GetCooldown(type, id); if (cool != null) { cool.Dispose(); } cool = Cooldown.Create(type, id, cdTime); string key = type.ToString() + id; cooldownDict[key] = cool; if (OnCooldownChange != null) { OnCooldownChange(cool); } }
public Rectangle GetCooldownRectangle(CooldownType type) { return(SpriteAtlas.Cooldowns[type.ToString()].Rectangle); }
public Rectangle GetCooldownRectangle(CooldownType type) { return SpriteAtlas.Cooldowns[type.ToString()].Rectangle; }