using CSGSI;
using CSGSI.Events;
using System;
using System.IO;
using System.Net;
using System.Threading;
namespace CSGOCore
{
class Program
{
static GameStateListener _gameStateListener;
const int PORT_NUMBER = 3000;
static void Main(string[] args)
{
CSGSI_Start();
}
private static void CSGSI_Start()
{
_gameStateListener = new GameStateListener(PORT_NUMBER);
_gameStateListener.NewGameState += NewGameState;
_gameStateListener.BombPlanted += BombPlanted; // Doesn't work
_gameStateListener.BombDefused += BombDefused; // Doesn't work
_gameStateListener.BombExploded += BombExploded; // Doesn't work
_gameStateListener.RoundEnd += RoundEnd;
_gameStateListener.RoundBegin += RoundBegin;
_gameStateListener.RoundPhaseChanged += RoundPhaseChanged;
_gameStateListener.PlayerFlashed += PlayerFlashed; // Doesn't work
_gameStateListener.EnableRaisingIntricateEvents = true;
if (!_gameStateListener.Start())
{
Console.WriteLine($"Game Sate could not listen on port #{PORT_NUMBER}");
Console.ReadLine();
Environment.Exit(0);
}
Console.WriteLine("CSGSI Listening...");
}
#region Game State Events
private static void PlayerFlashed(PlayerFlashedEventArgs e)
{
_LogEventMessage("PlayerFlashed Event");
}
private static void RoundPhaseChanged(RoundPhaseChangedEventArgs e)
{
_LogEventMessage("RoundPhaseChanged Event");
}
private static void RoundBegin(RoundBeginEventArgs e)
{
_LogEventMessage("RoundBegin Event");
}
private static void RoundEnd(RoundEndEventArgs e)
{
_LogEventMessage("RoundEnd Event");
}
private static void BombExploded(BombExplodedEventArgs e)
{
_LogEventMessage("BombExploded Event");
}
private static void BombDefused(BombDefusedEventArgs e)
{
_LogEventMessage("BombDefused Event");
}
///
///
///
/// Game State stores just about everything i think.
private static void NewGameState(GameState gameState)
{
var t = gameState.AllPlayers;
Console.WriteLine($"\n{DateTime.Now} - New Game State");
Console.WriteLine($"\t{gameState.Player.Name} on {gameState.Player.Team} Round #{gameState.Map.Round}");
Console.WriteLine($"\tRound Phase: {gameState.Round.Phase}");
if (gameState.Round.Bomb.ToString() != "Undefined")
Console.WriteLine($"\t Bomb: {gameState.Round.Bomb}");
Console.WriteLine($"\t {gameState.Player.Weapons.ActiveWeapon.Name}: {gameState.Player.Weapons.ActiveWeapon.AmmoClip} / {gameState.Player.Weapons.ActiveWeapon.AmmoClipMax}");
}
private static void BombPlanted(BombPlantedEventArgs e)
{
_LogEventMessage("BombPlanted Event");
}
#endregion
private static void _LogEventMessage(string message)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(message);
Console.ForegroundColor = ConsoleColor.White;
}
}
}