Skip to content

Commit

Permalink
Removed unnecessary fields in TagsChecker.
Browse files Browse the repository at this point in the history
  • Loading branch information
CptMoore committed Dec 28, 2023
1 parent dbd8b54 commit e4489c3
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions source/CustomComponents/TagRestrictions/TagsChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,16 @@ namespace CustomComponents;

internal class TagsChecker
{
private readonly ChassisDef chassisDef;
private readonly List<MechComponentRef> inventory;

private readonly Dictionary<ChassisLocations, HashSet<string>> tagsOnLocations = new();
private readonly HashSet<string> tagsOnMech = new();
private string error;
private Dictionary<MechValidationType, List<Text>> errors;

internal TagsChecker(MechDef mechDef)
{
chassisDef = mechDef.Chassis;
inventory = mechDef.Inventory.ToList();

if (Control.Settings.TagRestrictionUseMechTags)
{
tagsOnMech.UnionWith(mechDef.MechTags);
}

CollectChassisTags();
CollectComponentTags();
CollectMechTags(mechDef);
CollectChassisTags(mechDef.Chassis);
CollectComponentTags(mechDef.Inventory);
}

internal string Validate(Dictionary<MechValidationType, List<Text>> errors = null)
Expand Down Expand Up @@ -333,7 +323,21 @@ private bool IncompatiblesCheck(
return false;
}

private void CollectChassisTags()
private void CollectMechTags(MechDef mechDef)
{
if (!Control.Settings.TagRestrictionUseMechTags)
{
return;
}

// tags
if (mechDef.MechTags != null)
{
tagsOnMech.UnionWith(mechDef.MechTags);
}
}

private void CollectChassisTags(ChassisDef chassisDef)
{
// tags
if (chassisDef.ChassisTags != null)
Expand All @@ -346,7 +350,7 @@ private void CollectChassisTags()
tagsOnMech.Add(identifier);
}

private void CollectComponentTags()
private void CollectComponentTags(MechComponentRef[] inventory)
{
foreach (var def in inventory)
{
Expand Down

0 comments on commit e4489c3

Please sign in to comment.