Converted GetWeaponsDefaultMagazineTpl into extension method
This commit is contained in:
@@ -37,5 +37,15 @@ namespace SPTarkov.Server.Core.Extensions
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a weapons default magazine template id
|
||||
/// </summary>
|
||||
/// <param name="weaponTemplate">Weapon to get default magazine for</param>
|
||||
/// <returns>Tpl of magazine</returns>
|
||||
public static string? GetWeaponsDefaultMagazineTpl(this TemplateItem weaponTemplate)
|
||||
{
|
||||
return weaponTemplate.Properties.DefMagType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using SPTarkov.DI.Annotations;
|
||||
using SPTarkov.Server.Core.Extensions;
|
||||
using SPTarkov.Server.Core.Generators.WeaponGen;
|
||||
using SPTarkov.Server.Core.Helpers;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common;
|
||||
@@ -619,7 +620,7 @@ public class BotWeaponGenerator(
|
||||
// return default mag tpl
|
||||
if (weaponTemplate.Properties.ReloadMode == ReloadMode.OnlyBarrel)
|
||||
{
|
||||
return _botWeaponGeneratorHelper.GetWeaponsDefaultMagazineTpl(weaponTemplate);
|
||||
return weaponTemplate.GetWeaponsDefaultMagazineTpl();
|
||||
}
|
||||
|
||||
// log error if no magazine AND not a chamber loaded weapon (e.g. shotgun revolver)
|
||||
@@ -634,9 +635,7 @@ public class BotWeaponGenerator(
|
||||
);
|
||||
}
|
||||
|
||||
var defaultMagTplId = _botWeaponGeneratorHelper.GetWeaponsDefaultMagazineTpl(
|
||||
weaponTemplate
|
||||
);
|
||||
var defaultMagTplId = weaponTemplate.GetWeaponsDefaultMagazineTpl();
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
using SPTarkov.DI.Annotations;
|
||||
using SPTarkov.Server.Core.Extensions;
|
||||
using SPTarkov.Server.Core.Helpers;
|
||||
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
|
||||
using SPTarkov.Server.Core.Models.Enums;
|
||||
@@ -39,7 +40,7 @@ public class ExternalInventoryMagGen(
|
||||
var magazineTpl = magTemplate.Id;
|
||||
var weapon = inventoryMagGen.GetWeaponTemplate();
|
||||
List<string> attemptedMagBlacklist = [];
|
||||
var defaultMagazineTpl = _botWeaponGeneratorHelper.GetWeaponsDefaultMagazineTpl(weapon);
|
||||
var defaultMagazineTpl = weapon.GetWeaponsDefaultMagazineTpl();
|
||||
var isShotgun = _itemHelper.IsOfBaseclass(weapon.Id, BaseClasses.SHOTGUN);
|
||||
|
||||
var randomizedMagazineCount = _botWeaponGeneratorHelper.GetRandomizedMagazineCount(
|
||||
|
||||
@@ -117,7 +117,7 @@ public class BotWeaponGeneratorHelper(
|
||||
string ammoTpl,
|
||||
int cartridgeCount,
|
||||
BotBaseInventory inventory,
|
||||
HashSet<EquipmentSlots> equipmentSlotsToAddTo
|
||||
HashSet<EquipmentSlots>? equipmentSlotsToAddTo = null
|
||||
)
|
||||
{
|
||||
if (equipmentSlotsToAddTo is null)
|
||||
@@ -158,14 +158,4 @@ public class BotWeaponGeneratorHelper(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a weapons default magazine template id
|
||||
/// </summary>
|
||||
/// <param name="weaponTemplate">Weapon to get default magazine for</param>
|
||||
/// <returns>Tpl of magazine</returns>
|
||||
public string? GetWeaponsDefaultMagazineTpl(TemplateItem weaponTemplate)
|
||||
{
|
||||
return weaponTemplate.Properties.DefMagType;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user