Skip to content

Commit

Permalink
Merge pull request #291 from HumabHatterZed/main
Browse files Browse the repository at this point in the history
2.18.6 fixes
  • Loading branch information
IngoHHacks authored Dec 6, 2023
2 parents eb3fd0d + 691d6df commit 3289b23
Show file tree
Hide file tree
Showing 27 changed files with 351 additions and 275 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
<details>
<summary>View Changelog</summary>

## 2.18.6
- Added missing null checks to ResourceDrone patches
- Added pixel icon to Transformer
- Fixed Royal fight softlocking if config option 'Hide Act 1 Scenery' is set to true
- Fixed activated custom challenges not remaining activated when returning to the challenge screen
- Fixed TransformIntoCardInHand and TransformIntoCardAboveHand not checking for TriggersOncePerStack
- Transformer sigil icon will now display the number of turns till evolution if it's greater than 1
- Transformer and Fledgling sigils now correctly update their display when evolving into another card with the Fledgling/Transformer sigil
- Certain shield-giving effects no longer reset shields to prevent incorrect shield totals
- Improved the 'Custom Card Costs' section of the wiki

## 2.18.5
- Added missing null checks
- Added PlayableCard.GetStatIconHealthBuffs()
Expand Down
72 changes: 28 additions & 44 deletions InscryptionAPI/Ascension/AscensionChallengePaginator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,26 @@ public void Initialize(AscensionChallengeScreen screen, AscensionMenuScreenTrans
{
if (challengeObjectsForPages == null)
{
List<GameObject> toSort = new();
if (screen != null)
{
pageLength = screen.icons.Count;
List<GameObject> toSort = screen.icons.ConvertAll((x) => x.gameObject);
challengeObjectsForPages = new List<List<GameObject>>
{
toSort
};
toSort = screen.icons.ConvertAll((x) => x.gameObject);
}
else
{
List<AscensionIconInteractable> icons = new(transition.screenInteractables.FindAll((x) => x.GetComponent<AscensionIconInteractable>() != null).ConvertAll((x) =>
x.GetComponent<AscensionIconInteractable>()));
List<AscensionIconInteractable> icons = new(
transition.screenInteractables.FindAll((x) => x.GetComponent<AscensionIconInteractable>() != null)
.ConvertAll((x) => x.GetComponent<AscensionIconInteractable>())
);
pageLength = icons.Count;
List<GameObject> toSort = icons.ConvertAll((x) => x.gameObject);
challengeObjectsForPages = new List<List<GameObject>>
{
toSort
};
toSort = icons.ConvertAll((x) => x.gameObject);
}
challengeObjectsForPages = new List<List<GameObject>> { toSort };
}
this.screen = screen;
if (screen == null)
{
this.transition = transition;
}
}

public void AddPage(List<AscensionChallengeInfo> page)
Expand Down Expand Up @@ -92,48 +86,45 @@ public void AddPage(List<AscensionChallengeInfo> page)
public void NextPage()
{
pageIndex++;
if (pageIndex >= challengeObjectsForPages.Count)
{
if (pageIndex >= challengeObjectsForPages.Count) // wrap-around
pageIndex = 0;
}

LoadPage(pageIndex);
}

public void PreviousPage()
{
pageIndex--;
if (pageIndex < 0)
{
pageIndex = challengeObjectsForPages.Count - 1;
}
pageIndex = challengeObjectsForPages.Count - 1; // wrap-around

LoadPage(pageIndex);
}

public void LoadPage(int page)
{
// if page index corresponds to an index in challengeObjects
if (page >= 0 && page < challengeObjectsForPages.Count)
{
// for every list of objects
for (int i = 0; i < challengeObjectsForPages.Count; i++)
{
var value = challengeObjectsForPages[i];
List<GameObject> value = challengeObjectsForPages[i];
value.RemoveAll(x => x == null); // remove null game objects
if (i == page)
{
value.RemoveAll(x => x == null);
value.ForEach((x) =>
value.ForEach(x =>
{
if (x != null)
{
x?.SetActive(
x?.GetComponentInChildren<AscensionIconInteractable>()?.Info == null ||
x?.GetComponentInChildren<AscensionIconInteractable>().Info.challengeType != AscensionChallenge.FinalBoss ||
AscensionUnlockSchedule.ChallengeIsUnlockedForLevel(AscensionChallenge.FinalBoss, AscensionSaveData.Data.challengeLevel));
}
AscensionChallenge currentChallenge = x.GetComponentInChildren<AscensionIconInteractable>()?.Info?.challengeType ?? AscensionChallenge.FinalBoss;
x.SetActive(
currentChallenge != AscensionChallenge.FinalBoss ||
AscensionUnlockSchedule.ChallengeIsUnlockedForLevel(AscensionChallenge.FinalBoss, AscensionSaveData.Data.challengeLevel));
x.GetComponent<AscensionIconInteractable>()?.ShowActivated(AscensionSaveData.Data.activeChallenges.Contains(currentChallenge));
});
}
else
{
value.RemoveAll(x => x == null);
value.ForEach((x) => { if (x != null) { x?.SetActive(false); } });
value.ForEach(x => x.SetActive(false));
}
}
}
Expand All @@ -150,7 +141,7 @@ public void OnEnable()
Destroy(leftArrow);
for (int i = 1; i < challengeObjectsForPages.Count; i++)
{
challengeObjectsForPages[i].ForEach(x => DestroyImmediate(x));
challengeObjectsForPages[i].ForEach(DestroyImmediate);
}
challengeObjectsForPages.Clear();
screen?.icons?.RemoveAll(x => x == null);
Expand All @@ -159,23 +150,16 @@ public void OnEnable()
{
icons = screen.icons;
pageLength = screen.icons.Count;
List<GameObject> toSort = screen.icons.ConvertAll((x) => x.gameObject);
challengeObjectsForPages = new List<List<GameObject>>
{
toSort
};
}
else
{
icons = new(transition.screenInteractables.FindAll((x) => x.GetComponent<AscensionIconInteractable>() != null).ConvertAll((x) =>
x.GetComponent<AscensionIconInteractable>()));
pageLength = icons.Count;
List<GameObject> toSort = icons.ConvertAll((x) => x.gameObject);
challengeObjectsForPages = new List<List<GameObject>>
{
toSort
};
}
List<GameObject> toSort = icons.ConvertAll((x) => x.gameObject);
challengeObjectsForPages = new List<List<GameObject>> { toSort };

List<ChallengeManager.FullChallenge> fcs = ChallengeManager.AllChallenges.ToList();
List<(ChallengeManager.FullChallenge, AscensionChallengeInfo)> challengesToAdd = new(fcs.ConvertAll(x => (x, x.Challenge).Repeat(x.AppearancesInChallengeScreen)).SelectMany(x => x));
List<AscensionIconInteractable> sortedicons = new(screen.icons);
Expand Down Expand Up @@ -258,7 +242,7 @@ public void OnEnable()

// if the arrows would be offscreen/clipped by the screen edge,
// or if the arrows' positions have been overriden by the config
if (screenContinue.position.x < rightArrowPos.x || InscryptionAPIPlugin.configOverrideArrows.Value)
if (InscryptionAPIPlugin.configOverrideArrows.Value || screenContinue.position.x < rightArrowPos.x)
{
rightArrowPos = screenContinue.position + Vector3.left / 2f;

Expand Down
24 changes: 5 additions & 19 deletions InscryptionAPI/Ascension/AscensionChallengeScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,39 +101,24 @@ public static bool UpdateFooterText(AscensionChallengeScreen __instance, Ascensi
if (challengeInfo.pointValue < 0)
{
string arg = Localization.ToUpper(Localization.Translate(challengeInfo.title));
string text;
if (activated)
{
text = string.Format(Localization.Translate("{0} ENABLED"), arg);
}
else
{
text = string.Format(Localization.Translate("{0} DISABLED"), arg);
}
string text = string.Format(Localization.Translate(activated ? "{0} ENABLED" : "{0} DISABLED"), arg);

string text2;
if (activated)
{
text2 = string.Format(Localization.Translate("{0} Challenge Points Subtracted"), (-challengeInfo.pointValue).ToString());
}
else
{
text2 = string.Format(Localization.Translate("{0} Challenge Points Added"), (-challengeInfo.pointValue).ToString());
}

int challengeLevel = AscensionSaveData.Data.challengeLevel;
int activeChallengePoints = AscensionSaveData.Data.GetActiveChallengePoints();
string text3;
if (activeChallengePoints > AscensionSaveData.GetChallengePointsForLevel(challengeLevel))
{
text3 = string.Format(Localization.Translate("WARNING(!) Lvl Reqs EXCEEDED"), Array.Empty<object>());
}
else if (activeChallengePoints == AscensionSaveData.GetChallengePointsForLevel(challengeLevel))
{
text3 = string.Format(Localization.Translate("Lvl Reqs Met"), Array.Empty<object>());
}
else
{
text3 = string.Format(Localization.Translate("Lvl Reqs NOT MET"), Array.Empty<object>());
}

__instance.footerLines.ShowText(0.1f, new string[]
{
text,
Expand Down Expand Up @@ -161,6 +146,7 @@ public static void Postfix(AscensionMenuScreens __instance)
[HarmonyPostfix]
public static void Postfix(AscensionChallengeScreen __instance)
{
Debug.Log($"{AscensionSaveData.Data.activeChallenges.Count}");
if (__instance.GetComponent<AscensionChallengePaginator>() == null)
{
ChallengeManager.SyncChallengeList();
Expand Down
17 changes: 7 additions & 10 deletions InscryptionAPI/Ascension/ChallengeDisplayerPlus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,9 @@ public void DisplayChallenge(AscensionChallengeInfo challengeInfo, bool immediat
{
List<AscensionChallenge> dependencies = challengeInfo?.GetFullChallenge()?.DependantChallengeGetter?.Invoke(ChallengeManager.GetChallengeIcons())?.ToList();
List<AscensionChallenge> incompatibilities = challengeInfo?.GetFullChallenge()?.IncompatibleChallengeGetter?.Invoke(ChallengeManager.GetChallengeIcons())?.ToList();
if (dependencies != null && incompatibilities != null)
{
incompatibilities.RemoveAll(x => dependencies.Contains(x));
}
if (dependencies != null)
{
incompatibilities?.RemoveAll(dependencies.Contains);
dependencies.RemoveAll(x => x == challengeInfo.challengeType);
if (dependencies.Count > 0)
{
Expand All @@ -117,10 +114,12 @@ public void DisplayChallenge(AscensionChallengeInfo challengeInfo, bool immediat
}
else
{
PrefixedString pstr = new();
pstr.prefix = Localization.Translate(info.title);
pstr.challenge = d;
pstr.number = 1;
PrefixedString pstr = new()
{
prefix = Localization.Translate(info.title),
challenge = d,
number = 1
};
dependencyStrings.Add(pstr);
}
}
Expand Down Expand Up @@ -155,9 +154,7 @@ public void DisplayChallenge(AscensionChallengeInfo challengeInfo, bool immediat
}
}
if (incompatibilityStrings.Count > 0)
{
incompatibility = "Incompatible with: " + string.Join(", ", incompatibilityStrings);
}
}
}
}
Expand Down
45 changes: 15 additions & 30 deletions InscryptionAPI/Ascension/ChallengeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,16 @@ internal static FullChallenge[] GetChallengeIcons()

private static AscensionChallengeInfo CloneChallengeInfo(AscensionChallengeInfo info)
{
AscensionChallengeInfo retval = new();
retval.activatedSprite = info.activatedSprite;
retval.challengeType = info.challengeType;
retval.description = info.description;
retval.iconSprite = info.iconSprite;
retval.name = info.name;
retval.pointValue = info.pointValue;
retval.title = info.title;
AscensionChallengeInfo retval = new()
{
activatedSprite = info.activatedSprite,
challengeType = info.challengeType,
description = info.description,
iconSprite = info.iconSprite,
name = info.name,
pointValue = info.pointValue,
title = info.title
};
return retval;
}

Expand Down Expand Up @@ -679,9 +681,7 @@ private static IEnumerator ActivateChallenges(IEnumerator result, TurnManager __
foreach (ChallengeBehaviour bb in cbs)
{
if (bb != null && bb.RespondsToPostBattleSetup())
{
yield return bb.OnPostBattleSetup();
}
}
yield break;
}
Expand Down Expand Up @@ -712,18 +712,14 @@ private static IEnumerator Postfix(IEnumerator result)
foreach (ChallengeBehaviour bb in cbs)
{
if (bb != null && bb.RespondsToPreBattleCleanup())
{
yield return bb.OnPreBattleCleanup();
}
}
yield return result;
cbs = ChallengeBehaviour.Instances.ToArray();
foreach (ChallengeBehaviour bb in cbs)
{
if (bb != null && bb.RespondsToPostBattleCleanup())
{
yield return bb.OnPostBattleCleanup();
}
}
ChallengeBehaviour.DestroyAllInstances();
yield break;
Expand Down Expand Up @@ -804,17 +800,14 @@ private static void DoDependenciesAndIncompatibilities(AscensionIconInteractable
{
List<AscensionChallenge> dependencies2 = icon?.challengeInfo?.GetFullChallenge()?.DependantChallengeGetter?.Invoke(GetChallengeIcons())?.ToList();
List<AscensionChallenge> incompatibilities2 = icon?.challengeInfo?.GetFullChallenge()?.IncompatibleChallengeGetter?.Invoke(GetChallengeIcons())?.ToList();
if (dependencies2 != null && incompatibilities2 != null)
{
incompatibilities.RemoveAll(x => dependencies2.Contains(x));
}
if (incompatibilities2 != null)
{
if (dependencies2 != null)
incompatibilities.RemoveAll(dependencies2.Contains);

incompatibilities2.RemoveAll(x => x == icon.challengeInfo.challengeType);
if (screen.icons.Exists(x => x.Unlocked && x.clickable && x.Info != null && x.activatedRenderer != null && x.activatedRenderer.enabled && incompatibilities2.Contains(x.Info.challengeType)))
{
icon?.OnCursorSelectStart();
}
}
}
}
Expand All @@ -837,33 +830,25 @@ private static void DoDependenciesAndIncompatibilities(AscensionIconInteractable
{
List<AscensionChallenge> dependencies = icon?.challengeInfo?.GetFullChallenge()?.DependantChallengeGetter?.Invoke(GetChallengeIcons())?.ToList();
List<AscensionChallenge> incompatibilities = icon?.challengeInfo?.GetFullChallenge()?.IncompatibleChallengeGetter?.Invoke(GetChallengeIcons())?.ToList();
if (dependencies != null && incompatibilities != null)
{
incompatibilities.RemoveAll(x => dependencies.Contains(x));
}
if (dependencies != null)
{
incompatibilities?.RemoveAll(dependencies.Contains);

dependencies.RemoveAll(x => x == icon.challengeInfo.challengeType);
List<AscensionChallenge> dependenciesClone = new(dependencies);
foreach (var icon2 in screen.icons.Where(x => x.Unlocked && x.clickable && x.Info != null && x.activatedRenderer != null && x.activatedRenderer.enabled && dependencies.Contains(x.Info.challengeType)))
{
if (dependenciesClone.Contains(icon2.Info.challengeType))
{
dependenciesClone.Remove(icon2.Info.challengeType);
}
}
if (dependenciesClone.Count > 0)
{
icon?.OnCursorSelectStart();
}
}
}
}
}
if (setCurrentIcon)
{
currentIcon = null;
}
}
}

Expand Down
Binary file added InscryptionAPI/Assets/ability_transformer_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/ability_transformer_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added InscryptionAPI/Assets/ability_transformer_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3289b23

Please sign in to comment.