Skip to content

Commit 109ef3e

Browse files
Rulebook fixes for Magnificus' Act
1 parent 161ff8e commit 109ef3e

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
- Added 'GBC Vanilla Render' config to community patches (false by default) - makes GBC cards render with vanilla cost sprites
33
- Added 'Vanilla Stacking' config to community patches (false by default) - renders cards with only two (stacking) sigils as they appear in vanilla, eg Spore Mice and Sporedigger
44
- Fixed incorrect rulebook icon scaling in Act 3
5+
- Fixed rulebook-related null errors when playing during Magnificus' Act
6+
- Fixed slot modification rulebook pages not appearing correctly during Magnificus' Act
57
- Fixed cards shield sigils not rendering correctly
68
- DamageShieldBehaviour class now has 'initialised' boolean field
79
- Highest displayable bone cost value in Act 1 raised from 13+ to 15+

InscryptionAPI/Rulebook/RulebookRedirectPatches.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public static class RulebookRedirectPatches
3131
[HarmonyPostfix, HarmonyPatch(typeof(RuleBookController), nameof(RuleBookController.Start))]
3232
private static void CreateRedirectManager(RuleBookController __instance)
3333
{
34-
if (RuleBookRedirectManager.m_Instance == null)
34+
if (__instance.gameObject.GetComponent<RuleBookRedirectManager>() == null)
3535
{
36-
__instance.gameObject.AddComponent<RuleBookRedirectManager>();
36+
RuleBookRedirectManager.m_Instance = __instance.gameObject.AddComponent<RuleBookRedirectManager>();
3737
}
3838
}
3939

InscryptionAPI/Slots/SlotModificationManager.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,12 +551,14 @@ private static void AddSlotModificationsToRuleBook(AbilityMetaCategory metaCateg
551551
return;
552552

553553
int curPageNum = 1;
554-
GameObject itemPrefab = __instance.pageRanges.Find(x => x.type == PageRangeType.Items).rangePrefab;
555-
int insertPosition = __result.FindLastIndex(rbi => itemPrefab) + 1;
554+
PageRangeInfo itemPageRange = __instance.pageRanges.Find(x => x.type == PageRangeType.Items);
555+
PageRangeInfo abilityRange = __instance.pageRanges.Find(x => x.type == PageRangeType.Abilities);
556+
GameObject pagePrefab = (itemPageRange ?? abilityRange).rangePrefab;
557+
int insertPosition = __result.FindLastIndex(rbi => pagePrefab) + 1;
556558
foreach (Info slot in infos)
557559
{
558560
RuleBookPageInfo info = new();
559-
info.pagePrefab = SaveManager.SaveFile.IsPart1 ? itemPrefab : __instance.pageRanges.Find(x => x.type == PageRangeType.Abilities).rangePrefab;
561+
info.pagePrefab = (SaveManager.SaveFile.IsPart1 ? itemPageRange : abilityRange).rangePrefab;
560562
info.headerText = string.Format(Localization.Translate("APPENDIX XII, SUBSECTION I - SLOT EFFECTS {0}"), curPageNum);
561563
info.pageId = SLOT_PAGEID + (int)slot.ModificationType;
562564
__result.Insert(insertPosition, info);
@@ -608,6 +610,7 @@ private static bool OverrideWithSlotInfo(AbilityPage __instance, string headerTe
608610
slotRendererObj?.gameObject.SetActive(false);
609611
__instance.mainAbilityGroup.iconRenderer.transform.parent.gameObject.SetActive(true);
610612

613+
// if this page should be filled with info from a slot modification
611614
if (otherArgs.Length > 0 && otherArgs.Last() is string pageId && pageId.StartsWith(SLOT_PAGEID))
612615
{
613616
string modString = pageId.Replace(SLOT_PAGEID, "");
@@ -635,9 +638,21 @@ private static bool OverrideWithSlotInfo(AbilityPage __instance, string headerTe
635638
__instance.mainAbilityGroup.iconRenderer.transform.parent.gameObject.SetActive(false);
636639
slotRendererObj.GetComponent<SpriteRenderer>().sprite = info.P03RulebookSprite ?? info.RulebookSprite;
637640
}
641+
else if (SaveManager.SaveFile.IsMagnificus)
642+
{
643+
if (slotRendererObj == null)
644+
{
645+
slotRendererObj = Instantiate(__instance.mainAbilityGroup.iconRenderer.transform.parent, __instance.mainAbilityGroup.transform);
646+
slotRendererObj.name = "SlotRenderer";
647+
slotRendererObj.localPosition += new Vector3(0.1f, -0.1f, 0f);
648+
}
649+
slotRendererObj.gameObject.SetActive(true);
650+
__instance.mainAbilityGroup.iconRenderer.transform.parent.gameObject.SetActive(false);
651+
slotRendererObj.GetChild(0).GetComponent<MeshRenderer>().material.mainTexture = (info.MagnificusRulebookSprite ?? info.RulebookSprite).texture;
652+
}
638653
else
639654
{
640-
Debug.Log("Help");
655+
InscryptionAPIPlugin.Logger.LogDebug("Slot modification page: WIP");
641656
}
642657

643658
__instance.mainAbilityGroup.iconRenderer.transform.localScale = new(0.8f, 0.8f, 1f);

0 commit comments

Comments
 (0)