Fix repair context menu checking for hideout upgrades even when using traders

This commit is contained in:
Tyfon
2024-07-09 11:09:23 -07:00
parent ccdd6f3c21
commit 3038c71ed7
2 changed files with 30 additions and 12 deletions

View File

@@ -41,10 +41,11 @@ namespace UIFixes
{
text = string.Format("<b><color=#C6C4B2>{0}</color></b>", repairer.LocalizedName);
}
else if (repairer is GClass803 repairKit)
else if (R.RepairKit.Type.IsInstanceOfType(repairer))
{
var repairKit = new R.RepairKit(repairer);
float pointsLeft = repairKit.GetRepairPoints();
double amount = repairStrategy.GetRepairPrice(repairAmount, repairKit);
double amount = repairStrategy.GetRepairPrice(repairAmount, repairKit.Value);
string costColor = amount > pointsLeft ? "#FF0000" : "#ADB8BC";
text = string.Format("<b><color=#C6C4B2>{0}</color> <color={1}>({2} {3})</color></b>", repairer.LocalizedName, costColor, Math.Round(amount, 2).ToString(CultureInfo.InvariantCulture), "RP".Localized());
@@ -96,14 +97,21 @@ namespace UIFixes
float repairAmount = GetClampedRepairAmount(repairStrategy);
if (repairer is GClass803 repairKit)
if (R.RepairKit.Type.IsInstanceOfType(repairer))
{
var repairKit = new R.RepairKit(repairer);
float pointsLeft = repairKit.GetRepairPoints();
double amount = repairStrategy.GetRepairPrice(repairAmount, repairKit);
double amount = repairStrategy.GetRepairPrice(repairAmount, repairKit.Value);
if (amount > pointsLeft)
{
return new FailedResult(ERepairStatusWarning.NotEnoughRepairPoints.ToString());
}
// This check is only for repair kits
if (repairStrategy.IsNoCorrespondingArea())
{
return new FailedResult(ERepairStatusWarning.NoCorrespondingArea.ToString());
}
}
else
{
@@ -126,11 +134,6 @@ namespace UIFixes
return new FailedResult(ERepairStatusWarning.BrokenItem.ToString());
}*/
if (repairStrategy.IsNoCorrespondingArea())
{
return new FailedResult(ERepairStatusWarning.NoCorrespondingArea.ToString());
}
return SuccessfulResult.New;
}