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))
|
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);
|
||||||
|
@ -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,43 +75,92 @@ 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 ammo = new List<string>();
|
var allMapsAmmoDistro = new Dictionary<string, Dictionary<string, List<AmmoDistribution>>>();
|
||||||
foreach (var ci in container_counts)
|
foreach (var mapAndContainers in container_counts)
|
||||||
{
|
{
|
||||||
ammo.AddRange(from item in ci.Items
|
var mapid = mapAndContainers.Key;
|
||||||
where LootDumpProcessorContext.GetTarkovItems().IsBaseClass(item.Tpl, BaseClasses.Ammo)
|
var containers = mapAndContainers.Value;
|
||||||
select item.Tpl);
|
|
||||||
|
|
||||||
|
var ammo = new List<string>();
|
||||||
|
foreach (var ci in containers)
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
allMapsAmmoDistro.TryAdd(mapid, ammo_distribution);
|
||||||
}
|
}
|
||||||
|
|
||||||
var ammo_counts = new List<CaliberTemplateCount>();
|
return allMapsAmmoDistro;
|
||||||
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;
|
//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>
|
||||||
|
@ -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:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user