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(
|
||||
$"{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"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -21,3 +21,16 @@ public class HandbookRoot
|
||||
public List<Category> Categories { 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; }
|
||||
}
|
@ -102,7 +102,7 @@ public class MultithreadSteppedDumpProcessor : IDumpProcessor
|
||||
td => new StaticDataPoint
|
||||
{
|
||||
Template = td.Key,
|
||||
Probability = Math.Round((double)((decimal)td.Value / (decimal)mapDumpCounter[kv.Key]), 2)
|
||||
Probability = GetStaticProbability(kv.Key, td, mapDumpCounter)
|
||||
}
|
||||
).ToList()
|
||||
).ToList().ForEach(kv => staticContainers[kv.Key].StaticContainers = kv.Value);
|
||||
@ -136,6 +136,16 @@ public class MultithreadSteppedDumpProcessor : IDumpProcessor
|
||||
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)
|
||||
{
|
||||
var dumpProcessData = new DumpProcessData();
|
||||
|
@ -9,11 +9,13 @@ public class TarkovItems
|
||||
|
||||
private Dictionary<string, TemplateFileItem> _items;
|
||||
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));
|
||||
_handbook = _jsonSerializer.Deserialize<HandbookRoot>(File.ReadAllText(handbook));
|
||||
_streetsStatics = _jsonSerializer.Deserialize<List<StaticContainerRoot>>(File.ReadAllText(streetsStatics));
|
||||
}
|
||||
|
||||
public virtual bool IsBaseClass(string tpl, string baseclass_id)
|
||||
@ -42,4 +44,9 @@ public class TarkovItems
|
||||
var item_template = _items[tpl];
|
||||
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