Add forced loot system - adds loto item tpls into pocket/backpack/rig slots

This commit is contained in:
Dev 2024-01-03 22:34:16 +00:00
parent 5d9cfa776c
commit deb307fb6f
5 changed files with 2244 additions and 35 deletions

View File

@ -0,0 +1,9 @@
namespace Common.Models.Input
{
public class ForcedLoot
{
public string[] Backpack { get; set; }
public string[] Pockets { get; set; }
public string[] TacticalVest { get; set; }
}
}

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,7 @@ namespace Generator
return; return;
} }
AddLootToContainers(botToUpdate, rawBotsOfSameType); AddLootToContainers(botType, botToUpdate, rawBotsOfSameType);
//foreach (var rawParsedBot in rawBotsOfSameType) //foreach (var rawParsedBot in rawBotsOfSameType)
//{ //{
@ -59,40 +59,7 @@ namespace Generator
return botsWithGear; return botsWithGear;
} }
private static void AddPocketLoot(Bot botToUpdate, Datum rawBot) private static void AddLootToContainers(string botType, Bot botToUpdate, List<Datum> rawBotsOfSameType)
{
// pocket loot
foreach (var lootItem in rawBot.Inventory.items.Where(x => x?.slotId?.StartsWith("pocket") == true))
{
botToUpdate.inventory.items.Pockets.AddUnique(lootItem._tpl);
}
}
private static void AddTacticalVestLoot(Bot botToUpdate, IEnumerable<Datum> rawBots)
{
var tacVestItems = GetItemsStoredInEquipmentItem(rawBots, "TacticalVest");
botToUpdate.inventory.items.TacticalVest.AddRange(tacVestItems);
}
private static void AddBackpackLoot(Bot botToUpdate, IEnumerable<Datum> rawBots)
{
// add generic keys to bosses
if (botToUpdate.botType.IsBoss())
{
botToUpdate.inventory.items.Backpack.AddRange(SpecialLootHelper.GetGenericBossKeys());
}
var backpackItems = GetItemsStoredInEquipmentItem(rawBots, "Backpack");
botToUpdate.inventory.items.Backpack.AddRange(backpackItems);
}
private static void AddSecureContainerLoot(Bot botToUpdate, IEnumerable<Datum> rawBots)
{
var tacVestItems = GetItemsStoredInEquipmentItem(rawBots, "SecuredContainer");
botToUpdate.inventory.items.SecuredContainer.AddRange(tacVestItems);
}
private static void AddLootToContainers(Bot botToUpdate, List<Datum> rawBotsOfSameType)
{ {
var containerDict = new Dictionary<string, List<string>>(); var containerDict = new Dictionary<string, List<string>>();
foreach (var bot in rawBotsOfSameType) foreach (var bot in rawBotsOfSameType)
@ -134,13 +101,24 @@ namespace Generator
} }
} }
var forcedLoot = ForcedLootHelper.GetForcedLoot();
forcedLoot.TryGetValue(botType, out var lootToAdd);
if (backpack != null) if (backpack != null)
{ {
if (lootToAdd?.Backpack != null)
{
botToUpdate.inventory.items.Backpack.AddUniqueRange(lootToAdd.Backpack);
}
botToUpdate.inventory.items.Backpack.AddUniqueRange(containerDict[backpack._id]); botToUpdate.inventory.items.Backpack.AddUniqueRange(containerDict[backpack._id]);
} }
if (pocket != null) if (pocket != null)
{ {
if (lootToAdd?.Pockets != null)
{
botToUpdate.inventory.items.Pockets.AddUniqueRange(lootToAdd.Pockets);
}
botToUpdate.inventory.items.Pockets.AddUniqueRange(containerDict[pocket._id]); botToUpdate.inventory.items.Pockets.AddUniqueRange(containerDict[pocket._id]);
} }
@ -151,6 +129,10 @@ namespace Generator
if (tacVest != null) if (tacVest != null)
{ {
if (lootToAdd?.TacticalVest != null)
{
botToUpdate.inventory.items.TacticalVest.AddUniqueRange(lootToAdd.TacticalVest);
}
botToUpdate.inventory.items.TacticalVest.AddUniqueRange(containerDict[tacVest._id]); botToUpdate.inventory.items.TacticalVest.AddUniqueRange(containerDict[tacVest._id]);
} }

View File

@ -12,6 +12,7 @@
<None Remove="Assets\easy_assault_BotGlobalSettings.txt" /> <None Remove="Assets\easy_assault_BotGlobalSettings.txt" />
<None Remove="Assets\easy_cursedAssault_BotGlobalSettings.txt" /> <None Remove="Assets\easy_cursedAssault_BotGlobalSettings.txt" />
<None Remove="Assets\easy_marksman_BotGlobalSettings.txt" /> <None Remove="Assets\easy_marksman_BotGlobalSettings.txt" />
<None Remove="Assets\forcedLoot.json" />
<None Remove="Assets\hard_assault_BotGlobalSettings.txt" /> <None Remove="Assets\hard_assault_BotGlobalSettings.txt" />
<None Remove="Assets\hard_cursedAssault_BotGlobalSettings.txt" /> <None Remove="Assets\hard_cursedAssault_BotGlobalSettings.txt" />
<None Remove="Assets\hard_marksman_BotGlobalSettings.txt" /> <None Remove="Assets\hard_marksman_BotGlobalSettings.txt" />
@ -174,6 +175,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Include="Assets\forcedLoot.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Page>
<Page Include="Assets\normal_arenaFighterEvent_BotGlobalSettings.txt"> <Page Include="Assets\normal_arenaFighterEvent_BotGlobalSettings.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Page> </Page>

View File

@ -0,0 +1,31 @@
using Common.Models.Input;
using System.Text.Json;
namespace Generator.Helpers.Gear
{
public class ForcedLootHelper
{
static readonly JsonSerializerOptions serialiserOptions = new() { };
private static Dictionary<string, ForcedLoot> forcedLoot;
public static Dictionary<string, ForcedLoot> GetForcedLoot()
{
if (forcedLoot == null)
{
var workingPath = Directory.GetCurrentDirectory();
var assetPath = $"{workingPath}//assets";
var forcedLootFile = Directory.GetFiles(assetPath, "forcedLoot.json", SearchOption.TopDirectoryOnly).FirstOrDefault();
var parsedLoot = ParseJson(File.ReadAllText(forcedLootFile));
forcedLoot = parsedLoot;
}
return forcedLoot;
}
private static Dictionary<string, ForcedLoot> ParseJson(string json)
{
var deSerialisedObject = JsonSerializer.Deserialize<Dictionary<string, ForcedLoot>>(json, serialiserOptions);
return deSerialisedObject;
}
}
}