From 095fc983bee5c0311549a3ad1ebaf265c4246108 Mon Sep 17 00:00:00 2001 From: Martynas Gestautas Date: Wed, 1 Sep 2021 18:39:09 +0300 Subject: [PATCH] Fixed issue with required slot detection --- Generator/Helpers/Gear/GearChanceHelpers.cs | 45 +-------- Generator/Models/Output/Output.cs | 101 +------------------- Generator/Program.cs | 2 +- 3 files changed, 4 insertions(+), 144 deletions(-) diff --git a/Generator/Helpers/Gear/GearChanceHelpers.cs b/Generator/Helpers/Gear/GearChanceHelpers.cs index b60790c..c9c5b03 100644 --- a/Generator/Helpers/Gear/GearChanceHelpers.cs +++ b/Generator/Helpers/Gear/GearChanceHelpers.cs @@ -1,5 +1,4 @@ -using Generator.Models; -using Generator.Models.Input; +using Generator.Models.Input; using Generator.Models.Output; using System.Collections.Generic; using System.Linq; @@ -39,7 +38,7 @@ namespace Generator.Helpers.Gear var template = ItemTemplateHelper.GetTemplateById(inventoryItem._tpl); var parentTemplate = ItemTemplateHelper.GetTemplateById(baseBot.Inventory.items.Single(i => i._id == inventoryItem.parentId)._tpl); - if ((inventoryItem.slotId?.StartsWith("mod_") ?? false) && (parentTemplate?._props?.Slots?.FirstOrDefault(s => s._name == inventoryItem.slotId)?._required ?? false)) + if ((inventoryItem.slotId?.StartsWith("mod_") ?? false) && !(parentTemplate?._props?.Slots?.FirstOrDefault(s => s._name == inventoryItem.slotId)?._required ?? false)) { if (modCounts.ContainsKey(inventoryItem.slotId)) { @@ -74,46 +73,6 @@ namespace Generator.Helpers.Gear } } } - // muzzleCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_muzzle"); - // barrelCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_barrel"); - // handguardCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_handguard"); - // stockCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_stock"); - // magazineCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_magazine"); - // mountCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_mount"); - // flashlightCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_flashlight"); - // tactical001Count += baseBot.Inventory.items.Count(x => x.slotId == "mod_tactical_001"); - // tactical002Count += baseBot.Inventory.items.Count(x => x.slotId == "mod_tactical_002"); - // tactical003Count += baseBot.Inventory.items.Count(x => x.slotId == "mod_tactical_003"); - // mount000Count += baseBot.Inventory.items.Count(x => x.slotId == "mod_mount_000"); - // pistolGripCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_pistol_grip"); - // tacticalCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_tactical"); - // scopeCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_scope"); - // recieverCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_reciever"); - // sightRearCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_sight_rear"); - // chargeCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_charge"); - // mount001Count += baseBot.Inventory.items.Count(x => x.slotId == "mod_mount_001"); - // equipmentCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_equipment"); - // gasBlockCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_gas_block"); - // launcherCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_launcher"); - // sightFrontCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_sight_front"); - // stock000Count += baseBot.Inventory.items.Count(x => x.slotId == "mod_stock_000"); - // foregripCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_foregrip"); - // tactical000Count += baseBot.Inventory.items.Count(x => x.slotId == "mod_tactical_000"); - // nvgCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_nvg"); - // pistolGripAkmsCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_pistol_grip_akms"); - // stockAkmsCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_stock_akms"); - // equipment000Count += baseBot.Inventory.items.Count(x => x.slotId == "mod_equipment_000"); - // equipment001Count += baseBot.Inventory.items.Count(x => x.slotId == "mod_equipment_001"); - // equipment002Count += baseBot.Inventory.items.Count(x => x.slotId == "mod_equipment_002"); - // bipodCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_bipod"); - // mount002Count += baseBot.Inventory.items.Count(x => x.slotId == "mod_mount_002"); - // mount004Count += baseBot.Inventory.items.Count(x => x.slotId == "mod_mount_004"); - // triggerCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_trigger"); - // hammerCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_hammer"); - // catchCount += baseBot.Inventory.items.Count(x => x.slotId == "mod_catch"); - // stock001Count += baseBot.Inventory.items.Count(x => x.slotId == "mod_stock_001"); - // muzzle000Count += baseBot.Inventory.items.Count(x => x.slotId == "mod_muzzle_000"); - // mount003Count += baseBot.Inventory.items.Count(x => x.slotId == "mod_mount_003"); } bot.chances.mods = slotCounts.ToDictionary( diff --git a/Generator/Models/Output/Output.cs b/Generator/Models/Output/Output.cs index f22238f..33e01f0 100644 --- a/Generator/Models/Output/Output.cs +++ b/Generator/Models/Output/Output.cs @@ -170,106 +170,7 @@ namespace Generator.Models.Output public int Pockets { get; set; } public int SecuredContainer { get; set; } } - - // public class Mods - // { - // public Mods(int muzzle, int barrel, int handguard, int stock, - // int magazine, int mount, int flashlight, int tactical_001, - // int tactical_002, int tactical_003, int mount_000, int pistol_grip, - // int tactical, int scope, int reciever, int sight_rear, - // int charge, int mount_001, int equipment, int gas_block, - // int launcher, int sight_front, int stock_000, int foregrip, - // int tactical_000, int nvg, int pistol_grip_akms, int stock_akms, - // int equipment_000, int equipment_001, int equipment_002, int bipod, - // int mount_002, int mount_004, int trigger, int hammer, int _catch, - // int stock_001, int muzzle_000, int mount_003) - // { - // mod_muzzle = muzzle; - // mod_barrel = barrel; - // mod_handguard = handguard; - // mod_stock = stock; - // mod_magazine = magazine; - // mod_mount = mount; - // mod_flashlight = flashlight; - // mod_tactical_001 = tactical_001; - // mod_tactical_002 = tactical_002; - // mod_tactical_003 = tactical_003; - // mod_mount_000 = mount_000; - // mod_pistol_grip = pistol_grip; - // mod_tactical = tactical; - // mod_scope = scope; - // mod_reciever = reciever; - // mod_sight_rear = sight_rear; - // mod_charge = charge; - // mod_mount_001 = mount_001; - // mod_equipment = equipment; - // mod_gas_block = gas_block; - // mod_launcher = launcher; - // mod_sight_front = sight_front; - // mod_stock_000 = stock_000; - // mod_foregrip = foregrip; - // mod_tactical_000 = tactical_000; - // mod_nvg = nvg; - // mod_pistol_grip_akms = pistol_grip_akms; - // mod_stock_akms = stock_akms; - // mod_equipment_000 = equipment_000; - // mod_equipment_001 = equipment_001; - // mod_equipment_002 = equipment_002; - // mod_bipod = bipod; - // mod_mount_002 = mount_002; - // mod_mount_004 = mount_004; - // mod_trigger = trigger; - // mod_hammer = hammer; - // mod_catch = _catch; - // mod_stock_001 = stock_001; - // mod_muzzle_000 = muzzle_000; - // mod_mount_003 = mount_003; - // - // - // } - // - // public int mod_muzzle { get; set; } - // public int mod_mount { get; set; } - // public int mod_barrel { get; set; } - // public int mod_handguard { get; set; } - // public int mod_stock { get; set; } - // public int mod_flashlight { get; set; } - // public int mod_tactical_001 { get; set; } - // public int mod_tactical_002 { get; set; } - // public int mod_tactical_003 { get; set; } - // public int mod_mount_000 { get; set; } - // public int mod_magazine { get; set; } - // public int mod_pistol_grip { get; set; } - // public int mod_gas_block { get; set; } - // public int mod_reciever { get; set; } - // public int mod_charge { get; set; } - // public int mod_sight_rear { get; set; } - // public int mod_launcher { get; set; } - // public int mod_equipment { get; set; } - // public int mod_scope { get; set; } - // public int mod_mount_001 { get; set; } - // public int mod_mount_002 { get; set; } - // public int mod_mount_004 { get; set; } - // public int mod_tactical { get; set; } - // public int mod_stock_000 { get; set; } - // public int mod_sight_front { get; set; } - // public int mod_pistol_grip_akms { get; set; } - // public int mod_stock_akms { get; set; } - // public int mod_foregrip { get; set; } - // public int mod_tactical_000 { get; set; } - // public int mod_nvg { get; set; } - // public int mod_equipment_000 { get; set; } - // public int mod_equipment_001 { get; set; } - // public int mod_equipment_002 { get; set; } - // public int mod_bipod { get; set; } - // public int mod_trigger { get; set; } - // public int mod_hammer { get; set; } - // public int mod_catch { get; set; } - // public int mod_stock_001 { get; set; } - // public int mod_muzzle_000 { get; set; } - // public int mod_mount_003 { get; set; } - // } - + public class GenerationChances { public GenerationChances(int specialMin, int SpecialMax, diff --git a/Generator/Program.cs b/Generator/Program.cs index 4d9733a..8bc5cce 100644 --- a/Generator/Program.cs +++ b/Generator/Program.cs @@ -51,7 +51,7 @@ namespace Generator // Generate the base bot class and add basic details (health/body part hp etc) var baseBotGenerator = new BaseBotGenerator(parsedBots, workingPath, botTypes); var baseBots = baseBotGenerator.AddBaseDetails(); - + // Add weapons/armor to bots var botGearGenerator = new BotGearGenerator(baseBots, parsedBots); var botsWithGear = botGearGenerator.AddGear();