├── .gitattributes ├── .gitignore ├── CSGOTacticSimulator.sln ├── CSGOTacticSimulator ├── App.config ├── App.xaml ├── App.xaml.cs ├── CSGOTacticSimulator.csproj ├── CTS.ico ├── Controls │ ├── Selector.xaml │ ├── Selector.xaml.cs │ └── TSImage.cs ├── Global │ └── GlobalDictionary.cs ├── Helper │ ├── AnalyzeHelper.cs │ ├── CharacterHelper.cs │ ├── CommandHelper.cs │ ├── CompletionData.cs │ ├── IniHelper.cs │ ├── PathfindingHelper.cs │ ├── SteamHelper.cs │ ├── ThreadHelper.cs │ └── VectorHelper.cs ├── Model │ ├── Animation.cs │ ├── Character.cs │ ├── CurrentInfo.cs │ ├── Map.cs │ └── MapNode.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Screens │ ├── MainWindow.xaml │ └── MainWindow.xaml.cs ├── background │ ├── auto.png │ ├── background.jpg │ ├── backward.png │ ├── error.png │ ├── exit.png │ ├── forward.png │ ├── info.png │ ├── minimize.png │ ├── pause.png │ ├── preview.png │ ├── question.png │ ├── restore.png │ ├── resume.png │ ├── run.png │ ├── save.png │ ├── setting.png │ ├── stop.png │ └── warning.png ├── csgove │ ├── csgove.exe │ ├── tier0.dll │ └── vaudio_celt.dll ├── i18n │ ├── StringResource.en-US.xaml │ ├── StringResource.ja-JP.xaml │ └── StringResource.zh-CN.xaml ├── img │ ├── ENEMY_ALIVE_LOWER.png │ ├── ENEMY_ALIVE_UPPER.png │ ├── FRIENDLY_ALIVE_LOWER.png │ ├── FRIENDLY_ALIVE_UPPER.png │ ├── Weapon_AK47.png │ ├── Weapon_Aug.png │ ├── Weapon_CZ75-Auto.png │ ├── Weapon_R8.png │ ├── Weapon_awp.png │ ├── Weapon_bizon.png │ ├── Weapon_deagle.png │ ├── Weapon_elite.png │ ├── Weapon_famas.png │ ├── Weapon_fiveseven.png │ ├── Weapon_g3sg1.png │ ├── Weapon_galil_ar.png │ ├── Weapon_glock.png │ ├── Weapon_hkp2000.png │ ├── Weapon_knife.png │ ├── Weapon_m249.png │ ├── Weapon_m4a1_silencer.png │ ├── Weapon_m4a4.png │ ├── Weapon_mac10.png │ ├── Weapon_mag7.png │ ├── Weapon_mp5sd.png │ ├── Weapon_mp7.png │ ├── Weapon_mp9.png │ ├── Weapon_negev.png │ ├── Weapon_nova.png │ ├── Weapon_p250.png │ ├── Weapon_p90.png │ ├── Weapon_sawedoff.png │ ├── Weapon_scar20.png │ ├── Weapon_sg556.png │ ├── Weapon_ssg08.png │ ├── Weapon_taser.png │ ├── Weapon_tec9.png │ ├── Weapon_ump45.png │ ├── Weapon_usp_silencer.png │ ├── Weapon_xm1014.png │ ├── effect_decoy.png │ ├── effect_fire.png │ ├── effect_flash.png │ ├── effect_he.png │ ├── effect_smoke.png │ ├── enemy_dead_lower.png │ ├── enemy_dead_upper.png │ ├── explosion.png │ ├── eye.png │ ├── friendly_dead_lower.png │ ├── friendly_dead_upper.png │ ├── missile_decoy.png │ ├── missile_flashbang.png │ ├── missile_hegrenade.png │ ├── missile_incgrenade.png │ ├── missile_molotov.png │ ├── missile_smokegrenade.png │ ├── props_bomb.png │ └── props_defusekit.png ├── infos │ ├── CodeHighlight.xshd │ ├── LogHighlight.xshd │ └── setting.ini └── maps │ ├── mapframe │ └── Mirage.json │ └── mapimg │ ├── de_ancient_radar_spectate.dds │ ├── de_cache_radar_spectate.dds │ ├── de_dust2_radar_spectate.dds │ ├── de_inferno_radar_spectate.dds │ ├── de_mirage_radar_spectate.dds │ ├── de_nuke_radar_spectate.dds │ ├── de_overpass_radar_spectate.dds │ ├── de_train_radar_spectate.dds │ └── de_vertigo_radar_spectate.dds ├── CSGSI ├── CSGSI.csproj ├── Events │ ├── BombDefusedEventArgs.cs │ ├── BombExplodedEventArgs.cs │ ├── BombPlantedEventArgs.cs │ ├── PlayerFlashedEventArgs.cs │ ├── RoundBeginEventArgs.cs │ ├── RoundEndEventArgs.cs │ └── RoundPhaseChangedEventArgs.cs ├── GameState.cs ├── GameStateListener.cs ├── IGameStateListener.cs ├── Nodes │ ├── AllPlayersNode.cs │ ├── AuthNode.cs │ ├── BombNode.cs │ ├── Flame.cs │ ├── GrenadeNode.cs │ ├── GrenadesNode.cs │ ├── MapNode.cs │ ├── MapRoundWinsNode.cs │ ├── MapTeamNode.cs │ ├── MatchStatsNode.cs │ ├── NodeBase.cs │ ├── PhaseCountdownsNode.cs │ ├── PlayerNode.cs │ ├── PlayerStateNode.cs │ ├── ProviderNode.cs │ ├── RoundNode.cs │ ├── WeaponNode.cs │ └── WeaponsNode.cs ├── Properties │ └── AssemblyInfo.cs └── Vector3.cs ├── Facepunch.Steamworks ├── Callbacks │ ├── CallResult.cs │ └── ICallbackData.cs ├── Classes │ ├── AuthTicket.cs │ ├── Dispatch.cs │ ├── SteamApi.cs │ ├── SteamGameServer.cs │ └── SteamInternal.cs ├── Enum │ ├── LeaderboardDisplay.cs │ ├── LeaderboardSort.cs │ └── SendType.cs ├── Facepunch.Steamworks.Posix.csproj ├── Facepunch.Steamworks.Win32.csproj ├── Facepunch.Steamworks.Win64.csproj ├── Facepunch.Steamworks.jpg ├── Facepunch.Steamworks.targets ├── Generated │ ├── CustomEnums.cs │ ├── Interfaces │ │ ├── ISteamAppList.cs │ │ ├── ISteamApps.cs │ │ ├── ISteamClient.cs │ │ ├── ISteamController.cs │ │ ├── ISteamFriends.cs │ │ ├── ISteamGameSearch.cs │ │ ├── ISteamGameServer.cs │ │ ├── ISteamGameServerStats.cs │ │ ├── ISteamHTMLSurface.cs │ │ ├── ISteamHTTP.cs │ │ ├── ISteamInput.cs │ │ ├── ISteamInventory.cs │ │ ├── ISteamMatchmaking.cs │ │ ├── ISteamMatchmakingPingResponse.cs │ │ ├── ISteamMatchmakingPlayersResponse.cs │ │ ├── ISteamMatchmakingRulesResponse.cs │ │ ├── ISteamMatchmakingServerListResponse.cs │ │ ├── ISteamMatchmakingServers.cs │ │ ├── ISteamMusic.cs │ │ ├── ISteamMusicRemote.cs │ │ ├── ISteamNetworking.cs │ │ ├── ISteamNetworkingFakeUDPPort.cs │ │ ├── ISteamNetworkingMessages.cs │ │ ├── ISteamNetworkingSockets.cs │ │ ├── ISteamNetworkingUtils.cs │ │ ├── ISteamParentalSettings.cs │ │ ├── ISteamParties.cs │ │ ├── ISteamRemotePlay.cs │ │ ├── ISteamRemoteStorage.cs │ │ ├── ISteamScreenshots.cs │ │ ├── ISteamUGC.cs │ │ ├── ISteamUser.cs │ │ ├── ISteamUserStats.cs │ │ ├── ISteamUtils.cs │ │ └── ISteamVideo.cs │ ├── SteamCallbacks.cs │ ├── SteamConstants.cs │ ├── SteamEnums.cs │ ├── SteamStructFunctions.cs │ ├── SteamStructs.cs │ └── SteamTypes.cs ├── Networking │ ├── BroadcastBufferManager.cs │ ├── Connection.cs │ ├── ConnectionInfo.cs │ ├── ConnectionLaneStatus.cs │ ├── ConnectionManager.cs │ ├── ConnectionStatus.cs │ ├── Delegates.cs │ ├── IConnectionManager.cs │ ├── ISocketManager.cs │ ├── NetAddress.cs │ ├── NetErrorMessage.cs │ ├── NetIdentity.cs │ ├── NetKeyValue.cs │ ├── NetMsg.cs │ ├── NetPingLocation.cs │ ├── Socket.cs │ ├── SocketManager.cs │ └── SteamDatagramRelayAuthTicket.cs ├── ServerList │ ├── Base.cs │ ├── Favourites.cs │ ├── Friends.cs │ ├── History.cs │ ├── Internet.cs │ ├── IpList.cs │ └── LocalNetwork.cs ├── SteamApps.cs ├── SteamClient.cs ├── SteamFriends.cs ├── SteamInput.cs ├── SteamInventory.cs ├── SteamMatchmaking.cs ├── SteamMatchmakingServers.cs ├── SteamMusic.cs ├── SteamNetworking.cs ├── SteamNetworkingSockets.cs ├── SteamNetworkingUtils.cs ├── SteamParental.cs ├── SteamParties.cs ├── SteamRemotePlay.cs ├── SteamRemoteStorage.cs ├── SteamScreenshots.cs ├── SteamServer.cs ├── SteamServerStats.cs ├── SteamUgc.cs ├── SteamUser.cs ├── SteamUserStats.cs ├── SteamUtils.cs ├── SteamVideo.cs ├── Structs │ ├── Achievement.cs │ ├── AppId.cs │ ├── Clan.cs │ ├── Controller.cs │ ├── DepotId.cs │ ├── DlcInformation.cs │ ├── DownloadProgress.cs │ ├── DurationControl.cs │ ├── FileDetails.cs │ ├── Friend.cs │ ├── GameId.cs │ ├── Image.cs │ ├── InventoryDef.cs │ ├── InventoryItem.cs │ ├── InventoryPurchaseResult.cs │ ├── InventoryRecipe.cs │ ├── InventoryResult.cs │ ├── Leaderboard.cs │ ├── LeaderboardEntry.cs │ ├── LeaderboardUpdate.cs │ ├── Lobby.cs │ ├── LobbyQuery.cs │ ├── MatchMakingKeyValuePair.cs │ ├── NumericalFilter.cs │ ├── OutgoingPacket.cs │ ├── P2Packet.cs │ ├── PartyBeacon.cs │ ├── RemotePlaySession.cs │ ├── Screenshot.cs │ ├── Server.cs │ ├── ServerInit.cs │ ├── Stat.cs │ ├── SteamId.cs │ ├── SteamIpAddress.cs │ ├── SteamParamStringArray.cs │ ├── Ugc.cs │ ├── UgcAdditionalPreview.cs │ ├── UgcEditor.cs │ ├── UgcItem.cs │ ├── UgcQuery.cs │ ├── UgcResultPage.cs │ └── UserItemVote.cs ├── Utility │ ├── Epoch.cs │ ├── Helpers.cs │ ├── Platform.cs │ ├── SourceServerQuery.cs │ ├── SteamInterface.cs │ ├── Utf8String.cs │ └── Utility.cs ├── steam_api.dll └── steam_api64.dll ├── HltvSharp ├── HltvSharp.csproj ├── Models │ ├── AllSearchItem.cs │ ├── Coach.cs │ ├── Country.cs │ ├── Demo.cs │ ├── Enums │ │ └── MapSlug.cs │ ├── Event.cs │ ├── EventSearchItem.cs │ ├── FullEvent.cs │ ├── FullMatch.cs │ ├── MapResult.cs │ ├── Match.cs │ ├── MatchResult.cs │ ├── MatchStat.cs │ ├── Player.cs │ ├── PlayerSearchItem.cs │ ├── PlayerTeamInfo.cs │ ├── RankedTeam.cs │ ├── Team.cs │ ├── TeamSearchItem.cs │ ├── TeamSearchPlayerItem.cs │ ├── TimePeriod.cs │ ├── UpcomingMatch.cs │ └── Veto.cs ├── Parsing │ ├── .getmatch.cs.swp │ ├── GetEvent.cs │ ├── GetMatch.cs │ ├── GetPlayer.cs │ ├── GetRanking.cs │ ├── GetResults.cs │ ├── GetTeam.cs │ ├── GetUpcomingMatches.cs │ └── Utility.cs ├── Search │ └── Search.cs └── logo.png ├── LICENSE ├── README.md ├── README_CH.md ├── demoinfo ├── DemoInfo │ ├── AdditionalPlayerInformation.cs │ ├── App.config │ ├── BitStream │ │ ├── BitStreamUtil.cs │ │ ├── IBitStream.cs │ │ └── UnsafeBitStream.cs │ ├── DP │ │ ├── DemoPacketParser.cs │ │ ├── Entity.cs │ │ ├── FastNetmessages │ │ │ ├── CVar.cs │ │ │ ├── CVars.cs │ │ │ ├── CreateStringTable.cs │ │ │ ├── EncryptedMessage.cs │ │ │ ├── GameEvent.cs │ │ │ ├── GameEventList.cs │ │ │ ├── NETTick.cs │ │ │ ├── PacketEntities.cs │ │ │ ├── RankUpdate.cs │ │ │ ├── SayText.cs │ │ │ ├── SayText2.cs │ │ │ ├── SendTable.cs │ │ │ ├── ServerRankUpdate.cs │ │ │ ├── SetConVar.cs │ │ │ ├── UpdateStringTable.cs │ │ │ ├── UserMessage.cs │ │ │ ├── VoiceData.cs │ │ │ └── VoiceInit.cs │ │ └── Handler │ │ │ ├── CreateStringTableUserInfoHandler.cs │ │ │ ├── EncryptedDataHandler.cs │ │ │ ├── GameEventHandler.cs │ │ │ ├── PacketEntitesHandler.cs │ │ │ ├── PropDecoder.cs │ │ │ ├── SoundHandler.cs │ │ │ └── UpdateStringTableUserInfoHandler.cs │ ├── DT │ │ ├── DataTableParser.cs │ │ ├── SendTable.cs │ │ ├── SendTableProperty.cs │ │ └── ServerClass.cs │ ├── DemoInfo.csproj │ ├── DemoParser.cs │ ├── Events.cs │ ├── Helper.cs │ ├── IceKey.cs │ ├── Messages │ │ └── EnumConstants.cs │ ├── Player.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ST │ │ └── StringTableParser.cs │ └── Structs.cs └── License.txt └── test ├── 常规A点爆弹.txt ├── 快速夹B.txt └── 自动寻路.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/App.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Configuration; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | 9 | namespace CSGOTacticSimulator 10 | { 11 | /// 12 | /// App.xaml 的交互逻辑 13 | /// 14 | public partial class App : Application 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/CTS.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/CTS.ico -------------------------------------------------------------------------------- /CSGOTacticSimulator/Controls/Selector.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/Controls/TSImage.cs: -------------------------------------------------------------------------------- 1 | using CSGOTacticSimulator.Global; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | 10 | namespace CSGOTacticSimulator.Controls 11 | { 12 | public class TSImage : Image 13 | { 14 | private string tagStr; 15 | private string type; 16 | private Point mapPoint; 17 | private Point startMapPoint; 18 | private Point endMapPoint; 19 | private ImgType imgType; 20 | 21 | public string TagStr { get => tagStr; set => tagStr = value; } 22 | public string Type { get => type; set => type = value; } 23 | public Point MapPoint { get => mapPoint; set => mapPoint = value; } 24 | public Point StartMapPoint { get => startMapPoint; set => startMapPoint = value; } 25 | public Point EndMapPoint { get => endMapPoint; set => endMapPoint = value; } 26 | public ImgType ImgType { get => imgType; set => imgType = value; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/Helper/AnalyzeHelper.cs: -------------------------------------------------------------------------------- 1 | using CSGOTacticSimulator.Global; 2 | using Steamworks.ServerList; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | 10 | namespace CSGOTacticSimulator.Helper 11 | { 12 | public static class AnalyzeHelper 13 | { 14 | public static Point DemoPointToMapPoint(DemoInfo.Vector demoPoint, string mapName) 15 | { 16 | string[] splitListStr = null; 17 | string[] mapCalibrationDatas = GlobalDictionary.mapCalibrationDatas; 18 | foreach (string mapData in mapCalibrationDatas) 19 | { 20 | string[] mapCalibrationData = mapData.Split(':'); 21 | if (mapName.ToLowerInvariant().Contains(mapCalibrationData[0].ToLowerInvariant())) 22 | { 23 | string mapInfo; 24 | if (mapCalibrationData.Count() >= 2) 25 | { 26 | mapInfo = mapCalibrationData[1]; 27 | } 28 | else 29 | { 30 | mapInfo = mapCalibrationData[0]; 31 | } 32 | splitListStr = mapInfo.Split(','); 33 | break; 34 | } 35 | } 36 | 37 | double[] splitList = new double[3]; 38 | for (int i = 0; i < splitListStr.Count(); ++i) 39 | { 40 | splitList[i] = double.Parse(splitListStr[i]); 41 | } 42 | return new Point((demoPoint.X - splitList[0]) / splitList[2], (demoPoint.Y * (-1) + splitList[1]) / splitList[2]); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/Helper/CharacterHelper.cs: -------------------------------------------------------------------------------- 1 | using CSGOTacticSimulator.Model; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace CSGOTacticSimulator.Helper 9 | { 10 | static public class CharacterHelper 11 | { 12 | static private List characters = new List(); 13 | static private Dictionary characterNameDic = new Dictionary(); 14 | 15 | static public List GetCharacters() 16 | { 17 | return characters; 18 | } 19 | static public void AddCharacter(Character character) 20 | { 21 | characters.Add(character); 22 | } 23 | static public Character GetCharacter(int number) 24 | { 25 | return characters[number]; 26 | } 27 | static public Character GetCharacter(long steamId) 28 | { 29 | foreach (Character character in characters) 30 | { 31 | if (character.SteamId == steamId) 32 | { 33 | return character; 34 | } 35 | } 36 | return null; 37 | } 38 | 39 | static public bool AddIntoNameDic(string name, int number) 40 | { 41 | if (!characterNameDic.ContainsKey(name)) 42 | { 43 | characterNameDic.Add(name, number); 44 | return true; 45 | } 46 | else 47 | { 48 | return false; 49 | } 50 | } 51 | static public Character GetCharacter(string str) 52 | { 53 | int number; 54 | if(!int.TryParse(str, out number)) 55 | { 56 | number = characterNameDic[str]; 57 | } 58 | return GetCharacter(number); 59 | } 60 | 61 | static public void ClearCharacters() 62 | { 63 | characters.Clear(); 64 | characterNameDic.Clear(); 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/Helper/CompletionData.cs: -------------------------------------------------------------------------------- 1 | using ICSharpCode.AvalonEdit.CodeCompletion; 2 | using ICSharpCode.AvalonEdit.Document; 3 | using ICSharpCode.AvalonEdit.Editing; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Media; 10 | 11 | namespace CSGOTacticSimulator.Helper 12 | { 13 | /// Implements AvalonEdit ICompletionData interface to provide the entries in the 14 | /// completion drop down. 15 | class CompletionData : ICompletionData 16 | { 17 | public CompletionData(string text) 18 | { 19 | this.Text = text; 20 | } 21 | 22 | public System.Windows.Media.ImageSource Image 23 | { 24 | get { return null; } 25 | } 26 | 27 | public string Text { get; private set; } 28 | 29 | // Use this property if you want to show a fancy UIElement in the list. 30 | public object Content 31 | { 32 | get { return this.Text; } 33 | } 34 | 35 | public object Description 36 | { 37 | get { return "Description for " + this.Text; } 38 | } 39 | 40 | public void Complete(TextArea textArea, ISegment completionSegment, 41 | EventArgs insertionRequestEventArgs) 42 | { 43 | textArea.Document.Replace(completionSegment, this.Text); 44 | } 45 | 46 | double ICompletionData.Priority { get; } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/Helper/VectorHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | namespace CSGOTacticSimulator.Helper 9 | { 10 | static public class VectorHelper 11 | { 12 | static public double GetDistance(Point startPoint, Point endPoint) 13 | { 14 | return Math.Sqrt(Math.Pow((startPoint.X - endPoint.X), 2) + Math.Pow((startPoint.Y - endPoint.Y), 2)); 15 | } 16 | 17 | //static public Point GetDirection(Point startPoint, Point endPoint) 18 | //{ 19 | // return new Point(endPoint.X - startPoint.X, endPoint.Y - startPoint.Y); 20 | //} 21 | 22 | static public Point GetUnitVector(Point startPoint, Point endPoint) 23 | { 24 | double dist = GetDistance(startPoint, endPoint); 25 | return new Point((endPoint.X - startPoint.X) / dist, (endPoint.Y - startPoint.Y) / dist); 26 | } 27 | 28 | static public Point Multiply(Point point, double multiplier) 29 | { 30 | return new Point(point.X * multiplier, point.Y * multiplier); 31 | } 32 | 33 | static public Point Add(Point point, Point addend) 34 | { 35 | return new Point(point.X + addend.X, point.Y + addend.Y); 36 | } 37 | 38 | static public Point Parse(string pointStr) 39 | { 40 | pointStr = pointStr.Replace("(", "").Replace(")", ""); 41 | return new Point(Double.Parse(pointStr.Split(',')[0]), Double.Parse(pointStr.Split(',')[1])); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/Model/Animation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | 8 | namespace CSGOTacticSimulator.Helper 9 | { 10 | public enum Status 11 | { 12 | Waiting, 13 | Running, 14 | Finished 15 | } 16 | 17 | public enum Action 18 | { 19 | WaitFor, 20 | WaitUntil, 21 | Run, 22 | Walk, 23 | Squat, 24 | Teleport, 25 | Shoot, 26 | ChangeStatus, 27 | ChangeVerticalPosition, 28 | Throw, 29 | Plant, 30 | Defuse 31 | } 32 | public enum ActionLimit 33 | { 34 | RunJumpOnly, 35 | RunOrWalkJump, 36 | Jump, 37 | RunOnly, 38 | WalkOnly, 39 | SquatOnly, 40 | RunOrWalk, 41 | WalkOrSquat, 42 | RunClimbOrFall, 43 | WalkClimb, 44 | AllAllowed 45 | } 46 | public enum VolumeLimit 47 | { 48 | Quietly, 49 | Noisily 50 | } 51 | public class Animation 52 | { 53 | public int ownerIndex; 54 | 55 | public Status status = Status.Waiting; 56 | public Point endMapPoint; 57 | public Action action; 58 | public object[] objectPara; 59 | public Animation(int ownerIndex, Action action, Point endMapPoint, params object[] obj) 60 | { 61 | this.ownerIndex = ownerIndex; 62 | this.action = action; 63 | this.endMapPoint = endMapPoint; 64 | this.objectPara = obj; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/Model/CurrentInfo.cs: -------------------------------------------------------------------------------- 1 | using DemoInfo; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace CSGOTacticSimulator.Model 9 | { 10 | internal class CurrentInfo 11 | { 12 | public CurrentInfo(int tScore, int ctScore, string tName, string ctName, int currentTick, float currentTime, string map, float tickTime, IEnumerable participants, Dictionary> missileEquipDic = null, Dictionary> weaponEquipDic = null, Dictionary> equipDic = null) 13 | { 14 | TScore = tScore; 15 | CtScore = ctScore; 16 | TName = tName; 17 | CtName = ctName; 18 | CurrentTick = currentTick; 19 | CurrentTime = currentTime; 20 | Map = map; 21 | TickTime = tickTime; 22 | Participants = participants; 23 | MissileEquipDic = missileEquipDic; 24 | WeaponEquipDic = weaponEquipDic; 25 | EquipDic = equipDic; 26 | } 27 | 28 | public int TScore { get; set; } 29 | public int CtScore { get; set; } 30 | public string TName { get; set; } 31 | public string CtName { get; set; } 32 | public int CurrentTick { get; set; } 33 | public float CurrentTime { get; set; } 34 | public string Map { get; set; } 35 | public float TickTime { get; set; } 36 | public IEnumerable Participants { get; set; } 37 | public Dictionary> MissileEquipDic { get; set; } 38 | public Dictionary> WeaponEquipDic { get; set; } 39 | public Dictionary> EquipDic { get; set; } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/Model/Map.cs: -------------------------------------------------------------------------------- 1 | using CSGOTacticSimulator.Global; 2 | using Newtonsoft.Json; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace CSGOTacticSimulator.Model 10 | { 11 | public class Map 12 | { 13 | [JsonConstructor] 14 | public Map(string mapName) 15 | { 16 | this.mapName = mapName; 17 | 18 | if (!GlobalDictionary.mapDic.ContainsKey(this.mapName)) 19 | { 20 | GlobalDictionary.mapDic.Add(this.mapName, this); 21 | } 22 | else 23 | { 24 | GlobalDictionary.mapDic[mapName] = this; 25 | } 26 | } 27 | public Map(string mapName, List mapNodes) 28 | { 29 | this.mapName = mapName; 30 | this.mapNodes = mapNodes; 31 | if (!GlobalDictionary.mapDic.ContainsKey(this.mapName)) 32 | { 33 | GlobalDictionary.mapDic.Add(this.mapName, this); 34 | } 35 | } 36 | 37 | public string mapName; 38 | 39 | public List mapNodes = new List(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // 有关程序集的一般信息由以下 8 | // 控制。更改这些特性值可修改 9 | // 与程序集关联的信息。 10 | [assembly: AssemblyTitle("CSGOTacticSimulator")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("CSGOTacticSimulator")] 15 | [assembly: AssemblyCopyright("Copyright © 2020")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // 将 ComVisible 设置为 false 会使此程序集中的类型 20 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 21 | //请将此类型的 ComVisible 特性设置为 true。 22 | [assembly: ComVisible(false)] 23 | 24 | //若要开始生成可本地化的应用程序,请设置 25 | //.csproj 文件中的 CultureYouAreCodingWith 26 | //例如,如果您在源文件中使用的是美国英语, 27 | //使用的是美国英语,请将 设置为 en-US。 然后取消 28 | //对以下 NeutralResourceLanguage 特性的注释。 更新 29 | //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //主题特定资源词典所处位置 36 | //(未在页面中找到资源时使用, 37 | //或应用程序资源字典中找到时使用) 38 | ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置 39 | //(未在页面中找到资源时使用, 40 | //、应用程序或任何主题专用资源字典中找到时使用) 41 | )] 42 | 43 | 44 | // 程序集的版本信息由下列四个值组成: 45 | // 46 | // 主版本 47 | // 次版本 48 | // 生成号 49 | // 修订号 50 | // 51 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 52 | //通过使用 "*",如下所示: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // 此代码由工具生成。 4 | // 运行时版本:4.0.30319.42000 5 | // 6 | // 对此文件的更改可能会导致不正确的行为,并且如果 7 | // 重新生成代码,这些更改将会丢失。 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace CSGOTacticSimulator.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/auto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/auto.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/background.jpg -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/backward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/backward.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/error.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/exit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/exit.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/forward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/forward.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/info.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/minimize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/minimize.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/pause.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/preview.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/question.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/restore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/restore.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/resume.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/resume.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/run.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/save.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/setting.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/stop.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/background/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/background/warning.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/csgove/csgove.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/csgove/csgove.exe -------------------------------------------------------------------------------- /CSGOTacticSimulator/csgove/tier0.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/csgove/tier0.dll -------------------------------------------------------------------------------- /CSGOTacticSimulator/csgove/vaudio_celt.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/csgove/vaudio_celt.dll -------------------------------------------------------------------------------- /CSGOTacticSimulator/i18n/StringResource.ja-JP.xaml: -------------------------------------------------------------------------------- 1 |  4 | フォルダ設定: 5 | マップ: 6 | フレーム: 7 | プレイソース: 8 | 座標: 9 | 10 | 言語 11 | 実行 12 | 情報パネルを自動的に表示するか 13 | ドロップ武器を表示するか 14 | 発射体のドロップを表示するか 15 | 他のドロップを表示するか 16 | 準備フェーズをスキップするか 17 | ログ 18 | ローディングログを表示するか 19 | キルログを表示するか 20 | 発話ログを表示するか 21 | 購入履歴を表示するか 22 | アバター 23 | アバターを自動ロード 24 | Hltvからのみアバターを取得 25 | Steam からのみアバターを取得 26 | アバターを取得しない 27 | 音声 28 | 音を抽出するか 29 | 30 | ファイル 31 | スクリプト / デモファイル 32 | が見つかりません 33 | エラー 34 | どのラウンドを見るか 35 | ラウンド数を選択してください 36 | 数字を入力してください 37 | 38 | 保存後に終了します 39 | 直接終了します 40 | キャンセル 41 | 戦術的なスクリプトを保存するかどうか 42 | プログラムを終了します 43 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/i18n/StringResource.zh-CN.xaml: -------------------------------------------------------------------------------- 1 |  4 | 设定文件夹: 5 | 地图: 6 | 框架: 7 | 播放源: 8 | 坐标: 9 | 10 | 语言 11 | 运行 12 | 是否自动显示信息面板 13 | 是否显示武器掉落 14 | 是否显示投掷物掉落 15 | 是否显示其他掉落 16 | 是否跳过准备阶段 17 | 日志 18 | 是否显示加载日志 19 | 是否显示击杀日志 20 | 是否显示发言日志 21 | 是否显示购买日志 22 | 头像 23 | 自动加载头像 24 | 只从Hltv获取头像 25 | 只从Steam获取头像 26 | 不获取头像 27 | 声音 28 | 是否提取语音 29 | 30 | 文件 31 | 脚本 / DEMO文件 32 | 不存在 33 | 错误 34 | 需要观看第几回合 35 | 选择回合数 36 | 请输入数字 37 | 38 | 保存后退出 39 | 直接退出 40 | 取消 41 | 是否另存战术脚本 42 | 正在退出程序 43 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/ENEMY_ALIVE_LOWER.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/ENEMY_ALIVE_LOWER.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/ENEMY_ALIVE_UPPER.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/ENEMY_ALIVE_UPPER.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/FRIENDLY_ALIVE_LOWER.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/FRIENDLY_ALIVE_LOWER.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/FRIENDLY_ALIVE_UPPER.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/FRIENDLY_ALIVE_UPPER.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_AK47.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_AK47.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_Aug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_Aug.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_CZ75-Auto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_CZ75-Auto.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_R8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_R8.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_awp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_awp.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_bizon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_bizon.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_deagle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_deagle.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_elite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_elite.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_famas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_famas.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_fiveseven.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_fiveseven.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_g3sg1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_g3sg1.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_galil_ar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_galil_ar.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_glock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_glock.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_hkp2000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_hkp2000.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_knife.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_knife.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_m249.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_m249.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_m4a1_silencer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_m4a1_silencer.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_m4a4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_m4a4.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_mac10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_mac10.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_mag7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_mag7.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_mp5sd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_mp5sd.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_mp7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_mp7.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_mp9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_mp9.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_negev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_negev.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_nova.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_nova.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_p250.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_p250.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_p90.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_p90.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_sawedoff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_sawedoff.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_scar20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_scar20.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_sg556.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_sg556.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_ssg08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_ssg08.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_taser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_taser.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_tec9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_tec9.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_ump45.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_ump45.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_usp_silencer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_usp_silencer.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/Weapon_xm1014.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/Weapon_xm1014.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/effect_decoy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/effect_decoy.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/effect_fire.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/effect_fire.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/effect_flash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/effect_flash.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/effect_he.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/effect_he.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/effect_smoke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/effect_smoke.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/enemy_dead_lower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/enemy_dead_lower.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/enemy_dead_upper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/enemy_dead_upper.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/explosion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/explosion.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/eye.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/eye.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/friendly_dead_lower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/friendly_dead_lower.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/friendly_dead_upper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/friendly_dead_upper.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/missile_decoy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/missile_decoy.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/missile_flashbang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/missile_flashbang.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/missile_hegrenade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/missile_hegrenade.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/missile_incgrenade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/missile_incgrenade.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/missile_molotov.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/missile_molotov.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/missile_smokegrenade.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/missile_smokegrenade.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/props_bomb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/props_bomb.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/img/props_defusekit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/img/props_defusekit.png -------------------------------------------------------------------------------- /CSGOTacticSimulator/infos/LogHighlight.xshd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | bought 16 | 17 | 18 | 19 | Pre-loaded 20 | Round 21 | : 22 | 23 | 24 | 25 | killed 26 | by 27 | 28 | 29 | 30 | [[][\s\S]+[]] 31 | 32 | 33 | 34 | [(][\s\S]+[)] 35 | 36 | 37 | 38 | 39 | [ ][0-9]+ 40 | 41 | 42 | -------------------------------------------------------------------------------- /CSGOTacticSimulator/maps/mapimg/de_ancient_radar_spectate.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/maps/mapimg/de_ancient_radar_spectate.dds -------------------------------------------------------------------------------- /CSGOTacticSimulator/maps/mapimg/de_cache_radar_spectate.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/maps/mapimg/de_cache_radar_spectate.dds -------------------------------------------------------------------------------- /CSGOTacticSimulator/maps/mapimg/de_dust2_radar_spectate.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/maps/mapimg/de_dust2_radar_spectate.dds -------------------------------------------------------------------------------- /CSGOTacticSimulator/maps/mapimg/de_inferno_radar_spectate.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/maps/mapimg/de_inferno_radar_spectate.dds -------------------------------------------------------------------------------- /CSGOTacticSimulator/maps/mapimg/de_mirage_radar_spectate.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/maps/mapimg/de_mirage_radar_spectate.dds -------------------------------------------------------------------------------- /CSGOTacticSimulator/maps/mapimg/de_nuke_radar_spectate.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/maps/mapimg/de_nuke_radar_spectate.dds -------------------------------------------------------------------------------- /CSGOTacticSimulator/maps/mapimg/de_overpass_radar_spectate.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/maps/mapimg/de_overpass_radar_spectate.dds -------------------------------------------------------------------------------- /CSGOTacticSimulator/maps/mapimg/de_train_radar_spectate.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/maps/mapimg/de_train_radar_spectate.dds -------------------------------------------------------------------------------- /CSGOTacticSimulator/maps/mapimg/de_vertigo_radar_spectate.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/CSGOTacticSimulator/maps/mapimg/de_vertigo_radar_spectate.dds -------------------------------------------------------------------------------- /CSGSI/CSGSI.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net6.0-windows 4 | Library 5 | false 6 | 7 | 8 | bin\Release\CSGSI.XML 9 | 10 | 11 | 12 | 13 | 14 | 15 | all 16 | 17 | 18 | -------------------------------------------------------------------------------- /CSGSI/Events/BombDefusedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using CSGSI.Nodes; 2 | 3 | namespace CSGSI.Events 4 | { 5 | /// 6 | /// A delegate to handle the BombDefused event. 7 | /// 8 | /// 9 | public delegate void BombDefusedHandler(BombDefusedEventArgs e); 10 | 11 | /// 12 | /// Contains information about the BombDefused event (e.g. the defuser). 13 | /// 14 | public class BombDefusedEventArgs 15 | { 16 | /// 17 | /// The player that defused the bomb. 18 | /// 19 | public PlayerNode Defuser; 20 | 21 | /// 22 | /// Initializes a new instance from the given information. 23 | /// 24 | /// The defuser. 25 | public BombDefusedEventArgs(PlayerNode probableDefuser) 26 | { 27 | Defuser = probableDefuser; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /CSGSI/Events/BombExplodedEventArgs.cs: -------------------------------------------------------------------------------- 1 | namespace CSGSI.Events 2 | { 3 | /// 4 | /// A delegate to handle the BombExploded event. 5 | /// 6 | /// 7 | public delegate void BombExplodedHandler(BombExplodedEventArgs e); 8 | 9 | /// 10 | /// Contains information about the BombExploded event (currently none). 11 | /// 12 | public class BombExplodedEventArgs 13 | { 14 | /// 15 | /// Initializes a new instance. 16 | /// 17 | public BombExplodedEventArgs() 18 | { 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /CSGSI/Events/BombPlantedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using CSGSI.Nodes; 2 | 3 | namespace CSGSI.Events 4 | { 5 | /// 6 | /// A delegate to handle the BombPlanted event. 7 | /// 8 | /// 9 | public delegate void BombPlantedHandler(BombPlantedEventArgs e); 10 | 11 | /// 12 | /// Contains information about the BombPlanted event (e.g. the planter). 13 | /// 14 | public class BombPlantedEventArgs 15 | { 16 | /// 17 | /// The player that planted the bomb. 18 | /// 19 | public PlayerNode Planter; 20 | 21 | /// 22 | /// Initializes a new instance from the given information. 23 | /// 24 | /// The planter. 25 | public BombPlantedEventArgs(PlayerNode planter) 26 | { 27 | Planter = planter; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /CSGSI/Events/PlayerFlashedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using CSGSI.Nodes; 2 | 3 | namespace CSGSI.Events 4 | { 5 | /// 6 | /// A delegate to handle the PlayerFlashed event. 7 | /// 8 | /// 9 | public delegate void PlayerFlashedHandler(PlayerFlashedEventArgs e); 10 | 11 | /// 12 | /// Contains information about the PlayerFlashed event (e.g. the player that got flashed and how much). 13 | /// 14 | public class PlayerFlashedEventArgs 15 | { 16 | /// 17 | /// The player that was flashed. 18 | /// 19 | public PlayerNode Player; 20 | 21 | /// 22 | /// How much the player got flashed. 23 | /// 24 | public int Flashed => Player.State.Flashed; 25 | 26 | /// 27 | /// Initializes a new instance from the given information. 28 | /// 29 | /// The player that got flashed. 30 | public PlayerFlashedEventArgs(PlayerNode player) 31 | { 32 | Player = player; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /CSGSI/Events/RoundBeginEventArgs.cs: -------------------------------------------------------------------------------- 1 | using CSGSI.Nodes; 2 | 3 | namespace CSGSI.Events 4 | { 5 | /// 6 | /// A delegate to handle the RoundBegin event. 7 | /// 8 | /// 9 | public delegate void RoundBeginHandler(RoundBeginEventArgs e); 10 | 11 | /// 12 | /// Contains information about the RoundBegin event (e.g. the current map, scores of each team etc.). 13 | /// 14 | public class RoundBeginEventArgs 15 | { 16 | /// 17 | /// Information about the map state. 18 | /// 19 | public MapNode Map; 20 | 21 | /// 22 | /// The total amount of rounds (i.e. T Score + CT Score + 1) 23 | /// 24 | public int TotalRound => Map.TeamCT.Score + Map.TeamT.Score + 1; 25 | 26 | /// 27 | /// The current score of the terrorist team. 28 | /// 29 | public int TScore => Map.TeamT.Score; 30 | 31 | /// 32 | /// The current score of the counter-terrorist team. 33 | /// 34 | public int CTScore => Map.TeamCT.Score; 35 | 36 | /// 37 | /// Initializes a new instance from the given . 38 | /// 39 | /// The that should be used to initialize this instance. 40 | public RoundBeginEventArgs(GameState gameState) 41 | { 42 | Map = gameState.Map; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /CSGSI/Events/RoundEndEventArgs.cs: -------------------------------------------------------------------------------- 1 | using CSGSI.Nodes; 2 | using System.Linq; 3 | 4 | namespace CSGSI.Events 5 | { 6 | /// 7 | /// A delegate to handle the RoundEnd event. 8 | /// 9 | /// 10 | public delegate void RoundEndHandler(RoundEndEventArgs e); 11 | 12 | /// 13 | /// Contains information about the RoundEnd event (e.g. the team that won this round). 14 | /// 15 | public class RoundEndEventArgs 16 | { 17 | /// 18 | /// The team that won the round that just ended. 19 | /// 20 | public RoundWinTeam Winner; 21 | 22 | /// 23 | /// The reason why this round ended. 24 | /// 25 | public RoundWinReason Reason; 26 | 27 | /// 28 | /// Initializes a new instance from the given . 29 | /// 30 | /// The that should be used to initialize this instance. 31 | public RoundEndEventArgs(GameState gameState) 32 | { 33 | Winner = gameState.Round.WinTeam; 34 | 35 | //relying on the fact that the rounds are listed in the correct order... 36 | Reason = gameState.Map.RoundWins.RoundWinReasons.LastOrDefault(); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /CSGSI/Events/RoundPhaseChangedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using CSGSI.Nodes; 2 | 3 | namespace CSGSI.Events 4 | { 5 | /// 6 | /// A delegate to handle the RoundPhaseChanged event. 7 | /// 8 | /// 9 | public delegate void RoundPhaseChangedHandler(RoundPhaseChangedEventArgs e); 10 | 11 | /// 12 | /// Contains information about the PlayerGotKill event (e.g. previous and current phase). 13 | /// 14 | public class RoundPhaseChangedEventArgs 15 | { 16 | /// 17 | /// The phase that was active before this event was fired. 18 | /// 19 | public RoundPhase PreviousPhase; 20 | 21 | /// 22 | /// The phase that is active now. 23 | /// 24 | public RoundPhase CurrentPhase; 25 | 26 | /// 27 | /// Initializes a new instance from the given . 28 | /// 29 | /// The that should be used to initialize this instance. 30 | public RoundPhaseChangedEventArgs(GameState gameState) 31 | { 32 | PreviousPhase = gameState.Previously.Round.Phase; 33 | CurrentPhase = gameState.Round.Phase; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /CSGSI/Nodes/AuthNode.cs: -------------------------------------------------------------------------------- 1 | namespace CSGSI.Nodes 2 | { 3 | /// 4 | /// A node that contains information related to authentication. 5 | /// 6 | public class AuthNode : NodeBase 7 | { 8 | /// 9 | /// The provided authentication token. 10 | /// 11 | public string Token { get; set; } 12 | 13 | internal AuthNode(string json) 14 | : base(json) 15 | { 16 | Token = GetString("token"); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /CSGSI/Nodes/BombNode.cs: -------------------------------------------------------------------------------- 1 | namespace CSGSI.Nodes 2 | { 3 | /// 4 | /// Contains information about the bomb. This node is only available when spectating! 5 | /// 6 | public class BombNode : NodeBase 7 | { 8 | /// 9 | /// The current state of the bomb. 10 | /// 11 | public BombState State { get; set; } 12 | 13 | /// 14 | /// The current position of the bomb. 15 | /// 16 | public Vector3 Position { get; set; } 17 | 18 | /// 19 | /// The time remaining for the current state (i.e. time remaining until explosion if bomb is planted, time remaining until defused if defusing, etc). 20 | /// 21 | public float Countdown { get; set; } 22 | 23 | /// 24 | /// Initializes a new from the given JSON string. 25 | /// 26 | /// 27 | public BombNode(string json) 28 | : base(json) 29 | { 30 | State = GetEnum("state"); 31 | Position = GetVector3("position"); 32 | Countdown = GetFloat("countdown"); 33 | } 34 | } 35 | 36 | /// 37 | /// Represents the state of the bomb. 38 | /// 39 | public enum BombState 40 | { 41 | /// 42 | /// Bomb is in unknown state. 43 | /// 44 | Undefined, 45 | 46 | /// 47 | /// Bomb was dropped. 48 | /// 49 | Dropped, 50 | 51 | /// 52 | /// Bomb is currently being carried by a player. 53 | /// 54 | Carried, 55 | 56 | /// 57 | /// Bomb is currently being planted. 58 | /// 59 | Planting, 60 | 61 | /// 62 | /// Bomb was planted. 63 | /// 64 | Planted, 65 | 66 | /// 67 | /// Bomb is currently being defused. 68 | /// 69 | Defusing, 70 | 71 | /// 72 | /// Bomb was defused. 73 | /// 74 | Defused, 75 | 76 | /// 77 | /// Bomb has exploded. 78 | /// 79 | Exploded 80 | } 81 | } -------------------------------------------------------------------------------- /CSGSI/Nodes/Flame.cs: -------------------------------------------------------------------------------- 1 | namespace CSGSI.Nodes 2 | { 3 | /// 4 | /// Represents a flame that was generated by a molotov/incendiary grenade. 5 | /// 6 | public class Flame 7 | { 8 | /// 9 | /// The ID of this flame. 10 | /// 11 | public string ID { get; set; } 12 | 13 | /// 14 | /// The position of this flame. 15 | /// 16 | public Vector3 Position { get; set; } 17 | 18 | /// 19 | /// Initializes a new Flame with the given ID and position. 20 | /// 21 | /// The ID of this flame. 22 | /// The position of this flame. 23 | public Flame(string id, Vector3 position) 24 | { 25 | ID = id; 26 | Position = position; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /CSGSI/Nodes/GrenadesNode.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace CSGSI.Nodes 6 | { 7 | /// 8 | /// Contains information about all grenades that currently exist. 9 | /// 10 | public class GrenadesNode : NodeBase, IEnumerable 11 | { 12 | /// 13 | /// The list of all grenades that currently exist. 14 | /// 15 | public List Grenades { get; set; } = new List(); 16 | 17 | /// 18 | /// Initializes a new from the given JSON. 19 | /// 20 | /// The JSON that should be used to initialize this instance. 21 | public GrenadesNode(string json) 22 | : base(json) 23 | { 24 | foreach (var c in _data.Properties()) 25 | { 26 | int id = -1; 27 | int.TryParse(c.Name, out id); 28 | Grenades.Add(new GrenadeNode(c.Value.ToString(), id)); 29 | } 30 | } 31 | 32 | /// 33 | /// Returns an with all grenades of the given type. 34 | /// 35 | /// The type of grenades that should be returned. 36 | /// An with all grenades of the given type. 37 | public IEnumerable GetAllOfType(GrenadeType type) 38 | { 39 | return Grenades.Where(grenade => grenade.Type == type); 40 | } 41 | 42 | /// 43 | /// Returns an to iterate through all existing grenades. 44 | /// 45 | /// 46 | public IEnumerator GetEnumerator() 47 | { 48 | return Grenades.GetEnumerator(); 49 | } 50 | 51 | IEnumerator IEnumerable.GetEnumerator() 52 | { 53 | return Grenades.GetEnumerator(); 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /CSGSI/Nodes/MapTeamNode.cs: -------------------------------------------------------------------------------- 1 | namespace CSGSI.Nodes 2 | { 3 | /// 4 | /// A node containing information about a team. 5 | /// 6 | public class MapTeamNode : NodeBase 7 | { 8 | /// 9 | /// The current score of this team. 10 | /// 11 | public int Score { get; set; } 12 | 13 | /// 14 | /// The amount of remaining time-outs this team has left. 15 | /// 16 | public int TimeoutsRemaining { get; set; } 17 | 18 | /// 19 | /// Unknown. 20 | /// 21 | public int MatchesWonThisSeries { get; set; } 22 | 23 | /// 24 | /// Name of the team (e.g. Clan name if all players have the same tag or FACEIT teams). 25 | /// 26 | public string Name { get; set; } 27 | 28 | internal MapTeamNode(string json) 29 | : base(json) 30 | { 31 | Score = GetInt32("score"); 32 | TimeoutsRemaining = GetInt32("timeouts_remaining"); 33 | MatchesWonThisSeries = GetInt32("matches_won_this_series"); 34 | Name = GetString("name"); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /CSGSI/Nodes/MatchStatsNode.cs: -------------------------------------------------------------------------------- 1 | namespace CSGSI.Nodes 2 | { 3 | /// 4 | /// A node containing information about a players stats. 5 | /// 6 | public class MatchStatsNode : NodeBase 7 | { 8 | /// 9 | /// The amount of kills this player currently has. 10 | /// 11 | public int Kills { get; set; } 12 | 13 | /// 14 | /// The amount of assists this player currently has. 15 | /// 16 | public int Assists { get; set; } 17 | 18 | /// 19 | /// The amount of deaths this player currently has. 20 | /// 21 | public int Deaths { get; set; } 22 | 23 | /// 24 | /// The amount of MVPs this player currently has. 25 | /// 26 | public int MVPs { get; set; } 27 | 28 | /// 29 | /// The current score of the player. 30 | /// 31 | public int Score { get; set; } 32 | 33 | internal MatchStatsNode(string JSON) 34 | : base(JSON) 35 | { 36 | Kills = GetInt32("kills"); 37 | Assists = GetInt32("assists"); 38 | Deaths = GetInt32("deaths"); 39 | MVPs = GetInt32("mvps"); 40 | Score = GetInt32("score"); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /CSGSI/Nodes/PhaseCountdownsNode.cs: -------------------------------------------------------------------------------- 1 | namespace CSGSI.Nodes 2 | { 3 | /// 4 | /// A node containing information about a phases state. 5 | /// 6 | public class PhaseCountdownsNode : NodeBase 7 | { 8 | /// 9 | /// The phase that this node represents. 10 | /// 11 | public PhaseCountdownsPhase Phase { get; set; } 12 | 13 | /// 14 | /// How long (in seconds) the current phase is going to last (unless interrupted by a phase change, i.e. Live -> Bomb). 15 | /// 16 | public float PhaseEndsIn { get; set; } 17 | 18 | internal PhaseCountdownsNode(string json) 19 | : base(json) 20 | { 21 | Phase = GetEnum("phase"); 22 | PhaseEndsIn = GetFloat("phase_ends_in"); 23 | } 24 | } 25 | 26 | /// 27 | /// Indicates a phase in the match that has a cooldown associated with it. 28 | /// 29 | public enum PhaseCountdownsPhase 30 | { 31 | /// 32 | /// Undefined 33 | /// 34 | Undefined, 35 | 36 | /// 37 | /// Match is live. 38 | /// 39 | Live, 40 | 41 | /// 42 | /// Round is over but the next round has not started yet. 43 | /// 44 | Over, 45 | 46 | /// 47 | /// Match is currently in freezetime. 48 | /// 49 | FreezeTime, 50 | 51 | /// 52 | /// Bomb is currently being defused. 53 | /// 54 | Defuse, 55 | 56 | /// 57 | /// Bomb was planted and is ticking down. 58 | /// 59 | Bomb, 60 | 61 | /// 62 | /// Match is currently in a time-out called by the T team. 63 | /// 64 | Timeout_T, 65 | 66 | /// 67 | /// Match is currently in a time-out called by the CT team. 68 | /// 69 | Timeout_CT 70 | } 71 | } -------------------------------------------------------------------------------- /CSGSI/Nodes/ProviderNode.cs: -------------------------------------------------------------------------------- 1 | namespace CSGSI.Nodes 2 | { 3 | /// 4 | /// A node containing information about the entity that provided this gamestate. 5 | /// 6 | public class ProviderNode : NodeBase 7 | { 8 | /// 9 | /// The name of the entity. 10 | /// 11 | public string Name { get; set; } 12 | 13 | /// 14 | /// The App-ID of the entity. (730 in the case of CS:GO) 15 | /// 16 | public int AppID { get; set; } 17 | 18 | /// 19 | /// The version of the game. (not delimited by '.' as it is usually shown) 20 | /// 21 | public string Version { get; set; } 22 | 23 | /// 24 | /// The Steam-ID of the entity. 25 | /// 26 | public string SteamID { get; private set; } 27 | 28 | /// 29 | /// A Unix time stamp of when this data was sent. 30 | /// 31 | public string TimeStamp { get; private set; } 32 | 33 | internal ProviderNode(string json) 34 | : base(json) 35 | { 36 | Name = GetString("name"); 37 | AppID = GetInt32("appid"); 38 | Version = GetString("version"); 39 | SteamID = GetString("steamid"); 40 | TimeStamp = GetString("timestamp"); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /CSGSI/Nodes/RoundNode.cs: -------------------------------------------------------------------------------- 1 | namespace CSGSI.Nodes 2 | { 3 | /// 4 | /// A node containing information about the current round. 5 | /// 6 | public class RoundNode : NodeBase 7 | { 8 | /// 9 | /// The phase that the round is currently in. 10 | /// 11 | public RoundPhase Phase { get; set; } 12 | 13 | /// 14 | /// The current state of the bomb (does not include states like "Dropped" or "Planting"). 15 | /// 16 | public BombState Bomb { get; set; } 17 | 18 | /// 19 | /// The team that won the current round (only available when Phase == Over) 20 | /// 21 | public RoundWinTeam WinTeam { get; set; } 22 | 23 | internal RoundNode(string json) 24 | : base(json) 25 | { 26 | Phase = GetEnum("phase"); 27 | Bomb = GetEnum("bomb"); 28 | WinTeam = GetEnum("win_team"); 29 | } 30 | } 31 | 32 | /// 33 | /// Represents the phase of a round. 34 | /// 35 | public enum RoundPhase 36 | { 37 | /// 38 | /// Unknown round phase. 39 | /// 40 | Undefined, 41 | 42 | /// 43 | /// Round is live. 44 | /// 45 | Live, 46 | 47 | /// 48 | /// Round is over. 49 | /// 50 | Over, 51 | 52 | /// 53 | /// Round is currently in freeze time. 54 | /// 55 | FreezeTime 56 | } 57 | 58 | /// 59 | /// Represents the winning team of a round. 60 | /// 61 | public enum RoundWinTeam 62 | { 63 | /// 64 | /// Unknown winning team. 65 | /// 66 | Undefined, 67 | 68 | /// 69 | /// Terrorists won. 70 | /// 71 | T, 72 | 73 | /// 74 | /// Counter-Terrorists won. 75 | /// 76 | CT 77 | } 78 | } -------------------------------------------------------------------------------- /CSGSI/Nodes/WeaponsNode.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json.Linq; 2 | using System.Collections.Generic; 3 | 4 | namespace CSGSI.Nodes 5 | { 6 | /// 7 | /// A node containing a collection of s. 8 | /// 9 | public class WeaponsNode : NodeBase 10 | { 11 | /// 12 | /// The list of all weapons in this node. 13 | /// 14 | public List Weapons { get; set; } = new List(); 15 | 16 | /// 17 | /// Gets the list of s. 18 | /// 19 | public IEnumerable WeaponList => Weapons; 20 | 21 | /// 22 | /// The amount of weapons this node contains. 23 | /// 24 | public int Count => Weapons.Count; 25 | 26 | /// 27 | /// The weapon/equipment the player has currently pulled out. 28 | /// 29 | public WeaponNode ActiveWeapon 30 | { 31 | get 32 | { 33 | foreach (WeaponNode weapon in Weapons) 34 | { 35 | if (weapon.State == WeaponState.Active || weapon.State == WeaponState.Reloading) 36 | return weapon; 37 | } 38 | 39 | return new WeaponNode(""); 40 | } 41 | } 42 | 43 | internal WeaponsNode(string json) 44 | : base(json) 45 | { 46 | foreach (JToken weapon in _data.Children()) 47 | { 48 | Weapons.Add(new WeaponNode(weapon.First.ToString())); 49 | } 50 | } 51 | 52 | /// 53 | /// Gets the weapon with index <index> 54 | /// 55 | /// 56 | /// 57 | public WeaponNode this[int index] 58 | { 59 | get 60 | { 61 | if (index > Weapons.Count - 1) 62 | { 63 | return new WeaponNode(""); 64 | } 65 | 66 | return Weapons[index]; 67 | } 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /CSGSI/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("CSGSI")] 8 | [assembly: AssemblyDescription("A simple Game State Integration handler for CS:GO")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("CSGSI")] 12 | [assembly: AssemblyCopyright("")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("12de3576-5e68-4a3a-9355-faf4500e71bc")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.3.1.0")] 35 | [assembly: AssemblyFileVersion("1.3.1.0")] -------------------------------------------------------------------------------- /CSGSI/Vector3.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | 3 | namespace CSGSI 4 | { 5 | /// 6 | /// A 3 dimensional vector. 7 | /// 8 | public struct Vector3 9 | { 10 | /// 11 | /// The X component of the vector (left/right). 12 | /// 13 | public double X; 14 | 15 | /// 16 | /// The Y component of the vector (up/down). 17 | /// 18 | public double Y; 19 | 20 | /// 21 | /// The Z component of the vector (forward/backward). 22 | /// 23 | public double Z; 24 | 25 | /// 26 | /// Returns a Vector3 instance with X, Y and Z set to 0. 27 | /// 28 | public static Vector3 Empty => new Vector3(0, 0, 0); 29 | 30 | /// 31 | /// Initializes a new vector with the given X, Y and Z components. 32 | /// 33 | /// 34 | /// 35 | /// 36 | public Vector3(double x, double y, double z) 37 | { 38 | this.X = x; 39 | this.Y = y; 40 | this.Z = z; 41 | } 42 | 43 | /// 44 | /// Initializes a new from the given component string. 45 | /// 46 | /// A string in the format "x,y,z". Whitespace is permitted. 47 | /// A new with the given component values. 48 | public static Vector3 FromComponentString(string components) 49 | { 50 | string[] xyz = components.Split(','); 51 | if (xyz.Length != 3) 52 | return Vector3.Empty; 53 | 54 | if (double.TryParse(xyz[0].Trim(), NumberStyles.Any, CultureInfo.InvariantCulture, out double x) && 55 | double.TryParse(xyz[1].Trim(), NumberStyles.Any, CultureInfo.InvariantCulture, out double y) && 56 | double.TryParse(xyz[2].Trim(), NumberStyles.Any, CultureInfo.InvariantCulture, out double z)) 57 | { 58 | return new Vector3(x, y, z); 59 | } 60 | 61 | return Vector3.Empty; 62 | } 63 | 64 | /// 65 | /// Generates a string formatted like so: 66 | /// (X, Y, Z) 67 | /// 68 | /// The string representation of this vector. 69 | public override string ToString() 70 | { 71 | return $"({X}, {Y}, {Z})"; 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Callbacks/ICallbackData.cs: -------------------------------------------------------------------------------- 1 | using Steamworks.Data; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Runtime.InteropServices; 5 | using System.Threading.Tasks; 6 | 7 | namespace Steamworks 8 | { 9 | /// 10 | /// Gives us a generic way to get the CallbackId of structs 11 | /// 12 | internal interface ICallbackData 13 | { 14 | CallbackType CallbackType { get; } 15 | int DataSize { get; } 16 | } 17 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Classes/AuthTicket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Steamworks 4 | { 5 | public class AuthTicket : IDisposable 6 | { 7 | public byte[] Data; 8 | public uint Handle; 9 | 10 | /// 11 | /// Cancels a ticket. 12 | /// You should cancel your ticket when you close the game or leave a server. 13 | /// 14 | public void Cancel() 15 | { 16 | if ( Handle != 0 ) 17 | { 18 | SteamUser.Internal.CancelAuthTicket( Handle ); 19 | } 20 | 21 | Handle = 0; 22 | Data = null; 23 | } 24 | 25 | public void Dispose() 26 | { 27 | Cancel(); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Classes/SteamApi.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using Steamworks.Data; 6 | 7 | 8 | namespace Steamworks 9 | { 10 | internal static class SteamAPI 11 | { 12 | internal static class Native 13 | { 14 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_Init", CallingConvention = CallingConvention.Cdecl )] 15 | [return: MarshalAs( UnmanagedType.I1 )] 16 | public static extern bool SteamAPI_Init(); 17 | 18 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_Shutdown", CallingConvention = CallingConvention.Cdecl )] 19 | public static extern void SteamAPI_Shutdown(); 20 | 21 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_GetHSteamPipe", CallingConvention = CallingConvention.Cdecl )] 22 | public static extern HSteamPipe SteamAPI_GetHSteamPipe(); 23 | 24 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_RestartAppIfNecessary", CallingConvention = CallingConvention.Cdecl )] 25 | [return: MarshalAs( UnmanagedType.I1 )] 26 | public static extern bool SteamAPI_RestartAppIfNecessary( uint unOwnAppID ); 27 | 28 | } 29 | static internal bool Init() 30 | { 31 | return Native.SteamAPI_Init(); 32 | } 33 | 34 | static internal void Shutdown() 35 | { 36 | Native.SteamAPI_Shutdown(); 37 | } 38 | 39 | static internal HSteamPipe GetHSteamPipe() 40 | { 41 | return Native.SteamAPI_GetHSteamPipe(); 42 | } 43 | 44 | static internal bool RestartAppIfNecessary( uint unOwnAppID ) 45 | { 46 | return Native.SteamAPI_RestartAppIfNecessary( unOwnAppID ); 47 | } 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Classes/SteamGameServer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using Steamworks.Data; 6 | 7 | 8 | namespace Steamworks 9 | { 10 | internal static class SteamGameServer 11 | { 12 | internal static class Native 13 | { 14 | [DllImport( Platform.LibraryName, EntryPoint = "SteamGameServer_RunCallbacks", CallingConvention = CallingConvention.Cdecl )] 15 | public static extern void SteamGameServer_RunCallbacks(); 16 | 17 | [DllImport( Platform.LibraryName, EntryPoint = "SteamGameServer_Shutdown", CallingConvention = CallingConvention.Cdecl )] 18 | public static extern void SteamGameServer_Shutdown(); 19 | 20 | [DllImport( Platform.LibraryName, EntryPoint = "SteamGameServer_GetHSteamPipe", CallingConvention = CallingConvention.Cdecl )] 21 | public static extern HSteamPipe SteamGameServer_GetHSteamPipe(); 22 | 23 | } 24 | static internal void RunCallbacks() 25 | { 26 | Native.SteamGameServer_RunCallbacks(); 27 | } 28 | 29 | static internal void Shutdown() 30 | { 31 | Native.SteamGameServer_Shutdown(); 32 | } 33 | 34 | static internal HSteamPipe GetHSteamPipe() 35 | { 36 | return Native.SteamGameServer_GetHSteamPipe(); 37 | } 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Classes/SteamInternal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using Steamworks.Data; 6 | 7 | 8 | namespace Steamworks 9 | { 10 | internal static class SteamInternal 11 | { 12 | internal static class Native 13 | { 14 | [DllImport( Platform.LibraryName, EntryPoint = "SteamInternal_GameServer_Init", CallingConvention = CallingConvention.Cdecl )] 15 | [return: MarshalAs( UnmanagedType.I1 )] 16 | public static extern bool SteamInternal_GameServer_Init( uint unIP, ushort usPort, ushort usGamePort, ushort usQueryPort, int eServerMode, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchVersionString ); 17 | } 18 | 19 | static internal bool GameServer_Init( uint unIP, ushort usPort, ushort usGamePort, ushort usQueryPort, int eServerMode, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchVersionString ) 20 | { 21 | return Native.SteamInternal_GameServer_Init( unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString ); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Enum/LeaderboardDisplay.cs: -------------------------------------------------------------------------------- 1 | namespace Steamworks.Data 2 | { 3 | public enum LeaderboardDisplay : int 4 | { 5 | /// 6 | /// The score is just a simple numerical value 7 | /// 8 | Numeric = 1, 9 | 10 | /// 11 | /// The score represents a time, in seconds 12 | /// 13 | TimeSeconds = 2, 14 | 15 | /// 16 | /// The score represents a time, in milliseconds 17 | /// 18 | TimeMilliSeconds = 3, 19 | } 20 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Enum/LeaderboardSort.cs: -------------------------------------------------------------------------------- 1 | namespace Steamworks.Data 2 | { 3 | public enum LeaderboardSort : int 4 | { 5 | /// 6 | /// The top-score is the lowest number 7 | /// 8 | Ascending = 1, 9 | 10 | /// 11 | /// The top-score is the highest number 12 | /// 13 | Descending = 2, 14 | } 15 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Enum/SendType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Steamworks.Data 4 | { 5 | [Flags] 6 | public enum SendType : int 7 | { 8 | /// 9 | /// Send the message unreliably. Can be lost. Messages *can* be larger than a 10 | /// single MTU (UDP packet), but there is no retransmission, so if any piece 11 | /// of the message is lost, the entire message will be dropped. 12 | /// 13 | /// The sending API does have some knowledge of the underlying connection, so 14 | /// if there is no NAT-traversal accomplished or there is a recognized adjustment 15 | /// happening on the connection, the packet will be batched until the connection 16 | /// is open again. 17 | /// 18 | Unreliable = 0, 19 | 20 | /// 21 | /// Disable Nagle's algorithm. 22 | /// By default, Nagle's algorithm is applied to all outbound messages. This means 23 | /// that the message will NOT be sent immediately, in case further messages are 24 | /// sent soon after you send this, which can be grouped together. Any time there 25 | /// is enough buffered data to fill a packet, the packets will be pushed out immediately, 26 | /// but partially-full packets not be sent until the Nagle timer expires. 27 | /// 28 | NoNagle = 1 << 0, 29 | 30 | /// 31 | /// If the message cannot be sent very soon (because the connection is still doing some initial 32 | /// handshaking, route negotiations, etc), then just drop it. This is only applicable for unreliable 33 | /// messages. Using this flag on reliable messages is invalid. 34 | /// 35 | NoDelay = 1 << 2, 36 | 37 | /// Reliable message send. Can send up to 0.5mb in a single message. 38 | /// Does fragmentation/re-assembly of messages under the hood, as well as a sliding window for 39 | /// efficient sends of large chunks of data. 40 | Reliable = 1 << 3 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Facepunch.Steamworks.Posix.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Facepunch.Steamworks.Posix 5 | $(DefineConstants);PLATFORM_POSIX 6 | netstandard2.1;net6.0 7 | true 8 | 10 9 | true 10 | false 11 | Steamworks 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Facepunch.Steamworks.Win32.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | Facepunch.Steamworks.Win32 4 | $(DefineConstants);PLATFORM_WIN32;PLATFORM_WIN 5 | netcoreapp6.0 6 | true 7 | true 8 | true 9 | Steamworks 10 | 11 | 12 | C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client 13 | Garry Newman 14 | Facepunch.Steamworks.win32 15 | Steamworks implementation with an emphasis on making things easy. For Windows x86. 16 | https://github.com/Facepunch/Facepunch.Steamworks 17 | Facepunch.Steamworks.jpg 18 | facepunch;steam;unity;steamworks;valve 19 | 10 20 | MIT 21 | https://github.com/Facepunch/Facepunch.Steamworks.git 22 | git 23 | true 24 | 25 | 26 | 27 | true 28 | / 29 | 30 | 31 | Always 32 | true 33 | content 34 | 35 | 36 | 37 | 38 | 39 | all 40 | 41 | 42 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Facepunch.Steamworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/Facepunch.Steamworks/Facepunch.Steamworks.jpg -------------------------------------------------------------------------------- /Facepunch.Steamworks/Facepunch.Steamworks.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | PackageReference 5 | true 6 | 7 | 8 | 9 | 2.3.4 10 | 2.3.4 11 | 12 | 13 | 14 | $(DefineConstants);TRACE;DEBUG 15 | 1701;1702;1705;618;1591 16 | 17 | 18 | 19 | $(DefineConstants);TRACE;RELEASE 20 | 1701;1702;1705;618;1591 21 | 22 | 23 | 24 | $(DefineConstants);NET_CORE 25 | 26 | 27 | 28 | full 29 | true 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmakingPingResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using Steamworks.Data; 6 | 7 | 8 | namespace Steamworks 9 | { 10 | internal unsafe class ISteamMatchmakingPingResponse : SteamInterface 11 | { 12 | 13 | internal ISteamMatchmakingPingResponse( bool IsGameServer ) 14 | { 15 | SetupInterface( IsGameServer ); 16 | } 17 | 18 | #region FunctionMeta 19 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamMatchmakingPingResponse_ServerResponded", CallingConvention = Platform.CC)] 20 | private static extern void _ServerResponded( IntPtr self, ref gameserveritem_t server ); 21 | 22 | #endregion 23 | internal void ServerResponded( ref gameserveritem_t server ) 24 | { 25 | _ServerResponded( Self, ref server ); 26 | } 27 | 28 | #region FunctionMeta 29 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamMatchmakingPingResponse_ServerFailedToRespond", CallingConvention = Platform.CC)] 30 | private static extern void _ServerFailedToRespond( IntPtr self ); 31 | 32 | #endregion 33 | internal void ServerFailedToRespond() 34 | { 35 | _ServerFailedToRespond( Self ); 36 | } 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmakingPlayersResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using Steamworks.Data; 6 | 7 | 8 | namespace Steamworks 9 | { 10 | internal unsafe class ISteamMatchmakingPlayersResponse : SteamInterface 11 | { 12 | 13 | internal ISteamMatchmakingPlayersResponse( bool IsGameServer ) 14 | { 15 | SetupInterface( IsGameServer ); 16 | } 17 | 18 | #region FunctionMeta 19 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamMatchmakingPlayersResponse_AddPlayerToList", CallingConvention = Platform.CC)] 20 | private static extern void _AddPlayerToList( IntPtr self, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchName, int nScore, float flTimePlayed ); 21 | 22 | #endregion 23 | internal void AddPlayerToList( [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchName, int nScore, float flTimePlayed ) 24 | { 25 | _AddPlayerToList( Self, pchName, nScore, flTimePlayed ); 26 | } 27 | 28 | #region FunctionMeta 29 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamMatchmakingPlayersResponse_PlayersFailedToRespond", CallingConvention = Platform.CC)] 30 | private static extern void _PlayersFailedToRespond( IntPtr self ); 31 | 32 | #endregion 33 | internal void PlayersFailedToRespond() 34 | { 35 | _PlayersFailedToRespond( Self ); 36 | } 37 | 38 | #region FunctionMeta 39 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamMatchmakingPlayersResponse_PlayersRefreshComplete", CallingConvention = Platform.CC)] 40 | private static extern void _PlayersRefreshComplete( IntPtr self ); 41 | 42 | #endregion 43 | internal void PlayersRefreshComplete() 44 | { 45 | _PlayersRefreshComplete( Self ); 46 | } 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmakingRulesResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using Steamworks.Data; 6 | 7 | 8 | namespace Steamworks 9 | { 10 | internal unsafe class ISteamMatchmakingRulesResponse : SteamInterface 11 | { 12 | 13 | internal ISteamMatchmakingRulesResponse( bool IsGameServer ) 14 | { 15 | SetupInterface( IsGameServer ); 16 | } 17 | 18 | #region FunctionMeta 19 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamMatchmakingRulesResponse_RulesResponded", CallingConvention = Platform.CC)] 20 | private static extern void _RulesResponded( IntPtr self, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchRule, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchValue ); 21 | 22 | #endregion 23 | internal void RulesResponded( [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchRule, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchValue ) 24 | { 25 | _RulesResponded( Self, pchRule, pchValue ); 26 | } 27 | 28 | #region FunctionMeta 29 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamMatchmakingRulesResponse_RulesFailedToRespond", CallingConvention = Platform.CC)] 30 | private static extern void _RulesFailedToRespond( IntPtr self ); 31 | 32 | #endregion 33 | internal void RulesFailedToRespond() 34 | { 35 | _RulesFailedToRespond( Self ); 36 | } 37 | 38 | #region FunctionMeta 39 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamMatchmakingRulesResponse_RulesRefreshComplete", CallingConvention = Platform.CC)] 40 | private static extern void _RulesRefreshComplete( IntPtr self ); 41 | 42 | #endregion 43 | internal void RulesRefreshComplete() 44 | { 45 | _RulesRefreshComplete( Self ); 46 | } 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Generated/Interfaces/ISteamMatchmakingServerListResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using Steamworks.Data; 6 | 7 | 8 | namespace Steamworks 9 | { 10 | internal unsafe class ISteamMatchmakingServerListResponse : SteamInterface 11 | { 12 | 13 | internal ISteamMatchmakingServerListResponse( bool IsGameServer ) 14 | { 15 | SetupInterface( IsGameServer ); 16 | } 17 | 18 | #region FunctionMeta 19 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamMatchmakingServerListResponse_ServerResponded", CallingConvention = Platform.CC)] 20 | private static extern void _ServerResponded( IntPtr self, HServerListRequest hRequest, int iServer ); 21 | 22 | #endregion 23 | internal void ServerResponded( HServerListRequest hRequest, int iServer ) 24 | { 25 | _ServerResponded( Self, hRequest, iServer ); 26 | } 27 | 28 | #region FunctionMeta 29 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamMatchmakingServerListResponse_ServerFailedToRespond", CallingConvention = Platform.CC)] 30 | private static extern void _ServerFailedToRespond( IntPtr self, HServerListRequest hRequest, int iServer ); 31 | 32 | #endregion 33 | internal void ServerFailedToRespond( HServerListRequest hRequest, int iServer ) 34 | { 35 | _ServerFailedToRespond( Self, hRequest, iServer ); 36 | } 37 | 38 | #region FunctionMeta 39 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamMatchmakingServerListResponse_RefreshComplete", CallingConvention = Platform.CC)] 40 | private static extern void _RefreshComplete( IntPtr self, HServerListRequest hRequest, MatchMakingServerResponse response ); 41 | 42 | #endregion 43 | internal void RefreshComplete( HServerListRequest hRequest, MatchMakingServerResponse response ) 44 | { 45 | _RefreshComplete( Self, hRequest, response ); 46 | } 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Generated/Interfaces/ISteamNetworkingFakeUDPPort.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using Steamworks.Data; 6 | 7 | 8 | namespace Steamworks 9 | { 10 | internal unsafe class ISteamNetworkingFakeUDPPort : SteamInterface 11 | { 12 | 13 | internal ISteamNetworkingFakeUDPPort( bool IsGameServer ) 14 | { 15 | SetupInterface( IsGameServer ); 16 | } 17 | 18 | #region FunctionMeta 19 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingFakeUDPPort_DestroyFakeUDPPort", CallingConvention = Platform.CC)] 20 | private static extern void _DestroyFakeUDPPort( IntPtr self ); 21 | 22 | #endregion 23 | internal void DestroyFakeUDPPort() 24 | { 25 | _DestroyFakeUDPPort( Self ); 26 | } 27 | 28 | #region FunctionMeta 29 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingFakeUDPPort_SendMessageToFakeIP", CallingConvention = Platform.CC)] 30 | private static extern Result _SendMessageToFakeIP( IntPtr self, ref NetAddress remoteAddress, IntPtr pData, uint cbData, int nSendFlags ); 31 | 32 | #endregion 33 | internal Result SendMessageToFakeIP( ref NetAddress remoteAddress, IntPtr pData, uint cbData, int nSendFlags ) 34 | { 35 | var returnValue = _SendMessageToFakeIP( Self, ref remoteAddress, pData, cbData, nSendFlags ); 36 | return returnValue; 37 | } 38 | 39 | #region FunctionMeta 40 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingFakeUDPPort_ReceiveMessages", CallingConvention = Platform.CC)] 41 | private static extern int _ReceiveMessages( IntPtr self, IntPtr ppOutMessages, int nMaxMessages ); 42 | 43 | #endregion 44 | internal int ReceiveMessages( IntPtr ppOutMessages, int nMaxMessages ) 45 | { 46 | var returnValue = _ReceiveMessages( Self, ppOutMessages, nMaxMessages ); 47 | return returnValue; 48 | } 49 | 50 | #region FunctionMeta 51 | [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamNetworkingFakeUDPPort_ScheduleCleanup", CallingConvention = Platform.CC)] 52 | private static extern void _ScheduleCleanup( IntPtr self, ref NetAddress remoteAddress ); 53 | 54 | #endregion 55 | internal void ScheduleCleanup( ref NetAddress remoteAddress ) 56 | { 57 | _ScheduleCleanup( Self, ref remoteAddress ); 58 | } 59 | 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Networking/ConnectionInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace Steamworks.Data 4 | { 5 | /// 6 | /// Describe the state of a connection 7 | /// 8 | [StructLayout( LayoutKind.Sequential, Size = 696 )] 9 | public struct ConnectionInfo 10 | { 11 | internal NetIdentity identity; 12 | internal long userData; 13 | internal Socket listenSocket; 14 | internal NetAddress address; 15 | internal ushort pad; 16 | internal SteamNetworkingPOPID popRemote; 17 | internal SteamNetworkingPOPID popRelay; 18 | internal ConnectionState state; 19 | internal int endReason; 20 | [MarshalAs( UnmanagedType.ByValTStr, SizeConst = 128 )] 21 | internal string endDebug; 22 | [MarshalAs( UnmanagedType.ByValTStr, SizeConst = 128 )] 23 | internal string connectionDescription; 24 | 25 | /// 26 | /// High level state of the connection 27 | /// 28 | public ConnectionState State => state; 29 | 30 | /// 31 | /// Remote address. Might be all 0's if we don't know it, or if this is N/A. 32 | /// 33 | public NetAddress Address => address; 34 | 35 | /// 36 | /// Who is on the other end? Depending on the connection type and phase of the connection, we might not know 37 | /// 38 | public NetIdentity Identity => identity; 39 | 40 | /// 41 | /// Basic cause of the connection termination or problem. 42 | /// 43 | public NetConnectionEnd EndReason => (NetConnectionEnd)endReason; 44 | } 45 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Networking/ConnectionLaneStatus.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace Steamworks.Data 4 | { 5 | /// 6 | /// Describe the status of a connection 7 | /// 8 | [StructLayout( LayoutKind.Sequential, Pack = Platform.StructPlatformPackSize )] 9 | public struct ConnectionLaneStatus 10 | { 11 | internal int cbPendingUnreliable; // m_cbPendingUnreliable int 12 | internal int cbPendingReliable; // m_cbPendingReliable int 13 | internal int cbSentUnackedReliable; // m_cbSentUnackedReliable int 14 | internal int _reservePad1; // _reservePad1 int 15 | internal long ecQueueTime; // m_usecQueueTime SteamNetworkingMicroseconds 16 | [MarshalAs( UnmanagedType.ByValArray, SizeConst = 10, ArraySubType = UnmanagedType.U4 )] 17 | internal uint[] reserved; // reserved uint32 [10] 18 | 19 | /// 20 | /// Number of bytes unreliable data pending to be sent. This is data that you have recently requested to be sent but has not yet actually been put on the wire. 21 | /// 22 | public int PendingUnreliable => cbPendingUnreliable; 23 | 24 | /// 25 | /// Number of bytes reliable data pending to be sent. This is data that you have recently requested to be sent but has not yet actually been put on the wire. 26 | /// 27 | public int PendingReliable => cbPendingReliable; 28 | 29 | /// 30 | /// Number of bytes of reliable data that has been placed the wire, but for which we have not yet received an acknowledgment, and thus we may have to re-transmit. 31 | /// 32 | public int SentUnackedReliable => cbSentUnackedReliable; 33 | } 34 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Networking/Delegates.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using Steamworks.Data; 5 | 6 | namespace Steamworks 7 | { 8 | [UnmanagedFunctionPointer( Platform.CC )] 9 | internal delegate void NetDebugFunc( [In] NetDebugOutput nType, [In] IntPtr pszMsg ); 10 | 11 | [UnmanagedFunctionPointer( Platform.CC )] 12 | internal unsafe delegate void FnSteamNetConnectionStatusChanged( ref SteamNetConnectionStatusChangedCallback_t arg ); 13 | 14 | [UnmanagedFunctionPointer( Platform.CC )] 15 | internal delegate void FnSteamNetAuthenticationStatusChanged( ref SteamNetAuthenticationStatus_t arg ); 16 | 17 | [UnmanagedFunctionPointer( Platform.CC )] 18 | internal delegate void FnSteamRelayNetworkStatusChanged( ref SteamRelayNetworkStatus_t arg ); 19 | 20 | [UnmanagedFunctionPointer( Platform.CC )] 21 | internal delegate void FnSteamNetworkingMessagesSessionRequest( ref SteamNetworkingMessagesSessionRequest_t arg ); 22 | 23 | [UnmanagedFunctionPointer( Platform.CC )] 24 | internal delegate void FnSteamNetworkingMessagesSessionFailed( ref SteamNetworkingMessagesSessionFailed_t arg ); 25 | 26 | [UnmanagedFunctionPointer( Platform.CC )] 27 | internal delegate void FnSteamNetworkingFakeIPResult( ref SteamNetworkingFakeIPResult_t arg ); 28 | } 29 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Networking/IConnectionManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Steamworks.Data; 3 | 4 | namespace Steamworks 5 | { 6 | public interface IConnectionManager 7 | { 8 | /// 9 | /// We started connecting to this guy 10 | /// 11 | void OnConnecting( ConnectionInfo info ); 12 | 13 | /// 14 | /// Called when the connection is fully connected and can start being communicated with 15 | /// 16 | void OnConnected( ConnectionInfo info ); 17 | 18 | /// 19 | /// We got disconnected 20 | /// 21 | void OnDisconnected( ConnectionInfo info ); 22 | 23 | /// 24 | /// Received a message 25 | /// 26 | void OnMessage( IntPtr data, int size, long messageNum, long recvTime, int channel ); 27 | } 28 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Networking/ISocketManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Steamworks.Data; 3 | 4 | namespace Steamworks 5 | { 6 | public interface ISocketManager 7 | { 8 | /// 9 | /// Must call Accept or Close on the connection within a second or so 10 | /// 11 | void OnConnecting( Connection connection, ConnectionInfo info ); 12 | 13 | /// 14 | /// Called when the connection is fully connected and can start being communicated with 15 | /// 16 | void OnConnected( Connection connection, ConnectionInfo info ); 17 | 18 | /// 19 | /// Called when the connection leaves. Must call Close on the connection 20 | /// 21 | void OnDisconnected( Connection connection, ConnectionInfo info ); 22 | 23 | /// 24 | /// Received a message from a connection 25 | /// 26 | void OnMessage( Connection connection, NetIdentity identity, IntPtr data, int size, long messageNum, long recvTime, int channel ); 27 | } 28 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Networking/NetErrorMessage.cs: -------------------------------------------------------------------------------- 1 | 2 | using Steamworks.Data; 3 | 4 | namespace Steamworks.Data 5 | { 6 | internal unsafe struct NetErrorMessage 7 | { 8 | public fixed char Value[1024]; 9 | } 10 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Networking/NetKeyValue.cs: -------------------------------------------------------------------------------- 1 | using Steamworks.Data; 2 | using System; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace Steamworks.Data 6 | { 7 | [StructLayout( LayoutKind.Explicit, Pack = Platform.StructPlatformPackSize )] 8 | internal partial struct NetKeyValue 9 | { 10 | [FieldOffset(0)] 11 | internal NetConfig Value; // m_eValue ESteamNetworkingConfigValue 12 | 13 | [FieldOffset( 4 )] 14 | internal NetConfigType DataType; // m_eDataType ESteamNetworkingConfigDataType 15 | 16 | [FieldOffset( 8 )] 17 | internal long Int64Value; // m_int64 int64_t 18 | 19 | [FieldOffset( 8 )] 20 | internal int Int32Value; // m_val_int32 int32_t 21 | 22 | [FieldOffset( 8 )] 23 | internal float FloatValue; // m_val_float float 24 | 25 | [FieldOffset( 8 )] 26 | internal IntPtr PointerValue; // m_val_functionPtr void * 27 | 28 | 29 | // TODO - support strings, maybe 30 | } 31 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Networking/NetMsg.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Steamworks.Data 5 | { 6 | [StructLayout( LayoutKind.Sequential )] 7 | internal partial struct NetMsg 8 | { 9 | internal IntPtr DataPtr; 10 | internal int DataSize; 11 | internal Connection Connection; 12 | internal NetIdentity Identity; 13 | internal long ConnectionUserData; 14 | internal long RecvTime; 15 | internal long MessageNumber; 16 | internal IntPtr FreeDataPtr; 17 | internal IntPtr ReleasePtr; 18 | internal int Channel; 19 | internal SendType Flags; 20 | internal long UserData; 21 | internal ushort IdxLane; 22 | internal ushort _pad1__; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Networking/Socket.cs: -------------------------------------------------------------------------------- 1 |  2 | using System.Runtime.InteropServices; 3 | 4 | namespace Steamworks.Data 5 | { 6 | [StructLayout( LayoutKind.Sequential )] 7 | public struct Socket 8 | { 9 | internal uint Id; 10 | public override string ToString() => Id.ToString(); 11 | public static implicit operator Socket( uint value ) => new Socket() { Id = value }; 12 | public static implicit operator uint( Socket value ) => value.Id; 13 | 14 | /// 15 | /// Destroy a listen socket. All the connections that were accepting on the listen 16 | /// socket are closed ungracefully. 17 | /// 18 | public bool Close() 19 | { 20 | return SteamNetworkingSockets.Internal.CloseListenSocket( Id ); 21 | } 22 | 23 | public SocketManager Manager 24 | { 25 | get => SteamNetworkingSockets.GetSocketManager( Id ); 26 | set => SteamNetworkingSockets.SetSocketManager( Id, value ); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Networking/SteamDatagramRelayAuthTicket.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | 6 | namespace Steamworks.Data 7 | { 8 | struct SteamDatagramRelayAuthTicket 9 | { 10 | // Not implemented, not used 11 | }; 12 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/ServerList/Favourites.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Steamworks.ServerList 8 | { 9 | public class Favourites : Base 10 | { 11 | internal override void LaunchQuery() 12 | { 13 | var filters = GetFilters(); 14 | request = Internal.RequestFavoritesServerList( AppId.Value, ref filters, (uint)filters.Length, IntPtr.Zero ); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/ServerList/Friends.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Steamworks.ServerList 8 | { 9 | public class Friends : Base 10 | { 11 | internal override void LaunchQuery() 12 | { 13 | var filters = GetFilters(); 14 | request = Internal.RequestFriendsServerList( AppId.Value, ref filters, (uint)filters.Length, IntPtr.Zero ); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/ServerList/History.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Steamworks.ServerList 8 | { 9 | public class History : Base 10 | { 11 | internal override void LaunchQuery() 12 | { 13 | var filters = GetFilters(); 14 | request = Internal.RequestHistoryServerList( AppId.Value, ref filters, (uint)filters.Length, IntPtr.Zero ); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/ServerList/Internet.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Steamworks.ServerList 8 | { 9 | public class Internet : Base 10 | { 11 | internal override void LaunchQuery() 12 | { 13 | var filters = GetFilters(); 14 | 15 | request = Internal.RequestInternetServerList( AppId.Value, ref filters, (uint)filters.Length, IntPtr.Zero ); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/ServerList/IpList.cs: -------------------------------------------------------------------------------- 1 | using Steamworks.Data; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Steamworks.ServerList 10 | { 11 | public class IpList : Internet 12 | { 13 | public List Ips = new List(); 14 | bool wantsCancel; 15 | 16 | public IpList( IEnumerable list ) 17 | { 18 | Ips.AddRange( list ); 19 | } 20 | 21 | public IpList( params string[] list ) 22 | { 23 | Ips.AddRange( list ); 24 | } 25 | 26 | public override async Task RunQueryAsync( float timeoutSeconds = 10 ) 27 | { 28 | int blockSize = 16; 29 | int pointer = 0; 30 | 31 | var ips = Ips.ToArray(); 32 | 33 | while ( true ) 34 | { 35 | var sublist = ips.Skip( pointer ).Take( blockSize ); 36 | if ( sublist.Count() == 0 ) 37 | break; 38 | 39 | using ( var list = new ServerList.Internet() ) 40 | { 41 | list.AddFilter( "or", sublist.Count().ToString() ); 42 | 43 | foreach ( var server in sublist ) 44 | { 45 | list.AddFilter( "gameaddr", server ); 46 | } 47 | 48 | await list.RunQueryAsync( timeoutSeconds ); 49 | 50 | if ( wantsCancel ) 51 | return false; 52 | 53 | Responsive.AddRange( list.Responsive ); 54 | Responsive = Responsive.Distinct().ToList(); 55 | Unresponsive.AddRange( list.Unresponsive ); 56 | Unresponsive = Unresponsive.Distinct().ToList(); 57 | } 58 | 59 | pointer += sublist.Count(); 60 | 61 | InvokeChanges(); 62 | } 63 | 64 | return true; 65 | } 66 | 67 | public override void Cancel() 68 | { 69 | wantsCancel = true; 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/ServerList/LocalNetwork.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Steamworks.ServerList 8 | { 9 | public class LocalNetwork : Base 10 | { 11 | internal override void LaunchQuery() 12 | { 13 | request = Internal.RequestLANServerList( AppId.Value, IntPtr.Zero ); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/SteamMatchmakingServers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Steamworks.Data; 7 | 8 | namespace Steamworks 9 | { 10 | /// 11 | /// Methods for clients to access matchmaking services, favorites, and to operate on game lobbies 12 | /// 13 | internal class SteamMatchmakingServers : SteamClientClass 14 | { 15 | internal static ISteamMatchmakingServers Internal => Interface as ISteamMatchmakingServers; 16 | 17 | internal override bool InitializeInterface( bool server ) 18 | { 19 | SetInterface( server, new ISteamMatchmakingServers( server ) ); 20 | if ( Interface.Self == IntPtr.Zero ) return false; 21 | 22 | return true; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/SteamParental.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Steamworks.Data; 7 | 8 | namespace Steamworks 9 | { 10 | /// 11 | /// Undocumented Parental Settings 12 | /// 13 | public class SteamParental : SteamSharedClass 14 | { 15 | internal static ISteamParentalSettings Internal => Interface as ISteamParentalSettings; 16 | 17 | internal override bool InitializeInterface( bool server ) 18 | { 19 | SetInterface( server, new ISteamParentalSettings( server ) ); 20 | if ( Interface.Self == IntPtr.Zero ) return false; 21 | 22 | InstallEvents( server ); 23 | 24 | return true; 25 | } 26 | 27 | internal static void InstallEvents( bool server ) 28 | { 29 | Dispatch.Install( x => OnSettingsChanged?.Invoke(), server ); 30 | } 31 | 32 | /// 33 | /// Parental Settings Changed 34 | /// 35 | public static event Action OnSettingsChanged; 36 | 37 | 38 | /// 39 | /// 40 | /// 41 | public static bool IsParentalLockEnabled => Internal.BIsParentalLockEnabled(); 42 | 43 | /// 44 | /// 45 | /// 46 | public static bool IsParentalLockLocked => Internal.BIsParentalLockLocked(); 47 | 48 | /// 49 | /// 50 | /// 51 | public static bool IsAppBlocked( AppId app ) => Internal.BIsAppBlocked( app.Value ); 52 | 53 | /// 54 | /// 55 | /// 56 | public static bool BIsAppInBlockList( AppId app ) => Internal.BIsAppInBlockList( app.Value ); 57 | 58 | /// 59 | /// 60 | /// 61 | public static bool IsFeatureBlocked( ParentalFeature feature ) => Internal.BIsFeatureBlocked( feature ); 62 | 63 | /// 64 | /// 65 | /// 66 | public static bool BIsFeatureInBlockList( ParentalFeature feature ) => Internal.BIsFeatureInBlockList( feature ); 67 | } 68 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/SteamParties.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Steamworks.Data; 7 | 8 | namespace Steamworks 9 | { 10 | /// 11 | /// This API can be used to selectively advertise your multiplayer game session in a Steam chat room group. 12 | /// Tell Steam the number of player spots that are available for your party, and a join-game string, and it 13 | /// will show a beacon in the selected group and allow that many users to “follow” the beacon to your party. 14 | /// Adjust the number of open slots if other players join through alternate matchmaking methods. 15 | /// 16 | public class SteamParties : SteamClientClass 17 | { 18 | internal static ISteamParties Internal => Interface as ISteamParties; 19 | 20 | internal override bool InitializeInterface( bool server ) 21 | { 22 | SetInterface( server, new ISteamParties( server ) ); 23 | if ( Interface.Self == IntPtr.Zero ) return false; 24 | 25 | InstallEvents( server ); 26 | 27 | return true; 28 | } 29 | 30 | internal void InstallEvents( bool server ) 31 | { 32 | Dispatch.Install( x => OnBeaconLocationsUpdated?.Invoke(), server ); 33 | Dispatch.Install( x => OnActiveBeaconsUpdated?.Invoke(), server ); 34 | } 35 | 36 | /// 37 | /// Invoked when the list of possible Party beacon locations has changed 38 | /// 39 | public static event Action OnBeaconLocationsUpdated; 40 | 41 | /// 42 | /// Invoked when the list of active beacons may have changed 43 | /// 44 | public static event Action OnActiveBeaconsUpdated; 45 | 46 | /// 47 | /// Gets the amount of beacons that are active. 48 | /// 49 | public static int ActiveBeaconCount => (int) Internal.GetNumActiveBeacons(); 50 | 51 | /// 52 | /// Gets an of active beacons. 53 | /// 54 | public static IEnumerable ActiveBeacons 55 | { 56 | get 57 | { 58 | for ( uint i = 0; i < ActiveBeaconCount; i++ ) 59 | { 60 | yield return new PartyBeacon 61 | { 62 | Id = Internal.GetBeaconByIndex( i ) 63 | }; 64 | } 65 | } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/SteamRemotePlay.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Steamworks.Data; 7 | 8 | namespace Steamworks 9 | { 10 | /// 11 | /// Functions that provide information about Steam Remote Play sessions, streaming your game content to another computer or to a Steam Link app or hardware. 12 | /// 13 | public class SteamRemotePlay : SteamClientClass 14 | { 15 | internal static ISteamRemotePlay Internal => Interface as ISteamRemotePlay; 16 | 17 | internal override bool InitializeInterface( bool server ) 18 | { 19 | SetInterface( server, new ISteamRemotePlay( server ) ); 20 | if ( Interface.Self == IntPtr.Zero ) return false; 21 | 22 | InstallEvents( server ); 23 | 24 | return true; 25 | } 26 | 27 | internal void InstallEvents( bool server ) 28 | { 29 | Dispatch.Install( x => OnSessionConnected?.Invoke( x.SessionID ), server ); 30 | Dispatch.Install( x => OnSessionDisconnected?.Invoke( x.SessionID ), server ); 31 | } 32 | 33 | /// 34 | /// Invoked when a session is connected. 35 | /// 36 | public static event Action OnSessionConnected; 37 | 38 | /// 39 | /// Invoked when a session becomes disconnected. 40 | /// 41 | public static event Action OnSessionDisconnected; 42 | 43 | /// 44 | /// Gets the number of currently connected Steam Remote Play sessions 45 | /// 46 | public static int SessionCount => (int) Internal.GetSessionCount(); 47 | 48 | /// 49 | /// Get the currently connected Steam Remote Play session ID at the specified index. 50 | /// IsValid will return if it's out of bounds 51 | /// 52 | public static RemotePlaySession GetSession( int index ) => (RemotePlaySession) Internal.GetSessionID( index ).Value; 53 | 54 | 55 | /// 56 | /// Invite a friend to Remote Play Together. 57 | /// This returns if the invite can't be sent 58 | /// 59 | public static bool SendInvite( SteamId steamid ) => Internal.BSendRemotePlayTogetherInvite( steamid ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/SteamVideo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Steamworks.Data; 7 | 8 | namespace Steamworks 9 | { 10 | /// 11 | /// Class for utilizing the Steam Video API. 12 | /// 13 | public class SteamVideo : SteamClientClass 14 | { 15 | internal static ISteamVideo Internal => Interface as ISteamVideo; 16 | 17 | internal override bool InitializeInterface( bool server ) 18 | { 19 | SetInterface( server, new ISteamVideo( server ) ); 20 | if ( Interface.Self == IntPtr.Zero ) return false; 21 | 22 | InstallEvents(); 23 | 24 | return true; 25 | } 26 | 27 | internal static void InstallEvents() 28 | { 29 | } 30 | 31 | /// 32 | /// Return if currently using Steam's live broadcasting 33 | /// 34 | public static bool IsBroadcasting 35 | { 36 | get 37 | { 38 | int viewers = 0; 39 | return Internal.IsBroadcasting( ref viewers ); 40 | } 41 | } 42 | 43 | /// 44 | /// Returns the number of viewers that are watching the stream, or 0 if is . 45 | /// 46 | public static int NumViewers 47 | { 48 | get 49 | { 50 | int viewers = 0; 51 | 52 | if ( !Internal.IsBroadcasting( ref viewers ) ) 53 | return 0; 54 | 55 | return viewers; 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/AppId.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | 6 | 7 | namespace Steamworks 8 | { 9 | /// 10 | /// Represents the ID of a Steam application. 11 | /// 12 | public struct AppId 13 | { 14 | public uint Value; 15 | 16 | public override string ToString() => Value.ToString(); 17 | 18 | public static implicit operator AppId( uint value ) 19 | { 20 | return new AppId{ Value = value }; 21 | } 22 | 23 | public static implicit operator AppId( int value ) 24 | { 25 | return new AppId { Value = (uint) value }; 26 | } 27 | 28 | public static implicit operator uint( AppId value ) 29 | { 30 | return value.Value; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/Clan.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | 6 | namespace Steamworks 7 | { 8 | public struct Clan 9 | { 10 | public SteamId Id; 11 | 12 | public Clan(SteamId id) 13 | { 14 | Id = id; 15 | } 16 | 17 | public string Name => SteamFriends.Internal.GetClanName(Id); 18 | 19 | public string Tag => SteamFriends.Internal.GetClanTag(Id); 20 | 21 | public int ChatMemberCount => SteamFriends.Internal.GetClanChatMemberCount(Id); 22 | 23 | public Friend Owner => new Friend(SteamFriends.Internal.GetClanOwner(Id)); 24 | 25 | public bool Public => SteamFriends.Internal.IsClanPublic(Id); 26 | 27 | /// 28 | /// Is the clan an official game group? 29 | /// 30 | public bool Official => SteamFriends.Internal.IsClanOfficialGameGroup(Id); 31 | 32 | /// 33 | /// Asynchronously fetches the officer list for a given clan 34 | /// 35 | /// Whether the request was successful or not 36 | public async Task RequestOfficerList() 37 | { 38 | var req = await SteamFriends.Internal.RequestClanOfficerList(Id); 39 | return req.HasValue && req.Value.Success != 0x0; 40 | } 41 | 42 | public IEnumerable GetOfficers() 43 | { 44 | for (int i = 0; i < SteamFriends.Internal.GetClanOfficerCount(Id); i++) 45 | { 46 | yield return new Friend(SteamFriends.Internal.GetClanOfficerByIndex(Id, i)); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/DepotId.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | 6 | 7 | namespace Steamworks.Data 8 | { 9 | public struct DepotId 10 | { 11 | public uint Value; 12 | 13 | public static implicit operator DepotId( uint value ) 14 | { 15 | return new DepotId { Value = value }; 16 | } 17 | 18 | public static implicit operator DepotId( int value ) 19 | { 20 | return new DepotId { Value = (uint) value }; 21 | } 22 | 23 | public static implicit operator uint( DepotId value ) 24 | { 25 | return value.Value; 26 | } 27 | 28 | public override string ToString() => Value.ToString(); 29 | } 30 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/DlcInformation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | 6 | 7 | namespace Steamworks.Data 8 | { 9 | /// 10 | /// Provides information about a DLC. 11 | /// 12 | public struct DlcInformation 13 | { 14 | /// 15 | /// The of the DLC. 16 | /// 17 | public AppId AppId { get; internal set; } 18 | 19 | /// 20 | /// The name of the DLC. 21 | /// 22 | public string Name { get; internal set; } 23 | 24 | /// 25 | /// Whether or not the DLC is available. 26 | /// 27 | public bool Available { get; internal set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/DownloadProgress.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | 6 | 7 | namespace Steamworks.Data 8 | { 9 | /// 10 | /// Represents download progress. 11 | /// 12 | public struct DownloadProgress 13 | { 14 | /// 15 | /// Whether or not the download is currently active. 16 | /// 17 | public bool Active; 18 | 19 | /// 20 | /// How many bytes have been downloaded. 21 | /// 22 | public ulong BytesDownloaded; 23 | 24 | /// 25 | /// How many bytes in total the download is. 26 | /// 27 | public ulong BytesTotal; 28 | 29 | /// 30 | /// Gets the amount of bytes left that need to be downloaded. 31 | /// 32 | public ulong BytesRemaining => BytesTotal - BytesDownloaded; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/DurationControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | 6 | 7 | namespace Steamworks.Data 8 | { 9 | /// 10 | /// Sent for games with enabled anti indulgence / duration control, for enabled users. 11 | /// Lets the game know whether persistent rewards or XP should be granted at normal rate, half rate, or zero rate. 12 | /// 13 | public struct DurationControl 14 | { 15 | internal DurationControl_t _inner; 16 | 17 | /// 18 | /// appid generating playtime 19 | /// 20 | public AppId Appid => _inner.Appid; 21 | 22 | /// 23 | /// is duration control applicable to user + game combination 24 | /// 25 | public bool Applicable => _inner.Applicable; 26 | 27 | /// 28 | /// playtime since most recent 5 hour gap in playtime, only counting up to regulatory limit of playtime, in seconds 29 | /// 30 | internal TimeSpan PlaytimeInLastFiveHours => TimeSpan.FromSeconds( _inner.CsecsLast5h ); 31 | 32 | /// 33 | /// playtime on current calendar day 34 | /// 35 | internal TimeSpan PlaytimeToday => TimeSpan.FromSeconds( _inner.CsecsLast5h ); 36 | 37 | /// 38 | /// recommended progress 39 | /// 40 | internal DurationControlProgress Progress => _inner.Progress; 41 | } 42 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/FileDetails.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | 6 | 7 | namespace Steamworks.Data 8 | { 9 | /// 10 | /// Represents details of a file. 11 | /// 12 | public struct FileDetails 13 | { 14 | /// 15 | /// The size of the file in bytes. 16 | /// 17 | public ulong SizeInBytes; 18 | public string Sha1; 19 | public uint Flags; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/GameId.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | 6 | 7 | namespace Steamworks.Data 8 | { 9 | public struct GameId 10 | { 11 | // TODO - Be able to access these vars 12 | 13 | /* 14 | 15 | enum EGameIDType 16 | { 17 | k_EGameIDTypeApp = 0, 18 | k_EGameIDTypeGameMod = 1, 19 | k_EGameIDTypeShortcut = 2, 20 | k_EGameIDTypeP2P = 3, 21 | }; 22 | 23 | # ifdef VALVE_BIG_ENDIAN 24 | unsigned int m_nModID : 32; 25 | unsigned int m_nType : 8; 26 | unsigned int m_nAppID : 24; 27 | #else 28 | unsigned int m_nAppID : 24; 29 | unsigned int m_nType : 8; 30 | unsigned int m_nModID : 32; 31 | #endif 32 | */ 33 | public ulong Value; 34 | 35 | public static implicit operator GameId( ulong value ) 36 | { 37 | return new GameId { Value = value }; 38 | } 39 | 40 | public static implicit operator ulong( GameId value ) 41 | { 42 | return value.Value; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/Image.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace Steamworks.Data 3 | { 4 | public struct Image 5 | { 6 | public uint Width; 7 | public uint Height; 8 | public byte[] Data; 9 | 10 | /// 11 | /// Returns the color of the pixel at the specified position. 12 | /// 13 | /// X-coordinate 14 | /// Y-coordinate 15 | /// The color. 16 | /// If the X and Y or out of bounds. 17 | public Color GetPixel( int x, int y ) 18 | { 19 | if ( x < 0 || x >= Width ) throw new System.ArgumentException( "x out of bounds" ); 20 | if ( y < 0 || y >= Height ) throw new System.ArgumentException( "y out of bounds" ); 21 | 22 | Color c = new Color(); 23 | 24 | var i = (y * Width + x) * 4; 25 | 26 | c.r = Data[i + 0]; 27 | c.g = Data[i + 1]; 28 | c.b = Data[i + 2]; 29 | c.a = Data[i + 3]; 30 | 31 | return c; 32 | } 33 | 34 | /// 35 | /// Returns "{Width}x{Height} ({length of }bytes)" 36 | /// 37 | /// 38 | public override string ToString() 39 | { 40 | return $"{Width}x{Height} ({Data.Length}bytes)"; 41 | } 42 | } 43 | 44 | /// 45 | /// Represents a color. 46 | /// 47 | public struct Color 48 | { 49 | public byte r, g, b, a; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/InventoryPurchaseResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Steamworks.Data 9 | { 10 | public struct InventoryPurchaseResult 11 | { 12 | public Result Result; 13 | public ulong OrderID; 14 | public ulong TransID; 15 | } 16 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/LeaderboardEntry.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | 3 | namespace Steamworks.Data 4 | { 5 | public struct LeaderboardEntry 6 | { 7 | public Friend User; 8 | public int GlobalRank; 9 | public int Score; 10 | public int[] Details; 11 | // UGCHandle_t m_hUGC 12 | 13 | internal static LeaderboardEntry From( LeaderboardEntry_t e, int[] detailsBuffer ) 14 | { 15 | var r = new LeaderboardEntry 16 | { 17 | User = new Friend( e.SteamIDUser ), 18 | GlobalRank = e.GlobalRank, 19 | Score = e.Score, 20 | Details = null 21 | }; 22 | 23 | if ( e.CDetails > 0 ) 24 | { 25 | r.Details = detailsBuffer.Take( e.CDetails ).ToArray(); 26 | } 27 | 28 | return r; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/LeaderboardUpdate.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | 3 | namespace Steamworks.Data 4 | { 5 | public struct LeaderboardUpdate 6 | { 7 | public int Score; 8 | public bool Changed; 9 | public int NewGlobalRank; 10 | public int OldGlobalRank; 11 | public int RankChange => NewGlobalRank - OldGlobalRank; 12 | 13 | internal static LeaderboardUpdate From( LeaderboardScoreUploaded_t e ) => 14 | new LeaderboardUpdate 15 | { 16 | Score = e.Score, 17 | Changed = e.ScoreChanged == 1, 18 | NewGlobalRank = e.GlobalRankNew, 19 | OldGlobalRank = e.GlobalRankPrevious 20 | }; 21 | } 22 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/MatchMakingKeyValuePair.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace Steamworks.Data 5 | { 6 | [StructLayout( LayoutKind.Sequential, Pack = Platform.StructPackSize )] 7 | internal partial struct MatchMakingKeyValuePair 8 | { 9 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] 10 | internal string Key; 11 | 12 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] 13 | internal string Value; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/NumericalFilter.cs: -------------------------------------------------------------------------------- 1 | namespace Steamworks.Data 2 | { 3 | struct NumericalFilter 4 | { 5 | public string Key { get; internal set; } 6 | public int Value { get; internal set; } 7 | public LobbyComparison Comparer { get; internal set; } 8 | 9 | internal NumericalFilter ( string k, int v, LobbyComparison c ) 10 | { 11 | Key = k; 12 | Value = v; 13 | Comparer = c; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/OutgoingPacket.cs: -------------------------------------------------------------------------------- 1 | namespace Steamworks.Data 2 | { 3 | /// 4 | /// A server query packet. 5 | /// 6 | public struct OutgoingPacket 7 | { 8 | /// 9 | /// Target IP address 10 | /// 11 | public uint Address { get; internal set; } 12 | 13 | /// 14 | /// Target port 15 | /// 16 | public ushort Port { get; internal set; } 17 | 18 | /// 19 | /// This data is pooled. Make a copy if you don't use it immediately. 20 | /// This buffer is also quite large - so pay attention to Size. 21 | /// 22 | public byte[] Data { get; internal set; } 23 | 24 | /// 25 | /// Size of the data 26 | /// 27 | public int Size { get; internal set; } 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/P2Packet.cs: -------------------------------------------------------------------------------- 1 | namespace Steamworks.Data 2 | { 3 | public struct P2Packet 4 | { 5 | public SteamId SteamId; 6 | public byte[] Data; 7 | } 8 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/PartyBeacon.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Steamworks.Data; 3 | 4 | namespace Steamworks 5 | { 6 | public struct PartyBeacon 7 | { 8 | static ISteamParties Internal => SteamParties.Internal; 9 | 10 | internal PartyBeaconID_t Id; 11 | 12 | /// 13 | /// Gets the owner of the beacon. 14 | /// 15 | public SteamId Owner 16 | { 17 | get 18 | { 19 | var owner = default( SteamId ); 20 | var location = default( SteamPartyBeaconLocation_t ); 21 | Internal.GetBeaconDetails( Id, ref owner, ref location, out _ ); 22 | return owner; 23 | } 24 | } 25 | 26 | /// 27 | /// Gets metadata related to the beacon. 28 | /// 29 | public string MetaData 30 | { 31 | get 32 | { 33 | var owner = default( SteamId ); 34 | var location = default( SteamPartyBeaconLocation_t ); 35 | _ = Internal.GetBeaconDetails( Id, ref owner, ref location, out var strVal ); 36 | return strVal; 37 | } 38 | } 39 | 40 | /// 41 | /// Will attempt to join the party. If successful will return a connection string. 42 | /// If failed, will return 43 | /// 44 | public async Task JoinAsync() 45 | { 46 | var result = await Internal.JoinParty( Id ); 47 | if ( !result.HasValue || result.Value.Result != Result.OK ) 48 | return null; 49 | 50 | return result.Value.ConnectStringUTF8(); 51 | } 52 | 53 | /// 54 | /// When a user follows your beacon, Steam will reserve one of the open party slots for them, and send your game a ReservationNotification callback. 55 | /// When that user joins your party, call this method to notify Steam that the user has joined successfully. 56 | /// 57 | public void OnReservationCompleted( SteamId steamid ) 58 | { 59 | Internal.OnReservationCompleted( Id, steamid ); 60 | } 61 | 62 | /// 63 | /// To cancel a reservation (due to timeout or user input), call this. 64 | /// Steam will open a new reservation slot. 65 | /// Note: The user may already be in-flight to your game, so it's possible they will still connect and try to join your party. 66 | /// 67 | public void CancelReservation( SteamId steamid ) 68 | { 69 | Internal.CancelReservation( Id, steamid ); 70 | } 71 | 72 | /// 73 | /// Turn off the beacon. 74 | /// 75 | public bool Destroy() 76 | { 77 | return Internal.DestroyBeacon( Id ); 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/RemotePlaySession.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Steamworks.Data 5 | { 6 | /// 7 | /// Represents a RemotePlaySession from the SteamRemotePlay interface 8 | /// 9 | public struct RemotePlaySession 10 | { 11 | public uint Id { get; set; } 12 | 13 | public override string ToString() => Id.ToString(); 14 | public static implicit operator RemotePlaySession( uint value ) => new RemotePlaySession() { Id = value }; 15 | public static implicit operator uint( RemotePlaySession value ) => value.Id; 16 | 17 | /// 18 | /// Returns true if this session was valid when created. This will stay true even 19 | /// after disconnection - so be sure to watch SteamRemotePlay.OnSessionDisconnected 20 | /// 21 | public bool IsValid => Id > 0; 22 | 23 | /// 24 | /// Get the SteamID of the connected user 25 | /// 26 | public SteamId SteamId => SteamRemotePlay.Internal.GetSessionSteamID( Id ); 27 | 28 | /// 29 | /// Get the name of the session client device 30 | /// 31 | public string ClientName => SteamRemotePlay.Internal.GetSessionClientName( Id ); 32 | 33 | /// 34 | /// Get the name of the session client device 35 | /// 36 | public SteamDeviceFormFactor FormFactor => SteamRemotePlay.Internal.GetSessionClientFormFactor( Id ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/Screenshot.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | 6 | 7 | namespace Steamworks.Data 8 | { 9 | /// 10 | /// Represents a screenshot that was taken by a user. 11 | /// 12 | public struct Screenshot 13 | { 14 | internal ScreenshotHandle Value; 15 | 16 | /// 17 | /// Tags a user as being visible in the screenshot 18 | /// 19 | public bool TagUser( SteamId user ) 20 | { 21 | return SteamScreenshots.Internal.TagUser( Value, user ); 22 | } 23 | 24 | /// 25 | /// Sets the location of the screenshot. 26 | /// 27 | public bool SetLocation( string location ) 28 | { 29 | return SteamScreenshots.Internal.SetLocation( Value, location ); 30 | } 31 | 32 | public bool TagPublishedFile( PublishedFileId file ) 33 | { 34 | return SteamScreenshots.Internal.TagPublishedFile( Value, file ); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/ServerInit.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Net; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | 8 | namespace Steamworks 9 | { 10 | /// 11 | /// Used to set up the server. 12 | /// The variables in here are all required to be set, and can't be changed once the server is created. 13 | /// 14 | public struct SteamServerInit 15 | { 16 | public IPAddress IpAddress; 17 | public ushort GamePort; 18 | public ushort QueryPort; 19 | public bool Secure; 20 | 21 | /// 22 | /// The version string is usually in the form x.x.x.x, and is used by the master server to detect when the server is out of date. 23 | /// If you go into the dedicated server tab on steamworks you'll be able to server the latest version. If this version number is 24 | /// less than that latest version then your server won't show. 25 | /// 26 | public string VersionString; 27 | 28 | /// 29 | /// This should be the same directory game where gets installed into. Just the folder name, not the whole path. I.e. "Rust", "Garrysmod". 30 | /// 31 | public string ModDir; 32 | 33 | /// 34 | /// The game description. Setting this to the full name of your game is recommended. 35 | /// 36 | public string GameDescription; 37 | 38 | /// 39 | /// Is a dedicated server 40 | /// 41 | public bool DedicatedServer; 42 | 43 | 44 | public SteamServerInit( string modDir, string gameDesc ) 45 | { 46 | DedicatedServer = true; 47 | ModDir = modDir; 48 | GameDescription = gameDesc; 49 | GamePort = 27015; 50 | QueryPort = 27016; 51 | Secure = true; 52 | VersionString = "1.0.0.0"; 53 | IpAddress = null; 54 | } 55 | 56 | /// 57 | /// If you pass MASTERSERVERUPDATERPORT_USEGAMESOCKETSHARE into usQueryPort, then it causes the game server API to use 58 | /// "GameSocketShare" mode, which means that the game is responsible for sending and receiving UDP packets for the master 59 | /// server updater. 60 | /// 61 | /// More info about this here: https://partner.steamgames.com/doc/api/ISteamGameServer#HandleIncomingPacket 62 | /// 63 | public SteamServerInit WithQueryShareGamePort() 64 | { 65 | QueryPort = 0xFFFF; 66 | return this; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/SteamId.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | 6 | 7 | namespace Steamworks 8 | { 9 | /// 10 | /// Represents the ID of a user or steam lobby. 11 | /// 12 | public struct SteamId 13 | { 14 | public ulong Value; 15 | 16 | public static implicit operator SteamId( ulong value ) 17 | { 18 | return new SteamId { Value = value }; 19 | } 20 | 21 | public static implicit operator ulong( SteamId value ) 22 | { 23 | return value.Value; 24 | } 25 | 26 | public override string ToString() => Value.ToString(); 27 | 28 | public uint AccountId => (uint) (Value & 0xFFFFFFFFul); 29 | 30 | public bool IsValid => Value != default; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/SteamIpAddress.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices; 4 | using System.Text; 5 | 6 | 7 | namespace Steamworks.Data 8 | { 9 | [StructLayout( LayoutKind.Explicit, Pack = Platform.StructPlatformPackSize )] 10 | internal partial struct SteamIPAddress 11 | { 12 | [FieldOffset( 0 )] 13 | public uint Ip4Address; // Host Order 14 | 15 | [FieldOffset( 16 )] 16 | internal SteamIPType Type; // m_eType ESteamIPType 17 | 18 | public static implicit operator System.Net.IPAddress( SteamIPAddress value ) 19 | { 20 | if ( value.Type == SteamIPType.Type4 ) 21 | return Utility.Int32ToIp( value.Ip4Address ); 22 | 23 | throw new System.Exception( $"Oops - can't convert SteamIPAddress to System.Net.IPAddress because no-one coded support for {value.Type} yet" ); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/SteamParamStringArray.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using Steamworks.Data; 4 | 5 | namespace Steamworks.Ugc 6 | { 7 | internal struct SteamParamStringArray : IDisposable 8 | { 9 | public SteamParamStringArray_t Value; 10 | 11 | IntPtr[] NativeStrings; 12 | IntPtr NativeArray; 13 | 14 | public static SteamParamStringArray From( string[] array ) 15 | { 16 | var a = new SteamParamStringArray(); 17 | 18 | a.NativeStrings = new IntPtr[array.Length]; 19 | for ( int i = 0; i < a.NativeStrings.Length; i++ ) 20 | { 21 | a.NativeStrings[i] = Marshal.StringToHGlobalAnsi( array[i] ); 22 | } 23 | 24 | var size = Marshal.SizeOf( typeof( IntPtr ) ) * a.NativeStrings.Length; 25 | a.NativeArray = Marshal.AllocHGlobal( size ); 26 | Marshal.Copy( a.NativeStrings, 0, a.NativeArray, a.NativeStrings.Length ); 27 | 28 | a.Value = new SteamParamStringArray_t 29 | { 30 | Strings = a.NativeArray, 31 | NumStrings = array.Length 32 | }; 33 | 34 | return a; 35 | } 36 | 37 | public void Dispose() 38 | { 39 | foreach ( var x in NativeStrings ) 40 | Marshal.FreeHGlobal( x ); 41 | 42 | Marshal.FreeHGlobal( NativeArray ); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/Ugc.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | 3 | #pragma warning disable 649 4 | 5 | namespace Steamworks.Data 6 | { 7 | public struct Ugc 8 | { 9 | internal UGCHandle_t Handle; 10 | } 11 | } 12 | 13 | #pragma warning restore 649 14 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/UgcAdditionalPreview.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Steamworks.Data 8 | { 9 | public struct UgcAdditionalPreview 10 | { 11 | internal UgcAdditionalPreview( string urlOrVideoID, string originalFileName, ItemPreviewType itemPreviewType ) 12 | { 13 | this.UrlOrVideoID = urlOrVideoID; 14 | this.OriginalFileName = originalFileName; 15 | this.ItemPreviewType = itemPreviewType; 16 | } 17 | 18 | public string UrlOrVideoID { get; private set; } 19 | public string OriginalFileName { get; private set; } 20 | public ItemPreviewType ItemPreviewType { get; private set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Structs/UserItemVote.cs: -------------------------------------------------------------------------------- 1 | using Steamworks.Data; 2 | 3 | namespace Steamworks.Ugc 4 | { 5 | public struct UserItemVote 6 | { 7 | public bool VotedUp; 8 | public bool VotedDown; 9 | public bool VoteSkipped; 10 | 11 | internal static UserItemVote? From(GetUserItemVoteResult_t result) 12 | { 13 | return new UserItemVote 14 | { 15 | VotedUp = result.VotedUp, 16 | VotedDown = result.VotedDown, 17 | VoteSkipped = result.VoteSkipped 18 | }; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Utility/Epoch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Steamworks 4 | { 5 | static internal class Epoch 6 | { 7 | private static readonly DateTime epoch = new DateTime( 1970, 1, 1, 0, 0, 0, DateTimeKind.Utc ); 8 | 9 | /// 10 | /// Returns the current Unix Epoch 11 | /// 12 | public static int Current => (int)(DateTime.UtcNow.Subtract( epoch ).TotalSeconds); 13 | 14 | /// 15 | /// Convert an epoch to a datetime 16 | /// 17 | public static DateTime ToDateTime( decimal unixTime ) => epoch.AddSeconds( (long)unixTime ); 18 | 19 | /// 20 | /// Convert a DateTime to a unix time 21 | /// 22 | public static uint FromDateTime( DateTime dt ) => (uint)(dt.Subtract( epoch ).TotalSeconds); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Utility/Platform.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Net; 6 | using System.Runtime.InteropServices; 7 | using System.Text; 8 | 9 | namespace Steamworks 10 | { 11 | internal static class Platform 12 | { 13 | #if PLATFORM_WIN64 14 | public const int StructPlatformPackSize = 8; 15 | public const string LibraryName = "steam_api64"; 16 | #elif PLATFORM_WIN32 17 | public const int StructPlatformPackSize = 8; 18 | public const string LibraryName = "steam_api"; 19 | #elif PLATFORM_POSIX 20 | public const int StructPlatformPackSize = 4; 21 | public const string LibraryName = "libsteam_api"; 22 | #endif 23 | 24 | public const CallingConvention CC = CallingConvention.Cdecl; 25 | public const int StructPackSize = 4; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/Utility/Utf8String.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Net; 6 | using System.Runtime.InteropServices; 7 | using System.Text; 8 | 9 | namespace Steamworks 10 | { 11 | internal unsafe class Utf8StringToNative : ICustomMarshaler 12 | { 13 | public IntPtr MarshalManagedToNative(object managedObj) 14 | { 15 | if ( managedObj == null ) 16 | return IntPtr.Zero; 17 | 18 | if ( managedObj is string str ) 19 | { 20 | fixed ( char* strPtr = str ) 21 | { 22 | int len = Encoding.UTF8.GetByteCount( str ); 23 | var mem = Marshal.AllocHGlobal( len + 1 ); 24 | 25 | var wlen = System.Text.Encoding.UTF8.GetBytes( strPtr, str.Length, (byte*)mem, len + 1 ); 26 | 27 | ( (byte*)mem )[wlen] = 0; 28 | 29 | return mem; 30 | } 31 | } 32 | 33 | return IntPtr.Zero; 34 | } 35 | 36 | public object MarshalNativeToManaged(IntPtr pNativeData) => throw new System.NotImplementedException(); 37 | public void CleanUpNativeData(IntPtr pNativeData) => Marshal.FreeHGlobal( pNativeData ); 38 | public void CleanUpManagedData(object managedObj) => throw new System.NotImplementedException(); 39 | public int GetNativeDataSize() => -1; 40 | 41 | [Preserve] 42 | public static ICustomMarshaler GetInstance(string cookie) => new Utf8StringToNative(); 43 | } 44 | 45 | internal struct Utf8StringPointer 46 | { 47 | #pragma warning disable 649 48 | internal IntPtr ptr; 49 | #pragma warning restore 649 50 | 51 | public unsafe static implicit operator string( Utf8StringPointer p ) 52 | { 53 | if ( p.ptr == IntPtr.Zero ) 54 | return null; 55 | 56 | var bytes = (byte*)p.ptr; 57 | 58 | var dataLen = 0; 59 | while ( dataLen < 1024 * 1024 * 64 ) 60 | { 61 | if ( bytes[dataLen] == 0 ) 62 | break; 63 | 64 | dataLen++; 65 | } 66 | 67 | return Encoding.UTF8.GetString( bytes, dataLen ); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Facepunch.Steamworks/steam_api.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/Facepunch.Steamworks/steam_api.dll -------------------------------------------------------------------------------- /Facepunch.Steamworks/steam_api64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/Facepunch.Steamworks/steam_api64.dll -------------------------------------------------------------------------------- /HltvSharp/HltvSharp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Library 4 | netcoreapp6.0 5 | HltvSharp 6 | disable 7 | Arttu Kuikka 8 | https://github.com/ArttuKuikka/HltvSharp 9 | https://github.com/ArttuKuikka/HltvSharp 10 | An unofficial C# API for scraping data from hltv.org 11 | False 12 | logo.png 13 | 1.11 14 | False 15 | 16 | 17 | 18 | 19 | 20 | 21 | all 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | True 30 | \ 31 | 32 | 33 | -------------------------------------------------------------------------------- /HltvSharp/Models/AllSearchItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class AllSearchItem 8 | { 9 | public List Teams { get; set; } 10 | public List Players { get; set; } 11 | public List Events { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /HltvSharp/Models/Coach.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class Coach 8 | { 9 | public string Country { get; set; } 10 | public string Name { get; set; } 11 | public int id { get; set; } 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /HltvSharp/Models/Country.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class Country 8 | { 9 | public string Name { get; set; } 10 | public string Code { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /HltvSharp/Models/Demo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class Demo 8 | { 9 | public string Name { get; set; } 10 | public string Url { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /HltvSharp/Models/Enums/MapSlug.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models.Enums 6 | { 7 | public static class MapSlug 8 | { 9 | public static readonly Dictionary MapSlugs = new Dictionary() 10 | { 11 | { "tba", "TBA" }, 12 | { "trn", "Train" }, 13 | { "cbl", "Cobblestone" }, 14 | { "inf", "Inferno" }, 15 | { "cch", "Cache" }, 16 | { "mrg", "Mirage" }, 17 | { "ovp", "Overpass" }, 18 | { "d2", "Dust2" }, 19 | { "nuke", "Nuke" }, 20 | { "tcn", "Tuscan" }, 21 | { "vtg", "Vertigo" }, 22 | { "-", "Default" }, 23 | { "def", "Default" }, 24 | { "anc", "Ancient" }, 25 | }; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /HltvSharp/Models/Event.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class Event 8 | { 9 | public int? Id { get; set; } 10 | public string Name { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /HltvSharp/Models/EventSearchItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class EventsSearchItem 8 | { 9 | public int id { get; set; } 10 | public string name { get; set; } 11 | public string flagUrl { get; set; } 12 | public string eventLogoUrl { get; set; } 13 | public string webLocation { get; set; } 14 | public string physicalLocation { get; set; } 15 | public string prizePool { get; set; } 16 | public string eventType { get; set; } 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /HltvSharp/Models/FullEvent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class FullEvent 8 | { 9 | public int Id { get; set; } 10 | public string Name { get; set; } 11 | public DateTime DateStart { get; set; } 12 | public DateTime DateEnd { get; set; } 13 | public string PrizePool { get; set; } 14 | public Team[] Teams { get; set; } 15 | public Country Location { get; set; } 16 | public Event[] RelatedEvents { get; set; } 17 | public bool IsOnline { get; set; } 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /HltvSharp/Models/FullMatch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class FullMatch 8 | { 9 | public int Id { get; set; } 10 | public Team Team1 { get; set; } 11 | public Team Team2 { get; set; } 12 | public Team WinningTeam { get; set; } 13 | public DateTime Date { get; set; } 14 | public string Format { get; set; } 15 | public string AdditionalInfo { get; set; } 16 | public Veto[] Vetos { get; set; } 17 | public Event Event { get; set; } 18 | public MapResult[] Maps { get; set; } 19 | public Demo[] Demos { get; set; } 20 | public Player[] Team1Players { get; set; } 21 | public Player[] Team2Players { get; set; } 22 | public List Team1PlayerStats { get; set; } 23 | public List Team2PlayerStats { get; set; } 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /HltvSharp/Models/MapResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class MapResult 8 | { 9 | public string Name { get; set; } 10 | public int Team1Score { get; set; } 11 | public int Team2Score { get; set; } 12 | public int StatsId { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /HltvSharp/Models/Match.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class Match 8 | { 9 | 10 | public DateTime date { get; set; } 11 | public int id { get; set; } 12 | public string team1name { get; set; } 13 | public string team2name { get; set; } 14 | 15 | public int team1id { get; set; } 16 | public int team2id { get; set; } 17 | public string team1iconurl { get; set; } 18 | public string team2iconurl { get; set; } 19 | 20 | public int team1Score { get; set; } 21 | public int team2Score { get; set; } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /HltvSharp/Models/MatchResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class MatchResult 8 | { 9 | public int Id { get; set; } 10 | public DateTime Date { get; set; } 11 | public Event Event { get; set; } 12 | public Team Team1 { get; set; } 13 | public Team Team2 { get; set; } 14 | public Team WinningTeam { get; set; } 15 | public int Stars { get; set; } 16 | public string Format { get; set; } 17 | public string Map { get; set; } = null; 18 | public int Team1Score { get; set; } 19 | public int Team2Score { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /HltvSharp/Models/MatchStat.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class MatchStat 8 | { 9 | public string PlayerName { get; set; } 10 | public int PlayerID { get; set; } 11 | public string KD { get; set; } 12 | public decimal ADR { get; set; } 13 | public int plusminus { get; set; } 14 | public decimal KastProcentage { get; set; } 15 | public decimal Rating { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /HltvSharp/Models/Player.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class Player 8 | { 9 | public int Id { get; set; } 10 | public string Name { get; set; } 11 | public string playerImgUrl { get; set; } 12 | public string Country { get; set; } 13 | public string status { get; set; } 14 | public string timeOnTeam { get; set; } 15 | public int mapsPlayed { get; set; } 16 | public double rating { get; set; } 17 | public int age { get; set; } 18 | public string currentTeam { get; set; } 19 | public List teams { get; set; } 20 | public List recentMatches { get; set; } 21 | public List upcomingMatches { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /HltvSharp/Models/PlayerSearchItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class PlayerSearchItem 8 | { 9 | public string firstName { get; set; } 10 | public string lastName { get; set; } 11 | public string nickName { get; set; } 12 | public string flagUrl { get; set; } 13 | public string webLocation { get; set; } 14 | public int id { get; set; } 15 | public string pictureUrl { get; set; } 16 | public PlayerTeamItem team { get; set; } 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /HltvSharp/Models/PlayerTeamInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class PlayerTeamItem 8 | { 9 | public string name { get; set; } 10 | public string teamLogoDarkUrl { get; set; } 11 | public string teamLogoLightUrl { get; set; } 12 | public string webLocation { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /HltvSharp/Models/RankedTeam.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class RankedTeam 8 | { 9 | public int Id { get; set; } 10 | public int Rank { get; set; } 11 | public string Name { get; set; } 12 | public int Points { get; set; } 13 | public int? change { get; set; } 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /HltvSharp/Models/Team.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class Team 8 | { 9 | public string Name { get; set; } 10 | public string Country { get; set; } 11 | public int Id { get; set; } 12 | public int WorldRank { get; set; } 13 | public double AveragePlayerAge { get; set; } 14 | public double winRateProcentage { get; set; } 15 | public TimePeriod timePeriod { get; set; } 16 | public Coach Coach { get; set; } 17 | public List Players { get; set; } 18 | public List RecentMatches { get; set; } 19 | public List UpcomingMatches { get; set; } 20 | } 21 | } -------------------------------------------------------------------------------- /HltvSharp/Models/TeamSearchItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class TeamSearchItem 8 | { 9 | public int Id { get; set; } 10 | public string Name { get; set; } 11 | public string flagUrl { get; set; } 12 | public string teamLogoDarkUrl { get; set; } 13 | public string teamLogoLightUrl { get; set; } 14 | public string webLocation { get; set; } 15 | 16 | public List PlayerList { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /HltvSharp/Models/TeamSearchPlayerItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class TeamSearchPlayerItem 8 | { 9 | public string firstName { get; set; } 10 | public string lastName { get; set; } 11 | public string nickName { get; set; } 12 | public string flagUrl { get; set; } 13 | public string webLocation { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /HltvSharp/Models/TimePeriod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class TimePeriod 8 | { 9 | public DateTime from { get; set; } 10 | public DateTime to { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /HltvSharp/Models/UpcomingMatch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class UpcomingMatch 8 | { 9 | public int Id { get; set; } 10 | public Team Team1 { get; set; } 11 | public Team Team2 { get; set; } 12 | public DateTime Date { get; set; } 13 | public string Format { get; set; } 14 | public Event Event { get; set; } 15 | public string Map { get; set; } = null; 16 | public string Title { get; set; } 17 | public int Stars { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /HltvSharp/Models/Veto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace HltvSharp.Models 6 | { 7 | public class Veto 8 | { 9 | public Team Team { get; set; } 10 | public string Map { get; set; } 11 | public string Action { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /HltvSharp/Parsing/.getmatch.cs.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/HltvSharp/Parsing/.getmatch.cs.swp -------------------------------------------------------------------------------- /HltvSharp/Parsing/GetRanking.cs: -------------------------------------------------------------------------------- 1 | using Fizzler.Systems.HtmlAgilityPack; 2 | using HltvSharp.Models; 3 | using HltvSharp.Models.Enums; 4 | using HtmlAgilityPack; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Net; 9 | using System.Net.Http; 10 | using System.Text; 11 | using System.Text.RegularExpressions; 12 | using System.Threading.Tasks; 13 | 14 | namespace HltvSharp.Parsing 15 | { 16 | public static partial class HltvParser 17 | { 18 | public static Task> GetRankings(WebProxy proxy = null) 19 | { 20 | return FetchPage("ranking/teams/", GetRankingslist, proxy); 21 | } 22 | private static List GetRankingslist(Task response) 23 | { 24 | var content = response.Result.Content; 25 | string htmlContent = content.ReadAsStringAsync().Result; 26 | 27 | HtmlDocument html = new HtmlDocument(); 28 | html.LoadHtml(htmlContent); 29 | 30 | HtmlNode document = html.DocumentNode; 31 | 32 | var RankedTeamList = new List(); 33 | 34 | foreach(var team in document.QuerySelectorAll(".ranked-team")) 35 | { 36 | var rankedTeam = new RankedTeam(); 37 | 38 | //id 39 | var id = team.QuerySelector(".more").FirstChild.Attributes["href"].Value.Split('/')[2]; 40 | rankedTeam.Id = int.Parse(id); 41 | 42 | //name 43 | rankedTeam.Name = team.QuerySelector(".name").InnerText; 44 | 45 | //Rank 46 | var rank = team.QuerySelector(".position").InnerText.Replace("#", string.Empty); 47 | rankedTeam.Rank = int.Parse(rank); 48 | 49 | //points 50 | var points = team.QuerySelector(".points").InnerText; 51 | points = Regex.Replace(points, "[^0-9]", ""); 52 | rankedTeam.Points = int.Parse(points); 53 | 54 | //change 55 | var change = team.QuerySelector(".change").InnerText; 56 | if(change == "-") 57 | { 58 | rankedTeam.change = null; 59 | } 60 | else 61 | { 62 | rankedTeam.change = int.Parse(change); 63 | } 64 | 65 | 66 | RankedTeamList.Add(rankedTeam); 67 | } 68 | 69 | return RankedTeamList; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /HltvSharp/Parsing/Utility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Net; 4 | using System.Net.Http; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace HltvSharp.Parsing 9 | { 10 | public static partial class HltvParser 11 | { 12 | public static async Task FetchPage(string url, Func, T> continueWith, WebProxy proxy = null) 13 | { 14 | var httpClientHandler = new HttpClientHandler(); 15 | 16 | if (proxy != null) 17 | { 18 | httpClientHandler.UseProxy = true; 19 | httpClientHandler.Proxy = proxy; 20 | } 21 | 22 | var client = new HttpClient(httpClientHandler); 23 | var request = new HttpRequestMessage() 24 | { 25 | RequestUri = new Uri("http://www.hltv.org/" + url), 26 | Method = HttpMethod.Get, 27 | }; 28 | 29 | request.Headers.Add("Referer", "https://www.hltv.org/"); 30 | request.Headers.Add("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"); 31 | T result = await client.SendAsync(request).ContinueWith((response) => continueWith(response)); 32 | 33 | return result; 34 | } 35 | 36 | private static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); 37 | 38 | public static long GetCurrentUnixTimestampMillis() 39 | { 40 | return (long)(DateTime.UtcNow - UnixEpoch).TotalMilliseconds; 41 | } 42 | 43 | public static DateTime DateTimeFromUnixTimestampMillis(long millis) 44 | { 45 | return UnixEpoch.AddMilliseconds(millis); 46 | } 47 | 48 | public static long GetCurrentUnixTimestampSeconds() 49 | { 50 | return (long)(DateTime.UtcNow - UnixEpoch).TotalSeconds; 51 | } 52 | 53 | public static DateTime DateTimeFromUnixTimestampSeconds(long seconds) 54 | { 55 | return UnixEpoch.AddSeconds(seconds); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /HltvSharp/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZjzMisaka/CSGOTacticSimulator/25915b1cb1c178203d8a7f7ed42ca5a52671bdd8/HltvSharp/logo.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2020 ZjzMisaka 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/AdditionalPlayerInformation.cs: -------------------------------------------------------------------------------- 1 | namespace DemoInfo 2 | { 3 | public class AdditionalPlayerInformation 4 | { 5 | public int Kills { get; set; } 6 | public int Deaths { get; set; } 7 | public int Assists { get; set; } 8 | public int Score { get; set; } 9 | public int MVPs { get; set; } 10 | public int Ping { get; set; } 11 | public string Clantag { get; set; } 12 | public int TotalCashSpent { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/BitStream/IBitStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace DemoInfo 5 | { 6 | public interface IBitStream : IDisposable 7 | { 8 | void Initialize(Stream stream); 9 | 10 | uint ReadInt(int bits); 11 | int ReadSignedInt(int numBits); 12 | bool ReadBit(); 13 | byte ReadByte(); 14 | byte ReadByte(int bits); 15 | byte[] ReadBytes(int bytes); 16 | float ReadFloat(); 17 | byte[] ReadBits(int bits); 18 | int ReadProtobufVarInt(); 19 | long ReadFixedInt64(); 20 | 21 | // Chunking: You can begin chunks with a specified length. 22 | // You can then determine whether you've already read 23 | // the full chunk. You can also end the chunk and skip 24 | // ahead to where you would be had you read everything. 25 | // Chunks can be nested and it'll work just like you'd 26 | // expect (stack-like). 27 | // 28 | // tl;dr bitstream chunks are basically LimitStreams 29 | 30 | /// 31 | /// Begins a chunk. 32 | /// 33 | /// The chunk's length in bits. 34 | /// 35 | /// You must not try to read beyond the end of a chunk. Doing 36 | /// so may corrupt the bitstream's state, leading to 37 | /// implementation-defined behavior of all methods except 38 | /// Dispose. 39 | /// 40 | void BeginChunk(int bits); 41 | 42 | /// 43 | /// Ends a chunk. 44 | /// 45 | /// 46 | /// If there's no current chunk, this method may throw 47 | /// and leave the bitstream in an undefined state that can 48 | /// be cleaned up safely by disposing it. 49 | /// Alternatively, it may also return normally if it didn't 50 | /// corrupt or otherwise modify the bitstream's state. 51 | /// 52 | void EndChunk(); 53 | 54 | /// 55 | /// Gets a value indicating whether the current chunk was fully read. 56 | /// 57 | /// true if chunk is finished; otherwise, false. 58 | /// 59 | /// The return value is undefined if there's no current chunk. 60 | /// 61 | bool ChunkFinished { get; } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/DP/FastNetmessages/CVar.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace DemoInfo.DP.FastNetmessages 4 | { 5 | /// 6 | /// FastNetMessage adaptation of CMsg_CVars.CVar protobuf message 7 | /// https://github.com/SteamRE/SteamKit/blob/master/Resources/Protobufs/csgo/netmessages.proto#L128 8 | /// 9 | public struct CVar 10 | { 11 | public string Name; 12 | public string Value; 13 | public uint DictionaryName; 14 | 15 | public void Parse(IBitStream bitstream, DemoParser parser) 16 | { 17 | while (!bitstream.ChunkFinished) 18 | { 19 | var desc = bitstream.ReadProtobufVarInt(); 20 | var wireType = desc & 7; 21 | var fieldnum = desc >> 3; 22 | 23 | if (wireType == 2 && fieldnum == 1) 24 | { 25 | Name = bitstream.ReadProtobufString(); 26 | } 27 | else if (wireType == 2 && fieldnum == 2) 28 | { 29 | Value = bitstream.ReadProtobufString(); 30 | } 31 | else if (wireType == 0 && fieldnum == 3) 32 | { 33 | DictionaryName = (uint)bitstream.ReadProtobufVarInt(); 34 | } 35 | else 36 | { 37 | throw new InvalidDataException(); 38 | } 39 | } 40 | 41 | Raise(parser); 42 | } 43 | 44 | private void Raise(DemoParser parser) 45 | { 46 | ConVarChangeEventArgs e = new ConVarChangeEventArgs 47 | { 48 | Name = Name, 49 | Value = Value, 50 | DictionaryValue = DictionaryName, 51 | }; 52 | 53 | parser.RaiseConVarChange(e); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/DP/FastNetmessages/CVars.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace DemoInfo.DP.FastNetmessages 4 | { 5 | /// 6 | /// FastNetMessage adaptation of CMsg_CVars protobuf message 7 | /// https://github.com/SteamRE/SteamKit/blob/master/Resources/Protobufs/csgo/netmessages.proto#L127 8 | /// 9 | public struct CVars 10 | { 11 | public void Parse(IBitStream bitstream, DemoParser parser) 12 | { 13 | while (!bitstream.ChunkFinished) 14 | { 15 | var desc = bitstream.ReadProtobufVarInt(); 16 | var wireType = desc & 7; 17 | var fieldnum = desc >> 3; 18 | 19 | if (wireType == 2 && fieldnum == 1) 20 | { 21 | bitstream.BeginChunk(bitstream.ReadProtobufVarInt() * 8); 22 | new CVar().Parse(bitstream, parser); 23 | bitstream.EndChunk(); 24 | } 25 | else 26 | { 27 | throw new InvalidDataException(); 28 | } 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/DP/FastNetmessages/EncryptedMessage.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using DemoInfo.DP.Handler; 3 | 4 | namespace DemoInfo.DP.FastNetmessages 5 | { 6 | public struct EncryptedMessage 7 | { 8 | public int KeyType; 9 | public byte[] Encrypted; 10 | 11 | public void Parse(IBitStream bitstream, DemoParser parser) 12 | { 13 | while (!bitstream.ChunkFinished) 14 | { 15 | var desc = bitstream.ReadProtobufVarInt(); 16 | var wireType = desc & 7; 17 | var fieldnum = desc >> 3; 18 | 19 | if (wireType == 0 && fieldnum == 2) 20 | { 21 | KeyType = bitstream.ReadProtobufVarInt(); 22 | } 23 | else if (wireType == 2 && fieldnum == 1) 24 | { 25 | Encrypted = bitstream.ReadBytes(bitstream.ReadProtobufVarInt()); 26 | } 27 | else 28 | { 29 | throw new InvalidDataException(); 30 | } 31 | } 32 | 33 | EncryptedDataHandler.Apply(this, parser); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/DP/FastNetmessages/NETTick.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace DemoInfo 4 | { 5 | public struct NETTick 6 | { 7 | public uint Tick; 8 | public uint HostComputationTime; 9 | public uint HostComputationTimeStdDeviation; 10 | public uint HostFramestartTimeStdDeviation; 11 | 12 | public void Parse(IBitStream bitstream, DemoParser parser) 13 | { 14 | while (!bitstream.ChunkFinished) 15 | { 16 | var desc = bitstream.ReadProtobufVarInt(); 17 | var wireType = desc & 7; 18 | var fieldnum = desc >> 3; 19 | if (wireType != 0) 20 | { 21 | throw new InvalidDataException(); 22 | } 23 | 24 | var val = (uint)bitstream.ReadProtobufVarInt(); 25 | 26 | switch (fieldnum) 27 | { 28 | case 1: 29 | Tick = val; 30 | break; 31 | case 4: 32 | HostComputationTime = val; 33 | break; 34 | case 5: 35 | HostComputationTimeStdDeviation = val; 36 | break; 37 | case 6: 38 | HostFramestartTimeStdDeviation = val; 39 | break; 40 | default: 41 | // silently drop 42 | break; 43 | } 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/DP/FastNetmessages/RankUpdate.cs: -------------------------------------------------------------------------------- 1 | namespace DemoInfo.DP.FastNetmessages 2 | { 3 | /// 4 | /// FastNetMessage adaptation of CCSUsrMsg_ServerRankUpdate.RankUpdate protobuf message 5 | /// 6 | public class RankUpdate 7 | { 8 | private const long VALVE_MAGIC_NUMBER = 76561197960265728; 9 | 10 | public int AccountId; 11 | public int RankOld; 12 | public int RankNew; 13 | public int NumWins; 14 | public float RankChange; 15 | 16 | public void Parse(IBitStream bitstream, DemoParser parser) 17 | { 18 | while (!bitstream.ChunkFinished) 19 | { 20 | var desc = bitstream.ReadProtobufVarInt(); 21 | var wireType = desc & 7; 22 | var fieldnum = desc >> 3; 23 | 24 | if (wireType == 0 && fieldnum == 1) 25 | { 26 | AccountId = bitstream.ReadProtobufVarInt(); 27 | } 28 | else if (wireType == 0 && fieldnum == 2) 29 | { 30 | RankOld = bitstream.ReadProtobufVarInt(); 31 | } 32 | else if (wireType == 0 && fieldnum == 3) 33 | { 34 | RankNew = bitstream.ReadProtobufVarInt(); 35 | } 36 | else if (wireType == 0 && fieldnum == 4) 37 | { 38 | NumWins = bitstream.ReadProtobufVarInt(); 39 | } 40 | else if (wireType == 5 && fieldnum == 5) 41 | { 42 | RankChange = bitstream.ReadFloat(); 43 | } 44 | } 45 | 46 | Raise(parser); 47 | } 48 | 49 | private void Raise(DemoParser parser) 50 | { 51 | RankUpdateEventArgs e = new RankUpdateEventArgs 52 | { 53 | SteamId = AccountId + VALVE_MAGIC_NUMBER, 54 | RankOld = RankOld, 55 | RankNew = RankNew, 56 | WinCount = NumWins, 57 | RankChange = RankChange, 58 | }; 59 | 60 | parser.RaiseRankUpdate(e); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/DP/FastNetmessages/SayText.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace DemoInfo.DP.FastNetmessages 4 | { 5 | /// 6 | /// FastNetMessage adaptation of CCSUsrMsg_SayText protobuf message 7 | /// 8 | public struct SayText 9 | { 10 | public int EntityIndex; 11 | public string Text; 12 | private int _chat; 13 | public bool Chat => _chat != 0; 14 | private int _textAllChat; 15 | public bool TextAllChat => _textAllChat != 0; 16 | 17 | public void Parse(IBitStream bitstream, DemoParser parser) 18 | { 19 | while (!bitstream.ChunkFinished) 20 | { 21 | var desc = bitstream.ReadProtobufVarInt(); 22 | var wireType = desc & 7; 23 | var fieldnum = desc >> 3; 24 | 25 | if (wireType == 0 && fieldnum == 1) 26 | { 27 | EntityIndex = bitstream.ReadProtobufVarInt(); 28 | } 29 | else if (wireType == 2 && fieldnum == 2) 30 | { 31 | Text = bitstream.ReadProtobufString(); 32 | } 33 | else if (wireType == 0 && fieldnum == 3) 34 | { 35 | _chat = bitstream.ReadProtobufVarInt(); 36 | } 37 | else if (wireType == 0 && fieldnum == 4) 38 | { 39 | _textAllChat = bitstream.ReadProtobufVarInt(); 40 | } 41 | else 42 | { 43 | throw new InvalidDataException(); 44 | } 45 | } 46 | 47 | Raise(parser); 48 | } 49 | 50 | private void Raise(DemoParser parser) 51 | { 52 | SayTextEventArgs e = new SayTextEventArgs 53 | { 54 | EntityIndex = EntityIndex, 55 | Text = Text, 56 | IsChat = Chat, 57 | IsChatAll = TextAllChat, 58 | }; 59 | 60 | parser.RaiseSayText(e); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/DP/FastNetmessages/ServerRankUpdate.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace DemoInfo.DP.FastNetmessages 4 | { 5 | /// 6 | /// FastNetMessage adaptation of CCSUsrMsg_ServerRankUpdate protobuf message 7 | /// We don't raise this event but instead each RankUpdate events that it contains 8 | /// 9 | public struct ServerRankUpdate 10 | { 11 | public void Parse(IBitStream bitstream, DemoParser parser) 12 | { 13 | while (!bitstream.ChunkFinished) 14 | { 15 | var desc = bitstream.ReadProtobufVarInt(); 16 | var wireType = desc & 7; 17 | var fieldnum = desc >> 3; 18 | 19 | if (wireType == 2 && fieldnum == 1) 20 | { 21 | bitstream.BeginChunk(bitstream.ReadProtobufVarInt() * 8); 22 | new RankUpdate().Parse(bitstream, parser); 23 | bitstream.EndChunk(); 24 | } 25 | else 26 | { 27 | throw new InvalidDataException(); 28 | } 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/DP/FastNetmessages/SetConVar.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace DemoInfo.DP.FastNetmessages 4 | { 5 | /// 6 | /// FastNetMessage adaptation of CNETMsg_SetConVar protobuf message 7 | /// https://github.com/SteamRE/SteamKit/blob/master/Resources/Protobufs/csgo/netmessages.proto#L137 8 | /// 9 | public struct SetConVar 10 | { 11 | public void Parse(IBitStream bitstream, DemoParser parser) 12 | { 13 | while (!bitstream.ChunkFinished) 14 | { 15 | var desc = bitstream.ReadProtobufVarInt(); 16 | var wireType = desc & 7; 17 | var fieldnum = desc >> 3; 18 | 19 | if (wireType == 2 && fieldnum == 1) 20 | { 21 | bitstream.BeginChunk(bitstream.ReadProtobufVarInt() * 8); 22 | new CVars().Parse(bitstream, parser); 23 | bitstream.EndChunk(); 24 | } 25 | else 26 | { 27 | throw new InvalidDataException(); 28 | } 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/DP/FastNetmessages/UpdateStringTable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | namespace DemoInfo 5 | { 6 | public struct UpdateStringTable 7 | { 8 | public int TableId; 9 | public int NumChangedEntries; 10 | 11 | public void Parse(IBitStream bitstream, DemoParser parser) 12 | { 13 | while (!bitstream.ChunkFinished) 14 | { 15 | var desc = bitstream.ReadProtobufVarInt(); 16 | var wireType = desc & 7; 17 | var fieldnum = desc >> 3; 18 | 19 | if (wireType == 2 && fieldnum == 3) 20 | { 21 | // String data is special. 22 | // We'll simply hope that gaben is nice and sends 23 | // string_data last, just like he should. 24 | var len = bitstream.ReadProtobufVarInt(); 25 | bitstream.BeginChunk(len * 8); 26 | DP.Handler.UpdateStringTableUserInfoHandler.Apply(this, bitstream, parser); 27 | bitstream.EndChunk(); 28 | if (!bitstream.ChunkFinished) 29 | { 30 | throw new NotImplementedException("Lord Gaben wasn't nice to us :/"); 31 | } 32 | 33 | break; 34 | } 35 | 36 | if (wireType != 0) 37 | { 38 | throw new InvalidDataException(); 39 | } 40 | 41 | var val = bitstream.ReadProtobufVarInt(); 42 | 43 | switch (fieldnum) 44 | { 45 | case 1: 46 | TableId = val; 47 | break; 48 | case 2: 49 | NumChangedEntries = val; 50 | break; 51 | default: 52 | // silently drop 53 | break; 54 | } 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/DP/FastNetmessages/UserMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DemoInfo.Messages; 3 | 4 | namespace DemoInfo.DP.FastNetmessages 5 | { 6 | /// 7 | /// FastNetMessage adaptation of CSVCMsg_UserMessage protobuf message 8 | /// 9 | public struct UserMessage 10 | { 11 | /// 12 | /// Correspond to User_Messages enum values 13 | /// 14 | public int MsgType; 15 | 16 | /// 17 | /// Don't what is it? 18 | /// 19 | public int PassThrough; 20 | 21 | public void Parse(IBitStream bitstream, DemoParser parser) 22 | { 23 | while (!bitstream.ChunkFinished) 24 | { 25 | var desc = bitstream.ReadProtobufVarInt(); 26 | var wireType = desc & 7; 27 | var fieldnum = desc >> 3; 28 | 29 | if (wireType == 0 && fieldnum == 1) 30 | { 31 | MsgType = bitstream.ReadProtobufVarInt(); 32 | } 33 | else if (wireType == 0 && fieldnum == 3) 34 | { 35 | PassThrough = bitstream.ReadProtobufVarInt(); 36 | } 37 | else if (fieldnum == 2) 38 | { 39 | // msg data 40 | if (wireType == 2) 41 | { 42 | bitstream.BeginChunk(bitstream.ReadProtobufVarInt() * 8); 43 | switch (MsgType) 44 | { 45 | // This is where you can add others UserMessage parsing logic 46 | case (int)User_Messages.um_SayText: 47 | new SayText().Parse(bitstream, parser); 48 | break; 49 | case (int)User_Messages.um_SayText2: 50 | new SayText2().Parse(bitstream, parser); 51 | break; 52 | case (int)User_Messages.um_ServerRankUpdate: 53 | new ServerRankUpdate().Parse(bitstream, parser); 54 | break; 55 | } 56 | 57 | bitstream.EndChunk(); 58 | if (!bitstream.ChunkFinished) 59 | { 60 | throw new NotImplementedException("Lord Gaben wasn't nice to us :/"); 61 | } 62 | } 63 | } 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/DP/FastNetmessages/VoiceInit.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace DemoInfo.DP.FastNetmessages 4 | { 5 | public struct VoiceInit 6 | { 7 | public int Quality; 8 | public string Codec; 9 | public int Version; 10 | 11 | public void Parse(IBitStream bitstream, DemoParser parser) 12 | { 13 | while (!bitstream.ChunkFinished) 14 | { 15 | var desc = bitstream.ReadProtobufVarInt(); 16 | var wireType = desc & 7; 17 | var fieldnum = desc >> 3; 18 | 19 | if (wireType == 0 && fieldnum == 1) 20 | { 21 | Quality = bitstream.ReadProtobufVarInt(); 22 | } 23 | else if (wireType == 2 && fieldnum == 2) 24 | { 25 | Codec = bitstream.ReadProtobufString(); 26 | } 27 | else if (wireType == 0 && fieldnum == 3) 28 | { 29 | Version = bitstream.ReadProtobufVarInt(); 30 | } 31 | else 32 | { 33 | throw new InvalidDataException(); 34 | } 35 | } 36 | 37 | Raise(parser); 38 | } 39 | 40 | private void Raise(DemoParser parser) 41 | { 42 | var e = new VoiceInitEventArgs 43 | { 44 | Quality = Quality, 45 | Codec = Codec, 46 | Version = Version, 47 | }; 48 | 49 | parser.RaiseVoiceInit(e); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/DP/Handler/EncryptedDataHandler.cs: -------------------------------------------------------------------------------- 1 | using DemoInfo.DP.FastNetmessages; 2 | using DemoInfo.Messages; 3 | 4 | namespace DemoInfo.DP.Handler 5 | { 6 | public static class EncryptedDataHandler 7 | { 8 | public static void Apply(EncryptedMessage msg, DemoParser parser) 9 | { 10 | bool isPublicKey = msg.KeyType == 2; 11 | if (!isPublicKey) 12 | { 13 | return; 14 | } 15 | 16 | byte[] decrypted = parser.NetMessageDecryptionKey.DecryptFull(msg.Encrypted); 17 | int messageSize = decrypted.Length; 18 | var br = BitStreamUtil.Create(decrypted); 19 | int bytesPadding = 1; 20 | int bytesWrittenPadding = 4; 21 | 22 | byte paddingBytes = br.ReadByte(); 23 | if (paddingBytes >= messageSize - bytesPadding - bytesWrittenPadding) 24 | { 25 | return; 26 | } 27 | 28 | br.ReadBits(paddingBytes << 3); 29 | 30 | byte[] bytesWritten = br.ReadBytes(4); 31 | int bytesWrittenCount = bytesWritten[3] | bytesWritten[2] << 8 | bytesWritten[1] << 16 | bytesWritten[0] << 24; 32 | 33 | if (bytesPadding + bytesWrittenPadding + paddingBytes + bytesWrittenCount != messageSize) 34 | { 35 | return; 36 | } 37 | 38 | int cmd = br.ReadProtobufVarInt(); 39 | int size = br.ReadProtobufVarInt(); 40 | 41 | switch (cmd) 42 | { 43 | case (int)SVC_Messages.svc_UserMessage: 44 | byte[] data = br.ReadBytes(size); 45 | var bitstream = BitStreamUtil.Create(data); 46 | bitstream.BeginChunk(size * 8); 47 | new UserMessage().Parse(bitstream, parser); 48 | bitstream.EndChunk(); 49 | break; 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/DP/Handler/SoundHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DemoInfo 4 | { 5 | public class SoundHandler 6 | { 7 | public SoundHandler() 8 | { 9 | } 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/DP/Handler/UpdateStringTableUserInfoHandler.cs: -------------------------------------------------------------------------------- 1 | namespace DemoInfo.DP.Handler 2 | { 3 | public static class UpdateStringTableUserInfoHandler 4 | { 5 | public static void Apply(UpdateStringTable update, IBitStream reader, DemoParser parser) 6 | { 7 | CreateStringTable create = parser.stringTables[update.TableId]; 8 | if (create.Name == "userinfo" || create.Name == "modelprecache" || create.Name == "instancebaseline") 9 | { 10 | /* 11 | * Ignore updates for everything except the 3 used tables. 12 | * Create a fake CreateStringTable message and parse it. 13 | */ 14 | create.NumEntries = update.NumChangedEntries; 15 | CreateStringTableUserInfoHandler.Apply(create, reader, parser); 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/DT/SendTable.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace DemoInfo.DT 4 | { 5 | internal class SendTable 6 | { 7 | private List properties = new List(); 8 | 9 | public List Properties 10 | { 11 | get { return properties; } 12 | } 13 | 14 | public string Name { get; set; } 15 | public bool IsEnd { get; set; } 16 | 17 | public SendTable(IBitStream bitstream) 18 | { 19 | DemoInfo.SendTable dataTable = new DemoInfo.SendTable(); 20 | 21 | foreach (var prop in dataTable.Parse(bitstream)) 22 | { 23 | SendTableProperty property = new SendTableProperty() 24 | { 25 | DataTableName = prop.DtName, 26 | HighValue = prop.HighValue, 27 | LowValue = prop.LowValue, 28 | Name = prop.VarName, 29 | NumberOfBits = prop.NumBits, 30 | NumberOfElements = prop.NumElements, 31 | Priority = prop.Priority, 32 | RawFlags = prop.Flags, 33 | RawType = prop.Type, 34 | }; 35 | 36 | properties.Add(property); 37 | } 38 | 39 | Name = dataTable.NetTableName; 40 | IsEnd = dataTable.IsEnd; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/DemoInfo.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netcoreapp6.0 4 | Library 5 | false 6 | false 7 | 8 | 9 | true 10 | 11 | 12 | TRACE;YOLO 13 | true 14 | bin\Release\DemoInfo.xml 15 | 16 | 17 | true 18 | false 19 | DEBUG;TRACE;BITSTREAMDEBUG 20 | true 21 | 22 | 23 | true 24 | false 25 | TRACE;YOLO;DEBUG 26 | true 27 | 28 | 29 | true 30 | true 31 | TRACE;SAVE_PROP_VALUES 32 | true 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | all 43 | 44 | 45 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/Helper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Text; 5 | using DemoInfo.DT; 6 | using DemoInfo.DP; 7 | 8 | namespace DemoInfo 9 | { 10 | internal static class Helper 11 | { 12 | public static string ReadCString(this BinaryReader reader, int length) 13 | { 14 | return ReadCString(reader, length, Encoding.UTF8); 15 | } 16 | 17 | public static int ReadInt32SwapEndian(this BinaryReader reader) 18 | { 19 | return BitConverter.ToInt32(reader.ReadBytes(4).Reverse().ToArray(), 0); 20 | } 21 | 22 | public static long ReadInt64SwapEndian(this BinaryReader reader) 23 | { 24 | return BitConverter.ToInt64(reader.ReadBytes(8).Reverse().ToArray(), 0); 25 | } 26 | 27 | public static string ReadCString(this BinaryReader reader, int length, Encoding encoding) 28 | { 29 | return encoding.GetString(reader.ReadBytes(length)).Split(new char[] { '\0' }, 2)[0]; 30 | } 31 | 32 | public static bool HasFlagFast(this SendPropertyFlags flags, SendPropertyFlags check) 33 | { 34 | return (flags & check) == check; 35 | } 36 | 37 | public static RecordedPropertyUpdate Record(this PropertyUpdateEventArgs args) 38 | { 39 | return new RecordedPropertyUpdate(args.Property.Index, args.Value); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /demoinfo/DemoInfo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DemoInfo")] 9 | [assembly: AssemblyDescription("This is a C#-Library that makes reading CS:GO-Demos and analyzing them easier.")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("EHVAG")] 12 | [assembly: AssemblyProduct("DemoInfo")] 13 | [assembly: AssemblyCopyright("")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("adb0b537-c842-4082-9588-e5d3c762f541")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /demoinfo/License.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /test/自动寻路.txt: -------------------------------------------------------------------------------- 1 | 设置总体速度比率为 0.21 2 | set entirety speed 0.21 3 | 4 | 阵营为t 5 | set camp t 6 | 7 | 创建t角色 8 | create character t 852.15,816.72 9 | 10 | 自动寻路去B2楼 11 | action character 0 layer 0\ 12 | auto move 235.63,175.39 layer 0 noisily 13 | 自动寻路返回 14 | action character 0 from 235.63,175.39 layer 0\ 15 | auto move 852.15,816.72 layer 0 noisily 16 | 自动寻路去电话亭后 17 | action character 0 from 852.15,816.72 layer 0\ 18 | auto move 448.42,833.25 layer 0 noisily 19 | 自动寻路返回 20 | action character 0 from 448.42,833.25 layer 0\ 21 | auto move 852.15,816.72 layer 0 noisily 22 | --------------------------------------------------------------------------------