Test to see if reading statics data from json is better
This commit is contained in:
parent
1e809dba73
commit
b96e27868c
@ -117,7 +117,8 @@ public class LootDumpProcessorContext
|
|||||||
{
|
{
|
||||||
_tarkovItems = new TarkovItems(
|
_tarkovItems = new TarkovItems(
|
||||||
$"{GetConfig().ServerLocation}/project/assets/database/templates/items.json",
|
$"{GetConfig().ServerLocation}/project/assets/database/templates/items.json",
|
||||||
$"{GetConfig().ServerLocation}/project/assets/database/templates/handbook.json"
|
$"{GetConfig().ServerLocation}/project/assets/database/templates/handbook.json",
|
||||||
|
$"{GetConfig().ServerLocation}/project/assets/database/locations/tarkovstreets/statics.json"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,4 +20,17 @@ public class HandbookRoot
|
|||||||
{
|
{
|
||||||
public List<Category> Categories { get; set; }
|
public List<Category> Categories { get; set; }
|
||||||
public List<HandbookItem> Items { get; set; }
|
public List<HandbookItem> Items { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class StaticContainerRoot
|
||||||
|
{
|
||||||
|
public decimal probability { get; set; }
|
||||||
|
public StaticContainerTemplate template { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class StaticContainerTemplate
|
||||||
|
{
|
||||||
|
public string Id { get; set; }
|
||||||
|
public decimal SpawnChance { get; set; }
|
||||||
|
public bool IsAlwaysSpawn { get; set; }
|
||||||
}
|
}
|
@ -39,7 +39,7 @@ public class MultithreadSteppedDumpProcessor : IDumpProcessor
|
|||||||
// dictionary of maps, that has a dictionary of template and hit count
|
// dictionary of maps, that has a dictionary of template and hit count
|
||||||
var mapStaticContainersAggregated = new Dictionary<string, Dictionary<Template, int>>();
|
var mapStaticContainersAggregated = new Dictionary<string, Dictionary<Template, int>>();
|
||||||
var mapStaticContainersAggregatedLock = new object();
|
var mapStaticContainersAggregatedLock = new object();
|
||||||
|
|
||||||
Runners.Clear();
|
Runners.Clear();
|
||||||
// BSG changed the map data so static containers are now dynamic, so we need to scan all dumps for the static containers.
|
// BSG changed the map data so static containers are now dynamic, so we need to scan all dumps for the static containers.
|
||||||
foreach (var dumped in dumps)
|
foreach (var dumped in dumps)
|
||||||
@ -102,7 +102,7 @@ public class MultithreadSteppedDumpProcessor : IDumpProcessor
|
|||||||
td => new StaticDataPoint
|
td => new StaticDataPoint
|
||||||
{
|
{
|
||||||
Template = td.Key,
|
Template = td.Key,
|
||||||
Probability = Math.Round((double)((decimal)td.Value / (decimal)mapDumpCounter[kv.Key]), 2)
|
Probability = GetStaticProbability(kv.Key, td, mapDumpCounter)
|
||||||
}
|
}
|
||||||
).ToList()
|
).ToList()
|
||||||
).ToList().ForEach(kv => staticContainers[kv.Key].StaticContainers = kv.Value);
|
).ToList().ForEach(kv => staticContainers[kv.Key].StaticContainers = kv.Value);
|
||||||
@ -136,6 +136,16 @@ public class MultithreadSteppedDumpProcessor : IDumpProcessor
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static double GetStaticProbability(string mapName, KeyValuePair<Template, int> td, Dictionary<string, int> mapDumpCounter)
|
||||||
|
{
|
||||||
|
if (mapName == "Streets of Tarkov")
|
||||||
|
{
|
||||||
|
return Math.Round((double)(LootDumpProcessorContext.GetTarkovItems().GetProbabilityByContainerId(td.Key.Id).probability), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.Round((double)((decimal)td.Value / (decimal)mapDumpCounter[mapName]), 2);
|
||||||
|
}
|
||||||
|
|
||||||
private DumpProcessData GetDumpProcessData(List<PartialData> dumps)
|
private DumpProcessData GetDumpProcessData(List<PartialData> dumps)
|
||||||
{
|
{
|
||||||
var dumpProcessData = new DumpProcessData();
|
var dumpProcessData = new DumpProcessData();
|
||||||
|
@ -9,11 +9,13 @@ public class TarkovItems
|
|||||||
|
|
||||||
private Dictionary<string, TemplateFileItem> _items;
|
private Dictionary<string, TemplateFileItem> _items;
|
||||||
private HandbookRoot _handbook;
|
private HandbookRoot _handbook;
|
||||||
|
private List<StaticContainerRoot> _streetsStatics;
|
||||||
|
|
||||||
public TarkovItems(string items, string handbook)
|
public TarkovItems(string items, string handbook, string streetsStatics)
|
||||||
{
|
{
|
||||||
_items = _jsonSerializer.Deserialize<Dictionary<string, TemplateFileItem>>(File.ReadAllText(items));
|
_items = _jsonSerializer.Deserialize<Dictionary<string, TemplateFileItem>>(File.ReadAllText(items));
|
||||||
_handbook = _jsonSerializer.Deserialize<HandbookRoot>(File.ReadAllText(handbook));
|
_handbook = _jsonSerializer.Deserialize<HandbookRoot>(File.ReadAllText(handbook));
|
||||||
|
_streetsStatics = _jsonSerializer.Deserialize<List<StaticContainerRoot>>(File.ReadAllText(streetsStatics));
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool IsBaseClass(string tpl, string baseclass_id)
|
public virtual bool IsBaseClass(string tpl, string baseclass_id)
|
||||||
@ -42,4 +44,9 @@ public class TarkovItems
|
|||||||
var item_template = _items[tpl];
|
var item_template = _items[tpl];
|
||||||
return item_template.Props.Caliber;
|
return item_template.Props.Caliber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual StaticContainerRoot GetProbabilityByContainerId(string id)
|
||||||
|
{
|
||||||
|
return _streetsStatics.FirstOrDefault(x => x.template.Id == id);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user