Pdoxcl2Sharp
Pdoxcl2Sharp copied to clipboard
Can't read Victoria 3 files
I might miss something, as it's the first time I use this parser 00_building_groups.txt This files is like a dictionnary : 1 string lead to 1 data mapping a class. So I wrote a console program to parse this file from Victoria 3, and I could not get a result.
string filename = @"C:\Program Files (x86)\Steam\steamapps\common\Victoria 3\game\common\building_groups\00_building_groups.txt";
Dictionary<string, Vic3ToolConsole.Model.building_group> bg = new();
using (FileStream filestream = new FileStream(filename, FileMode.Open))
{
bg = Pdoxcl2Sharp.ParadoxParser.Deserialize<Dictionary<string, Vic3ToolConsole.Model.building_group>>(filestream);
}
Console.ReadLine();
I only get 1 item, with a wrong key.
Here is the model :
namespace Vic3ToolConsole.Model
{
public class building_group
{
public string? parent_group { get; set; } = null;
public bool always_possible { get; set; } = false;
public bool economy_of_scale { get; set; } = false;
public bool is_subsistence { get; set; } = false;
public string? default_building { get; set; } = null;
public string? lens { get; set; } = null;
public bool auto_place_buildings { get; set; } = false;
public bool capped_by_resources { get; set; } = false;
public bool discoverable_resource { get; set; } = false;
public bool depletable_resource { get; set; } = false;
public bool can_use_slaves { get; set; } = false;
public string? land_usage { get; set; } = null;
public int cash_reserves_max { get; set; } = 0;
public bool? inheritable_construction { get; set; } = null;
public bool? stateregion_max_level { get; set; } = null;
public int? urbanization { get; set; } = null;
public ExpandMethod? should_auto_expand { get; set; }
public int? hiring_rate { get; set; }
public int? proportionality_limit { get; set; }
public bool hires_unemployed_only { get; set; } = false;
}
public class ExpandMethod
{
bool default_auto_expand_rule { get; set; } = false;
}
}
I've had some success with wrapping the input like { <insert building groups.txt> } and deserializing that way. I'm not sure why this is required, and I'm too time strapped to look into the issue further.