Skip to content

Commit 5dad2f1

Browse files
Proper support for assists (challenges with negative costs)
1 parent e3b29c4 commit 5dad2f1

2 files changed

Lines changed: 34 additions & 16 deletions

File tree

InscryptionAPI/Challenges/AscensionChallengePaginator.cs

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
using DiskCardGame;
2-
using System;
32
using System.Linq;
4-
using HarmonyLib;
5-
using Mono.Collections.Generic;
6-
using Sirenix.Serialization.Utilities;
73
using UnityEngine;
8-
using System.Diagnostics.CodeAnalysis;
94
using System.Collections.Generic;
105

116
namespace InscryptionAPI.Challenges
@@ -26,16 +21,10 @@ public class AscensionChallengePaginator : MonoBehaviour
2621

2722
public List<List<bool>> pageStates = new();
2823

29-
public void GeneratePages()
24+
private void PageBuilder(List<AscensionChallengeInfo> challenges, int startIdx)
3025
{
31-
// The first page is nice and easy
32-
List<AscensionChallengeInfo> pageOne = new List<AscensionChallengeInfo>();
33-
pageOne.AddRange(availableChallenges.GetRange(0, 14));
34-
pages.Add(pageOne);
35-
36-
// The rest get more challenging
3726
List<AscensionChallengeInfo> curPage = new List<AscensionChallengeInfo>();
38-
for (int i = 14; i < availableChallenges.Count; i++)
27+
for (int i = startIdx; i < challenges.Count; i++)
3928
{
4029
// Check to see if we need a new page
4130
if (curPage.Count == 14)
@@ -47,13 +36,31 @@ public void GeneratePages()
4736
// Check to see if we need a blank buffer
4837
// This happens if the next icon is the same as the current, and the
4938
// current icon would be on the bottom row
50-
if (i < availableChallenges.Count - 1 && availableChallenges[i + 1].challengeType == availableChallenges[i].challengeType && curPage.Count % 2 == 1)
39+
if (i < challenges.Count - 1 && challenges[i + 1].challengeType == challenges[i].challengeType && curPage.Count % 2 == 1)
5140
curPage.Add(null);
5241

53-
curPage.Add(availableChallenges[i]);
42+
curPage.Add(challenges[i]);
5443
}
55-
5644
pages.Add(curPage);
45+
}
46+
47+
public void GeneratePages()
48+
{
49+
// The first page is nice and easy
50+
List<AscensionChallengeInfo> pageOne = new List<AscensionChallengeInfo>();
51+
pageOne.AddRange(availableChallenges.GetRange(0, 14));
52+
pages.Add(pageOne);
53+
54+
// Do the challenges first:
55+
List<AscensionChallengeInfo> challenges = availableChallenges.Where(i => i.pointValue > 0).ToList();
56+
List<AscensionChallengeInfo> assists = availableChallenges.Where(i => i.pointValue < 0).ToList();
57+
58+
// Do the challenges
59+
if (challenges.Count > 14)
60+
PageBuilder(challenges, 14);
61+
62+
if (assists.Count > 0)
63+
PageBuilder(assists, 0);
5764

5865
while (pageStates.Count < pages.Count)
5966
{

InscryptionAPI/Challenges/AscensionChallengeScreen.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ public static void ReassignableIconFixes(ref AscensionIconInteractable __instanc
2626
{
2727
if (info.activatedSprite == null)
2828
__instance.activatedRenderer.sprite = DEFAULT_ACTIVATED_SPRITE;
29+
30+
if (info.pointValue > 0)
31+
{
32+
__instance.blinkEffect.blinkOffColor = GameColors.Instance.red;
33+
__instance.iconRenderer.color = GameColors.Instance.red;
34+
}
35+
else
36+
{
37+
__instance.blinkEffect.blinkOffColor = GameColors.Instance.darkLimeGreen;
38+
__instance.iconRenderer.color = GameColors.Instance.darkLimeGreen;
39+
}
2940
}
3041

3142
[HarmonyPatch(typeof(AscensionMenuScreens), "ConfigurePostGameScreens")]

0 commit comments

Comments
 (0)