Removed filledContainerIds system as its handled by botInventoryContainerService
This commit is contained in:
@@ -36,22 +36,22 @@ public class BotLootGenerator(
|
|||||||
protected readonly PmcConfig PMCConfig = configServer.GetConfig<PmcConfig>();
|
protected readonly PmcConfig PMCConfig = configServer.GetConfig<PmcConfig>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Get a dictionary of item tpls and the number of times they can be spawned on a single bot
|
||||||
|
/// Keyed by bot type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="botRole"></param>
|
/// <param name="botRole">Role of bot to get limits for</param>
|
||||||
/// <returns></returns>
|
/// <returns>Item spawn limits</returns>
|
||||||
protected ItemSpawnLimitSettings GetItemSpawnLimitsForBot(string botRole)
|
protected ItemSpawnLimitSettings GetItemSpawnLimitsForBot(string botRole)
|
||||||
{
|
{
|
||||||
var limits = GetItemSpawnLimitsForBotType(botRole);
|
|
||||||
|
|
||||||
// Clone limits and set all values to 0 to use as a running total
|
// Clone limits and set all values to 0 to use as a running total
|
||||||
var limitsForBotDict = cloner.Clone(limits);
|
var limitsForBotDictClone = cloner.Clone(GetItemSpawnLimitsForBotType(botRole));
|
||||||
// Init current count of items we want to limit
|
// Init current count of items we want to limit
|
||||||
foreach (var limit in limitsForBotDict)
|
foreach (var limit in limitsForBotDictClone)
|
||||||
{
|
{
|
||||||
limitsForBotDict[limit.Key] = 0;
|
limitsForBotDictClone[limit.Key] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ItemSpawnLimitSettings { CurrentLimits = limitsForBotDict, GlobalLimits = GetItemSpawnLimitsForBotType(botRole) };
|
return new ItemSpawnLimitSettings { CurrentLimits = limitsForBotDictClone, GlobalLimits = GetItemSpawnLimitsForBotType(botRole) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -128,10 +128,6 @@ public class BotLootGenerator(
|
|||||||
|
|
||||||
var containersBotHasAvailable = GetAvailableContainersBotCanStoreItemsIn(botInventory);
|
var containersBotHasAvailable = GetAvailableContainersBotCanStoreItemsIn(botInventory);
|
||||||
|
|
||||||
// This set is passed as a reference to fill up the containers that are already full, this alleviates
|
|
||||||
// generation of the bots by avoiding checking the slots of containers we already know are full
|
|
||||||
HashSet<string> filledContainerIds = [];
|
|
||||||
|
|
||||||
// Special items
|
// Special items
|
||||||
AddLootFromPool(
|
AddLootFromPool(
|
||||||
botId,
|
botId,
|
||||||
@@ -140,8 +136,7 @@ public class BotLootGenerator(
|
|||||||
specialLootItemCount,
|
specialLootItemCount,
|
||||||
botInventory,
|
botInventory,
|
||||||
botRole,
|
botRole,
|
||||||
botItemLimits,
|
botItemLimits
|
||||||
containersIdFull: filledContainerIds
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Healing items / Meds
|
// Healing items / Meds
|
||||||
@@ -154,8 +149,7 @@ public class BotLootGenerator(
|
|||||||
botRole,
|
botRole,
|
||||||
null,
|
null,
|
||||||
0,
|
0,
|
||||||
isPmc,
|
isPmc
|
||||||
filledContainerIds
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Drugs
|
// Drugs
|
||||||
@@ -168,8 +162,7 @@ public class BotLootGenerator(
|
|||||||
botRole,
|
botRole,
|
||||||
null,
|
null,
|
||||||
0,
|
0,
|
||||||
isPmc,
|
isPmc
|
||||||
filledContainerIds
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Food
|
// Food
|
||||||
@@ -182,8 +175,7 @@ public class BotLootGenerator(
|
|||||||
botRole,
|
botRole,
|
||||||
null,
|
null,
|
||||||
0,
|
0,
|
||||||
isPmc,
|
isPmc
|
||||||
filledContainerIds
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Drink
|
// Drink
|
||||||
@@ -196,8 +188,7 @@ public class BotLootGenerator(
|
|||||||
botRole,
|
botRole,
|
||||||
null,
|
null,
|
||||||
0,
|
0,
|
||||||
isPmc,
|
isPmc
|
||||||
filledContainerIds
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Currency
|
// Currency
|
||||||
@@ -210,8 +201,7 @@ public class BotLootGenerator(
|
|||||||
botRole,
|
botRole,
|
||||||
null,
|
null,
|
||||||
0,
|
0,
|
||||||
isPmc,
|
isPmc
|
||||||
filledContainerIds
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Stims
|
// Stims
|
||||||
@@ -224,8 +214,7 @@ public class BotLootGenerator(
|
|||||||
botRole,
|
botRole,
|
||||||
botItemLimits,
|
botItemLimits,
|
||||||
0,
|
0,
|
||||||
isPmc,
|
isPmc
|
||||||
filledContainerIds
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Grenades
|
// Grenades
|
||||||
@@ -238,8 +227,7 @@ public class BotLootGenerator(
|
|||||||
botRole,
|
botRole,
|
||||||
null,
|
null,
|
||||||
0,
|
0,
|
||||||
isPmc,
|
isPmc
|
||||||
filledContainerIds
|
|
||||||
);
|
);
|
||||||
|
|
||||||
var itemPriceLimits = GetSingleItemLootPriceLimits(botLevel, isPmc);
|
var itemPriceLimits = GetSingleItemLootPriceLimits(botLevel, isPmc);
|
||||||
@@ -259,8 +247,7 @@ public class BotLootGenerator(
|
|||||||
botJsonTemplate.BotChances?.WeaponModsChances,
|
botJsonTemplate.BotChances?.WeaponModsChances,
|
||||||
botRole,
|
botRole,
|
||||||
isPmc,
|
isPmc,
|
||||||
botLevel,
|
botLevel
|
||||||
filledContainerIds
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,8 +264,7 @@ public class BotLootGenerator(
|
|||||||
botRole,
|
botRole,
|
||||||
botItemLimits,
|
botItemLimits,
|
||||||
backpackLootRoubleTotal,
|
backpackLootRoubleTotal,
|
||||||
isPmc,
|
isPmc
|
||||||
filledContainerIds
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,8 +283,7 @@ public class BotLootGenerator(
|
|||||||
botRole,
|
botRole,
|
||||||
botItemLimits,
|
botItemLimits,
|
||||||
vestLootRoubleTotal,
|
vestLootRoubleTotal,
|
||||||
isPmc,
|
isPmc
|
||||||
filledContainerIds
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,8 +299,7 @@ public class BotLootGenerator(
|
|||||||
botRole,
|
botRole,
|
||||||
botItemLimits,
|
botItemLimits,
|
||||||
pocketLootRoubleTotal,
|
pocketLootRoubleTotal,
|
||||||
isPmc,
|
isPmc
|
||||||
filledContainerIds
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Secure
|
// Secure
|
||||||
@@ -332,8 +316,7 @@ public class BotLootGenerator(
|
|||||||
botRole,
|
botRole,
|
||||||
null,
|
null,
|
||||||
-1,
|
-1,
|
||||||
isPmc,
|
isPmc
|
||||||
filledContainerIds
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -411,7 +394,6 @@ public class BotLootGenerator(
|
|||||||
/// <param name="inventoryToAddItemsTo">Bot inventory loot will be added to</param>
|
/// <param name="inventoryToAddItemsTo">Bot inventory loot will be added to</param>
|
||||||
/// <param name="botRole">Role of the bot loot is being generated for (assault/pmcbot)</param>
|
/// <param name="botRole">Role of the bot loot is being generated for (assault/pmcbot)</param>
|
||||||
/// <param name="itemSpawnLimits">Item spawn limits the bot must adhere to</param>
|
/// <param name="itemSpawnLimits">Item spawn limits the bot must adhere to</param>
|
||||||
/// <param name="containersIdFull"></param>
|
|
||||||
/// <param name="totalValueLimitRub">Total value of loot allowed in roubles</param>
|
/// <param name="totalValueLimitRub">Total value of loot allowed in roubles</param>
|
||||||
/// <param name="isPmc">Is bot being generated for a pmc</param>
|
/// <param name="isPmc">Is bot being generated for a pmc</param>
|
||||||
protected internal void AddLootFromPool(
|
protected internal void AddLootFromPool(
|
||||||
@@ -423,8 +405,7 @@ public class BotLootGenerator(
|
|||||||
string botRole,
|
string botRole,
|
||||||
ItemSpawnLimitSettings? itemSpawnLimits,
|
ItemSpawnLimitSettings? itemSpawnLimits,
|
||||||
double totalValueLimitRub = 0,
|
double totalValueLimitRub = 0,
|
||||||
bool isPmc = false,
|
bool isPmc = false
|
||||||
HashSet<string>? containersIdFull = null
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Loot pool has items
|
// Loot pool has items
|
||||||
@@ -514,8 +495,7 @@ public class BotLootGenerator(
|
|||||||
newRootItemId,
|
newRootItemId,
|
||||||
itemToAddTemplate.Id,
|
itemToAddTemplate.Id,
|
||||||
itemWithChildrenToAdd,
|
itemWithChildrenToAdd,
|
||||||
inventoryToAddItemsTo,
|
inventoryToAddItemsTo
|
||||||
containersIdFull
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Handle when item cannot be added
|
// Handle when item cannot be added
|
||||||
@@ -639,8 +619,7 @@ public class BotLootGenerator(
|
|||||||
/// <param name="modChances">Chances for mods to spawn on weapon</param>
|
/// <param name="modChances">Chances for mods to spawn on weapon</param>
|
||||||
/// <param name="botRole">bots role .e.g. pmcBot</param>
|
/// <param name="botRole">bots role .e.g. pmcBot</param>
|
||||||
/// <param name="isPmc">are we generating for a pmc</param>
|
/// <param name="isPmc">are we generating for a pmc</param>
|
||||||
/// <param name="botLevel"></param>
|
/// <param name="botLevel">Level of bot having loose weapon generated</param>
|
||||||
/// <param name="containersIdFull"></param>
|
|
||||||
public void AddLooseWeaponsToInventorySlot(
|
public void AddLooseWeaponsToInventorySlot(
|
||||||
MongoId botId,
|
MongoId botId,
|
||||||
MongoId sessionId,
|
MongoId sessionId,
|
||||||
@@ -650,8 +629,7 @@ public class BotLootGenerator(
|
|||||||
Dictionary<string, double> modChances,
|
Dictionary<string, double> modChances,
|
||||||
string botRole,
|
string botRole,
|
||||||
bool isPmc,
|
bool isPmc,
|
||||||
int botLevel,
|
int botLevel
|
||||||
HashSet<string>? containersIdFull
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
var chosenWeaponType = randomUtil.GetArrayValue<string>(
|
var chosenWeaponType = randomUtil.GetArrayValue<string>(
|
||||||
@@ -698,8 +676,7 @@ public class BotLootGenerator(
|
|||||||
weaponRootItem.Id,
|
weaponRootItem.Id,
|
||||||
weaponRootItem.Template,
|
weaponRootItem.Template,
|
||||||
generatedWeapon.Weapon,
|
generatedWeapon.Weapon,
|
||||||
botInventory,
|
botInventory
|
||||||
containersIdFull
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (result != ItemAddedResult.SUCCESS)
|
if (result != ItemAddedResult.SUCCESS)
|
||||||
|
|||||||
@@ -436,7 +436,6 @@ public class BotGeneratorHelper(
|
|||||||
/// <param name="rootItemTplId">Root items tpl id</param>
|
/// <param name="rootItemTplId">Root items tpl id</param>
|
||||||
/// <param name="itemWithChildren">Item to add</param>
|
/// <param name="itemWithChildren">Item to add</param>
|
||||||
/// <param name="inventory">Inventory to add item+children into</param>
|
/// <param name="inventory">Inventory to add item+children into</param>
|
||||||
/// <param name="containersIdFull">Container Ids with no space for more items</param>
|
|
||||||
/// <returns>ItemAddedResult result object</returns>
|
/// <returns>ItemAddedResult result object</returns>
|
||||||
public ItemAddedResult AddItemWithChildrenToEquipmentSlot(
|
public ItemAddedResult AddItemWithChildrenToEquipmentSlot(
|
||||||
MongoId botId,
|
MongoId botId,
|
||||||
@@ -444,8 +443,7 @@ public class BotGeneratorHelper(
|
|||||||
MongoId rootItemId,
|
MongoId rootItemId,
|
||||||
MongoId rootItemTplId,
|
MongoId rootItemTplId,
|
||||||
IEnumerable<Item> itemWithChildren,
|
IEnumerable<Item> itemWithChildren,
|
||||||
BotBaseInventory inventory,
|
BotBaseInventory inventory
|
||||||
HashSet<string>? containersIdFull = null
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
var itemWithChildrenList = itemWithChildren.ToList();
|
var itemWithChildrenList = itemWithChildren.ToList();
|
||||||
@@ -454,12 +452,6 @@ public class BotGeneratorHelper(
|
|||||||
var missingContainerCount = 0;
|
var missingContainerCount = 0;
|
||||||
foreach (var equipmentSlotId in equipmentSlots)
|
foreach (var equipmentSlotId in equipmentSlots)
|
||||||
{
|
{
|
||||||
if (containersIdFull is not null && containersIdFull.Contains(equipmentSlotId.ToString()))
|
|
||||||
{
|
|
||||||
// Container has been flagged as full already, skip trying to add item into it
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get container from inventory to put item into
|
// Get container from inventory to put item into
|
||||||
var container = inventory.Items?.FirstOrDefault(item => item.SlotId == equipmentSlotId.ToString());
|
var container = inventory.Items?.FirstOrDefault(item => item.SlotId == equipmentSlotId.ToString());
|
||||||
if (container is null)
|
if (container is null)
|
||||||
|
|||||||
Reference in New Issue
Block a user