Skip to content

Commit

Permalink
Remove more interface usage
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains committed Dec 16, 2024
1 parent 39754c8 commit 305ecdf
Show file tree
Hide file tree
Showing 27 changed files with 67 additions and 68 deletions.
6 changes: 3 additions & 3 deletions ImperatorToCK3/CK3/Characters/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ public string? DeathReason {
}
}

public IList<Pregnancy> Pregnancies { get; } = new List<Pregnancy>();
public List<Pregnancy> Pregnancies { get; } = [];

public IDictionary<string, int> MenAtArmsStacksPerType { get; } = new Dictionary<string, int>();
public Dictionary<string, int> MenAtArmsStacksPerType { get; } = [];

public IDictionary<string, string> PrisonerIds { get; } = new Dictionary<string, string>(); // <prisoner id, imprisonment type>
public Dictionary<string, string> PrisonerIds { get; } = []; // <prisoner id, imprisonment type>

internal DNA? DNA { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3/CK3/Cultures/Culture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace ImperatorToCK3.CK3.Cultures;

public sealed class Culture : IIdentifiable<string>, IPDXSerializable {
internal sealed class Culture : IIdentifiable<string>, IPDXSerializable {
public string Id { get; }
public Color Color { get; }
public OrderedSet<string> ParentCultureIds { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions ImperatorToCK3/CK3/Cultures/CultureData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

namespace ImperatorToCK3.CK3.Cultures;

public record CultureData {
public IEnumerable<string> InvalidatingCultureIds { get; set; } = new List<string>();
internal record CultureData {
public List<string> InvalidatingCultureIds { get; set; } = [];
public Color? Color { get; set; }
public OrderedSet<string> ParentCultureIds { get; set; } = new();
public Pillar? Heritage { get; set; }
public Pillar? Language { get; set; }
public OrderedSet<string> TraditionIds { get; set; } = new();
public OrderedSet<NameList> NameLists { get; } = new();

public IList<KeyValuePair<string, StringOfItem>> Attributes { get; } = new List<KeyValuePair<string, StringOfItem>>();
public List<KeyValuePair<string, StringOfItem>> Attributes { get; } = [];
}
2 changes: 1 addition & 1 deletion ImperatorToCK3/CK3/Cultures/Pillar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace ImperatorToCK3.CK3.Cultures;

public sealed class Pillar : IIdentifiable<string>, IPDXSerializable {
internal sealed class Pillar : IIdentifiable<string>, IPDXSerializable {
public string Id { get; }
public string Type { get; }
public Color? Color { get; }
Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3/CK3/Cultures/PillarCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace ImperatorToCK3.CK3.Cultures;

public sealed class PillarCollection : IdObjectCollection<string, Pillar> {
internal sealed class PillarCollection : IdObjectCollection<string, Pillar> {
private readonly Dictionary<string, string> mergedPillarsDict = [];

public PillarCollection(ColorFactory colorFactory, OrderedDictionary<string, bool> ck3ModFlags) {
Expand Down
8 changes: 4 additions & 4 deletions ImperatorToCK3/CK3/Cultures/PillarData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace ImperatorToCK3.CK3.Cultures;

public record PillarData {
public IEnumerable<string> InvalidatingPillarIds { get; set; } = new List<string>();
internal record PillarData {
public List<string> InvalidatingPillarIds { get; set; } = [];
public string? Type { get; set; }
public Color? Color { get; set; }
public IList<KeyValuePair<string, StringOfItem>> Attributes { get; } = new List<KeyValuePair<string, StringOfItem>>();

public List<KeyValuePair<string, StringOfItem>> Attributes { get; } = [];
}
10 changes: 5 additions & 5 deletions ImperatorToCK3/CK3/Religions/FaithData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace ImperatorToCK3.CK3.Religions;

public record FaithData {
public IEnumerable<string> InvalidatingFaithIds { get; set; } = new List<string>();
internal record FaithData {
public List<string> InvalidatingFaithIds { get; set; } = [];
public Color? Color { get; set; }
public string? ReligiousHeadTitleId { get; set; }
public IList<string> DoctrineIds { get; } = new List<string>();
public IList<string> HolySiteIds { get; init; } = new List<string>();
public List<string> DoctrineIds { get; } = [];
public List<string> HolySiteIds { get; init; } = [];

public IList<KeyValuePair<string, StringOfItem>> Attributes { get; init; } = new List<KeyValuePair<string, StringOfItem>>();
public List<KeyValuePair<string, StringOfItem>> Attributes { get; init; } = [];
}
20 changes: 10 additions & 10 deletions ImperatorToCK3/CK3/Titles/Title.cs
Original file line number Diff line number Diff line change
Expand Up @@ -721,9 +721,9 @@ public Date GetDateOfLastHolderChange() {
return lastDate ?? new Date(1, 1, 1);
}

public ISet<string> GetAllHolderIds() {
public HashSet<string> GetAllHolderIds() {
if (!History.Fields.TryGetValue("holder", out var holderField)) {
return new HashSet<string>();
return [];
}

var ids = new HashSet<string>();
Expand Down Expand Up @@ -980,10 +980,10 @@ public void SetDeFactoLiege(Title? newLiege, Date date) {

private readonly TitleCollection deJureVassals = [];
[SerializeOnlyValue] public IReadOnlyTitleCollection DeJureVassals => deJureVassals; // DIRECT de jure vassals
public IDictionary<string, Title> GetDeJureVassalsAndBelow() {
public Dictionary<string, Title> GetDeJureVassalsAndBelow() {
return GetDeJureVassalsAndBelow("bcdke");
}
public IDictionary<string, Title> GetDeJureVassalsAndBelow(string rankFilter) {
public Dictionary<string, Title> GetDeJureVassalsAndBelow(string rankFilter) {
var rankFilterAsArray = rankFilter.ToCharArray();
Dictionary<string, Title> deJureVassalsAndBelow = new();
foreach (var vassalTitle in DeJureVassals) {
Expand All @@ -1003,14 +1003,14 @@ public IDictionary<string, Title> GetDeJureVassalsAndBelow(string rankFilter) {

return deJureVassalsAndBelow;
}
public IDictionary<string, Title> GetDeFactoVassals(Date date) { // DIRECT de facto vassals
public Dictionary<string, Title> GetDeFactoVassals(Date date) { // DIRECT de facto vassals
return parentCollection.Where(t => t.GetDeFactoLiege(date)?.Id == Id)
.ToDictionary(t => t.Id, t => t);
}
public IDictionary<string, Title> GetDeFactoVassalsAndBelow(Date date) {
public Dictionary<string, Title> GetDeFactoVassalsAndBelow(Date date) {
return GetDeFactoVassalsAndBelow(date, "bcdke");
}
public IDictionary<string, Title> GetDeFactoVassalsAndBelow(Date date, string rankFilter) {
public Dictionary<string, Title> GetDeFactoVassalsAndBelow(Date date, string rankFilter) {
var rankFilterAsArray = rankFilter.ToCharArray();
Dictionary<string, Title> deFactoVassalsAndBelow = new();
foreach (var (vassalTitleName, vassalTitle) in GetDeFactoVassals(date)) {
Expand Down Expand Up @@ -1052,9 +1052,9 @@ public IDictionary<string, Title> GetDeFactoVassalsAndBelow(Date date, string ra
[SerializedName("always_follows_primary_heir")] public bool? AlwaysFollowsPrimaryHeir { get; set; }
[SerializedName("de_jure_drift_disabled")] public bool? DeJureDriftDisabled { get; set; }
[SerializedName("can_be_named_after_dynasty")] public bool? CanBeNamedAfterDynasty { get; set; }
[SerializedName("male_names")] public IList<string>? MaleNames { get; private set; }
[SerializedName("male_names")] public List<string>? MaleNames { get; private set; }
// <culture, loc key>
[SerializedName("cultural_names")] public IDictionary<string, string>? CulturalNames { get; private set; }
[SerializedName("cultural_names")] public Dictionary<string, string>? CulturalNames { get; private set; }

public int? GetOwnOrInheritedDevelopmentLevel(Date date) {
var ownDev = GetDevelopmentLevel(date);
Expand Down Expand Up @@ -1196,7 +1196,7 @@ public async Task OutputHistory(StreamWriter writer) {
await writer.WriteAsync(sb);
}

public ISet<ulong> GetProvincesInCountry(Date date) {
public HashSet<ulong> GetProvincesInCountry(Date date) {
var holderId = GetHolderId(date);
var heldCounties = new List<Title>(
parentCollection.Where(t => t.GetHolderId(date) == holderId && t.Rank == TitleRank.county)
Expand Down
4 changes: 2 additions & 2 deletions ImperatorToCK3/CK3/Wars/War.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ internal sealed class War {
public Date EndDate { get; }
public OrderedSet<string> TargetedTitles { get; } = [];
public string? CasusBelli { get; }
public IList<string> Attackers { get; } = [];
public IList<string> Defenders { get; } = [];
public List<string> Attackers { get; } = [];
public List<string> Defenders { get; } = [];
public string Claimant { get; }

public War(Imperator.Diplomacy.War irWar, Mappers.War.WarMapper warMapper, ProvinceMapper provinceMapper, Imperator.Countries.CountryCollection impCountries, StateCollection irStates, ProvinceCollection ck3Provinces, Title.LandedTitles titles, Date ck3BookmarkDate) {
Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3/CK3/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal sealed class World {
public ReligionCollection Religions { get; }
public IdObjectCollection<string, MenAtArmsType> MenAtArmsTypes { get; } = new();
public MapData MapData { get; private set; } = null!;
public IList<Wars.War> Wars { get; } = new List<Wars.War>();
public List<Wars.War> Wars { get; } = [];
public LegendSeedCollection LegendSeeds { get; } = [];
internal CoaMapper CK3CoaMapper { get; private set; } = null!;
private readonly List<string> enabledDlcFlags = [];
Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3/CommonUtils/Genes/AccessoryGene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace ImperatorToCK3.CommonUtils.Genes;

public sealed class AccessoryGene : Gene, IIdentifiable<string> {
internal sealed class AccessoryGene : Gene, IIdentifiable<string> {
public string Id { get; }
public uint? Index { get; private set; }
public IdObjectCollection<string, AccessoryGeneTemplate> GeneTemplates { get; } = [];
Expand Down
4 changes: 2 additions & 2 deletions ImperatorToCK3/CommonUtils/Genes/AccessoryGeneTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace ImperatorToCK3.CommonUtils.Genes;

public sealed class AccessoryGeneTemplate : IIdentifiable<string> {
internal sealed class AccessoryGeneTemplate : IIdentifiable<string> {
public string Id { get; }
public uint Index { get; private set; } = 0;
public IDictionary<string, WeightBlock> AgeSexWeightBlocks { get; } = new Dictionary<string, WeightBlock>();
public Dictionary<string, WeightBlock> AgeSexWeightBlocks { get; } = [];

public AccessoryGeneTemplate(string id, BufferedReader reader) {
Id = id;
Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3/CommonUtils/Genes/GenesDB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace ImperatorToCK3.CommonUtils.Genes;

public sealed class GenesDB {
internal sealed class GenesDB {
public IdObjectCollection<string, AccessoryGene> AccessoryGenes { get; } = new();
public IdObjectCollection<string, MorphGene> MorphGenes { get; } = new();
public IdObjectCollection<string, AccessoryGene> SpecialAccessoryGenes { get; } = new();
Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3/CommonUtils/Map/MapData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace ImperatorToCK3.CommonUtils.Map;

public sealed class MapData {
internal sealed class MapData {
[StructLayout(LayoutKind.Auto)]
private struct Point(int x, int y) : IEquatable<Point> {
public int X { get; set; } = x;
Expand Down
4 changes: 2 additions & 2 deletions ImperatorToCK3/CommonUtils/Map/ProvinceDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

namespace ImperatorToCK3.CommonUtils.Map;

public sealed class ProvinceDefinitions : IdObjectCollection<ulong, ProvinceDefinition> {
public IDictionary<Rgb24, ulong> ColorToProvinceDict { get; } = new Dictionary<Rgb24, ulong>();
internal sealed class ProvinceDefinitions : IdObjectCollection<ulong, ProvinceDefinition> {
public Dictionary<Rgb24, ulong> ColorToProvinceDict { get; } = [];
public Dictionary<ulong, Rgb24> ProvinceToColorDict { get; } = [];

public void LoadDefinitions(string definitionsFilename, ModFilesystem modFS) {
Expand Down
6 changes: 3 additions & 3 deletions ImperatorToCK3/Imperator/Characters/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ public bool LinkFamily(FamilyCollection families, SortedSet<ulong>? missingDefin
public bool IsDead => DeathDate is not null;
public string? DeathReason { get; set; }
private HashSet<ulong> parsedSpouseIds = [];
public IDictionary<ulong, Character> Spouses { get; set; } = new Dictionary<ulong, Character>();
public Dictionary<ulong, Character> Spouses { get; set; } = [];
public OrderedSet<ulong> FriendIds { get; } = [];
public OrderedSet<ulong> RivalIds { get; } = [];
private HashSet<ulong> parsedChildrenIds = [];
public IDictionary<ulong, Character> Children { get; set; } = new Dictionary<ulong, Character>();
public Dictionary<ulong, Character> Children { get; set; } = [];
private ulong? parsedMotherId;
public Character? Mother { get; set; }
private ulong? parsedFatherId;
Expand All @@ -88,7 +88,7 @@ public Family? Family {
}
}

public IList<string> Traits { get; set; } = [];
public List<string> Traits { get; set; } = [];
public CharacterAttributes Attributes { get; private set; } = new();
public IReadOnlySet<string> Variables { get; private set; } = ImmutableHashSet<string>.Empty;
public bool IsBald => Variables.Contains("bald");
Expand Down
7 changes: 3 additions & 4 deletions ImperatorToCK3/Imperator/Characters/PortraitData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@

namespace ImperatorToCK3.Imperator.Characters;

public sealed class PortraitData {
internal sealed class PortraitData {
public PaletteCoordinates HairColorPaletteCoordinates { get; } = new();
public PaletteCoordinates HairColor2PaletteCoordinates { get; } = new();
public PaletteCoordinates SkinColorPaletteCoordinates { get; } = new();
public PaletteCoordinates SkinColor2PaletteCoordinates { get; } = new();
public PaletteCoordinates EyeColorPaletteCoordinates { get; } = new();
public PaletteCoordinates EyeColor2PaletteCoordinates { get; } = new();

public IDictionary<string, AccessoryGeneData> AccessoryGenesDict { get; } =
new Dictionary<string, AccessoryGeneData>();
public IDictionary<string, MorphGeneData> MorphGenesDict { get; } = new Dictionary<string, MorphGeneData>();
public Dictionary<string, AccessoryGeneData> AccessoryGenesDict { get; } = [];
public Dictionary<string, MorphGeneData> MorphGenesDict { get; } = [];

public PortraitData(string dnaString, GenesDB genesDB, string ageSexString = "male") {
var decodedDnaStr = Convert.FromBase64String(dnaString);
Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3/Imperator/Diplomacy/DiplomacyDB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace ImperatorToCK3.Imperator.Diplomacy;

public sealed class DiplomacyDB {
internal sealed class DiplomacyDB {
private readonly List<War> wars = [];
public IReadOnlyList<War> Wars => wars;

Expand Down
6 changes: 3 additions & 3 deletions ImperatorToCK3/Imperator/Diplomacy/War.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

namespace ImperatorToCK3.Imperator.Diplomacy;

public sealed class War {
internal sealed class War {
public Date StartDate { get; private set; } = new(1, 1, 1);
public bool Previous { get; private set; }
public IList<ulong> AttackerCountryIds { get; } = new List<ulong>();
public IList<ulong> DefenderCountryIds { get; } = new List<ulong>();
public List<ulong> AttackerCountryIds { get; } = [];
public List<ulong> DefenderCountryIds { get; } = [];
public string? WarGoal { get; private set; }
public ulong? TargetedStateId { get; private set; }

Expand Down
4 changes: 2 additions & 2 deletions ImperatorToCK3/Imperator/Jobs/JobsDB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
namespace ImperatorToCK3.Imperator.Jobs;

internal sealed class JobsDB {
public IList<Governorship> Governorships { get; } = [];
public IList<OfficeJob> OfficeJobs { get; } = [];
public List<Governorship> Governorships { get; } = [];
public List<OfficeJob> OfficeJobs { get; } = [];

public JobsDB() { }
public JobsDB(BufferedReader jobsReader, CharacterCollection characters, CountryCollection countries, ImperatorRegionMapper irRegionMapper) {
Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3/Imperator/Provinces/Province.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal sealed partial class Province : IIdentifiable<ulong> {
public State? State { get; private set; } = null;
public Country? OwnerCountry { get; set; }
public ulong Controller { get; set; } = 0;
public IDictionary<ulong, Pop> Pops { get; } = new Dictionary<ulong, Pop>();
public Dictionary<ulong, Pop> Pops { get; } = [];
public ProvinceRank ProvinceRank { get; set; } = ProvinceRank.settlement;
public bool Fort { get; set; } = false;
public bool IsHolySite => HolySiteId is not null;
Expand Down
4 changes: 2 additions & 2 deletions ImperatorToCK3/Mappers/Gene/AccessoryGeneMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
namespace ImperatorToCK3.Mappers.Gene;

public sealed class AccessoryGeneMapper {
private Dictionary<string, IList<Assignment>> ObjectToObjectMappings { get; } = [];
private Dictionary<string, IList<Assignment>> TemplateToTemplateMappings { get; } = [];
private Dictionary<string, List<Assignment>> ObjectToObjectMappings { get; } = [];
private Dictionary<string, List<Assignment>> TemplateToTemplateMappings { get; } = [];

public AccessoryGeneMapper(string mappingsFilePath) {
var objectToObjectMappingsParser = new Parser();
Expand Down
14 changes: 7 additions & 7 deletions ImperatorToCK3/Mappers/Province/ProvinceMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace ImperatorToCK3.Mappers.Province;

public sealed class ProvinceMapper {
private readonly Dictionary<ulong, IList<ulong>> imperatorToCK3ProvinceMap = new();
private readonly Dictionary<ulong, IList<ulong>> ck3ToImperatorProvinceMap = new();
internal sealed class ProvinceMapper {
private readonly Dictionary<ulong, List<ulong>> imperatorToCK3ProvinceMap = [];
private readonly Dictionary<ulong, List<ulong>> ck3ToImperatorProvinceMap = [];

public void LoadMappings(string mappingsPath) {
Logger.Info("Loading province mappings...");
Expand Down Expand Up @@ -50,17 +50,17 @@ private void CreateMappings(ProvinceMappingsVersion mappingsVersion) {
}
}

public IList<ulong> GetImperatorProvinceNumbers(ulong ck3ProvinceNumber) {
public List<ulong> GetImperatorProvinceNumbers(ulong ck3ProvinceNumber) {
if (ck3ToImperatorProvinceMap.TryGetValue(ck3ProvinceNumber, out var impProvs)) {
return impProvs;
}
return new List<ulong>();
return [];
}

public IList<ulong> GetCK3ProvinceNumbers(ulong impProvinceNumber) {
public List<ulong> GetCK3ProvinceNumbers(ulong impProvinceNumber) {
if (imperatorToCK3ProvinceMap.TryGetValue(impProvinceNumber, out var ck3Provs)) {
return ck3Provs;
}
return new List<ulong>();
return [];
}
}
4 changes: 2 additions & 2 deletions ImperatorToCK3/Mappers/Province/ProvinceMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
namespace ImperatorToCK3.Mappers.Province;

internal sealed class ProvinceMapping {
public IList<ulong> CK3Provinces { get; } = new List<ulong>();
public IList<ulong> ImperatorProvinces { get; } = new List<ulong>();
public List<ulong> CK3Provinces { get; } = [];
public List<ulong> ImperatorProvinces { get; } = [];

private static readonly Parser parser = new();
private static ProvinceMapping tempMapping = new();
Expand Down
2 changes: 1 addition & 1 deletion ImperatorToCK3/Mappers/Province/ProvinceMappingsVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace ImperatorToCK3.Mappers.Province;

internal sealed class ProvinceMappingsVersion {
public IList<ProvinceMapping> Mappings { get; } = [];
public List<ProvinceMapping> Mappings { get; } = [];
public ProvinceMappingsVersion() { }
public ProvinceMappingsVersion(BufferedReader reader) {
var referencedImperatorProvs = new HashSet<ulong>();
Expand Down
Loading

0 comments on commit 305ecdf

Please sign in to comment.