Various changes
This commit is contained in:
@@ -229,7 +229,7 @@ public class HideoutController(
|
||||
HideoutArea dbHideoutArea, Stage hideoutStage)
|
||||
{
|
||||
// Add key/value to `hideoutAreaStashes` dictionary - used to link hideout area to inventory stash by its id
|
||||
if (pmcData.Inventory.HideoutAreaStashes.GetValueOrDefault(dbHideoutArea.Type.ToString()) is null)
|
||||
if (!pmcData.Inventory.HideoutAreaStashes.ContainsKey(dbHideoutArea.Type.ToString()))
|
||||
{
|
||||
pmcData.Inventory.HideoutAreaStashes[dbHideoutArea.Type.ToString()] = dbHideoutArea.Id;
|
||||
}
|
||||
@@ -432,7 +432,7 @@ public class HideoutController(
|
||||
}
|
||||
|
||||
// Assume only one item in slot
|
||||
var itemToReturn = hideoutArea.Slots.FirstOrDefault(slot => slot.LocationIndex == slotIndexToRemove)?.Items.FirstOrDefault();
|
||||
var itemToReturn = hideoutArea.Slots?.FirstOrDefault(slot => slot.LocationIndex == slotIndexToRemove)?.Items.FirstOrDefault();
|
||||
if (itemToReturn is null)
|
||||
{
|
||||
_logger.Warning($"Unable to remove resource from area: {removeResourceRequest.AreaType} slot as no item found, RESTART CLIENT IMMEDIATELY");
|
||||
@@ -440,7 +440,7 @@ public class HideoutController(
|
||||
return output;
|
||||
}
|
||||
|
||||
AddItemDirectRequest request = new AddItemDirectRequest
|
||||
var request = new AddItemDirectRequest
|
||||
{
|
||||
ItemWithModsToAdd = [itemToReturn.ConvertToItem()],
|
||||
FoundInRaid = itemToReturn.Upd?.SpawnedInSession,
|
||||
@@ -451,7 +451,7 @@ public class HideoutController(
|
||||
_inventoryHelper.AddItemToStash(sessionID, request, pmcData, output);
|
||||
if (output.Warnings?.Count > 0)
|
||||
{
|
||||
// Adding to stash failed, drop out - dont remove item from hideout area slot
|
||||
// Adding to stash failed, drop out - don't remove item from hideout area slot
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -555,7 +555,7 @@ public class HideoutController(
|
||||
}
|
||||
}
|
||||
|
||||
var recipe = _databaseService.GetHideout().Production.ScavRecipes.FirstOrDefault(r => r.Id == body.RecipeId);
|
||||
var recipe = _databaseService.GetHideout().Production?.ScavRecipes?.FirstOrDefault(r => r.Id == body.RecipeId);
|
||||
if (recipe is null)
|
||||
{
|
||||
_logger.Error(
|
||||
@@ -1015,9 +1015,9 @@ public class HideoutController(
|
||||
var hasSeverePain = pmcData.Health.BodyParts["Chest"].Effects?.ContainsKey("SevereMusclePain");
|
||||
|
||||
// Has no muscle pain at all, add mild
|
||||
if (hasMildPain is null && hasSeverePain is null)
|
||||
if (!hasMildPain.GetValueOrDefault(false) && !hasSeverePain.GetValueOrDefault(false))
|
||||
{
|
||||
// nullguard
|
||||
// Nullguard
|
||||
pmcData.Health.BodyParts["Chest"].Effects ??= new Dictionary<string, BodyPartEffectProperties>();
|
||||
pmcData.Health.BodyParts["Chest"].Effects["MildMusclePain"] = new BodyPartEffectProperties
|
||||
{
|
||||
@@ -1027,7 +1027,7 @@ public class HideoutController(
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasMildPain is not null)
|
||||
if (hasMildPain.GetValueOrDefault(false))
|
||||
{
|
||||
// Already has mild pain, remove mild and add severe
|
||||
pmcData.Health.BodyParts["Chest"].Effects.Remove("MildMusclePain");
|
||||
@@ -1041,7 +1041,7 @@ public class HideoutController(
|
||||
|
||||
public void RecordShootingRangePoints(string sessionId, PmcData pmcData, RecordShootingRangePoints request)
|
||||
{
|
||||
var shootingRangeKey = "ShootingRangePoints";
|
||||
const string shootingRangeKey = "ShootingRangePoints";
|
||||
var overallCounterItems = pmcData.Stats.Eft.OverallCounters.Items;
|
||||
|
||||
// Find counter by key
|
||||
@@ -1218,7 +1218,7 @@ public class HideoutController(
|
||||
var slots = _itemHelper.GetItem(equipmentPresetStage.Container).Value.Properties.Slots;
|
||||
foreach (var mannequinSlot in slots)
|
||||
{
|
||||
// Chek if we've already added this manniquin
|
||||
// Check if we've already added this mannequin
|
||||
var existingMannequin = pmcData.Inventory.Items.FirstOrDefault(
|
||||
(item) => item.ParentId == equipmentPresetHideoutArea.Id && item.SlotId == mannequinSlot.Name
|
||||
);
|
||||
|
||||
@@ -169,11 +169,8 @@ public class QuestController(
|
||||
if (repeatableQuestProfile.Side == "Scav" && _questTypes.Contains(repeatableQuestProfile.Type.ToString()))
|
||||
{
|
||||
var fullProfile = _profileHelper.GetFullProfile(sessionID);
|
||||
if (fullProfile.CharacterData.ScavData.Quests is null)
|
||||
{
|
||||
fullProfile.CharacterData.ScavData.Quests = [];
|
||||
}
|
||||
|
||||
fullProfile.CharacterData.ScavData.Quests ??= [];
|
||||
fullProfile.CharacterData.ScavData.Quests.Add(newRepeatableQuest);
|
||||
}
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ public class RagfairController
|
||||
var firstItem = offer.Items[0];
|
||||
var traderAssorts = _traderHelper.GetTraderAssortsByTraderId(offer.User.Id).Items;
|
||||
|
||||
var assortPurchased = traderAssorts.FirstOrDefault(x => x.Id == offer.Items.First().Id);
|
||||
var assortPurchased = traderAssorts?.FirstOrDefault(x => x.Id == offer.Items.First().Id);
|
||||
if (assortPurchased is null)
|
||||
{
|
||||
_logger.Warning(
|
||||
@@ -939,7 +939,7 @@ public class RagfairController
|
||||
// Count how many items are being sold and multiply the requested amount accordingly
|
||||
foreach (var itemId in itemIdsFromFleaOfferRequest)
|
||||
{
|
||||
var item = pmcData.Inventory.Items.FirstOrDefault((i) => i.Id == itemId);
|
||||
var item = pmcData.Inventory?.Items?.FirstOrDefault((i) => i.Id == itemId);
|
||||
if (item is null)
|
||||
{
|
||||
errorMessage = _localisationService.GetText("ragfair-unable_to_find_item_in_inventory", new { id = itemId });
|
||||
|
||||
@@ -238,7 +238,7 @@ public class RepeatableQuestController(
|
||||
}
|
||||
}
|
||||
|
||||
private RepeatableQuest AttemptToGenerateRepeatableQuest(string sessionId, PmcData pmcData,
|
||||
private RepeatableQuest? AttemptToGenerateRepeatableQuest(string sessionId, PmcData pmcData,
|
||||
QuestTypePool questTypePool, RepeatableQuestConfig repeatableConfig)
|
||||
{
|
||||
const int maxAttempts = 10;
|
||||
|
||||
@@ -1576,10 +1576,7 @@ public class BotEquipmentModGenerator(
|
||||
);
|
||||
}
|
||||
|
||||
if (!modPool.ContainsKey(modTemplate.Id))
|
||||
{
|
||||
modPool[modTemplate.Id] = new();
|
||||
}
|
||||
modPool.TryAdd(modTemplate.Id, new Dictionary<string, HashSet<string>>());
|
||||
|
||||
modPool[modTemplate.Id][desiredSlotObject.Name] = supportedSubMods.ToHashSet();
|
||||
}
|
||||
@@ -1646,8 +1643,7 @@ public class BotEquipmentModGenerator(
|
||||
public void FillCamora(List<Item> items, Dictionary<string, Dictionary<string, HashSet<string>>> modPool, string cylinderMagParentId,
|
||||
TemplateItem cylinderMagTemplate)
|
||||
{
|
||||
var itemModPool = modPool[cylinderMagTemplate.Id];
|
||||
if (itemModPool is null)
|
||||
if (!modPool.TryGetValue(cylinderMagTemplate.Id, out var itemModPool))
|
||||
{
|
||||
_logger.Warning(
|
||||
_localisationService.GetText(
|
||||
@@ -1672,8 +1668,8 @@ public class BotEquipmentModGenerator(
|
||||
}
|
||||
|
||||
ExhaustableArray<string> exhaustableModPool = null;
|
||||
var modSlot = "cartridges";
|
||||
var camoraFirstSlot = "camora_000";
|
||||
string modSlot = "cartridges";
|
||||
const string camoraFirstSlot = "camora_000";
|
||||
if (itemModPool.TryGetValue(modSlot, out var value))
|
||||
{
|
||||
exhaustableModPool = CreateExhaustableArray(value.ToList());
|
||||
@@ -1690,7 +1686,7 @@ public class BotEquipmentModGenerator(
|
||||
return;
|
||||
}
|
||||
|
||||
string modTpl = null;
|
||||
string? modTpl = null;
|
||||
var found = false;
|
||||
while (exhaustableModPool.HasValues())
|
||||
{
|
||||
@@ -1713,7 +1709,13 @@ public class BotEquipmentModGenerator(
|
||||
{
|
||||
var modSlotId = slot.Name;
|
||||
var modId = _hashUtil.Generate();
|
||||
items.Add(new() { Id = modId, Template = modTpl, ParentId = cylinderMagParentId, SlotId = modSlotId });
|
||||
items.Add(new()
|
||||
{
|
||||
Id = modId,
|
||||
Template = modTpl,
|
||||
ParentId = cylinderMagParentId,
|
||||
SlotId = modSlotId
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1744,8 +1746,7 @@ public class BotEquipmentModGenerator(
|
||||
var weaponDetails = _itemHelper.GetItem(weapon.Template);
|
||||
|
||||
// Return original scopes array if whitelist not found
|
||||
var whitelistedSightTypes = botWeaponSightWhitelist[weaponDetails.Value.Parent];
|
||||
if (whitelistedSightTypes is null)
|
||||
if (!botWeaponSightWhitelist.TryGetValue(weaponDetails.Value.Parent, out var whitelistedSightTypes))
|
||||
{
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
|
||||
@@ -394,9 +394,9 @@ public class BotWeaponGenerator(
|
||||
|
||||
return;
|
||||
}
|
||||
var isInternalMag = magTemplate.Properties.ReloadMagType == ReloadMode.InternalMagazine;
|
||||
var ammoTemplate = _itemHelper.GetItem(generatedWeaponResult.ChosenAmmoTemplate).Value;
|
||||
if (ammoTemplate is null)
|
||||
//var isInternalMag = magTemplate.Properties.ReloadMagType == ReloadMode.InternalMagazine;
|
||||
var ammoTemplate = _itemHelper.GetItem(generatedWeaponResult.ChosenAmmoTemplate);
|
||||
if (!ammoTemplate.Key)
|
||||
{
|
||||
_logger.Error(
|
||||
_localisationService.GetText("bot-unable_to_find_ammo_item", generatedWeaponResult.ChosenAmmoTemplate)
|
||||
@@ -415,7 +415,7 @@ public class BotWeaponGenerator(
|
||||
magWeights,
|
||||
magTemplate,
|
||||
weaponTemplate,
|
||||
ammoTemplate,
|
||||
ammoTemplate.Value,
|
||||
inventory
|
||||
);
|
||||
|
||||
@@ -426,7 +426,7 @@ public class BotWeaponGenerator(
|
||||
AddAmmoToSecureContainer(
|
||||
_botConfig.SecureContainerAmmoStackCount,
|
||||
generatedWeaponResult.ChosenAmmoTemplate,
|
||||
ammoTemplate.Properties.StackMaxSize ?? 0,
|
||||
ammoTemplate.Value.Properties.StackMaxSize ?? 0,
|
||||
inventory
|
||||
);
|
||||
}
|
||||
@@ -605,7 +605,7 @@ public class BotWeaponGenerator(
|
||||
/// </summary>
|
||||
/// <param name="weaponTemplate">Weapon db template to get cartridges for</param>
|
||||
/// <returns>List of cartridge tpls</returns>
|
||||
protected List<string> GetCompatibleCartridgesFromWeaponTemplate(TemplateItem weaponTemplate)
|
||||
protected List<string>? GetCompatibleCartridgesFromWeaponTemplate(TemplateItem weaponTemplate)
|
||||
{
|
||||
var cartridges = weaponTemplate.Properties?.Chambers.FirstOrDefault()?.Props?.Filters?[0].Filter;
|
||||
if (cartridges is not null)
|
||||
|
||||
Reference in New Issue
Block a user