Skip to content

Commit 868cd6f

Browse files
Fixed positioning errors caused by having multiple custom boss challenge icons
1 parent ba391e1 commit 868cd6f

5 files changed

Lines changed: 24 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<details>
22
<summary>View Changelog</summary>
33

4+
# 2.22.2
5+
- Fixed positioning errors caused by having multiple custom boss challenge icons
6+
47
# 2.22.1
58
- Added IShieldPreventedDamage and IShieldPreventedDamageInHand ability triggers and interfaces
69
- Added TriggerBreakShield, wraps BreakShield in an IEnumerator for additional customisation by modders

InscryptionAPI/Ascension/AscensionChallengePaginator.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,29 +71,37 @@ public void AddPage(List<AscensionChallengeInfo> challengeInfos)
7171
List<AscensionChallengeInfo> bossChallengeInfos = challengeInfos.FindAll(x => x.challengeType.GetFullChallenge().Boss);
7272

7373
// keep track of the number of bosses that are on this page, and account for them when determining how many icons to create
74-
int numBosses = challengeInfos.Count(x => x.challengeType.GetFullChallenge().Boss);
74+
int numBosses = bossChallengeInfos.Count;
7575
int numIcons = Mathf.Min(14, challengeObjectsForPages[0].Count) - numBosses;
7676

7777
// the list index when we begin adding boss icons
7878
int bossStartingIndex = (1 + regularChallengeInfos.Count) / 2;
7979
int numBossesAdded = 0;
8080

81-
//Debug.Log($"NumIcons for Page: {numIcons}: {regularChallengeInfos.Count} {bossChallengeInfos.Count}");
81+
// 14 = regular + boss * 2
82+
//Debug.Log($"NumIcons for Page: {numIcons}: {regularChallengeInfos.Count} {bossChallengeInfos.Count} | {bossStartingIndex}");
8283

8384
for (int i = 0; i < 14; i++)
8485
{
8586
GameObject objectRef = null;
8687

87-
if (i % 7 < bossStartingIndex + numBosses && i % 7 >= bossStartingIndex)
88+
int columnIndex = i % 7;
89+
//Debug.Log($"{i} ({columnIndex}) | {bossStartingIndex + numBosses} / {bossStartingIndex}");
90+
91+
if (columnIndex >= bossStartingIndex && columnIndex < bossStartingIndex + numBosses)
8892
{
93+
//Debug.Log($"In boss column {i}");
8994
if (numBossesAdded < numBosses)
9095
{
96+
//Debug.Log($"Use boss icon");
9197
numBossesAdded++;
9298
objectRef = challengeObjectsForPages[0][14];
9399
}
94100
else
95101
{
96-
i += numBosses;
102+
//Debug.Log($"Skip to end");
103+
i += numBosses - 1; // account for loop iteration
104+
continue;
97105
}
98106
}
99107

@@ -117,21 +125,22 @@ public void AddPage(List<AscensionChallengeInfo> challengeInfos)
117125
int infoCount = challengeInfos.Count;
118126
for (int i = 0; i < newPage.Count; i++)
119127
{
120-
//Debug.Log($"Checking icon [{i}] info {infoIdx}");
128+
AscensionChallengeInfo info = challengeInfos[infoIdx];
121129
AscensionIconInteractable interactable = newPage[i].GetComponent<AscensionIconInteractable>();
122-
130+
//Debug.Log($"Checking icon [{i}] info at {infoIdx} : {info.title}");
123131
if (i < infoCount)
124132
{
125133
// if we're assigning boss info to an icon that isn't a boss icon
126-
if (challengeInfos[infoIdx].GetFullChallenge().Boss && (interactable.coll2D as BoxCollider2D).size.y < 1f)
134+
if (info.GetFullChallenge().Boss && (interactable.coll2D as BoxCollider2D).size.y < 1f)
127135
{
136+
//Debug.Log("Boss error: y < 1");
128137
interactable.challengeInfo = missingChallengeInfo;
129138
newPage[i].AddComponent<NoneChallengeDisplayer>();
130139
infoCount++;
131140
}
132141
else
133142
{
134-
interactable.challengeInfo = challengeInfos[infoIdx];
143+
interactable.challengeInfo = info;
135144
infoIdx++;
136145
}
137146
}

InscryptionAPI/Ascension/ChallengeDisplayerPlus.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public static ChallengeDisplayerPlus TryAddChallengeDisplayerPlusToDisplayer(Asc
2626
if (plus.incompatibilityText == null)
2727
{
2828
GameObject cloned = Instantiate(displayer.titleText.gameObject);
29+
cloned.name = "PixelTextLine_INCOMPATIBLE";
2930
cloned.transform.parent = displayer.titleText.transform.parent;
3031
float y = plus.originalTitlePos;
3132
if (displayer.descriptionText != null)
@@ -47,6 +48,7 @@ public static ChallengeDisplayerPlus TryAddChallengeDisplayerPlusToDisplayer(Asc
4748
if (plus.dependencyText == null)
4849
{
4950
GameObject cloned = Instantiate(displayer.titleText.gameObject);
51+
cloned.name = "PixelTextLine_DEPENDENCY";
5052
cloned.transform.parent = displayer.titleText.transform.parent;
5153
float y = plus.originalTitlePos;
5254
if (displayer.descriptionText != null)

InscryptionAPI/InscryptionAPI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<DebugType>full</DebugType>
1111
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1212
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
13-
<Version>2.22.1</Version>
13+
<Version>2.22.2</Version>
1414
</PropertyGroup>
1515

1616
<PropertyGroup>

InscryptionAPI/InscryptionAPIPlugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class InscryptionAPIPlugin : BaseUnityPlugin
3030
{
3131
public const string ModGUID = "cyantist.inscryption.api";
3232
public const string ModName = "InscryptionAPI";
33-
public const string ModVer = "2.22.0";
33+
public const string ModVer = "2.22.2";
3434

3535
public static string Directory = "";
3636

0 commit comments

Comments
 (0)