private CooldownID(ICooldown cooldownAsset, Type interactableComponentType, NetworkSide networkSide, CooldownType cooldownType) { this.cooldownAsset = cooldownAsset; this.interactableComponentType = interactableComponentType; this.cooldownType = cooldownType; this.networkSide = networkSide; }
private IEnumerator StartCooldown(ICooldown cd, CooldownSettings cds) { cd.OnCooldown = true; yield return(new WaitForSeconds(cds.cooldownTime)); cd.OnCooldown = false; }
// TODO - Calculate delay private IEnumerator Cooldown(ICooldown cooldownObject) { cooldownObject.NotifyCooldownStart(); yield return(new WaitForSeconds(cooldownObject.GetCooldown())); StopCooldown(cooldownObject); }
private void StopCooldown(ICooldown cooldownObject) { cooldownObject.NotifyCooldownEnd(); StopCoroutine(_cooldowns[cooldownObject]); _cooldowns[cooldownObject] = null; }
public void PutOnCooldown(GameObject go, ICooldown cooldown) { var key = go.GetHashCode() + cooldown.Id.GetHashCode(); if (!_cooldowns.ContainsKey(key)) { _cooldowns.Add(key, new CooldownData(cooldown)); } }
public void PutOnCooldown(ICooldown cooldown) { var key = cooldown.Id.GetHashCode(); if (!_cooldowns.ContainsKey(key)) { _cooldowns.Add(key, new CooldownData(cooldown)); } }
public CommandHandler(IServiceProvider services) { _services = services; _client = services.GetRequiredService <DiscordSocketClient>(); _commands = services.GetRequiredService <CommandService>(); _log = services.GetRequiredService <ILogger>(); _wordSearch = services.GetRequiredService <IWordSearch>(); _cooldown = services.GetRequiredService <ICooldown>(); }
private void StartCooldown(ICooldown cooldownObject) { if (_cooldowns.ContainsKey(cooldownObject)) { _cooldowns[cooldownObject] = StartCoroutine(Cooldown(cooldownObject)); } else { _cooldowns.Add(cooldownObject, StartCoroutine(Cooldown(cooldownObject))); } }
public bool TryAbility(ICooldown cooldownObject) { // If dictionary has key, we used this tool at least once // so we have to check for its cooldown if (_cooldowns.ContainsKey(cooldownObject) && _cooldowns[cooldownObject] != null) { return(false); } StartCooldown(cooldownObject); return(true); }
/// <summary> /// Usar cooldown. /// </summary> /// <param name="cooldownSkill">Interface da habilidade que deseja implementar o cooldown</param> /// <returns>Retorna True se houver, False caso contrario.</returns> public bool Use(ICooldown cooldownSkill) { /// Caso a habilidade use o cooldown sobre o tempo. var cd = cooldownSkill.OverTime ? cooldownSkill.CooldownRequired * Time.deltaTime : cooldownSkill.CooldownRequired; if (AvailableCooldown >= cd) { AvailableCooldown -= cd; currentDelay = 0f; return(true); } return(false); }
private void SaveCooldowns <T>(List <T> cooldowns) where T : ICooldown { for (var i = cooldowns.Count - 1; i >= 0; i--) { ICooldown cooldown = cooldowns[i]; if (cooldown.Until < DateTime.Now.AddMilliseconds(SpellHandler.MinCooldownSaveTimeMillis)) { // already expired or will expire very soon if (cooldown is ActiveRecordBase) { ((ActiveRecordBase)cooldown).DeleteLater(); } } else { var cd = cooldown.AsConsistent(); cd.CharId = Owner.EntityId.Low; cd.Save(); // update or create cooldowns.Add((T)cd); } cooldowns.RemoveAt(i); } }
private void SaveCooldowns <T>(List <T> cooldowns) where T : ICooldown { for (int index = cooldowns.Count - 1; index >= 0; --index) { ICooldown cooldown = (ICooldown)cooldowns[index]; if (cooldown.Until < DateTime.Now.AddMilliseconds((double)SpellHandler.MinCooldownSaveTimeMillis)) { if (cooldown is ActiveRecordBase) { ((ActiveRecordBase)cooldown).DeleteLater(); } } else { IConsistentCooldown consistentCooldown = cooldown.AsConsistent(); consistentCooldown.CharId = this.Owner.EntityId.Low; consistentCooldown.Save(); cooldowns.Add((T)consistentCooldown); } cooldowns.RemoveAt(index); } }
// Update is called once per frame private void Update() { for (int i = 0; i < NUMBEROFSKILLS; i++) { if (cooldowns[i] == null) { continue; } // Updates sprite icons for combos spriteIcons[i].sprite = cooldowns[i].GetIcon(); ICooldown cooldown = cooldowns[i]; float nextAvailableTime = cooldown.GetNextAvailableTime(); float cooldownDuration = cooldown.GetCooldownDuration(); if (nextAvailableTime < Time.time) // Skill is available and ready to use { darkMasks[i].fillAmount = 0; } else { darkMasks[i].fillAmount = Mathf.Lerp(0f, 1f, (nextAvailableTime - Time.time) / cooldownDuration); } } }
/// <summary>Provides the observer with new data.</summary> /// <param name="value">The current notification information.</param> public void OnNext(ICooldown value) { if (this.Skill.Level.Current == 0) { this.BorderColor = this.NotLearnedColor; return; } if (value.Current > 0) { // this.CooldownText.Text = (Math.Min(value.Current, 99)).ToString(CultureInfo.CurrentCulture); // this.CooldownText.CenterOnRectangle(this.blackOverlay); this.cooldownNumber.Value = (int)Math.Min(value.Current, 99); this.cooldownNumber.CenterOnRectangle(this.blackOverlay); ///this.CooldownText.CenterOnRectangle(this.blackOverlay); if (this.Skill.CastData.EnoughMana) { this.BorderColor = this.NotReadyColor; } else { this.BorderColor = this.NotEnoughManaColor; } } else { if (this.Skill.CastData.EnoughMana) { this.BorderColor = this.ReadyColor; } else { this.BorderColor = this.NotEnoughManaColor; } } }
/// <summary> /// Same as IsOn for for indicated serverside Cooldown /// </summary> public static bool IsOnServer(Interaction interaction, ICooldown cooldown) { return(IsOnServer(interaction.PerformerPlayerScript, cooldown)); }
public float GetRemainingDuration(GameObject go, ICooldown cooldown) { return(_cooldowns.ContainsKey(go.GetHashCode() + cooldown.Id.GetHashCode()) ? _cooldowns[cooldown.Id.GetHashCode()].RemainingTime : 0f); }
public bool IsOnCooldown(ICooldown cooldown) { return(_cooldowns.ContainsKey(cooldown.Id.GetHashCode())); }
public bool IsOnCooldown(GameObject go, ICooldown cooldown) { return(_cooldowns.ContainsKey(go.GetHashCode() + cooldown.Id.GetHashCode())); }
/// <summary> /// Cooldown identified by a particular cooldown asset. /// </summary> /// <param name="cooldownAsset"></param> /// <param name="side">network side this cooldown is for</param> /// <returns></returns> public static CooldownID Asset(ICooldown cooldownAsset, NetworkSide side) { return(new CooldownID(cooldownAsset, null, side, CooldownType.Asset)); }
public void Init(ICooldown itemCooldown, CooldownSettings CDS) { pCDS = CDS; pItemCooldown = itemCooldown; StartCoroutine(StartCooldown(itemCooldown, CDS)); }
public float GetRemainingDuration(ICooldown cooldown) { return(_cooldowns.ContainsKey(cooldown.Id.GetHashCode()) ? _cooldowns[cooldown.Id.GetHashCode()].RemainingTime : 0f); }
/// <summary> /// Same as TryStart with NetworkSide.Server /// </summary> public static bool TryStartServer(Interaction interaction, ICooldown cooldown, float secondsOverride = float.NaN) { return(TryStartServer(interaction.PerformerPlayerScript, cooldown, secondsOverride)); }
/// <summary> /// Cooldown Data constructor. /// Initializes the cooldown properties. /// </summary> /// <param name="cooldown">ICooldown class to init values for cooldown data</param> public CooldownData(ICooldown cooldown) { Id = cooldown.Id; RemainingTime = cooldown.CooldownDuration; }
/// <summary> /// Same as IsOn for for indicated clientside Cooldown /// </summary> public static bool IsOnClient(PlayerScript player, ICooldown cooldown) { return(IsOn(player, CooldownID.Asset(cooldown, NetworkSide.Client))); }
/// <summary> /// Same as IsOn for for indicated serverside Cooldown /// </summary> public static bool IsOnServer(PlayerScript player, ICooldown cooldown) { return(IsOn(player, CooldownID.Asset(cooldown, NetworkSide.Server))); }
/// <summary> /// Starts the cooldown for the player if it's not currently on. /// </summary> /// <param name="player"></param> /// <param name="cooldown">cooldown to try starting</param> /// <param name="side">indicates which side's cooldown should be started</param> /// <param name="secondsOverride">custom cooldown time in seconds</param> /// <returns>true if cooldown was successfully started, false if cooldown was already on.</returns> public static bool TryStart(PlayerScript player, ICooldown cooldown, NetworkSide side, float secondsOverride = float.NaN) { return(player.Cooldowns.TryStart(cooldown, side, secondsOverride)); }
/// <summary> /// This function adds new cooldown to the cooldowns list. /// </summary> /// <param name="cooldown">New cooldown to add</param> public void AddCooldown(ICooldown cooldown) { cooldowns.Add(new CooldownData(cooldown)); }
/// <summary> /// Starts the cooldown for the interaction's performer if it's not currently on. /// </summary> /// <param name="interaction">interaction whose performer's cooldown should be started</param> /// <param name="cooldown">cooldown to try starting</param> /// <param name="side">indicates which side's cooldown should be started</param> /// <returns>true if cooldown was successfully started, false if cooldown was already on.</returns> public static bool TryStart(Interaction interaction, ICooldown cooldown, NetworkSide side) { return(TryStart(interaction.PerformerPlayerScript, cooldown, side)); }
public void StartDashCooldown() { dashCooldown = new SimpleTimer(settings.dashSettings.dashCooldown); }
/// <summary> /// Same as TryStart with NetworkSide.Server /// </summary> public static bool TryStartServer(PlayerScript player, ICooldown cooldown, float secondsOverride = float.NaN) { return(TryStart(player, cooldown, NetworkSide.Server, secondsOverride)); }