Add OnDamageTaken

This commit is contained in:
glax 2024-01-16 01:20:41 +01:00
parent f01d721281
commit 9f961f2c65
3 changed files with 15 additions and 2 deletions

View File

@ -53,8 +53,20 @@ public class OpenCS2hock
case "OnRoundWin":
this._cs2GSI.OnRoundWin += (cs2EventArgs) => shocker.Control(Settings.StringToAction(kv.Value));
break;
case "OnDamageTaken":
this._cs2GSI.OnDamageTaken += (cs2EventArgs) =>
shocker.Control(Settings.StringToAction(kv.Value),
intensity: MapInt(cs2EventArgs.ValueAsOrDefault<int>(), 0, 100,
_settings.IntensityRange.Min, _settings.IntensityRange.Max));
break;
}
}
}
}
private int MapInt(int input, int fromLow, int fromHigh, int toLow, int toHigh)
{
int mappedValue = (input - fromLow) * (toHigh - toLow) / (fromHigh - fromLow) + toLow;
return mappedValue;
}
}

View File

@ -9,7 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CS2GSI" Version="1.0.2" />
<PackageReference Include="CS2GSI" Version="1.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

View File

@ -32,7 +32,8 @@ public struct Settings
{"OnRoundStart", "Vibrate"},
{"OnRoundEnd", "Nothing"},
{"OnRoundWin", "Beep"},
{"OnRoundLoss", "Nothing"}
{"OnRoundLoss", "Nothing"},
{"OnDamageTaken", "Vibrate"}
};
public Settings()