Migrate static ammo values to be per-map

This commit is contained in:
Dev 2024-04-22 22:29:06 +01:00
parent f3c904e1d5
commit 82059d1d13
3 changed files with 93 additions and 38 deletions

View File

@ -141,10 +141,10 @@ public class MultithreadSteppedDumpProcessor : IDumpProcessor
if (LoggerFactory.GetInstance().CanBeLogged(LogLevel.Info)) if (LoggerFactory.GetInstance().CanBeLogged(LogLevel.Info))
LoggerFactory.GetInstance().Log("Processing ammo distribution", LogLevel.Info); LoggerFactory.GetInstance().Log("Processing ammo distribution", LogLevel.Info);
// Ammo distribution // Ammo distribution
//output.Add( output.Add(
// OutputFileType.StaticAmmo, OutputFileType.StaticAmmo,
// StaticLootProcessor.CreateAmmoDistribution(dumpProcessData.ContainerCounts) StaticLootProcessor.CreateAmmoDistribution(dumpProcessData.ContainerCounts)
//); );
if (LoggerFactory.GetInstance().CanBeLogged(LogLevel.Info)) if (LoggerFactory.GetInstance().CanBeLogged(LogLevel.Info))
LoggerFactory.GetInstance().Log("Processing static loot distribution", LogLevel.Info); LoggerFactory.GetInstance().Log("Processing static loot distribution", LogLevel.Info);

View File

@ -4,6 +4,7 @@ using LootDumpProcessor.Model.Output;
using LootDumpProcessor.Model.Output.StaticContainer; using LootDumpProcessor.Model.Output.StaticContainer;
using LootDumpProcessor.Model.Processing; using LootDumpProcessor.Model.Processing;
using LootDumpProcessor.Utils; using LootDumpProcessor.Utils;
using System.Collections.Generic;
namespace LootDumpProcessor.Process.Processor; namespace LootDumpProcessor.Process.Processor;
@ -74,12 +75,24 @@ public static class StaticLootProcessor
return data; return data;
} }
public static Dictionary<string, List<AmmoDistribution>> CreateAmmoDistribution( /// <summary>
List<PreProcessedStaticLoot> container_counts ///
/// </summary>
/// <param name="container_counts"></param>
/// <returns>key = mapid / </returns>
public static Dictionary<string, Dictionary<string, List<AmmoDistribution>>> CreateAmmoDistribution(
Dictionary<string, List<PreProcessedStaticLoot>> container_counts
) )
{ {
var allMapsAmmoDistro = new Dictionary<string, Dictionary<string, List<AmmoDistribution>>>();
foreach (var mapAndContainers in container_counts)
{
var mapid = mapAndContainers.Key;
var containers = mapAndContainers.Value;
var ammo = new List<string>(); var ammo = new List<string>();
foreach (var ci in container_counts) foreach (var ci in containers)
{ {
ammo.AddRange(from item in ci.Items ammo.AddRange(from item in ci.Items
where LootDumpProcessorContext.GetTarkovItems().IsBaseClass(item.Tpl, BaseClasses.Ammo) where LootDumpProcessorContext.GetTarkovItems().IsBaseClass(item.Tpl, BaseClasses.Ammo)
@ -110,7 +123,44 @@ public static class StaticLootProcessor
}).ToList(); }).ToList();
} }
return ammo_distribution; allMapsAmmoDistro.TryAdd(mapid, ammo_distribution);
}
return allMapsAmmoDistro;
//var ammo = new List<string>();
//foreach (var ci in container_counts)
//{
// ammo.AddRange(from item in ci.Items
// where LootDumpProcessorContext.GetTarkovItems().IsBaseClass(item.Tpl, BaseClasses.Ammo)
// select item.Tpl);
//}
//var ammo_counts = new List<CaliberTemplateCount>();
//ammo_counts.AddRange(
// ammo.GroupBy(a => a)
// .Select(g => new CaliberTemplateCount
// {
// Caliber = LootDumpProcessorContext.GetTarkovItems().AmmoCaliber(g.Key),
// Template = g.Key,
// Count = g.Count()
// })
//);
//ammo_counts = ammo_counts.OrderBy(x => x.Caliber).ToList();
//var ammo_distribution = new Dictionary<string, List<AmmoDistribution>>();
//foreach (var _tup_3 in ammo_counts.GroupBy(x => x.Caliber))
//{
// var k = _tup_3.Key;
// var g = _tup_3.ToList();
// ammo_distribution[k] = (from gi in g
// select new AmmoDistribution
// {
// Tpl = gi.Template,
// RelativeProbability = gi.Count
// }).ToList();
//}
//return ammo_distribution;
} }
/// <summary> /// <summary>

View File

@ -77,9 +77,14 @@ public class FileWriter : IWriter
break; break;
case OutputFileType.StaticAmmo: case OutputFileType.StaticAmmo:
var staticAmmo = (Dictionary<string, List<AmmoDistribution>>)data; var staticAmmo = (Dictionary<string, Dictionary<string, List<AmmoDistribution>>>)data;
File.WriteAllText($@"{_outputPath}\loot\staticAmmo.json", foreach (var (key, value) in staticAmmo)
_jsonSerializer.Serialize(staticAmmo)); {
if (!Directory.Exists($@"{_outputPath}\locations\{key}"))
Directory.CreateDirectory($@"{_outputPath}\locations\{key}");
File.WriteAllText($@"{_outputPath}\locations\{key}\staticAmmo.json",
_jsonSerializer.Serialize(value));
}
break; break;
default: default: