Convert TemplateItem to MongoId (#436)

* Convert TemplateItem to MongoId

* Push new extensions

* Handle null mongoid's being passed to regex

* Handle null strings, fixes item events

* Updated loot generation to work with new property `composedKey`

Fixed typo in `SlotId`

* Fix missing method after merge

* Remove duplicately named MongoIDExtensions?

* Fixed location loot generation to handle impending loot json changes

* Updated location JSONs with new properties (excluding lighthouse loose loot)

* Fixed build issue with ItemTplGenerator

* use correct handing for new mongo ids

* Added helper method to improve readability

---------

Co-authored-by: Chomp <dev@dev.sp-tarkov.com>
This commit is contained in:
Jesse
2025-07-02 11:14:04 +02:00
committed by GitHub
parent 46989aa19e
commit 54f0d0779c
89 changed files with 529 additions and 413 deletions
@@ -1679,7 +1679,7 @@ public class ItemHelper(
string caliber,
Dictionary<string, List<StaticAmmoDetails>> staticAmmoDist,
string? fallbackCartridgeTpl = null,
ICollection<string>? cartridgeWhitelist = null
ICollection<MongoId>? cartridgeWhitelist = null
)
{
var ammos = staticAmmoDist.GetValueOrDefault(caliber, []);
@@ -1766,7 +1766,7 @@ public class ItemHelper(
/// </summary>
/// <param name="desiredBaseType">Item base type wanted</param>
/// <returns>Array of tpls</returns>
public List<string> GetItemTplsOfBaseType(string desiredBaseType)
public List<MongoId> GetItemTplsOfBaseType(string desiredBaseType)
{
return _databaseService
.GetItems()
@@ -1791,7 +1791,7 @@ public class ItemHelper(
)
{
var result = itemToAdd;
HashSet<string> incompatibleModTpls = [];
HashSet<MongoId> incompatibleModTpls = [];
foreach (var slot in itemToAddTemplate.Properties.Slots)
{
// If only required mods is requested, skip non-essential
@@ -1867,8 +1867,8 @@ public class ItemHelper(
/// <param name="incompatibleModTpls">Incompatible tpls to not allow</param>
/// <returns>Chosen tpl or undefined</returns>
public string? GetCompatibleTplFromArray(
HashSet<string> possibleTpls,
HashSet<string> incompatibleModTpls
HashSet<MongoId> possibleTpls,
HashSet<MongoId> incompatibleModTpls
)
{
if (!possibleTpls.Any())
@@ -2062,7 +2062,7 @@ public class ItemHelper(
return currentItem.Id;
}
if (currentItem.Parent is null)
if (currentItem.Parent.IsEmpty())
// No parent, reached root
{
return currentItem.Id;