Compare commits
11 Commits
3659e357f2
...
master
Author | SHA1 | Date | |
---|---|---|---|
6631f4fe97 | |||
89e368c176 | |||
da43815a8a | |||
dc54d7d640 | |||
ffb8592972 | |||
2d429fcb6b | |||
c6bd342e87 | |||
82e14c8b9e | |||
3fe43b6e63 | |||
4c7a3c9069 | |||
fcb5bf0a68 |
12
.idea/.idea.OpenCS2hock/.idea/riderPublish.xml
generated
Normal file
12
.idea/.idea.OpenCS2hock/.idea/riderPublish.xml
generated
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="LocationsWithSilentDeleteHolder">
|
||||||
|
<option name="locations">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/OpenCS2hock/bin/Release/net7.0/win-x86/publish" />
|
||||||
|
<option value="$PROJECT_DIR$/OpenCS2hock/bin/Release/net9.0/win-x64/publish" />
|
||||||
|
<option value="$PROJECT_DIR$/OpenCS2hock/bin/Release/net9.0/linux-x64/publish" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -1,5 +1,10 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CUsers_005CGlax_005CRiderProjects_005CCShocker_005CCShocker_005Cbin_005CDebug_005Cnet7_002E0_005CCShocker_002Edll/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CUsers_005CGlax_005CRiderProjects_005CCShocker_005CCShocker_005Cbin_005CDebug_005Cnet7_002E0_005CCShocker_002Edll/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CUsers_005CGlax_005CRiderProjects_005CCShocker_005CCShocker_005Cbin_005CRelease_005Cnet7_002E0_005Cpublish_005CCShocker_002Edll/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CUsers_005CGlax_005CRiderProjects_005CCShocker_005CCShocker_005Cbin_005CRelease_005Cnet9_002E0_005Cwin_002Dx64_005CCShocker_002Edll/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACS2GSI_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F72ce34e4a785473f820cb3a549e2f506c400_003Fc8_003Ff99c719c_003FCS2GSI_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AGSIServer_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F72ce34e4a785473f820cb3a549e2f506c400_003Fa5_003F706f7dd4_003FGSIServer_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F2c8e7ca976f350cba9836d5565dac56b11e0b56656fa786460eb1395857a6fa_003FThrowHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer>
|
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue"><AssemblyExplorer>
|
||||||
<Assembly Path="C:\Users\Glax\RiderProjects\CShocker\CShocker\bin\Debug\net7.0\CShocker.dll" />
|
<Assembly Path="C:\Users\Glax\RiderProjects\CShocker\CShocker\bin\Debug\net7.0\CShocker.dll" />
|
||||||
</AssemblyExplorer></s:String>
|
</AssemblyExplorer></s:String>
|
||||||
|
@ -61,8 +61,9 @@ public class OpenCS2hock
|
|||||||
case CS2Event.OnBombPlanted: this._cs2GSI.OnBombPlanted += args => EventHandler(args, shockerAction); break;
|
case CS2Event.OnBombPlanted: this._cs2GSI.OnBombPlanted += args => EventHandler(args, shockerAction); break;
|
||||||
case CS2Event.OnBombDefused: this._cs2GSI.OnBombDefused += args => EventHandler(args, shockerAction); break;
|
case CS2Event.OnBombDefused: this._cs2GSI.OnBombDefused += args => EventHandler(args, shockerAction); break;
|
||||||
case CS2Event.OnBombExploded: this._cs2GSI.OnBombExploded += args => EventHandler(args, shockerAction); break;
|
case CS2Event.OnBombExploded: this._cs2GSI.OnBombExploded += args => EventHandler(args, shockerAction); break;
|
||||||
case CS2Event.AnyEvent: this._cs2GSI.AnyEvent += args => EventHandler(args, shockerAction); break;
|
case CS2Event.AnyEvent: this._cs2GSI.OnAnyEvent += args => EventHandler(args, shockerAction); break;
|
||||||
case CS2Event.AnyMessage: this._cs2GSI.AnyMessage += args => EventHandler(args, shockerAction); break;
|
case CS2Event.AnyMessage: this._cs2GSI.OnAnyMessage += args => EventHandler(args, shockerAction); break;
|
||||||
|
case CS2Event.OnActivityChange: this._cs2GSI.OnActivityChange += args => EventHandler(args, shockerAction); break;
|
||||||
default: this._logger?.Log(LogLevel.Debug, $"CS2Event {nameof(shockerAction.TriggerEvent)} unknown."); break;
|
default: this._logger?.Log(LogLevel.Debug, $"CS2Event {nameof(shockerAction.TriggerEvent)} unknown."); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,18 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<RootNamespace>OpenCS2Hock</RootNamespace>
|
<RootNamespace>OpenCS2Hock</RootNamespace>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
|
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
|
||||||
|
<LangVersion>latestmajor</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CS2GSI" Version="1.0.7" />
|
<PackageReference Include="CS2GSI" Version="1.1.0" />
|
||||||
<PackageReference Include="CShocker" Version="2.3.1" />
|
<PackageReference Include="CShocker" Version="3.1.0" />
|
||||||
<PackageReference Include="GlaxLogger" Version="1.0.6" />
|
<PackageReference Include="GlaxLogger" Version="1.0.7.2" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
using System.Text.RegularExpressions;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.Versioning;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using CShocker.Devices.Abstract;
|
using CShocker.Devices.Abstract;
|
||||||
using CShocker.Devices.Additional;
|
using CShocker.Devices.Additional;
|
||||||
using CShocker.Devices.APIs;
|
using CShocker.Devices.APIs;
|
||||||
@ -44,15 +46,15 @@ public static class Setup
|
|||||||
switch (pressedKey)
|
switch (pressedKey)
|
||||||
{
|
{
|
||||||
case ConsoleKey.D1:
|
case ConsoleKey.D1:
|
||||||
Console.WriteLine("New LogLevel:");
|
|
||||||
string[] levels = Enum.GetNames<LogLevel>();
|
string[] levels = Enum.GetNames<LogLevel>();
|
||||||
for(int i = 0; i < levels.Length; i++)
|
|
||||||
Console.WriteLine($"{i}) {levels[i]}");
|
|
||||||
int selected;
|
int selected;
|
||||||
while (!int.TryParse(Console.ReadKey().KeyChar.ToString(), out selected) || selected < 0 ||
|
do
|
||||||
selected >= levels.Length)
|
{
|
||||||
{//NYAA
|
Console.Clear();
|
||||||
}
|
Console.WriteLine("New LogLevel:");
|
||||||
|
for (int i = 0; i < levels.Length; i++)
|
||||||
|
Console.WriteLine($"{i}) {levels[i]}");
|
||||||
|
} while (!int.TryParse(Console.ReadKey().KeyChar.ToString(), out selected) || selected < 0 || selected >= levels.Length);
|
||||||
Console.WriteLine();//NewLine after Input
|
Console.WriteLine();//NewLine after Input
|
||||||
c.LogLevel = Enum.Parse<LogLevel>(levels[selected]);
|
c.LogLevel = Enum.Parse<LogLevel>(levels[selected]);
|
||||||
break;
|
break;
|
||||||
@ -60,6 +62,7 @@ public static class Setup
|
|||||||
AddApisWorkflow(ref c);
|
AddApisWorkflow(ref c);
|
||||||
break;
|
break;
|
||||||
case ConsoleKey.D3:
|
case ConsoleKey.D3:
|
||||||
|
// ReSharper disable once PossibleInvalidCastExceptionInForeachLoop Only returning OpenShockApi Objects
|
||||||
foreach (OpenShockApi api in c.Apis.Where(a => a is OpenShockApi))
|
foreach (OpenShockApi api in c.Apis.Where(a => a is OpenShockApi))
|
||||||
{
|
{
|
||||||
Configuration configuration = c;
|
Configuration configuration = c;
|
||||||
@ -108,12 +111,12 @@ public static class Setup
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Select API:");
|
Console.WriteLine("Select API:");
|
||||||
Console.WriteLine("1) OpenShock (HTTP)");
|
Console.WriteLine("1) OpenShock (HTTP)");
|
||||||
Console.WriteLine("2) OpenShock (Serial)");
|
Console.WriteLine("2) OpenShock (Serial Windows Only)");
|
||||||
Console.WriteLine("3) PiShock (HTTP) NotImplemented"); //TODO
|
Console.WriteLine("3) PiShock (HTTP) NotImplemented"); //TODO
|
||||||
Console.WriteLine("4) PiShock (Serial) NotImplemented"); //TODO
|
Console.WriteLine("4) PiShock (Serial Windows Only) NotImplemented"); //TODO
|
||||||
char selectedChar = Console.ReadKey().KeyChar;
|
char selectedChar = Console.ReadKey().KeyChar;
|
||||||
int selected = 0;
|
int selected;
|
||||||
while (!int.TryParse(selectedChar.ToString(), out selected) || selected < 1 || selected > 3)
|
while (!int.TryParse(selectedChar.ToString(), out selected) || selected < 1 || selected > 4)
|
||||||
selectedChar = Console.ReadKey().KeyChar;
|
selectedChar = Console.ReadKey().KeyChar;
|
||||||
Console.WriteLine();//NewLine after Input
|
Console.WriteLine();//NewLine after Input
|
||||||
|
|
||||||
@ -122,14 +125,16 @@ public static class Setup
|
|||||||
switch (selected)
|
switch (selected)
|
||||||
{
|
{
|
||||||
case 1: //OpenShock (HTTP)
|
case 1: //OpenShock (HTTP)
|
||||||
apiUri = QueryString("OpenShock API-Endpoint (https://api.shocklink.net):", "https://api.shocklink.net");
|
apiUri = QueryString($"OpenShock API-Endpoint ({OpenShockApi.DefaultEndpoint}):", OpenShockApi.DefaultEndpoint);
|
||||||
apiKey = QueryString("OpenShock API-Key:","");
|
apiKey = QueryString("OpenShock API-Key:","");
|
||||||
api = new OpenShockHttp(apiKey, apiUri);
|
api = new OpenShockHttp(apiKey, apiUri);
|
||||||
foreach(OpenShockShocker shocker in ((OpenShockHttp)api).GetShockers())
|
foreach(OpenShockShocker shocker in ((OpenShockHttp)api).GetShockers())
|
||||||
c.Shockers.Add(c.Shockers.Any() ? c.Shockers.Keys.Max() + 1 : 0, shocker);
|
c.Shockers.Add(c.Shockers.Any() ? c.Shockers.Keys.Max() + 1 : 0, shocker);
|
||||||
goto default;
|
goto default;
|
||||||
case 2: //OpenShock (Serial)
|
case 2: //OpenShock (Serial)
|
||||||
apiUri = QueryString("OpenShock API-Endpoint (https://api.shocklink.net):", "https://api.shocklink.net");
|
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
|
throw new PlatformNotSupportedException("Serial is only supported on Windows.");
|
||||||
|
apiUri = QueryString($"OpenShock API-Endpoint ({OpenShockApi.DefaultEndpoint}):", OpenShockApi.DefaultEndpoint);
|
||||||
apiKey = QueryString("OpenShock API-Key:","");
|
apiKey = QueryString("OpenShock API-Key:","");
|
||||||
SerialPortInfo serialPort = SelectSerialPort();
|
SerialPortInfo serialPort = SelectSerialPort();
|
||||||
api = new OpenShockSerial(serialPort, apiKey, apiUri);
|
api = new OpenShockSerial(serialPort, apiKey, apiUri);
|
||||||
@ -137,7 +142,11 @@ public static class Setup
|
|||||||
c.Shockers.Add(c.Shockers.Any() ? c.Shockers.Keys.Max() + 1 : 0, shocker);
|
c.Shockers.Add(c.Shockers.Any() ? c.Shockers.Keys.Max() + 1 : 0, shocker);
|
||||||
goto default;
|
goto default;
|
||||||
case 3: //PiShock (HTTP)
|
case 3: //PiShock (HTTP)
|
||||||
|
goto default;
|
||||||
case 4: //PiShock (Serial)
|
case 4: //PiShock (Serial)
|
||||||
|
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
|
throw new PlatformNotSupportedException("Serial is only supported on Windows.");
|
||||||
|
goto default;
|
||||||
default:
|
default:
|
||||||
if (api is null)
|
if (api is null)
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
@ -146,21 +155,19 @@ public static class Setup
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
private static SerialPortInfo SelectSerialPort()
|
private static SerialPortInfo SelectSerialPort()
|
||||||
{
|
{
|
||||||
List<SerialPortInfo> serialPorts = SerialHelper.GetSerialPorts();
|
List<SerialPortInfo> serialPorts = SerialHelper.GetSerialPorts();
|
||||||
|
|
||||||
for(int i = 0; i < serialPorts.Count; i++)
|
|
||||||
Console.WriteLine($"{i}) {serialPorts[i]}");
|
|
||||||
|
|
||||||
Console.WriteLine($"Select Serial Port [0-{serialPorts.Count-1}]:");
|
int selectedPort;
|
||||||
string? selectedPortStr = Console.ReadLine();
|
do
|
||||||
int selectedPort = -1;
|
|
||||||
while (!int.TryParse(selectedPortStr, out selectedPort) || selectedPort < 0 || selectedPort > serialPorts.Count - 1)
|
|
||||||
{
|
{
|
||||||
|
Console.Clear();
|
||||||
|
for(int i = 0; i < serialPorts.Count; i++)
|
||||||
|
Console.WriteLine($"{i}) {serialPorts[i]}");
|
||||||
Console.WriteLine($"Select Serial Port [0-{serialPorts.Count-1}]:");
|
Console.WriteLine($"Select Serial Port [0-{serialPorts.Count-1}]:");
|
||||||
selectedPortStr = Console.ReadLine();
|
} while (!int.TryParse(Console.ReadLine(), out selectedPort) || selectedPort < 0 || selectedPort >= serialPorts.Count);
|
||||||
}
|
|
||||||
Console.WriteLine();//NewLine after Input
|
Console.WriteLine();//NewLine after Input
|
||||||
|
|
||||||
return serialPorts[selectedPort];
|
return serialPorts[selectedPort];
|
||||||
@ -180,14 +187,15 @@ public static class Setup
|
|||||||
|
|
||||||
private static int GetShockerId(Dictionary<int, Shocker> shockersDict)
|
private static int GetShockerId(Dictionary<int, Shocker> shockersDict)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Select Shocker:");
|
|
||||||
List<Shocker> shockers = shockersDict.Values.ToList();
|
List<Shocker> shockers = shockersDict.Values.ToList();
|
||||||
for (int i = 0; i < shockers.Count; i++)
|
|
||||||
Console.WriteLine($"{i}) {shockers[i]}");
|
|
||||||
|
|
||||||
int selectedShockerIndex;
|
int selectedShockerIndex;
|
||||||
while (!int.TryParse(Console.ReadLine(), out selectedShockerIndex) || selectedShockerIndex < 0 || selectedShockerIndex > shockersDict.Count)
|
do
|
||||||
|
{
|
||||||
|
Console.Clear();
|
||||||
Console.WriteLine("Select Shocker:");
|
Console.WriteLine("Select Shocker:");
|
||||||
|
for (int i = 0; i < shockers.Count; i++)
|
||||||
|
Console.WriteLine($"{i}) {shockers[i]}");
|
||||||
|
} while (!int.TryParse(Console.ReadLine(), out selectedShockerIndex) || selectedShockerIndex < 0 || selectedShockerIndex > shockersDict.Count);
|
||||||
Console.WriteLine();//NewLine after Input
|
Console.WriteLine();//NewLine after Input
|
||||||
|
|
||||||
Shocker shocker = shockers[selectedShockerIndex];
|
Shocker shocker = shockers[selectedShockerIndex];
|
||||||
@ -195,6 +203,49 @@ public static class Setup
|
|||||||
return shockersDict.First(s => s.Value == shocker).Key;
|
return shockersDict.First(s => s.Value == shocker).Key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IntegerRange GetIntegerRange(int min, int max, string? unit = null)
|
||||||
|
{
|
||||||
|
Regex rangeRex = new (@"([0-9]{1,5})\-([0-9]{1,5})");
|
||||||
|
|
||||||
|
string intensityRangeStr;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
intensityRangeStr = QueryString($"Range ({min}-{max}) {(unit is null ? "" : $"in {unit}")}:", "0-100");
|
||||||
|
} while (!rangeRex.IsMatch(intensityRangeStr));
|
||||||
|
return new IntegerRange(short.Parse(rangeRex.Match(intensityRangeStr).Groups[1].Value), short.Parse(rangeRex.Match(intensityRangeStr).Groups[2].Value));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CS2Event GetTrigger()
|
||||||
|
{
|
||||||
|
string[] eventNames = Enum.GetNames(typeof(CS2Event));
|
||||||
|
|
||||||
|
int selectedIndex;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Console.Clear();
|
||||||
|
Console.WriteLine("Select CS2 Trigger-Event:");
|
||||||
|
for (int i = 0; i < eventNames.Length; i++)
|
||||||
|
Console.WriteLine($"{i}) {eventNames[i]}");
|
||||||
|
} while (!int.TryParse(Console.ReadLine(), out selectedIndex) || selectedIndex < 0 || selectedIndex >= eventNames.Length);
|
||||||
|
|
||||||
|
return Enum.Parse<CS2Event>(eventNames[selectedIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ControlAction GetControlAction()
|
||||||
|
{
|
||||||
|
string[] actionNames = Enum.GetNames(typeof(ControlAction));
|
||||||
|
int selectedIndex;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Console.Clear();
|
||||||
|
Console.WriteLine("Select Action:");
|
||||||
|
for (int i = 0; i < actionNames.Length; i++)
|
||||||
|
Console.WriteLine($"{i}) {actionNames[i]}");
|
||||||
|
} while (!int.TryParse(Console.ReadLine(), out selectedIndex) || selectedIndex < 0 || selectedIndex >= actionNames.Length);
|
||||||
|
|
||||||
|
return Enum.Parse<ControlAction>(actionNames[selectedIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
private static bool QueryBool(string queryString, bool defaultResult)
|
private static bool QueryBool(string queryString, bool defaultResult)
|
||||||
{
|
{
|
||||||
Console.WriteLine(queryString);
|
Console.WriteLine(queryString);
|
||||||
@ -209,41 +260,4 @@ public static class Setup
|
|||||||
string? userInput = Console.ReadLine();
|
string? userInput = Console.ReadLine();
|
||||||
return userInput?.Length > 0 ? userInput : defaultResult;
|
return userInput?.Length > 0 ? userInput : defaultResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IntegerRange GetIntegerRange(int min, int max, string? unit = null)
|
|
||||||
{
|
|
||||||
Regex rangeRex = new (@"([0-9]{1,5})\-([0-9]{1,5})");
|
|
||||||
string intensityRangeStr = "";
|
|
||||||
while(!rangeRex.IsMatch(intensityRangeStr))
|
|
||||||
intensityRangeStr = QueryString($"Range ({min}-{max}) {(unit is null ? "" : $"in {unit}")}:", "0-100");
|
|
||||||
return new IntegerRange(short.Parse(rangeRex.Match(intensityRangeStr).Groups[1].Value), short.Parse(rangeRex.Match(intensityRangeStr).Groups[2].Value));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static CS2Event GetTrigger()
|
|
||||||
{
|
|
||||||
string[] names = Enum.GetNames(typeof(CS2Event));
|
|
||||||
Console.WriteLine("Select CS2 Trigger-Event:");
|
|
||||||
for (int i = 0; i < names.Length; i++)
|
|
||||||
Console.WriteLine($"{i}) {names[i]}");
|
|
||||||
|
|
||||||
int selectedIndex;
|
|
||||||
while (!int.TryParse(Console.ReadLine(), out selectedIndex))
|
|
||||||
Console.WriteLine("Select CS2 Trigger-Event:");
|
|
||||||
|
|
||||||
return Enum.Parse<CS2Event>(names[selectedIndex]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ControlAction GetControlAction()
|
|
||||||
{
|
|
||||||
string[] names = Enum.GetNames(typeof(ControlAction));
|
|
||||||
Console.WriteLine("Select Action:");
|
|
||||||
for (int i = 0; i < names.Length; i++)
|
|
||||||
Console.WriteLine($"{i}) {names[i]}");
|
|
||||||
|
|
||||||
int selectedIndex;
|
|
||||||
while (!int.TryParse(Console.ReadLine(), out selectedIndex))
|
|
||||||
Console.WriteLine("Select Action:");
|
|
||||||
|
|
||||||
return Enum.Parse<ControlAction>(names[selectedIndex]);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -8,7 +8,7 @@ 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 int ShockerId;
|
||||||
public ControlAction Action;
|
public ControlAction Action;
|
||||||
public bool ValueFromInput;
|
public bool ValueFromInput;
|
||||||
@ -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()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ Example `config.json`. Place next to executable. Will also be generated on first
|
|||||||
"Max": 1000
|
"Max": 1000
|
||||||
},
|
},
|
||||||
"ApiType": 0,
|
"ApiType": 0,
|
||||||
"Endpoint": "https://api.shocklink.net",
|
"Endpoint": "https://api.shocklink.app",
|
||||||
"ApiKey": "API KEY HERE"
|
"ApiKey": "API KEY HERE"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
Reference in New Issue
Block a user