Add count of bomb spots for the current map

This commit is contained in:
MathiasL 2022-05-15 02:30:53 +02:00
parent aac448d227
commit d1652aa588
3 changed files with 39 additions and 0 deletions

View file

@ -174,6 +174,10 @@
<TextBlock Text="Bomb radius:" />
<TextBlock Margin="5,0,0,0" x:Name="txtBombRadius" Text="0" Foreground="IndianRed" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Bomb spots:" />
<TextBlock Margin="5,0,0,0" x:Name="txtAmountBombTargets" Text="0" Foreground="IndianRed" />
</StackPanel>
</StackPanel>
<StackPanel Margin="0,10,0,0">
<TextBlock Text="Cursor position:" />

View file

@ -406,6 +406,8 @@ namespace Damage_Calculator
this.txtBombMaxDamage.Text = this.txtBombRadius.Text = "None";
}
this.txtAmountBombTargets.Text = map.AmountBombTargets.ToString(); // We always count these so it will just be 0 if no targets exist
// Set the map's coordinates offset from the settings file in case we have a manual offset
var mapOffsetMapping = Globals.Settings.MapCoordinateOffsets.FirstOrDefault(m => m.DDSFileName == System.IO.Path.GetFileNameWithoutExtension(map.MapImagePath));
if (mapOffsetMapping != null)
@ -440,6 +442,8 @@ namespace Damage_Calculator
// }
//
map.AmountBombTargets = 0; // Just make sure we're counting from 0
// Separate all entities, which temporarily removes curly braces from the start and/or end of entities
string[] entities = map.EntityList.Split(new string[] { "}\n{" }, StringSplitOptions.None);
for (int i = 0; i < entities.Length; i++)
@ -473,6 +477,14 @@ namespace Damage_Calculator
}
}
// Check for amount of bomb sites, if available
if (className == "func_bomb_target")
{
// Map contains at least one bomb target, meaning it's a defusal map, so count them
map.AmountBombTargets++;
}
// Check for spawns
if (className == "info_player_terrorist" || className == "info_player_counterterrorist")
{
// Entity is spawn point

View file

@ -174,18 +174,30 @@ namespace Shared.Models
/// </summary>
public MapCustomOverwriteMapping MapOverwrite { get; set; } = new();
/// <summary>
/// Gets whether or not there are any terrorist spawns that have
/// a higher priority than others.
/// </summary>
public bool HasPrioritySpawnsT
{
get
{
// If there are no spawns with higher priority,
// then all of them are marked as priority.
return this.AmountPrioritySpawnsT < this.AmountSpawnsT;
}
}
/// <summary>
/// Gets whether or not there are any counter-terrorist spawns that have
/// a higher priority than others.
/// </summary>
public bool HasPrioritySpawnsCT
{
get
{
// If there are no spawns with higher priority,
// then all of them are marked as priority.
return this.AmountPrioritySpawnsCT < this.AmountSpawnsCT;
}
}
@ -216,8 +228,19 @@ namespace Shared.Models
get => this.BspFilePath != null;
}
/// <summary>
/// Gets or sets the player spawns for this map, for both teams.
/// </summary>
public List<PlayerSpawn> SpawnPoints { get; set; } = new List<PlayerSpawn>();
/// <summary>
/// Gets or sets the navigation mesh for bots (NAV files).
/// </summary>
public NavMesh? NavMesh { get; set; }
/// <summary>
/// Gets or sets the amount of bomb target brushes (bomb sites) for this map.
/// </summary>
public int AmountBombTargets { get; set; } = 0;
}
}