Skip to content

Commit

Permalink
Check cooldown for IShock
Browse files Browse the repository at this point in the history
  • Loading branch information
LucHeart committed Apr 24, 2024
1 parent ba28093 commit 716eae4
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion ShockOsc/Services/ShockOsc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ private async Task ReceiveLogic()
switch (action)
{
case "IShock":
// TODO: check Cooldowns
if (value is not true) return;
if (_underscoreConfig.KillSwitch)
{
Expand All @@ -308,6 +307,21 @@ private async Task ReceiveLogic()
await LogIgnoredAfk();
return;
}

var cooldownTime = _configManager.Config.Behaviour.CooldownTime;
if(programGroup.ConfigGroup is { OverrideCooldownTime: true })
cooldownTime = programGroup.ConfigGroup.CooldownTime;

var isActiveOrOnCooldown =
programGroup.LastExecuted.AddMilliseconds(cooldownTime)
.AddMilliseconds(programGroup.LastDuration) > DateTime.UtcNow;

if (isActiveOrOnCooldown)
{
programGroup.TriggerMethod = TriggerMethod.None;
_logger.LogInformation("Ignoring IShock, group {Group} is on cooldown", programGroup.Name);
return;
}

OsTask.Run(() => InstantShock(programGroup, GetDuration(programGroup), GetIntensity(programGroup)));

Expand Down

0 comments on commit 716eae4

Please sign in to comment.