Migrate static ammo values to be per-map
This commit is contained in:
parent
f3c904e1d5
commit
82059d1d13
@ -141,10 +141,10 @@ public class MultithreadSteppedDumpProcessor : IDumpProcessor
|
||||
if (LoggerFactory.GetInstance().CanBeLogged(LogLevel.Info))
|
||||
LoggerFactory.GetInstance().Log("Processing ammo distribution", LogLevel.Info);
|
||||
// Ammo distribution
|
||||
//output.Add(
|
||||
// OutputFileType.StaticAmmo,
|
||||
// StaticLootProcessor.CreateAmmoDistribution(dumpProcessData.ContainerCounts)
|
||||
//);
|
||||
output.Add(
|
||||
OutputFileType.StaticAmmo,
|
||||
StaticLootProcessor.CreateAmmoDistribution(dumpProcessData.ContainerCounts)
|
||||
);
|
||||
|
||||
if (LoggerFactory.GetInstance().CanBeLogged(LogLevel.Info))
|
||||
LoggerFactory.GetInstance().Log("Processing static loot distribution", LogLevel.Info);
|
||||
|
@ -4,6 +4,7 @@ using LootDumpProcessor.Model.Output;
|
||||
using LootDumpProcessor.Model.Output.StaticContainer;
|
||||
using LootDumpProcessor.Model.Processing;
|
||||
using LootDumpProcessor.Utils;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LootDumpProcessor.Process.Processor;
|
||||
|
||||
@ -74,12 +75,24 @@ public static class StaticLootProcessor
|
||||
return data;
|
||||
}
|
||||
|
||||
public static Dictionary<string, List<AmmoDistribution>> CreateAmmoDistribution(
|
||||
List<PreProcessedStaticLoot> container_counts
|
||||
/// <summary>
|
||||
///
|
||||
/// </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>();
|
||||
foreach (var ci in container_counts)
|
||||
foreach (var ci in containers)
|
||||
{
|
||||
ammo.AddRange(from item in ci.Items
|
||||
where LootDumpProcessorContext.GetTarkovItems().IsBaseClass(item.Tpl, BaseClasses.Ammo)
|
||||
@ -110,7 +123,44 @@ public static class StaticLootProcessor
|
||||
}).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>
|
||||
|
@ -77,9 +77,14 @@ public class FileWriter : IWriter
|
||||
|
||||
break;
|
||||
case OutputFileType.StaticAmmo:
|
||||
var staticAmmo = (Dictionary<string, List<AmmoDistribution>>)data;
|
||||
File.WriteAllText($@"{_outputPath}\loot\staticAmmo.json",
|
||||
_jsonSerializer.Serialize(staticAmmo));
|
||||
var staticAmmo = (Dictionary<string, Dictionary<string, List<AmmoDistribution>>>)data;
|
||||
foreach (var (key, value) in staticAmmo)
|
||||
{
|
||||
if (!Directory.Exists($@"{_outputPath}\locations\{key}"))
|
||||
Directory.CreateDirectory($@"{_outputPath}\locations\{key}");
|
||||
File.WriteAllText($@"{_outputPath}\locations\{key}\staticAmmo.json",
|
||||
_jsonSerializer.Serialize(value));
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user