Skip to content

Commit be101d5

Browse files
Added rescueZoneStats + Added trigger location information for bombsites + rescue zones + Minor other changes
1 parent d790518 commit be101d5

File tree

8 files changed

+94
-14
lines changed

8 files changed

+94
-14
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<Company>Source Engine Discord</Company>
1616
<Copyright>© 2014 EHVAG, 2020 Source Engine Discord and contributors</Copyright>
1717
<Product>SourceEngine.Demo</Product>
18-
<Version>2.1.1</Version>
18+
<Version>2.2.0</Version>
1919
</PropertyGroup>
2020

2121
<PropertyGroup Label="Package Metadata">

src/SourceEngine.Demo.Parser/DP/Handler/GameEventHandler.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,9 +574,11 @@ public static void Apply(GameEvent rawEvent, DemoParser parser, bool parseChicke
574574

575575
//currently assumes only one rescue zone,
576576
//might be able to use "site" in 'eventDescriptor' or 'rawEvent' to determine which rescue zone was used ?
577-
rescued.RescueZone = (int)data["site"];
577+
int rescueZone = (int)data["site"];
578+
parser.rescueZoneIndex = rescueZone;
579+
rescued.RescueZone = rescueZone;
578580

579-
int hostage = (int)data["hostage"];
581+
int hostage = (int)data["hostage"];
580582

581583
//works out which hostage was rescued
582584
if (hostage == parser.hostageAIndex)
@@ -594,13 +596,13 @@ public static void Apply(GameEvent rawEvent, DemoParser parser, bool parseChicke
594596
if (parser.hostageAIndex == -1)
595597
{
596598
rescued.Hostage = 'A';
597-
parser.hostageAIndex = hostage;
599+
parser.hostageAIndex = hostage;
598600
rescued.HostageIndex = parser.hostageAIndex;
599601
}
600602
else if (parser.hostageBIndex == -1)
601603
{
602604
rescued.Hostage = 'B';
603-
parser.hostageBIndex = hostage;
605+
parser.hostageBIndex = hostage;
604606
rescued.HostageIndex = parser.hostageBIndex;
605607
}
606608
else

src/SourceEngine.Demo.Parser/DemoParser.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ public IEnumerable<Player> PlayingParticipants {
386386
/// </summary>
387387
public int hostageAIndex { get; internal set; } = -1;
388388
public int hostageBIndex { get; internal set; } = -1;
389+
public int rescueZoneIndex { get; internal set; } = -1;
389390

390391
/// <summary>
391392
/// The ID of the CT-Team
@@ -1196,7 +1197,7 @@ void HandleWeapon (object sender, EntityCreatedEventArgs e)
11961197
}
11971198
}
11981199

1199-
internal List<BoundingBoxInformation> triggers = new List<BoundingBoxInformation>();
1200+
public List<BoundingBoxInformation> triggers = new List<BoundingBoxInformation>();
12001201
public void HandleBombSites()
12011202
{
12021203
SendTableParser.FindByName("CCSPlayerResource").OnNewEntity += (s1, newResource) => {

src/SourceEngine.Demo.Parser/Structs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public static PlayerInfo ParseFrom(BinaryReader reader)
286286
/// <summary>
287287
/// This contains information about Collideables (specific edicts), mostly used for bombsites.
288288
/// </summary>
289-
class BoundingBoxInformation
289+
public class BoundingBoxInformation
290290
{
291291
public int Index { get; private set; }
292292
public Vector Min { get; set; }

src/SourceEngine.Demo.Stats/DemoProcessor.cs

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@ public AllStats CreateFiles(ProcessedData processedData, bool createJsonFile = t
829829

830830
allStats.bombsiteStats = GetBombsiteStats(processedData);
831831
allStats.hostageStats = GetHostageStats(processedData);
832+
allStats.rescueZoneStats = GetRescueZoneStats();
832833

833834
string[] nadeTypes = { "Flash", "Smoke", "HE", "Incendiary", "Decoy" };
834835
var nadeGroups = GetNadeGroups(processedData, nadeTypes);
@@ -1340,6 +1341,9 @@ public List<bombsiteStats> GetBombsiteStats(ProcessedData processedData)
13401341
{
13411342
List<bombsiteStats> bombsiteStats = new List<bombsiteStats>();
13421343

1344+
var bombsiteATrigger = dp.triggers.Where(x => x.Index == dp.bombsiteAIndex).FirstOrDefault();
1345+
var bombsiteBTrigger = dp.triggers.Where(x => x.Index == dp.bombsiteBIndex).FirstOrDefault();
1346+
13431347
List<char> bombsitePlants = new List<char>(processedData.BombsitePlantValues.Select(x => x.Bombsite));
13441348
List<char> bombsiteExplosions = new List<char>(processedData.BombsiteExplodeValues.Select(x => x.Bombsite));
13451349
List<char> bombsiteDefuses = new List<char>(processedData.BombsiteDefuseValues.Select(x => x.Bombsite));
@@ -1352,8 +1356,32 @@ public List<bombsiteStats> GetBombsiteStats(ProcessedData processedData)
13521356
int explosionsB = bombsiteExplosions.Where(b => b.ToString().Equals("B")).Count();
13531357
int defusesB = bombsiteDefuses.Where(b => b.ToString().Equals("B")).Count();
13541358

1355-
bombsiteStats.Add(new bombsiteStats() { Bombsite = 'A', Plants = plantsA, Explosions = explosionsA, Defuses = defusesA });
1356-
bombsiteStats.Add(new bombsiteStats() { Bombsite = 'B', Plants = plantsB, Explosions = explosionsB, Defuses = defusesB });
1359+
bombsiteStats.Add(new bombsiteStats()
1360+
{
1361+
Bombsite = 'A',
1362+
Plants = plantsA,
1363+
Explosions = explosionsA,
1364+
Defuses = defusesA,
1365+
XPositionMin = bombsiteATrigger?.Min.X,
1366+
YPositionMin = bombsiteATrigger?.Min.Y,
1367+
ZPositionMin = bombsiteATrigger?.Min.Z,
1368+
XPositionMax = bombsiteATrigger?.Max.X,
1369+
YPositionMax = bombsiteATrigger?.Max.Y,
1370+
ZPositionMax = bombsiteATrigger?.Max.Z,
1371+
});
1372+
bombsiteStats.Add(new bombsiteStats()
1373+
{
1374+
Bombsite = 'B',
1375+
Plants = plantsB,
1376+
Explosions = explosionsB,
1377+
Defuses = defusesB,
1378+
XPositionMin = bombsiteBTrigger?.Min.X,
1379+
YPositionMin = bombsiteBTrigger?.Min.Y,
1380+
ZPositionMin = bombsiteBTrigger?.Min.Z,
1381+
XPositionMax = bombsiteBTrigger?.Max.X,
1382+
YPositionMax = bombsiteBTrigger?.Max.Y,
1383+
ZPositionMax = bombsiteBTrigger?.Max.Z,
1384+
});
13571385

13581386
return bombsiteStats;
13591387
}
@@ -1365,21 +1393,50 @@ public List<hostageStats> GetHostageStats(ProcessedData processedData)
13651393
List<char> hostagePickedUps = new List<char>(processedData.HostagePickedUpValues.Select(x => x.Hostage));
13661394
List<char> hostageRescues = new List<char>(processedData.HostageRescueValues.Select(x => x.Hostage));
13671395

1368-
var hostageIndexA = processedData.HostageRescueValues.Where(r => r.Hostage == 'A').FirstOrDefault()?.HostageIndex;
1369-
var hostageIndexB = processedData.HostageRescueValues.Where(r => r.Hostage == 'B').FirstOrDefault()?.HostageIndex;
1370-
13711396
int pickedUpsA = hostagePickedUps.Where(b => b.ToString().Equals("A")).Count();
13721397
int pickedUpsB = hostagePickedUps.Where(b => b.ToString().Equals("B")).Count();
13731398

13741399
int rescuesA = hostageRescues.Where(b => b.ToString().Equals("A")).Count();
13751400
int rescuesB = hostageRescues.Where(b => b.ToString().Equals("B")).Count();
13761401

1377-
hostageStats.Add(new hostageStats() { Hostage = 'A', HostageIndex = hostageIndexA, PickedUps = pickedUpsA, Rescues = rescuesA });
1378-
hostageStats.Add(new hostageStats() { Hostage = 'B', HostageIndex = hostageIndexB, PickedUps = pickedUpsB, Rescues = rescuesB });
1402+
hostageStats.Add(new hostageStats()
1403+
{
1404+
Hostage = 'A',
1405+
HostageIndex = dp.hostageAIndex,
1406+
PickedUps = pickedUpsA,
1407+
Rescues = rescuesA,
1408+
});
1409+
hostageStats.Add(new hostageStats()
1410+
{
1411+
Hostage = 'B',
1412+
HostageIndex = dp.hostageBIndex,
1413+
PickedUps = pickedUpsB,
1414+
Rescues = rescuesB,
1415+
});
13791416

13801417
return hostageStats;
13811418
}
13821419

1420+
public List<rescueZoneStats> GetRescueZoneStats()
1421+
{
1422+
List<rescueZoneStats> rescueZoneStats = new List<rescueZoneStats>();
1423+
1424+
var rescueZoneTrigger = dp.triggers.FirstOrDefault(); // assume only one rescue zone, (int)data["site"] in GameEventHandler.cs does not line up with newResource.Entity.ID at SendTableParser.FindByName("CBaseTrigger").OnNewEntity
1425+
1426+
rescueZoneStats.Add(new rescueZoneStats()
1427+
{
1428+
rescueZoneIndex = dp.rescueZoneIndex, // doesn't line up with the trigger Entity ID
1429+
XPositionMin = rescueZoneTrigger?.Min.X,
1430+
YPositionMin = rescueZoneTrigger?.Min.Y,
1431+
ZPositionMin = rescueZoneTrigger?.Min.Z,
1432+
XPositionMax = rescueZoneTrigger?.Max.X,
1433+
YPositionMax = rescueZoneTrigger?.Max.Y,
1434+
ZPositionMax = rescueZoneTrigger?.Max.Z,
1435+
});
1436+
1437+
return rescueZoneStats;
1438+
}
1439+
13831440
public List<IEnumerable<NadeEventArgs>> GetNadeGroups(ProcessedData processedData, string[] nadeTypes)
13841441
{
13851442
var flashes = processedData.GrenadeValues.Where(f => f.NadeType.ToString().Equals(nadeTypes[0]));

src/SourceEngine.Demo.Stats/Models/AllStats.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class AllStats
1313
public List<roundsStats> roundsStats { get; set; }
1414
public List<bombsiteStats> bombsiteStats { get; set; }
1515
public List<hostageStats> hostageStats { get; set; }
16+
public List<rescueZoneStats> rescueZoneStats { get; set; }
1617
public List<grenadesTotalStats> grenadesTotalStats { get; set; }
1718
public List<grenadesSpecificStats> grenadesSpecificStats { get; set; }
1819
public List<killsStats> killsStats { get; set; }

src/SourceEngine.Demo.Stats/Models/BombsiteStats.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ public class bombsiteStats
66
public int Plants { get; set; }
77
public int Explosions { get; set; }
88
public int Defuses { get; set; }
9+
public double? XPositionMin { get; set; }
10+
public double? YPositionMin { get; set; }
11+
public double? ZPositionMin { get; set; }
12+
public double? XPositionMax { get; set; }
13+
public double? YPositionMax { get; set; }
14+
public double? ZPositionMax { get; set; }
915

1016
public bombsiteStats() { }
1117
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace SourceEngine.Demo.Stats.Models
2+
{
3+
public class rescueZoneStats
4+
{
5+
public int? rescueZoneIndex { get; set; } // doesn't line up with the trigger Entity ID
6+
public double? XPositionMin { get; set; }
7+
public double? YPositionMin { get; set; }
8+
public double? ZPositionMin { get; set; }
9+
public double? XPositionMax { get; set; }
10+
public double? YPositionMax { get; set; }
11+
public double? ZPositionMax { get; set; }
12+
}
13+
}

0 commit comments

Comments
 (0)