fix null guards
This commit is contained in:
@@ -775,11 +775,11 @@ public class BotEquipmentModGenerator
|
||||
case "patron_in_weapon":
|
||||
case "patron_in_weapon_000":
|
||||
case "patron_in_weapon_001":
|
||||
return parentTemplate.Properties.Chambers.FirstOrDefault((chamber) => chamber.Name.Contains(modSlotLower));
|
||||
return parentTemplate?.Properties?.Chambers?.FirstOrDefault((chamber) => chamber.Name.Contains(modSlotLower));
|
||||
case "cartridges":
|
||||
return parentTemplate.Properties.Cartridges.FirstOrDefault((c) => c.Name.ToLower() == modSlotLower);
|
||||
return parentTemplate?.Properties?.Cartridges?.FirstOrDefault((c) => c.Name?.ToLower() == modSlotLower);
|
||||
default:
|
||||
return parentTemplate.Properties.Slots.FirstOrDefault((s) => s.Name.ToLower() == modSlotLower);
|
||||
return parentTemplate?.Properties?.Slots?.FirstOrDefault((s) => s.Name?.ToLower() == modSlotLower);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -224,8 +224,9 @@ public class BotWeaponGenerator
|
||||
);
|
||||
}
|
||||
|
||||
var tempList = _cloner.Clone(weaponWithModsArray.Where((item) => item.SlotId == _modMagazineSlotId));
|
||||
// Fill existing magazines to full and sync ammo type
|
||||
foreach (var magazine in weaponWithModsArray.Where((item) => item.SlotId == _modMagazineSlotId))
|
||||
foreach (var magazine in tempList)
|
||||
{
|
||||
FillExistingMagazines(weaponWithModsArray, magazine, ammoTpl);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user