Created WildSpawnTypeExtensions
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Diagnostics;
|
||||
using System.Text.Json.Serialization;
|
||||
using SPTarkov.DI.Annotations;
|
||||
using SPTarkov.Server.Core.Constants;
|
||||
using SPTarkov.Server.Core.Extensions;
|
||||
using SPTarkov.Server.Core.Generators;
|
||||
using SPTarkov.Server.Core.Helpers;
|
||||
using SPTarkov.Server.Core.Models.Common;
|
||||
@@ -136,8 +137,8 @@ public class BotController(
|
||||
foreach (var botType in botTypes)
|
||||
{
|
||||
// If bot is usec/bear, swap to different name
|
||||
var botTypeLower = _botHelper.IsBotPmc(botType)
|
||||
? _botHelper.GetPmcSideByRole(botType).ToLower()
|
||||
var botTypeLower = botType.IsPmc()
|
||||
? (botType.GetPmcSideByRole() ?? "usec").ToLower()
|
||||
: botType.ToString().ToLower();
|
||||
|
||||
// Get details from db
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using SPTarkov.Server.Core.Constants;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common;
|
||||
|
||||
namespace SPTarkov.Server.Core.Extensions
|
||||
{
|
||||
public static class WildSpawnTypeExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Is the passed in bot role a PMC (USEC/Bear/PMC)
|
||||
/// </summary>
|
||||
/// <param name="botRole">bot role to check</param>
|
||||
/// <returns>true if is pmc</returns>
|
||||
public static bool IsPmc(this WildSpawnType botRole)
|
||||
{
|
||||
return botRole is WildSpawnType.pmcBEAR or WildSpawnType.pmcUSEC;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the corresponding side when pmcBEAR or pmcUSEC is passed in
|
||||
/// </summary>
|
||||
/// <param name="botRole">role to get side for</param>
|
||||
/// <returns>Usec/Bear</returns>
|
||||
public static string? GetPmcSideByRole(this WildSpawnType botRole)
|
||||
{
|
||||
switch (botRole)
|
||||
{
|
||||
case WildSpawnType.pmcBEAR:
|
||||
return Sides.Bear;
|
||||
case WildSpawnType.pmcUSEC:
|
||||
return Sides.Usec;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class BotLootGenerator(
|
||||
/// <param name="sessionId">Session id</param>
|
||||
/// <param name="botJsonTemplate">Clone of Base JSON db file for the bot having its loot generated</param>
|
||||
/// <param name="isPmc">Will bot be a pmc</param>
|
||||
/// <param name="botRole">Role of bot, e.g. asssult</param>
|
||||
/// <param name="botRole">Role of bot, e.g. assault</param>
|
||||
/// <param name="botInventory">Inventory to add loot to</param>
|
||||
/// <param name="botLevel">Level of bot</param>
|
||||
public void GenerateLoot(
|
||||
|
||||
@@ -59,16 +59,6 @@ public class BotHelper(
|
||||
return _pmcTypeIds.Contains(botRole?.ToLower());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is the passed in bot role a PMC (USEC/Bear/PMC)
|
||||
/// </summary>
|
||||
/// <param name="botRole">bot role to check</param>
|
||||
/// <returns>true if is pmc</returns>
|
||||
public bool IsBotPmc(WildSpawnType botRole)
|
||||
{
|
||||
return botRole is WildSpawnType.pmcBEAR or WildSpawnType.pmcUSEC;
|
||||
}
|
||||
|
||||
public bool IsBotBoss(string botRole)
|
||||
{
|
||||
return !IsBotFollower(botRole)
|
||||
@@ -169,17 +159,6 @@ public class BotHelper(
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Choose between pmcBEAR and pmcUSEC at random based on the % defined in pmcConfig.isUsec
|
||||
/// </summary>
|
||||
/// <returns>pmc role</returns>
|
||||
public string GetRandomizedPmcRole()
|
||||
{
|
||||
return _randomUtil.GetChance100(_pmcConfig.IsUsec)
|
||||
? _pmcConfig.UsecType
|
||||
: _pmcConfig.BearType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the corresponding side when pmcBEAR or pmcUSEC is passed in
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user