diff --git a/Generator/Assets/weights.json b/Generator/Assets/weights.json
new file mode 100644
index 0000000..f4a7b80
--- /dev/null
+++ b/Generator/Assets/weights.json
@@ -0,0 +1,163 @@
+{
+ "assault": {
+ "FirstPrimaryWeapon": {
+ "54491c4f4bdc2db1078b4568": 61,
+ "5580223e4bdc2d1c128b457f": 4,
+ "5644bd2b4bdc2d3b4c8b4572": 10,
+ "56dee2bdd2720bc8328b4567": 80,
+ "574d967124597745970e7c94": 56,
+ "576165642459773c7a400233": 80,
+ "57d14d2524597714373db789": 16,
+ "57dc2fa62459775949412633": 41,
+ "587e02ff24597743df3deaeb": 37,
+ "59d6088586f774275f37482f": 22,
+ "59e6152586f77473dc057aa1": 83,
+ "59e6687d86f77411d949b251": 61,
+ "59f9cabd86f7743a10721f46": 49,
+ "59ff346386f77477562ff5e2": 12,
+ "5a38e6bac4a2826c6e06d79b": 78,
+ "5ab8e9fcd8ce870019439434": 4,
+ "5ac4cd105acfc40016339859": 32,
+ "5ac66d9b5acfc4001633997a": 9,
+ "5ae08f0a5acfc408fb1398a1": 4,
+ "5bf3e03b0db834001d2c4a9c": 4,
+ "5bf3e0490db83400196199af": 7,
+ "5bfd297f0db834001a669119": 5,
+ "5c07c60e0db834002330051f": 33,
+ "5c501a4d2e221602b412b540": 27,
+ "5de652c31b7e3716273428be": 17,
+ "5e870397991fd70db46995c8": 29,
+ "5ea03f7400685063ec28bfa8": 11,
+ "606dae0ab0e443224b421bb7": 57,
+ "60db29ce99594040e04c4a27": 4,
+ "61f7c9e189e6fb1a5e3ea78d": 32
+ },
+ "Backpack": {
+ "544a5cde4bdc2d39388b456b": 9,
+ "56e335e4d2720b6c058b456d": 4,
+ "56e33634d2720bd8058b456b": 10,
+ "56e33680d2720be2748b4576": 12,
+ "59e763f286f7742ee57895da": 1,
+ "5ab8ee7786f7742d8f33f0b9": 1,
+ "5ab8f04f86f774585f4237d8": 12,
+ "5f5e45cc5021ce62144be7aa": 4,
+ "60a2828e8689911a226117f9": 1
+ }
+ },
+ "pmcBot": {
+ "FirstPrimaryWeapon": {
+ "5447a9cd4bdc2dbd208b4567": 30,
+ "54491c4f4bdc2db1078b4568": 50,
+ "574d967124597745970e7c94": 58,
+ "576165642459773c7a400233": 36,
+ "57c44b372459772d2b39b8ce": 10,
+ "57d14d2524597714373db789": 93,
+ "57dc2fa62459775949412633": 81,
+ "583990e32459771419544dd2": 103,
+ "58948c8e86f77409493f7266": 12,
+ "5926bb2186f7744b1c6c6e60": 107,
+ "5a7828548dc32e5a9c28b516": 120,
+ "5ac4cd105acfc40016339859": 34,
+ "5ac66d725acfc43b321d4b60": 41,
+ "5ac66d9b5acfc4001633997a": 53,
+ "5b0bbe4e5acfc40dc528a72d": 3,
+ "5bb2475ed4351e00853264e3": 17,
+ "5bd70322209c4d00d7167b8f": 6,
+ "5c488a752e221602b412af63": 10,
+ "5d43021ca4b9362eab4b5e25": 6,
+ "5df8ce05b11454561e39243b": 4,
+ "5f2a9575926fd9352339381f": 27,
+ "5fbcc1d9016cce60e8341ab3": 12,
+ "5fc3f2d5900b1d5091531e57": 14,
+ "60339954d62c9b14ed777c06": 18,
+ "606587252535c57a13424cfd": 4,
+ "623063e994fc3f7b302a9696": 35
+ }
+ },
+ "bossBully": {
+ "FirstPrimaryWeapon": {
+ "576165642459773c7a400233": 15,
+ "5926bb2186f7744b1c6c6e60": 11,
+ "5ac66cb05acfc40198510a10": 45,
+ "5ac66d015acfc400180ae6e4": 41,
+ "5dcbd56fdbd3d91b3e5468d5": 13
+ },
+ "Holster": {
+ "5b3b713c5acfc4330140bd8d": 1,
+ "602a9740da11d6478d5a06dc": 5,
+ "6193a720f8ee7e52e42109ed": 1
+ }
+ },
+ "bossKilla": {
+ "FirstPrimaryWeapon": {
+ "59984ab886f7743e98271174": 2,
+ "59ff346386f77477562ff5e2": 3,
+ "5beed0f50db834001c062b12": 17
+ }
+ },
+ "bossKojaniy": {
+ "Backpack": {
+ "56e335e4d2720b6c058b456d": 37,
+ "5c0e805e86f774683f3dd637": 11,
+ "5ca20d5986f774331e7c9602": 38,
+ "6034d103ca006d2dca39b3f0": 11,
+ "6038d614d10cbf667352dd44": 11,
+ "618cfae774bb2d036a049e7c": 11
+ },
+ "FirstPrimaryWeapon": {
+ "5c46fbd72e2216398b5a8c9c": 4,
+ "6176aca650224f204c1da3fb": 1
+ }
+ },
+ "bossTagilla": {
+ "FirstPrimaryWeapon": {
+ "576165642459773c7a400233": 12,
+ "583990e32459771419544dd2": 7,
+ "5beed0f50db834001c062b12": 2,
+ "606dae0ab0e443224b421bb7": 1
+ }
+ },
+ "exUsec": {
+ "ArmorVest": {
+ "5648a7494bdc2d9d488b4583": 32,
+ "5b44cf1486f77431723e3d05": 7,
+ "5b44d0de86f774503d30cba8": 18,
+ "5c0e655586f774045612eeb2": 26,
+ "5fd4c474dd870108a754b241": 7,
+ "609e8540d5c319764c2bc2e9": 18
+ },
+ "FirstPrimaryWeapon": {
+ "5447a9cd4bdc2dbd208b4567": 31,
+ "59d6088586f774275f37482f": 22,
+ "5ac4cd105acfc40016339859": 10,
+ "5ac66d725acfc43b321d4b60": 7,
+ "5b0bbe4e5acfc40dc528a72d": 2,
+ "5bb2475ed4351e00853264e3": 4,
+ "5df8ce05b11454561e39243b": 1,
+ "5fbcc1d9016cce60e8341ab3": 1,
+ "606587252535c57a13424cfd": 2,
+ "6184055050224f204c1da540": 1,
+ "618428466ef05c2ce828f218": 19,
+ "628a60ae6b1d481ff772e9c8": 7
+ }
+ },
+ "marksman": {
+ "FirstPrimaryWeapon": {
+ "55801eed4bdc2d89578b4588": 87,
+ "5644bd2b4bdc2d3b4c8b4572": 58,
+ "574d967124597745970e7c94": 149,
+ "57838ad32459774a17445cd2": 12,
+ "57dc2fa62459775949412633": 27,
+ "5839a40f24597726f856b511": 16,
+ "587e02ff24597743df3deaeb": 292,
+ "5ae08f0a5acfc408fb1398a1": 244,
+ "5bfea6e90db834001b7347f3": 13,
+ "5c46fbd72e2216398b5a8c9c": 97
+ },
+ "TacticalVest": {
+ "572b7adb24597762ae139821": 20,
+ "5929a2a086f7744f4b234d43": 4,
+ "5ca20abf86f77418567a43f2": 1
+ }
+ }
+}
diff --git a/Generator/Generator.csproj b/Generator/Generator.csproj
index c4776ba..0f41044 100644
--- a/Generator/Generator.csproj
+++ b/Generator/Generator.csproj
@@ -43,6 +43,7 @@
+
@@ -154,6 +155,9 @@
Always
+
+ Always
+
diff --git a/Generator/Helpers/Gear/GearHelpers.cs b/Generator/Helpers/Gear/GearHelpers.cs
index b70f906..c5b35c3 100644
--- a/Generator/Helpers/Gear/GearHelpers.cs
+++ b/Generator/Helpers/Gear/GearHelpers.cs
@@ -1,6 +1,7 @@
using Common.Extensions;
using Common.Models.Input;
using Common.Models.Output;
+using Generator.Weighting;
using System.Collections.Generic;
using System.Linq;
@@ -66,51 +67,52 @@ namespace Generator.Helpers.Gear
public static void AddEquippedGear(Bot botToUpdate, Datum bot)
{
// add equipped gear
+ var weightService = new WeightingService();
foreach (var inventoryItem in bot.Inventory.items.Where(x=>x.slotId != null))
{
switch (inventoryItem.slotId?.ToLower())
{
case "headwear":
- botToUpdate.inventory.equipment.Headwear.AddUnique(inventoryItem._tpl, GetItemWeight(inventoryItem._tpl));
+ botToUpdate.inventory.equipment.Headwear.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "headwear"));
break;
case "earpiece":
- botToUpdate.inventory.equipment.Earpiece.AddUnique(inventoryItem._tpl, GetItemWeight(inventoryItem._tpl));
+ botToUpdate.inventory.equipment.Earpiece.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "earpiece"));
break;
case "facecover":
- botToUpdate.inventory.equipment.FaceCover.AddUnique(inventoryItem._tpl, GetItemWeight(inventoryItem._tpl));
+ botToUpdate.inventory.equipment.FaceCover.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "facecover"));
break;
case "armorvest":
- botToUpdate.inventory.equipment.ArmorVest.AddUnique(inventoryItem._tpl, GetItemWeight(inventoryItem._tpl));
+ botToUpdate.inventory.equipment.ArmorVest.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "armorvest"));
break;
case "eyewear":
- botToUpdate.inventory.equipment.Eyewear.AddUnique(inventoryItem._tpl, GetItemWeight(inventoryItem._tpl));
+ botToUpdate.inventory.equipment.Eyewear.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "eyewear"));
break;
case "armband":
- botToUpdate.inventory.equipment.ArmBand.AddUnique(inventoryItem._tpl, GetItemWeight(inventoryItem._tpl));
+ botToUpdate.inventory.equipment.ArmBand.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "armband"));
break;
case "tacticalvest":
- botToUpdate.inventory.equipment.TacticalVest.AddUnique(inventoryItem._tpl, GetItemWeight(inventoryItem._tpl));
+ botToUpdate.inventory.equipment.TacticalVest.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "tacticalvest"));
break;
case "backpack":
- botToUpdate.inventory.equipment.Backpack.AddUnique(inventoryItem._tpl, GetItemWeight(inventoryItem._tpl));
+ botToUpdate.inventory.equipment.Backpack.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "backpack"));
break;
case "firstprimaryweapon":
- botToUpdate.inventory.equipment.FirstPrimaryWeapon.AddUnique(inventoryItem._tpl, GetItemWeight(inventoryItem._tpl));
+ botToUpdate.inventory.equipment.FirstPrimaryWeapon.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "firstprimaryweapon"));
break;
case "secondprimaryweapon":
- botToUpdate.inventory.equipment.SecondPrimaryWeapon.AddUnique(inventoryItem._tpl, GetItemWeight(inventoryItem._tpl));
+ botToUpdate.inventory.equipment.SecondPrimaryWeapon.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "secondprimaryweapon"));
break;
case "holster":
- botToUpdate.inventory.equipment.Holster.AddUnique(inventoryItem._tpl, GetItemWeight(inventoryItem._tpl));
+ botToUpdate.inventory.equipment.Holster.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "holster"));
break;
case "scabbard":
- botToUpdate.inventory.equipment.Scabbard.AddUnique(inventoryItem._tpl, GetItemWeight(inventoryItem._tpl));
+ botToUpdate.inventory.equipment.Scabbard.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "scabbard"));
break;
case "pockets":
- botToUpdate.inventory.equipment.Pockets.AddUnique(inventoryItem._tpl, GetItemWeight(inventoryItem._tpl));
+ botToUpdate.inventory.equipment.Pockets.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "pockets"));
break;
case "securedcontainer":
- botToUpdate.inventory.equipment.SecuredContainer.AddUnique(inventoryItem._tpl, GetItemWeight(inventoryItem._tpl));
+ botToUpdate.inventory.equipment.SecuredContainer.AddUnique(inventoryItem._tpl, weightService.GetItemWeight(inventoryItem._tpl, botToUpdate.botType, "securedcontainer"));
break;
default:
break;
@@ -118,12 +120,6 @@ namespace Generator.Helpers.Gear
}
}
- private static int GetItemWeight(string tpl)
- {
- // TODO: implement
- return 1;
- }
-
public static void AddCartridges(Bot botToUpdate, Datum rawParsedBot)
{
var cartridgesInRawBot = rawParsedBot.Inventory.items
diff --git a/Generator/Weighting/WeightingService.cs b/Generator/Weighting/WeightingService.cs
new file mode 100644
index 0000000..4878b3a
--- /dev/null
+++ b/Generator/Weighting/WeightingService.cs
@@ -0,0 +1,47 @@
+using Common.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+
+namespace Generator.Weighting
+{
+
+ public class WeightingService
+ {
+ private readonly Dictionary>> _weights;
+ public WeightingService()
+ {
+
+ var itemsFilePath = $"{Directory.GetCurrentDirectory()}\\Assets\\weights.json";
+ if (!File.Exists(itemsFilePath))
+ {
+ throw new Exception($"Missing weights.json in /assets ({itemsFilePath})");
+ }
+
+ var itemsJson = File.ReadAllText(itemsFilePath);
+ _weights = JsonSerializer.Deserialize>>>(itemsJson);
+ }
+
+ public int GetItemWeight(string tpl, BotType botType, string slot)
+ {
+ if (_weights.ContainsKey(botType))
+ {
+ var botWeights = _weights[botType];
+ if (botWeights.Keys.Contains(slot, StringComparer.CurrentCultureIgnoreCase))
+ {
+ var slotWeights = botWeights.FirstOrDefault(x => x.Key.ToLower() == slot).Value;
+ if (slotWeights.Keys.Contains(tpl, StringComparer.CurrentCultureIgnoreCase))
+ {
+ var itemWeight = slotWeights[tpl];
+ return itemWeight;
+ }
+ }
+ }
+
+ return 1;
+ }
+ }
+}
diff --git a/Generator/Weighting/Weights.cs b/Generator/Weighting/Weights.cs
new file mode 100644
index 0000000..fc8dbf5
--- /dev/null
+++ b/Generator/Weighting/Weights.cs
@@ -0,0 +1,10 @@
+using Common.Models;
+
+namespace Generator.Weighting
+{
+ public class ItemWeights
+ {
+ public Dictionary firstprimaryweapon {get;set;}
+ public Dictionary backpack { get; set; }
+ }
+}