forked from chomp/BotGenerator
Add forced loot system - adds loto item tpls into pocket/backpack/rig slots
This commit is contained in:
parent
5d9cfa776c
commit
deb307fb6f
9
Common.Models/Input/ForcedLoot.cs
Normal file
9
Common.Models/Input/ForcedLoot.cs
Normal 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; }
|
||||
}
|
||||
}
|
2183
Generator/Assets/forcedLoot.json
Normal file
2183
Generator/Assets/forcedLoot.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -37,7 +37,7 @@ namespace Generator
|
||||
return;
|
||||
}
|
||||
|
||||
AddLootToContainers(botToUpdate, rawBotsOfSameType);
|
||||
AddLootToContainers(botType, botToUpdate, rawBotsOfSameType);
|
||||
|
||||
//foreach (var rawParsedBot in rawBotsOfSameType)
|
||||
//{
|
||||
@ -59,40 +59,7 @@ namespace Generator
|
||||
return botsWithGear;
|
||||
}
|
||||
|
||||
private static void AddPocketLoot(Bot botToUpdate, Datum rawBot)
|
||||
{
|
||||
// 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)
|
||||
private static void AddLootToContainers(string botType, Bot botToUpdate, List<Datum> rawBotsOfSameType)
|
||||
{
|
||||
var containerDict = new Dictionary<string, List<string>>();
|
||||
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 (lootToAdd?.Backpack != null)
|
||||
{
|
||||
botToUpdate.inventory.items.Backpack.AddUniqueRange(lootToAdd.Backpack);
|
||||
}
|
||||
botToUpdate.inventory.items.Backpack.AddUniqueRange(containerDict[backpack._id]);
|
||||
}
|
||||
|
||||
if (pocket != null)
|
||||
{
|
||||
if (lootToAdd?.Pockets != null)
|
||||
{
|
||||
botToUpdate.inventory.items.Pockets.AddUniqueRange(lootToAdd.Pockets);
|
||||
}
|
||||
botToUpdate.inventory.items.Pockets.AddUniqueRange(containerDict[pocket._id]);
|
||||
}
|
||||
|
||||
@ -151,6 +129,10 @@ namespace Generator
|
||||
|
||||
if (tacVest != null)
|
||||
{
|
||||
if (lootToAdd?.TacticalVest != null)
|
||||
{
|
||||
botToUpdate.inventory.items.TacticalVest.AddUniqueRange(lootToAdd.TacticalVest);
|
||||
}
|
||||
botToUpdate.inventory.items.TacticalVest.AddUniqueRange(containerDict[tacVest._id]);
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
<None Remove="Assets\easy_assault_BotGlobalSettings.txt" />
|
||||
<None Remove="Assets\easy_cursedAssault_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_cursedAssault_BotGlobalSettings.txt" />
|
||||
<None Remove="Assets\hard_marksman_BotGlobalSettings.txt" />
|
||||
@ -174,6 +175,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Include="Assets\forcedLoot.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Page>
|
||||
<Page Include="Assets\normal_arenaFighterEvent_BotGlobalSettings.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Page>
|
||||
|
31
Generator/Helpers/Gear/ForcedLootHelper.cs
Normal file
31
Generator/Helpers/Gear/ForcedLootHelper.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user