diff --git a/JotunnModStub/RaceStationLock.cs b/JotunnModStub/RaceStationLock.cs
index ba84346..b7eaab6 100644
--- a/JotunnModStub/RaceStationLock.cs
+++ b/JotunnModStub/RaceStationLock.cs
@@ -77,8 +77,9 @@ namespace RacesOfValheim
}
///
- /// The race in the build panel's requirement row, in the first slot after the materials and
- /// the crafting station - the slots Hud.SetupPieceInfo has just filled or switched off.
+ /// The race in the build panel's requirement row, FIRST: the race decides whether the rest
+ /// matters at all. Hud.SetupPieceInfo has just filled one row per material and one for the
+ /// crafting station; each of those is moved one row to the right, and the race takes row 0.
///
[HarmonyPatch(typeof(Hud), "SetupPieceInfo")]
public static class RaceStation_PieceInfo_Patch
@@ -100,10 +101,13 @@ namespace RacesOfValheim
string[] races = For(piece);
if (races == null || races.Length == 0 || __instance.m_requirementItems == null) return;
- int slot = piece.m_resources.Length + (piece.m_craftingStation != null ? 1 : 0);
- if (slot >= __instance.m_requirementItems.Length) return;
+ GameObject[] rows = __instance.m_requirementItems;
+ int used = piece.m_resources.Length + (piece.m_craftingStation != null ? 1 : 0);
+ if (used >= rows.Length) return;
- GameObject row = __instance.m_requirementItems[slot];
+ for (int i = used; i > 0; i--) CopyRow(rows[i - 1], rows[i]);
+
+ GameObject row = rows[0];
Image icon = row.transform.Find("res_icon")?.GetComponent();
TMP_Text name = row.transform.Find("res_name")?.GetComponent();
TMP_Text amount = row.transform.Find("res_amount")?.GetComponent();
@@ -126,6 +130,34 @@ namespace RacesOfValheim
// Vanilla's blink for a missing crafting station, on the name since there is no number.
name.color = ok || Mathf.Sin(Time.time * 10f) <= 0f ? Color.white : Color.red;
}
+
+ /// Everything SetupRequirement and the station row write, from one row to the next.
+ private static void CopyRow(GameObject from, GameObject to)
+ {
+ to.SetActive(from.activeSelf);
+ foreach (string child in new[] { "res_icon", "res_name", "res_amount" })
+ {
+ Transform a = from.transform.Find(child);
+ Transform b = to.transform.Find(child);
+ if (a == null || b == null) continue;
+ b.gameObject.SetActive(a.gameObject.activeSelf);
+ }
+
+ Image fromIcon = from.transform.Find("res_icon")?.GetComponent();
+ Image toIcon = to.transform.Find("res_icon")?.GetComponent();
+ if (fromIcon != null && toIcon != null) { toIcon.sprite = fromIcon.sprite; toIcon.color = fromIcon.color; }
+
+ foreach (string child in new[] { "res_name", "res_amount" })
+ {
+ TMP_Text a = from.transform.Find(child)?.GetComponent();
+ TMP_Text b = to.transform.Find(child)?.GetComponent();
+ if (a != null && b != null) { b.text = a.text; b.color = a.color; }
+ }
+
+ UITooltip fromTip = from.GetComponent();
+ UITooltip toTip = to.GetComponent();
+ if (fromTip != null && toTip != null) toTip.m_text = fromTip.m_text;
+ }
}
}
}