fixes
This commit is contained in:
parent
c6bd342e87
commit
2d429fcb6b
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CS2GSI" Version="1.0.7" />
|
<PackageReference Include="CS2GSI" Version="1.0.7" />
|
||||||
<PackageReference Include="CShocker" Version="2.3.1" />
|
<PackageReference Include="CShocker" Version="2.4.0" />
|
||||||
<PackageReference Include="GlaxLogger" Version="1.0.6" />
|
<PackageReference Include="GlaxLogger" Version="1.0.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -8,11 +8,11 @@ namespace OpenCS2hock;
|
|||||||
public struct ShockerAction
|
public struct ShockerAction
|
||||||
{
|
{
|
||||||
public CS2Event TriggerEvent;
|
public CS2Event TriggerEvent;
|
||||||
// ReSharper disable thrice FieldCanBeMadeReadOnly.Global JsonDeserializer will throw a fit
|
// ReSharper disable MemberCanBePrivate.Global -> exposed
|
||||||
public int ShockerId;
|
public readonly int ShockerId;
|
||||||
public ControlAction Action;
|
public readonly ControlAction Action;
|
||||||
public bool ValueFromInput;
|
public readonly bool ValueFromInput;
|
||||||
public IntegerRange IntensityRange, DurationRange;
|
public readonly IntegerRange IntensityRange, DurationRange;
|
||||||
|
|
||||||
public ShockerAction(CS2Event trigger, int shockerId, ControlAction action, bool valueFromInput, IntegerRange intensityRange, IntegerRange durationRange)
|
public ShockerAction(CS2Event trigger, int shockerId, ControlAction action, bool valueFromInput, IntegerRange intensityRange, IntegerRange durationRange)
|
||||||
{
|
{
|
||||||
@ -28,23 +28,18 @@ public struct ShockerAction
|
|||||||
{
|
{
|
||||||
if (!shockers.ContainsKey(ShockerId))
|
if (!shockers.ContainsKey(ShockerId))
|
||||||
return;
|
return;
|
||||||
int intensity = ValueFromInput ? IntensityFromCS2Event(cs2EventArgs) : RandomValueFromRange(IntensityRange);
|
int intensity = ValueFromInput ? IntensityFromCS2Event(cs2EventArgs) : IntensityRange.RandomValueWithinLimits();
|
||||||
int duration = RandomValueFromRange(DurationRange);
|
int duration = DurationRange.RandomValueWithinLimits();
|
||||||
shockers[ShockerId].Control(Action, intensity, duration);
|
shockers[ShockerId].Control(Action, intensity, duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int RandomValueFromRange(IntegerRange range)
|
|
||||||
{
|
|
||||||
return Random.Shared.Next(range.Min, range.Max);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int IntensityFromCS2Event(CS2EventArgs cs2EventArgs)
|
private int IntensityFromCS2Event(CS2EventArgs cs2EventArgs)
|
||||||
{
|
{
|
||||||
return TriggerEvent switch
|
return TriggerEvent switch
|
||||||
{
|
{
|
||||||
CS2Event.OnDamageTaken => MapInt(cs2EventArgs.ValueAsOrDefault<int>(), 0, 100, IntensityRange.Min, IntensityRange.Max),
|
CS2Event.OnDamageTaken => MapInt(cs2EventArgs.ValueAsOrDefault<int>(), 0, 100, IntensityRange.Min, IntensityRange.Max),
|
||||||
CS2Event.OnArmorChange => MapInt(cs2EventArgs.ValueAsOrDefault<int>(), 0, 100, IntensityRange.Min, IntensityRange.Max),
|
CS2Event.OnArmorChange => MapInt(cs2EventArgs.ValueAsOrDefault<int>(), 0, 100, IntensityRange.Min, IntensityRange.Max),
|
||||||
_ => RandomValueFromRange(IntensityRange)
|
_ => IntensityRange.RandomValueWithinLimits()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user