Compare commits
No commits in common. "master" and "1.0" have entirely different histories.
@ -1,3 +0,0 @@
|
|||||||
<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:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CS/@EntryIndexedValue">CS</s:String>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=steamid/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
|
@ -1,4 +0,0 @@
|
|||||||
<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/ResxEditorPersonal/CheckedGroups/=CS2GSI_002FResources/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
|
|
||||||
<s:Boolean x:Key="/Default/ResxEditorPersonal/Initialized/@EntryValue">True</s:Boolean></wpf:ResourceDictionary>
|
|
@ -1,31 +0,0 @@
|
|||||||
namespace CS2GSI;
|
|
||||||
|
|
||||||
public enum CS2Event : byte {
|
|
||||||
OnKill = 0,
|
|
||||||
OnHeadshot = 1,
|
|
||||||
OnDeath = 2,
|
|
||||||
OnFlashed = 3,
|
|
||||||
OnBurning = 4,
|
|
||||||
OnSmoked = 5,
|
|
||||||
OnRoundStart = 6,
|
|
||||||
OnRoundOver = 7,
|
|
||||||
OnRoundWin = 8,
|
|
||||||
OnRoundLoss = 9,
|
|
||||||
OnDamageTaken = 10,
|
|
||||||
OnMatchStart = 11,
|
|
||||||
OnMatchOver = 12,
|
|
||||||
OnMoneyChange = 13,
|
|
||||||
OnHealthChange = 14,
|
|
||||||
OnArmorChange = 15,
|
|
||||||
OnHelmetChange = 16,
|
|
||||||
OnEquipmentValueChange = 17,
|
|
||||||
OnTeamChange = 18,
|
|
||||||
OnPlayerChange = 19,
|
|
||||||
OnHalfTime = 20,
|
|
||||||
OnFreezeTime = 21,
|
|
||||||
OnBombPlanted = 22,
|
|
||||||
OnBombDefused = 23,
|
|
||||||
OnBombExploded = 24,
|
|
||||||
AnyEvent = 25,
|
|
||||||
AnyMessage = 26,
|
|
||||||
}
|
|
@ -2,22 +2,20 @@
|
|||||||
|
|
||||||
public class CS2EventArgs : EventArgs
|
public class CS2EventArgs : EventArgs
|
||||||
{
|
{
|
||||||
private readonly object? _value;
|
public object? Value;
|
||||||
public readonly bool HasValue;
|
|
||||||
|
|
||||||
public CS2EventArgs(object? value = null)
|
public CS2EventArgs(object? value = null)
|
||||||
{
|
{
|
||||||
this._value = value;
|
this.Value = value;
|
||||||
this.HasValue = value is not null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public T? ValueAsOrDefault<T>()
|
public T? ValueAsOrDefault<T>()
|
||||||
{
|
{
|
||||||
return _value is T val ? val : default;
|
return Value is T val ? val : default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return _value?.ToString() ?? "NoArgs";
|
return Value?.ToString() ?? "NoArgs";
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using CS2GSI.GameState;
|
using CS2GSI.GameState;
|
||||||
|
using CS2Event = CS2GSI.CS2GSI.CS2Event;
|
||||||
|
|
||||||
namespace CS2GSI;
|
namespace CS2GSI;
|
||||||
|
|
||||||
@ -31,18 +32,9 @@ internal static class CS2EventGenerator
|
|||||||
|
|
||||||
if(newGameState.Round?.Phase == Round.RoundPhase.Over && lastGameState.Round?.Phase == Round.RoundPhase.Live)
|
if(newGameState.Round?.Phase == Round.RoundPhase.Over && lastGameState.Round?.Phase == Round.RoundPhase.Live)
|
||||||
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnRoundOver, new CS2EventArgs()));
|
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnRoundOver, new CS2EventArgs()));
|
||||||
|
|
||||||
if (newGameState.Map?.Round is not null && newGameState.Map?.Round != previousPlayerState.Map?.Round)
|
|
||||||
{
|
|
||||||
if(newGameState.Round?.WinnerTeam is not null && newGameState.Round?.WinnerTeam == previousPlayerState.Player?.Team)
|
|
||||||
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnRoundWin, new CS2EventArgs()));
|
|
||||||
|
|
||||||
if(newGameState.Round?.WinnerTeam is not null && newGameState.Round?.WinnerTeam != previousPlayerState.Player?.Team)
|
|
||||||
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnRoundLoss, new CS2EventArgs()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newGameState.Map?.Phase == Map.MapPhase.Live && lastGameState.Map?.Phase == Map.MapPhase.Warmup)
|
if(newGameState.Map?.Phase == Map.MapPhase.Live && lastGameState.Map?.Phase != Map.MapPhase.Live)
|
||||||
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnMatchStart, new CS2EventArgs()));
|
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnMatchStart, new CS2EventArgs()));
|
||||||
|
|
||||||
if(newGameState.Map?.Phase == Map.MapPhase.GameOver && lastGameState.Map?.Phase != Map.MapPhase.GameOver)
|
if(newGameState.Map?.Phase == Map.MapPhase.GameOver && lastGameState.Map?.Phase != Map.MapPhase.GameOver)
|
||||||
@ -91,22 +83,22 @@ internal static class CS2EventGenerator
|
|||||||
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnSmoked, new CS2EventArgs()));
|
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnSmoked, new CS2EventArgs()));
|
||||||
|
|
||||||
if(newGameState.Player?.State?.Health < previousPlayerState.Player?.State?.Health && newGameState.Player is { State: not null})
|
if(newGameState.Player?.State?.Health < previousPlayerState.Player?.State?.Health && newGameState.Player is { State: not null})
|
||||||
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnDamageTaken, new CS2EventArgs(previousPlayerState.Player?.State?.Health - newGameState.Player?.State?.Health)));
|
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnDamageTaken, new CS2EventArgs(newGameState.Player?.State?.Health)));
|
||||||
|
|
||||||
if(newGameState.Player?.State?.Health != previousPlayerState.Player?.State?.Health && newGameState.Player is { State: not null})
|
if(newGameState.Player?.State?.Health != previousPlayerState.Player?.State?.Health && newGameState.Player is { State: not null})
|
||||||
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnHealthChange, new CS2EventArgs(newGameState.Player?.State?.Health - previousPlayerState.Player?.State?.Health)));
|
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnHealthChange, new CS2EventArgs(newGameState.Player?.State?.Health)));
|
||||||
|
|
||||||
if(newGameState.Player?.State?.Money != previousPlayerState.Player?.State?.Money && newGameState.Player is { State: not null})
|
if(newGameState.Player?.State?.Money != previousPlayerState.Player?.State?.Money && newGameState.Player is { State: not null})
|
||||||
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnMoneyChange, new CS2EventArgs(newGameState.Player?.State?.Money - previousPlayerState.Player?.State?.Money)));
|
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnMoneyChange, new CS2EventArgs(newGameState.Player?.State?.Money)));
|
||||||
|
|
||||||
if(newGameState.Player?.State?.Armor != previousPlayerState.Player?.State?.Armor && newGameState.Player is { State: not null})
|
if(newGameState.Player?.State?.Armor != previousPlayerState.Player?.State?.Armor && newGameState.Player is { State: not null})
|
||||||
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnArmorChange, new CS2EventArgs(newGameState.Player?.State?.Armor - previousPlayerState.Player?.State?.Armor)));
|
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnArmorChange, new CS2EventArgs(newGameState.Player?.State?.Armor)));
|
||||||
|
|
||||||
if(newGameState.Player?.State?.Helmet != previousPlayerState.Player?.State?.Helmet && newGameState.Player is { State: not null})
|
if(newGameState.Player?.State?.Helmet != previousPlayerState.Player?.State?.Helmet && newGameState.Player is { State: not null})
|
||||||
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnHelmetChange, new CS2EventArgs(newGameState.Player?.State?.Helmet)));
|
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnHelmetChange, new CS2EventArgs(newGameState.Player?.State?.Helmet)));
|
||||||
|
|
||||||
if(newGameState.Player?.State?.EquipmentValue != previousPlayerState.Player?.State?.EquipmentValue && newGameState.Player is { State: not null})
|
if(newGameState.Player?.State?.EquipmentValue != previousPlayerState.Player?.State?.EquipmentValue && newGameState.Player is { State: not null})
|
||||||
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnEquipmentValueChange, new CS2EventArgs(newGameState.Player?.State?.EquipmentValue - previousPlayerState.Player?.State?.EquipmentValue)));
|
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnEquipmentValueChange, new CS2EventArgs(newGameState.Player?.State?.EquipmentValue)));
|
||||||
|
|
||||||
if(newGameState.Player?.Team != previousPlayerState.Player?.Team && newGameState.Player is not null)
|
if(newGameState.Player?.Team != previousPlayerState.Player?.Team && newGameState.Player is not null)
|
||||||
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnTeamChange, new CS2EventArgs(newGameState.Player?.Team)));
|
events.Add(new ValueTuple<CS2Event, CS2EventArgs>(CS2Event.OnTeamChange, new CS2EventArgs(newGameState.Player?.Team)));
|
||||||
|
172
CS2GSI/CS2GSI.cs
172
CS2GSI/CS2GSI.cs
@ -6,45 +6,46 @@ namespace CS2GSI;
|
|||||||
|
|
||||||
public class CS2GSI
|
public class CS2GSI
|
||||||
{
|
{
|
||||||
private readonly GSIServer _gsiServer = null!;
|
private GSIServer _gsiServer;
|
||||||
private readonly List<CS2GameState> _allGameStates = new();
|
private List<CS2GameState> _allGameStates = new();
|
||||||
private CS2GameState? _lastLocalGameState = null;
|
private CS2GameState? _lastLocalGameState = null;
|
||||||
private readonly ILogger? _logger;
|
private ILogger? logger;
|
||||||
public bool IsRunning => this._gsiServer.IsRunning;
|
|
||||||
public CS2GameState? CurrentGameState => _lastLocalGameState;
|
|
||||||
|
|
||||||
public CS2GSI(ILogger? logger = null)
|
public CS2GSI(ILogger? logger = null)
|
||||||
{
|
{
|
||||||
this._logger = logger;
|
this.logger = logger;
|
||||||
this._logger?.Log(LogLevel.Information, Resources.Installing_GSI_File);
|
this.logger?.Log(LogLevel.Information, "Installing GSI-Configfile...");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GsiConfigInstaller.InstallGsi();
|
GsiConfigInstaller.InstallGsi();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
this._logger?.Log(LogLevel.Error, e.StackTrace);
|
this.logger?.Log(LogLevel.Error, e.StackTrace);
|
||||||
this._logger?.Log(LogLevel.Critical, Resources.Installing_GSI_File_Failed);
|
this.logger?.Log(LogLevel.Critical, "Could not install GSI-Configfile. Exiting.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._gsiServer = new GSIServer(3000, logger);
|
this._gsiServer = new GSIServer(3000, logger);
|
||||||
this._gsiServer.OnMessage += GsiServerOnOnMessage;
|
this._gsiServer.OnMessage += GsiServerOnOnMessage;
|
||||||
|
|
||||||
|
while(this._gsiServer.IsRunning)
|
||||||
|
Thread.Sleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GsiServerOnOnMessage(string messageJson)
|
private void GsiServerOnOnMessage(string messageJson)
|
||||||
{
|
{
|
||||||
JObject jsonObject = JObject.Parse(messageJson);
|
JObject jsonObject = JObject.Parse(messageJson);
|
||||||
CS2GameState newState = CS2GameState.ParseFromJObject(jsonObject);
|
CS2GameState newState = CS2GameState.ParseFromJObject(jsonObject);
|
||||||
this._logger?.Log(LogLevel.Debug, $"{Resources.Received_State}:\n{newState.ToString()}");
|
this.logger?.Log(LogLevel.Debug, $"Received State:\n{newState.ToString()}");
|
||||||
|
|
||||||
if (_lastLocalGameState is not null && _allGameStates.Count > 0)
|
if (_lastLocalGameState is not null && _allGameStates.Count > 0)
|
||||||
{
|
{
|
||||||
List<ValueTuple<CS2Event, CS2EventArgs>> generatedEvents = CS2EventGenerator.GenerateEvents(_lastLocalGameState, newState, _allGameStates.Last());
|
List<ValueTuple<CS2Event, CS2EventArgs>> generatedEvents = CS2EventGenerator.GenerateEvents(_lastLocalGameState.Value, newState, _allGameStates.Last());
|
||||||
this._logger?.Log(LogLevel.Information, $"Generated {generatedEvents.Count} event{(generatedEvents.Count > 1 ? 's' : null)}:\n- {string.Join("\n- ", generatedEvents)}");
|
this.logger?.Log(LogLevel.Information, $"Generated {generatedEvents.Count} events:\n\t{string.Join("\n\t", generatedEvents)}");
|
||||||
InvokeEvents(generatedEvents);
|
InvokeEvents(generatedEvents);
|
||||||
}
|
}
|
||||||
this._lastLocalGameState = newState.UpdateGameStateForLocal(_lastLocalGameState);
|
this._lastLocalGameState = newState.UpdateGameStateForLocal(_lastLocalGameState);
|
||||||
this._logger?.Log(LogLevel.Debug, $"\n{Resources.Updated_Local_State}:\n{_lastLocalGameState}");
|
this.logger?.Log(LogLevel.Debug, $"Updated Local State:\n{_lastLocalGameState.ToString()}");
|
||||||
_allGameStates.Add(newState);
|
_allGameStates.Add(newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,46 +58,117 @@ public class CS2GSI
|
|||||||
|
|
||||||
private void InvokeEvent(ValueTuple<CS2Event, CS2EventArgs> cs2Event)
|
private void InvokeEvent(ValueTuple<CS2Event, CS2EventArgs> cs2Event)
|
||||||
{
|
{
|
||||||
GetEventHandlerForEvent(cs2Event.Item1)?.Invoke(cs2Event.Item2);
|
switch (cs2Event.Item1)
|
||||||
|
{
|
||||||
|
case CS2Event.OnKill:
|
||||||
|
OnKill?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnHeadshot:
|
||||||
|
OnHeadshot?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnDeath:
|
||||||
|
OnDeath?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnFlashed:
|
||||||
|
OnFlashed?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnBurning:
|
||||||
|
OnBurning?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnSmoked:
|
||||||
|
OnSmoked?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnRoundStart:
|
||||||
|
OnRoundStart?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnRoundOver:
|
||||||
|
OnRoundOver?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnDamageTaken:
|
||||||
|
OnDamageTaken?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnMatchStart:
|
||||||
|
OnMatchStart?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnMatchOver:
|
||||||
|
OnMatchOver?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnMoneyChange:
|
||||||
|
OnMoneyChange?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnHealthChange:
|
||||||
|
OnHealthChange?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnArmorChange:
|
||||||
|
OnArmorChange?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnHelmetChange:
|
||||||
|
OnHelmetChange?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnEquipmentValueChange:
|
||||||
|
OnEquipmentValueChange?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnTeamChange:
|
||||||
|
OnTeamChange?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnPlayerChange:
|
||||||
|
OnPlayerChange?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnFreezeTime:
|
||||||
|
OnFreezeTime?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnHalfTime:
|
||||||
|
OnHalfTime?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnBombDefused:
|
||||||
|
OnBombDefused?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnBombExploded:
|
||||||
|
OnBombExploded?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.OnBombPlanted:
|
||||||
|
OnBombPlanted?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.AnyEvent:
|
||||||
|
AnyEvent?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
case CS2Event.AnyMessage:
|
||||||
|
AnyMessage?.Invoke(cs2Event.Item2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.logger?.Log(LogLevel.Error, $"Unknown Event {cs2Event}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CS2EventHandler? GetEventHandlerForEvent(CS2Event cs2Event)
|
internal enum CS2Event {
|
||||||
{
|
OnKill,
|
||||||
return cs2Event switch
|
OnHeadshot,
|
||||||
{
|
OnDeath,
|
||||||
CS2Event.OnKill => this.OnKill,
|
OnFlashed,
|
||||||
CS2Event.OnHeadshot => this.OnHeadshot,
|
OnBurning,
|
||||||
CS2Event.OnDeath => this.OnDeath,
|
OnSmoked,
|
||||||
CS2Event.OnFlashed => this.OnFlashed,
|
OnRoundStart,
|
||||||
CS2Event.OnBurning => this.OnBurning,
|
OnRoundOver,
|
||||||
CS2Event.OnSmoked => this.OnSmoked,
|
OnDamageTaken,
|
||||||
CS2Event.OnRoundStart => this.OnRoundStart,
|
OnMatchStart,
|
||||||
CS2Event.OnRoundOver => this.OnRoundOver,
|
OnMatchOver,
|
||||||
CS2Event.OnRoundWin => this.OnRoundWin,
|
OnMoneyChange,
|
||||||
CS2Event.OnRoundLoss => this.OnRoundLoss,
|
OnHealthChange,
|
||||||
CS2Event.OnDamageTaken => this.OnDamageTaken,
|
OnArmorChange,
|
||||||
CS2Event.OnMatchStart => this.OnMatchStart,
|
OnHelmetChange,
|
||||||
CS2Event.OnMatchOver => this.OnMatchOver,
|
OnEquipmentValueChange,
|
||||||
CS2Event.OnMoneyChange => this.OnMoneyChange,
|
OnTeamChange,
|
||||||
CS2Event.OnHealthChange => this.OnHealthChange,
|
OnPlayerChange,
|
||||||
CS2Event.OnArmorChange => this.OnArmorChange,
|
OnHalfTime,
|
||||||
CS2Event.OnHelmetChange => this.OnHelmetChange,
|
OnFreezeTime,
|
||||||
CS2Event.OnEquipmentValueChange => this.OnEquipmentValueChange,
|
OnBombPlanted,
|
||||||
CS2Event.OnTeamChange => this.OnTeamChange,
|
OnBombDefused,
|
||||||
CS2Event.OnPlayerChange => this.OnPlayerChange,
|
OnBombExploded,
|
||||||
CS2Event.OnHalfTime => this.OnHalfTime,
|
AnyEvent,
|
||||||
CS2Event.OnFreezeTime => this.OnFreezeTime,
|
AnyMessage
|
||||||
CS2Event.OnBombPlanted => this.OnBombPlanted,
|
|
||||||
CS2Event.OnBombDefused => this.OnBombDefused,
|
|
||||||
CS2Event.OnBombExploded => this.OnBombExploded,
|
|
||||||
CS2Event.AnyEvent => this.AnyEvent,
|
|
||||||
CS2Event.AnyMessage => this.AnyMessage,
|
|
||||||
_ => throw new ArgumentException(Resources.Unknown_Event, nameof(cs2Event))
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public delegate void CS2EventHandler(CS2EventArgs eventArgs);
|
public delegate void CS2EventHandler(CS2EventArgs eventArgs);
|
||||||
|
|
||||||
public event CS2EventHandler? OnKill,
|
public event CS2EventHandler? OnKill,
|
||||||
@ -107,8 +179,6 @@ public class CS2GSI
|
|||||||
OnSmoked,
|
OnSmoked,
|
||||||
OnRoundStart,
|
OnRoundStart,
|
||||||
OnRoundOver,
|
OnRoundOver,
|
||||||
OnRoundWin,
|
|
||||||
OnRoundLoss,
|
|
||||||
OnDamageTaken,
|
OnDamageTaken,
|
||||||
OnMatchStart,
|
OnMatchStart,
|
||||||
OnMatchOver,
|
OnMatchOver,
|
||||||
|
@ -4,11 +4,6 @@
|
|||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Version>1.0.8</Version>
|
|
||||||
<Title>CS2GSI</Title>
|
|
||||||
<Authors>Glax</Authors>
|
|
||||||
<RepositoryUrl>https://github.com/C9Glax/CS2GSI</RepositoryUrl>
|
|
||||||
<RepositoryType>git</RepositoryType>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -31,20 +26,4 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="..\LICENSE" Pack="true" PackagePath=""/>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="..\README.md" Pack="true" PackagePath="\"/>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
<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:String x:Key="/Default/CodeEditing/Localization/MoveToResource/LastResourceFile/@EntryValue">F2272524-6CDD-4ACD-8CFF-64B9AF98D54A/f:Resources.resx</s:String></wpf:ResourceDictionary>
|
|
@ -42,8 +42,8 @@ internal static class GsiConfigInstaller
|
|||||||
path = "~/.local/share/Steam/steamapps/libraryfolders.vdf";
|
path = "~/.local/share/Steam/steamapps/libraryfolders.vdf";
|
||||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||||
path = "~/Library/Application Support/Steam/steamapps/libraryfolders.vdf";
|
path = "~/Library/Application Support/Steam/steamapps/libraryfolders.vdf";
|
||||||
else throw new Exception(Resources.No_Installation_Folderpath);
|
else throw new Exception("Could not get Installation FolderPath");
|
||||||
return path ?? throw new FileNotFoundException(Resources.No_Libraryfolders_vdf);
|
return path ?? throw new FileNotFoundException("No libraryfolders.vdf found");
|
||||||
}
|
}
|
||||||
|
|
||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
@ -51,7 +51,7 @@ internal static class GsiConfigInstaller
|
|||||||
{
|
{
|
||||||
string steamInstallation =
|
string steamInstallation =
|
||||||
(string)(Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Valve\Steam", "SteamPath", null) ??
|
(string)(Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Valve\Steam", "SteamPath", null) ??
|
||||||
throw new DirectoryNotFoundException(Resources.No_Steam));
|
throw new DirectoryNotFoundException("No Steam Installation found."));
|
||||||
return Path.Combine(steamInstallation, "steamapps\\libraryfolders.vdf");
|
return Path.Combine(steamInstallation, "steamapps\\libraryfolders.vdf");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,20 +19,20 @@ internal class GSIServer
|
|||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
string prefix = $"http://127.0.0.1:{port}/";
|
string prefix = $"http://127.0.0.1:{port}/";
|
||||||
this.HttpListener = new HttpListener();
|
HttpListener = new HttpListener();
|
||||||
this.HttpListener.Prefixes.Add(prefix);
|
HttpListener.Prefixes.Add(prefix);
|
||||||
this.HttpListener.Start();
|
HttpListener.Start();
|
||||||
this.logger?.Log(LogLevel.Information, $"Listening on {prefix}");
|
this.logger?.Log(LogLevel.Information, $"Listening on {prefix}");
|
||||||
|
|
||||||
Thread connectionListener = new (HandleConnection);
|
Thread connectionListener = new (HandleConnection);
|
||||||
connectionListener.Start();
|
connectionListener.Start();
|
||||||
|
|
||||||
this.IsRunning = true;
|
IsRunning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void HandleConnection()
|
private async void HandleConnection()
|
||||||
{
|
{
|
||||||
while (this._keepRunning)
|
while (_keepRunning)
|
||||||
{
|
{
|
||||||
HttpListenerContext context = await HttpListener.GetContextAsync();
|
HttpListenerContext context = await HttpListener.GetContextAsync();
|
||||||
HttpListenerRequest request = context.Request;
|
HttpListenerRequest request = context.Request;
|
||||||
@ -44,18 +44,18 @@ internal class GSIServer
|
|||||||
|
|
||||||
StreamReader reader = new (request.InputStream, request.ContentEncoding);
|
StreamReader reader = new (request.InputStream, request.ContentEncoding);
|
||||||
string content = await reader.ReadToEndAsync();
|
string content = await reader.ReadToEndAsync();
|
||||||
this.logger?.Log(LogLevel.Debug, $"Message Content:\n{content}");
|
this.logger?.Log(LogLevel.Debug, content);
|
||||||
OnMessage?.Invoke(content);
|
OnMessage?.Invoke(content);
|
||||||
}
|
}
|
||||||
this.HttpListener.Close();
|
HttpListener.Close();
|
||||||
this.IsRunning = false;
|
IsRunning = false;
|
||||||
this.logger?.Log(LogLevel.Information, "Stopped GSIServer.");
|
this.logger?.Log(LogLevel.Information, "Stopped GSIServer.");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Dispose()
|
internal void Dispose()
|
||||||
{
|
{
|
||||||
this.logger?.Log(LogLevel.Information, "Stopping GSIServer.");
|
this.logger?.Log(LogLevel.Information, "Stopping GSIServer.");
|
||||||
this._keepRunning = false;
|
_keepRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace CS2GSI.GameState;
|
namespace CS2GSI.GameState;
|
||||||
|
|
||||||
public record CS2GameState : GameState
|
public struct CS2GameState
|
||||||
{
|
{
|
||||||
public string ProviderSteamId = null!;
|
public string ProviderSteamId;
|
||||||
public int Timestamp;
|
public int Timestamp;
|
||||||
public Map? Map;
|
public Map? Map;
|
||||||
public Player? Player;
|
public Player? Player;
|
||||||
@ -12,7 +12,11 @@ public record CS2GameState : GameState
|
|||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return base.ToString();
|
return $"{GetType().Name}\n" +
|
||||||
|
$"..Time: {Timestamp}\tProviderSteamId: {ProviderSteamId}\n" +
|
||||||
|
$"..{Map.ToString()?.Replace("\n", "\n...")}\n" +
|
||||||
|
$"..{Round.ToString()?.Replace("\n", "\n...")}\n" +
|
||||||
|
$"..{Player.ToString()?.Replace("\n", "\n...")}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static CS2GameState ParseFromJObject(JObject jsonObject)
|
internal static CS2GameState ParseFromJObject(JObject jsonObject)
|
||||||
@ -21,9 +25,9 @@ public record CS2GameState : GameState
|
|||||||
{
|
{
|
||||||
ProviderSteamId = jsonObject.SelectToken("provider.steamid")!.Value<string>()!,
|
ProviderSteamId = jsonObject.SelectToken("provider.steamid")!.Value<string>()!,
|
||||||
Timestamp = jsonObject.SelectToken("provider.timestamp")!.Value<int>(),
|
Timestamp = jsonObject.SelectToken("provider.timestamp")!.Value<int>(),
|
||||||
Map = Map.ParseFromJObject(jsonObject),
|
Map = GameState.Map.ParseFromJObject(jsonObject),
|
||||||
Player = Player.ParseFromJObject(jsonObject),
|
Player = GameState.Player.ParseFromJObject(jsonObject),
|
||||||
Round = Round.ParseFromJObject(jsonObject)
|
Round = GameState.Round.ParseFromJObject(jsonObject)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +36,7 @@ public record CS2GameState : GameState
|
|||||||
if (previousLocalState is null)
|
if (previousLocalState is null)
|
||||||
return this.Player?.SteamId == ProviderSteamId ? this : null;
|
return this.Player?.SteamId == ProviderSteamId ? this : null;
|
||||||
if (this.Player?.SteamId != ProviderSteamId)
|
if (this.Player?.SteamId != ProviderSteamId)
|
||||||
return this.WithPlayer(previousLocalState.Player);
|
return this.WithPlayer(previousLocalState.Value.Player);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace CS2GSI.GameState;
|
|
||||||
|
|
||||||
public abstract record GameState
|
|
||||||
{
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
string ret = "";
|
|
||||||
foreach (FieldInfo field in GetType().GetFields())
|
|
||||||
{
|
|
||||||
string filler = GetType().GetFields().Last() != field ? "\u251c\u2500" : "\u2514\u2500";
|
|
||||||
string filler2 = GetType().GetFields().Last() != field ? "\u2502" : " ";
|
|
||||||
if (field.FieldType.BaseType == typeof(GameState))
|
|
||||||
ret += $"\b{filler}\u2510 {field.Name}\n{field.GetValue(this)?.ToString()?.Replace("\b", $"\b{filler2} ")}";
|
|
||||||
else
|
|
||||||
ret += $"\b{filler} {field.Name}{new string('.', field.Name.Length > 25 ? 0 : 25-field.Name.Length)}{field.GetValue(this)}\n";
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,14 +2,18 @@
|
|||||||
|
|
||||||
namespace CS2GSI.GameState;
|
namespace CS2GSI.GameState;
|
||||||
|
|
||||||
public record GameStateTeam : GameState
|
public struct GameStateTeam
|
||||||
{
|
{
|
||||||
public CS2Team Team;
|
public CS2Team Team;
|
||||||
public int Score, ConsecutiveRoundLosses, TimeoutsRemaining, MatchesWonThisSeries;
|
public int Score, ConsecutiveRoundLosses, TimeoutsRemaining, MatchesWonThisSeries;
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return base.ToString();
|
return $"{GetType().Name}\n" +
|
||||||
|
$"..Team {Team}\tScore: {Score}\n" +
|
||||||
|
$"..ConsecutiveRoundLosses: {ConsecutiveRoundLosses}\n" +
|
||||||
|
$"..TimeoutsRemaining: {TimeoutsRemaining}\n" +
|
||||||
|
$"..MatchesWonThisSeries: {MatchesWonThisSeries}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static GameStateTeam ParseFromJObject(JObject jsonObject, CS2Team team)
|
internal static GameStateTeam ParseFromJObject(JObject jsonObject, CS2Team team)
|
||||||
|
@ -2,16 +2,22 @@
|
|||||||
|
|
||||||
namespace CS2GSI.GameState;
|
namespace CS2GSI.GameState;
|
||||||
|
|
||||||
public record Map : GameState
|
public struct Map
|
||||||
{
|
{
|
||||||
public string Mode = null!, MapName = null!;
|
public string Mode, MapName;
|
||||||
public MapPhase Phase;
|
public MapPhase Phase;
|
||||||
public int Round, NumMatchesToWinSeries;
|
public int Round, NumMatchesToWinSeries;
|
||||||
public GameStateTeam GameStateTeamCT = null!, GameStateTeamT = null!;
|
public GameStateTeam GameStateTeamCT, GameStateTeamT;
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return base.ToString();
|
return $"{GetType().Name}\n" +
|
||||||
|
$"..Mode: {Mode} Map: {MapName}\n" +
|
||||||
|
$"..Round: {Round}\n" +
|
||||||
|
$"..Matches to Win Series: {NumMatchesToWinSeries}\n" +
|
||||||
|
$"..Phase: {Phase}\n" +
|
||||||
|
$"..{GameStateTeamCT.ToString().Replace("\n", "\n...")}\n" +
|
||||||
|
$"..{GameStateTeamT.ToString().Replace("\n", "\n...")}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Map? ParseFromJObject(JObject jsonObject)
|
internal static Map? ParseFromJObject(JObject jsonObject)
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace CS2GSI.GameState;
|
namespace CS2GSI.GameState;
|
||||||
|
|
||||||
public record Player : GameState
|
public struct Player
|
||||||
{
|
{
|
||||||
public string SteamId = null!, Name = null!;
|
public string SteamId, Name;
|
||||||
public PlayerActivity Activity;
|
public PlayerActivity Activity;
|
||||||
public CS2Team? Team;
|
public CS2Team? Team;
|
||||||
public int? ObserverSlot;
|
public int? ObserverSlot;
|
||||||
@ -13,7 +13,12 @@ public record Player : GameState
|
|||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return base.ToString();
|
return $"{GetType().Name}\n" +
|
||||||
|
$"..Name: {Name} SteamId: {SteamId}\n" +
|
||||||
|
$"..Activity: {Activity}\n" +
|
||||||
|
$"..Team: {Team}\n" +
|
||||||
|
$"..{State.ToString()?.Replace("\n", "\n...")}\n" +
|
||||||
|
$"..{MatchStats.ToString()?.Replace("\n", "\n...")}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Player? ParseFromJObject(JObject jsonObject)
|
internal static Player? ParseFromJObject(JObject jsonObject)
|
||||||
|
@ -2,13 +2,16 @@
|
|||||||
|
|
||||||
namespace CS2GSI.GameState;
|
namespace CS2GSI.GameState;
|
||||||
|
|
||||||
public record PlayerMatchStats : GameState
|
public struct PlayerMatchStats
|
||||||
{
|
{
|
||||||
public int Kills, Assists, Deaths, MVPs, Score;
|
public int Kills, Assists, Deaths, MVPs, Score;
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return base.ToString();
|
return $"{GetType().Name}\n" +
|
||||||
|
$"..KAD: {Kills} {Assists} {Deaths}\n" +
|
||||||
|
$"..MVPs: {MVPs}\n" +
|
||||||
|
$"..Score: {Score}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static PlayerMatchStats? ParseFromJObject(JObject jsonObject)
|
internal static PlayerMatchStats? ParseFromJObject(JObject jsonObject)
|
||||||
|
@ -2,14 +2,23 @@
|
|||||||
|
|
||||||
namespace CS2GSI.GameState;
|
namespace CS2GSI.GameState;
|
||||||
|
|
||||||
public record PlayerState : GameState
|
public struct PlayerState
|
||||||
{
|
{
|
||||||
public int Health, Armor, Flashed, Smoked, Burning, Money, RoundKills, RoundHs, EquipmentValue;
|
public int Health, Armor, Flashed, Smoked, Burning, Money, RoundKills, RoundHs, EquipmentValue;
|
||||||
public bool Helmet;
|
public bool Helmet;
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return base.ToString();
|
return $"{GetType().Name}\n" +
|
||||||
|
$"..Health: {Health}\n" +
|
||||||
|
$"..Armor: {Armor}\n" +
|
||||||
|
$"..Flashed: {Flashed}\n" +
|
||||||
|
$"..Smoked: {Smoked}\n" +
|
||||||
|
$"..Burning: {Burning}\n" +
|
||||||
|
$"..Money: {Money}\n" +
|
||||||
|
$"..RoundKills: {RoundKills}\n" +
|
||||||
|
$"..RoundHs: {RoundHs}\n" +
|
||||||
|
$"..EquipmentValue: {EquipmentValue}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static PlayerState? ParseFromJObject(JObject jsonObject)
|
internal static PlayerState? ParseFromJObject(JObject jsonObject)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace CS2GSI.GameState;
|
namespace CS2GSI.GameState;
|
||||||
|
|
||||||
public record Round : GameState
|
public struct Round
|
||||||
{
|
{
|
||||||
public RoundPhase Phase;
|
public RoundPhase Phase;
|
||||||
public BombStatus? Bomb;
|
public BombStatus? Bomb;
|
||||||
@ -10,7 +10,10 @@ public record Round : GameState
|
|||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return base.ToString();
|
return $"{GetType().Name}\n" +
|
||||||
|
$"..Phase: {Phase}\n" +
|
||||||
|
$"..Winner: {WinnerTeam}\n" +
|
||||||
|
$"..Bomb: {Bomb}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Round? ParseFromJObject(JObject jsonObject)
|
internal static Round? ParseFromJObject(JObject jsonObject)
|
||||||
|
72
CS2GSI/Resources.Designer.cs
generated
72
CS2GSI/Resources.Designer.cs
generated
@ -89,77 +89,5 @@ namespace CS2GSI {
|
|||||||
return ResourceManager.GetString("GSI_CFG_Content", resourceCulture);
|
return ResourceManager.GetString("GSI_CFG_Content", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to Installing GSI-Configfile....
|
|
||||||
/// </summary>
|
|
||||||
internal static string Installing_GSI_File {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("Installing_GSI_File", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to Could not install GSI-Configfile. Exiting..
|
|
||||||
/// </summary>
|
|
||||||
internal static string Installing_GSI_File_Failed {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("Installing_GSI_File_Failed", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to Could not get Steam-Installation FolderPath.
|
|
||||||
/// </summary>
|
|
||||||
internal static string No_Installation_Folderpath {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("No_Installation_Folderpath", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to No libraryfolders.vdf found.
|
|
||||||
/// </summary>
|
|
||||||
internal static string No_Libraryfolders_vdf {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("No_Libraryfolders_vdf", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to No Steam Installation found..
|
|
||||||
/// </summary>
|
|
||||||
internal static string No_Steam {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("No_Steam", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to Received State.
|
|
||||||
/// </summary>
|
|
||||||
internal static string Received_State {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("Received_State", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to Unknown Event.
|
|
||||||
/// </summary>
|
|
||||||
internal static string Unknown_Event {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("Unknown_Event", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Looks up a localized string similar to Updated Local State.
|
|
||||||
/// </summary>
|
|
||||||
internal static string Updated_Local_State {
|
|
||||||
get {
|
|
||||||
return ResourceManager.GetString("Updated_Local_State", resourceCulture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
<root>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>1.3</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<data name="Installing_GSI_File" xml:space="preserve">
|
|
||||||
<value>Installiere GSI-Konfigurationsdatei...</value>
|
|
||||||
</data>
|
|
||||||
<data name="Installing_GSI_File_Failed" xml:space="preserve">
|
|
||||||
<value>GSI-Konfigurationsdatei nicht installiert.</value>
|
|
||||||
</data>
|
|
||||||
<data name="No_Installation_Folderpath" xml:space="preserve">
|
|
||||||
<value>Steam-Installationspfad konnte nicht gefunden werden.</value>
|
|
||||||
</data>
|
|
||||||
<data name="No_Libraryfolders_vdf" xml:space="preserve">
|
|
||||||
<value>libraryfolders.vdf nicht gefunden</value>
|
|
||||||
</data>
|
|
||||||
<data name="No_Steam" xml:space="preserve">
|
|
||||||
<value>Keine Steam Installation gefunden.</value>
|
|
||||||
</data>
|
|
||||||
<data name="Received_State" xml:space="preserve">
|
|
||||||
<value>Erhaltener Zustand</value>
|
|
||||||
</data>
|
|
||||||
<data name="Unknown_Event" xml:space="preserve">
|
|
||||||
<value>Unbekanntes Ereignis</value>
|
|
||||||
</data>
|
|
||||||
<data name="Updated_Local_State" xml:space="preserve">
|
|
||||||
<value>Erneuerter Lokaler Zustand</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
|
@ -21,29 +21,4 @@
|
|||||||
<data name="GSI_CFG_Content" type="System.Resources.ResXFileRef">
|
<data name="GSI_CFG_Content" type="System.Resources.ResXFileRef">
|
||||||
<value>gamestate_integration_cs2gsi.cfg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral</value>
|
<value>gamestate_integration_cs2gsi.cfg;System.String, mscorlib, Version=4.0.0.0, Culture=neutral</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Unknown_Event" xml:space="preserve">
|
|
||||||
<value>Unknown Event</value>
|
|
||||||
<comment>Event is not defined</comment>
|
|
||||||
</data>
|
|
||||||
<data name="Installing_GSI_File" xml:space="preserve">
|
|
||||||
<value>Installing GSI-Configfile...</value>
|
|
||||||
</data>
|
|
||||||
<data name="Installing_GSI_File_Failed" xml:space="preserve">
|
|
||||||
<value>Could not install GSI-Configfile. Exiting.</value>
|
|
||||||
</data>
|
|
||||||
<data name="Received_State" xml:space="preserve">
|
|
||||||
<value>Received State</value>
|
|
||||||
</data>
|
|
||||||
<data name="Updated_Local_State" xml:space="preserve">
|
|
||||||
<value>Updated Local State</value>
|
|
||||||
</data>
|
|
||||||
<data name="No_Installation_Folderpath" xml:space="preserve">
|
|
||||||
<value>Could not get Steam-Installation FolderPath</value>
|
|
||||||
</data>
|
|
||||||
<data name="No_Libraryfolders_vdf" xml:space="preserve">
|
|
||||||
<value>No libraryfolders.vdf found</value>
|
|
||||||
</data>
|
|
||||||
<data name="No_Steam" xml:space="preserve">
|
|
||||||
<value>No Steam Installation found.</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
</root>
|
52
README.md
52
README.md
@ -1,54 +1,2 @@
|
|||||||
# CS2GSI
|
# CS2GSI
|
||||||
[![GitHub License](https://img.shields.io/github/license/c9glax/CS2GSI)](/LICENSE)
|
|
||||||
[![NuGet Version](https://img.shields.io/nuget/v/CS2GSI)](https://www.nuget.org/packages/CS2GSI/)
|
|
||||||
[![Github](https://img.shields.io/badge/Github-8A2BE2)](https://github.com/C9Glax/CS2GSI)
|
|
||||||
[![GitHub Release](https://img.shields.io/github/v/release/c9glax/CS2GSI)](https://github.com/C9Glax/CS2GSI/releases/latest)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Example Usage
|
|
||||||
```csharp
|
|
||||||
public static void Main(string[] args)
|
|
||||||
{
|
|
||||||
CS2GSI.CS2GSI gsi = new ();
|
|
||||||
gsi.AnyMessage += eventArgs => Console.WriteLine("Message");
|
|
||||||
gsi.OnKill += eventArgs => Console.WriteLine($"Kill number {eventArgs.ValueAsOrDefault<int>()}");
|
|
||||||
while(gsi.IsRunning)
|
|
||||||
Thread.Sleep(10);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### Events
|
|
||||||
|
|
||||||
All Events with IDs here: https://github.com/C9Glax/CS2GSI/blob/master/CS2GSI/CS2Event.cs
|
|
||||||
|
|
||||||
`EventName` (_ParameterType_) Description
|
|
||||||
|
|
||||||
* `OnKill` (_int_) Number of Kills in Match
|
|
||||||
* `OnHeadshot` (_int_) Number of Headshots in Round
|
|
||||||
* `OnDeath` (_int_) Number of Deaths in Match
|
|
||||||
* `OnFlashed`
|
|
||||||
* `OnBurning`
|
|
||||||
* `OnSmoked`
|
|
||||||
* `OnRoundStart`
|
|
||||||
* `OnRoundOver`
|
|
||||||
* `OnRoundWin`
|
|
||||||
* `OnRoundLoss`
|
|
||||||
* `OnDamageTaken` (_int_) Amount of Damage Taken
|
|
||||||
* `OnMatchStart`
|
|
||||||
* `OnMatchOver`
|
|
||||||
* `OnMoneyChange` (_int_) Delta in Money
|
|
||||||
* `OnHealthChange` (_int_) Delta in Health
|
|
||||||
* `OnArmorChange` (_int_) Delta in Armor
|
|
||||||
* `OnHelmetChange` (_bool_) Helmet on/off
|
|
||||||
* `OnEquipmentValueChange` (_int_) Delta in Equipmentvalue
|
|
||||||
* `OnTeamChange`
|
|
||||||
* `OnPlayerChange` (_string_) SteamId64
|
|
||||||
* `OnHalfTime`
|
|
||||||
* `OnFreezeTime`
|
|
||||||
* `OnBombPlanted`
|
|
||||||
* `OnBombDefused`
|
|
||||||
* `OnBombExploded`
|
|
||||||
* `AnyEvent`
|
|
||||||
* `AnyMessage`
|
|
@ -7,8 +7,6 @@ public class TestApp
|
|||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
CS2GSI.CS2GSI gsi = new (new Logger(LogLevel.Debug));
|
new CS2GSI.CS2GSI(new Logger(LogLevel.Information));
|
||||||
while(gsi.IsRunning)
|
|
||||||
Thread.Sleep(10);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user