Skip to content

Commit

Permalink
Merge branch 'main' into multi-same-mox
Browse files Browse the repository at this point in the history
  • Loading branch information
IngoHHacks authored Jul 19, 2024
2 parents c269f9f + 99f6fa8 commit 01ccda2
Show file tree
Hide file tree
Showing 42 changed files with 1,960 additions and 390 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
<details>
<summary>View Changelog</summary>

# 2.20.0
- Updated wiki sections for Adding Map Nodes, and Conditional Map Nodes; moved Special Sequencers section to Opponents
- Fixed issues related to challlenge icon sorting when a boss icon is present
- Fixed TalkingCardManager not properly configuring talking cards in Part 3on the page
- Fixed extension properties for CardModificationInfos saved to the save file not consistently loading
- Fixed cards not shaking when losing a shield
- Fixed ShieldManager.BreakShield not being called when a shielded card takes damage
- Added SlotModificationManager for adding behaviour to card slots; see wiki for more info
- Added SaveFileExtensions class
- Added support for cards costing multiple of the same colour Mox
- Added debugging to GetCustomCardCosts method; please let the API folks know if you receive any warnings/errors marked by '[GetCustomCardCosts]'
- Added StatIconInfo.SetRulebookInfo and StatIconInfo.SetAppliesToStats
- Added NodeData.SelectionCondition's ChallengeIsActive and NumChallengesOfTypeActive
- Added PlayableCard.GetShieldCount<\T>() for getting a specific shield ability's NumShield value
- Added new config to the community patches to reduce the size of the price tags during the Buy Pelts sequence
- Added CardModificationInfo.AddNegateAbilities extension method
- Removed leftover debugging related to boss challenge icons and custom costs
- P03 Face Card Displayer can now show card costs other than energy
- Publiciser warnings from the API and Community Patches no longer appear in the console
- SaveFile.CurrentDeck now returns gbcData.deck in Act 2
- DeathShieldLatch can longer target cards with an active shield
- Cards with a broken shield return to their default portrait when regaining their shield
- Shield abilities now use NumShields to determine visual sigil stacking
- CardModificationInfo.SetNameReplacement now accepts null value for the name replacement

# 2.19.5
- Fixed pixel Bones cost icons not appearing when the cost is greater than vanilla amounts
- Fixed interaction where a Gemified card that gives a blue gem doesn't spend the correct resource amount when played
Expand Down
127 changes: 48 additions & 79 deletions InscryptionAPI/Ascension/AscensionChallengePaginator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,6 @@

namespace InscryptionAPI.Ascension;

/// <summary>
/// The purpose of this class is to help sync challenge icons as they appear in the selection menu.
///
/// </summary>
/*public class GameObject
{
public AscensionIconInteractable IconInteractable;
public GameObject IconObject;
public int Index;
public int PageNum;
public bool Activated;
public bool BossIcon;
public GameObject(int pageNum, AscensionIconInteractable iconInteractable, int index = -1)
{
this.Activated = false;
this.Index = index;
this.PageNum = pageNum;
this.IconInteractable = iconInteractable;
this.IconObject = iconInteractable.gameObject;
this.BossIcon = iconInteractable.challengeInfo.GetFullChallenge()?.Boss ?? false;
}
}*/

public class AscensionChallengePaginator : MonoBehaviour
{
public bool initialized;
Expand Down Expand Up @@ -99,36 +74,18 @@ public void AddPage(List<AscensionChallengeInfo> challengeInfos)
int numBosses = challengeInfos.Count(x => x.challengeType.GetFullChallenge().Boss);
int numIcons = Mathf.Min(14, challengeObjectsForPages[0].Count) - numBosses;

//int occupiedRows = (1 + regularChallengeInfos.Count) / 2 + bossChallengeInfos.Count;
// the list index when we begin adding boss icons
int bossStartingIndex = (1 + regularChallengeInfos.Count) / 2;
int numBossesAdded = 0;
int bossStartingIndex = (1 + regularChallengeInfos.Count) / 2;//numRows - bossChallengeInfos.Count;

Debug.Log($"NumIcons for Page: {numIcons}: {regularChallengeInfos.Count} {bossChallengeInfos.Count}");

/*// Prototyping for a more complicated system of sorting boss icons according to their challenge type (reds w/ reds, greens w/ greens, etc.)
// Current system just sticks them at the end of the page, regardless of their colour or the colour of preceding challenges
// | | |2| |4| |6| // | | |2| |4| | |
// |+|+|B|B|-|x| | // |=|=|-|B|x|x| |
// |+|+|=|=|B| | | // |=|B|-|x|x|x| |
//Debug.Log($"NumIcons for Page: {numIcons}: {regularChallengeInfos.Count} {bossChallengeInfos.Count}");

// | | | |3| | | | // | | |2| | |5| |
// |=|=|-|x|x|x|x| // |+|=|-|-|B|x| |
// |=|-|B|x|x|x| | // |=|B|-|-|x|x| |
int positiveChalls = regularChallengeInfos.FindAll(x => x.pointValue > 0).Count;
int neutralChalls = regularChallengeInfos.FindAll(x => x.pointValue == 0).Count;
int negativeChalls = regularChallengeInfos.FindAll(x => x.pointValue < 0).Count;*/

for (int i = 0; i < Mathf.Min(14, numIcons); i++)
for (int i = 0; i < 14; i++)
{
GameObject objectRef;
GameObject objectRef = null;

// if there are boss icons we still need to add to the page
if (i % 7 >= bossStartingIndex && i % 7 < bossStartingIndex + numBosses)
if (i % 7 < bossStartingIndex + numBosses && i % 7 >= bossStartingIndex)
{

// if this is the correct index for adding a boss
// but one has already been added, skip to the next non-boss index
if (numBossesAdded < numBosses)
{
numBossesAdded++;
Expand All @@ -137,13 +94,10 @@ public void AddPage(List<AscensionChallengeInfo> challengeInfos)
else
{
i += numBosses;
objectRef = challengeObjectsForPages[0][i];
}
}
else
{
objectRef = challengeObjectsForPages[0][i];
}

objectRef ??= challengeObjectsForPages[0][i];

if (objectRef != null)
{
Expand All @@ -155,16 +109,31 @@ public void AddPage(List<AscensionChallengeInfo> challengeInfos)
newPage.Sort((x, x2) => Mathf.RoundToInt(
(Mathf.Abs(x.transform.position.x - x2.transform.position.x) < 0.1f ? x2.transform.position.y - x.transform.position.y : x.transform.position.x - x2.transform.position.x) * 100
));
DebugChallengePageArray(challengeObjectsForPages.Count, newPage);

//DebugChallengePageArray(challengeObjectsForPages.Count, newPage);

// set the challenge info for each icon in the page
int infoIdx = 0;
int infoCount = challengeInfos.Count;
for (int i = 0; i < newPage.Count; i++)
{
//Debug.Log($"Assign info at: {i}");
//Debug.Log($"Checking icon [{i}] info {infoIdx}");
AscensionIconInteractable interactable = newPage[i].GetComponent<AscensionIconInteractable>();
if (i < challengeInfos.Count)

if (i < infoCount)
{
interactable.challengeInfo = challengeInfos[i];
// if we're assigning boss info to an icon that isn't a boss icon
if (challengeInfos[infoIdx].GetFullChallenge().Boss && (interactable.coll2D as BoxCollider2D).size.y < 1f)
{
interactable.challengeInfo = missingChallengeInfo;
newPage[i].AddComponent<NoneChallengeDisplayer>();
infoCount++;
}
else
{
interactable.challengeInfo = challengeInfos[infoIdx];
infoIdx++;
}
}
else
{
Expand Down Expand Up @@ -261,7 +230,7 @@ public void OnEnable()
icon.conqueredRenderer.gameObject.SetActive(icon.Conquered && icon.showConquered);
}

// sort challenges in order of: positive pts, 0 pts, negatve pts, positive pts boss, 0 pts boss, negative pts boss
// sort challenges in order of: positive pts, 0 pts, negative pts, positive pts boss, 0 pts boss, negative pts boss
challengesToAdd.Sort((x, x2) =>
{
if (x.Item1.SortValue != x2.Item1.SortValue)
Expand Down Expand Up @@ -293,7 +262,7 @@ public void OnEnable()
// re-sort the page so boss challenges have the correct info
page.Sort((x, x2) =>
{
if (x.Item1.SortValue != x2.Item1.SortValue)
if (x.Item1.BossSortValue != x2.Item1.BossSortValue)
{
return x2.Item1.BossSortValue - x.Item1.BossSortValue;
}
Expand All @@ -303,7 +272,7 @@ public void OnEnable()
}
});
pagesToAdd.Add(page.ConvertAll(x => x.Item2));
DebugChallengePageArray(pagesToAdd.Count, null, page.ConvertAll(x => x.Item2));
//DebugChallengePageArray(pagesToAdd.Count, null, page.ConvertAll(x => x.Item2));
}

challengeObjectsForPages.ForEach(x => x.RemoveAll(x => x == null));
Expand Down Expand Up @@ -426,24 +395,6 @@ public void LoadPage(int page)
CommandLineTextDisplayer.PlayCommandLineClickSound();
}

/// <summary>
/// A List representing the entire collection of challenge pages.
/// </summary>
public List<List<GameObject>> challengeObjectsForPages;

public int pageIndex;
public int pageLength;

public AscensionChallengeScreen screen;

public AscensionMenuScreenTransition transition;

public AscensionMenuInteractable leftArrow;
public AscensionMenuInteractable rightArrow;

public static Sprite missingChallengeSprite;
public static AscensionChallengeInfo missingChallengeInfo;

private void DebugChallengePageArray(int page, List<GameObject> iconsForPage, List<AscensionChallengeInfo> infos = null)
{
InscryptionAPIPlugin.Logger.LogDebug($"Current Page: {page} | {iconsForPage?.Count ?? infos.Count}");
Expand Down Expand Up @@ -501,6 +452,24 @@ private char DebugArrayCode(GameObject icon, AscensionChallengeInfo info = null)
return interactable.activatedRenderer.enabled ? 'X' : 'O';
}

/// <summary>
/// A List representing the entire collection of challenge pages.
/// </summary>
public List<List<GameObject>> challengeObjectsForPages;

public int pageIndex;
public int pageLength;

public AscensionChallengeScreen screen;

public AscensionMenuScreenTransition transition;

public AscensionMenuInteractable leftArrow;
public AscensionMenuInteractable rightArrow;

public static Sprite missingChallengeSprite;
public static AscensionChallengeInfo missingChallengeInfo;

private class NoneChallengeDisplayer : MonoBehaviour
{
public void Start()
Expand Down
37 changes: 32 additions & 5 deletions InscryptionAPI/Card/AbilityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static void SetCustomFlippedTexture(this FullAbility info, Texture2D icon
/// <param name="info">The instance of StatIconInfo.</param>
/// <param name="icon">A 49x49 texture containing the icon.</param>
/// <param name="filterMode">The filter mode for the icon texture. Leave this at its default value unless you have a specific reason to change it.</param>
/// <returns>The same stat icon so a chain can continue.</returns>
/// <returns>The same StatIconInfo so a chain can continue.</returns>
public static StatIconInfo SetIcon(this StatIconInfo info, Texture2D icon, FilterMode? filterMode = null)
{
info.iconGraphic = icon;
Expand All @@ -133,7 +133,7 @@ public static StatIconInfo SetIcon(this StatIconInfo info, Texture2D icon, Filte
/// <param name="info">The instance of StatIconInfo.</param>
/// <param name="pathToArt">The path to a 49x49 texture containing the icon on disk.</param>
/// <param name="filterMode">The filter mode for the icon texture. Leave this at its default value unless you have a specific reason to change it.</param>
/// <returns>The same stat icon so a chain can continue.</returns>
/// <returns>The same StatIconInfo so a chain can continue.</returns>
public static StatIconInfo SetIcon(this StatIconInfo info, string pathToArt, FilterMode? filterMode = null)
{
info.iconGraphic = TextureHelper.GetImageAsTexture(pathToArt);
Expand All @@ -142,13 +142,40 @@ public static StatIconInfo SetIcon(this StatIconInfo info, string pathToArt, Fil
return info;
}

/// <summary>
/// Set the StatIconInfo's rulebookName and rulebookDescription. Does not make the stat icon appear in the Rulebook.
/// </summary>
/// <param name="info"></param>
/// <param name="rulebookName"></param>
/// <param name="rulebookDescription"></param>
/// <returns>The same StatIconInfo so a chain can continue.</returns>
public static StatIconInfo SetRulebookInfo(this StatIconInfo info, string rulebookName, string rulebookDescription = null)
{
info.rulebookName = rulebookName;
info.rulebookDescription = rulebookDescription;
return info;
}
/// <summary>
/// Sets the StatIconInfo's appliesToAttack and appliesToHealth fields. Note these fields don't make the stat icon affect the stat; you still need to implement that logic.
/// </summary>
/// <param name="info"></param>
/// <param name="appliesToAttack">If the stat icon should cover a card's Power.</param>
/// <param name="appliesToHealth">If the stat icon should cover a card's Health.</param>
/// <returns>The same StatIconInfo so a chain can continue.</returns>
public static StatIconInfo SetAppliesToStats(this StatIconInfo info, bool appliesToAttack, bool appliesToHealth)
{
info.appliesToAttack = appliesToAttack;
info.appliesToHealth = appliesToHealth;
return info;
}

/// <summary>
/// Sets the icon that will be displayed for this stat icon when the card is in the player's hand in Act 2.
/// </summary>
/// <param name="info">The instance of StatIconInfo.</param>
/// <param name="icon">A 16x8 texture containing the icon .</param>
/// <param name="filterMode">The filter mode for the icon texture. Leave this at its default value unless you have a specific reason to change it.</param>
/// <returns>The same stat icon so a chain can continue.</returns>
/// <returns>The same StatIconInfo so a chain can continue.</returns>
public static StatIconInfo SetPixelIcon(this StatIconInfo info, Texture2D icon, FilterMode? filterMode = null)
{
info.pixelIconGraphic = TextureHelper.ConvertTexture(icon, TextureHelper.SpriteType.PixelStatIcon, filterMode ?? FilterMode.Point);
Expand Down Expand Up @@ -196,7 +223,7 @@ public static AbilityInfo AddMetaCategories(this AbilityInfo info, params Abilit
/// </summary>
/// <param name="info">The instance of StatIconInfo.</param>
/// <param name="categories">The metacategories to add.</param>
/// <returns>The same stat icon so a chain can continue.</returns>
/// <returns>The same StatIconInfo so a chain can continue.</returns>
public static StatIconInfo AddMetaCategories(this StatIconInfo info, params AbilityMetaCategory[] categories)
{
info.metaCategories ??= new();
Expand Down Expand Up @@ -247,7 +274,7 @@ public static AbilityInfo SetDefaultPart3Ability(this AbilityInfo info)
/// Helper method: automatically adds the Part3Rulebook metacategories to the stat icon.
/// </summary>
/// <param name="info">The instance of StatIconInfo.</param>
/// <returns>The same stat icon so a chain can continue.</returns>
/// <returns>The same StatIconInfo so a chain can continue.</returns>
public static StatIconInfo SetDefaultPart3Ability(this StatIconInfo info)
{
return info.AddMetaCategories(AbilityMetaCategory.Part3Rulebook);
Expand Down
Loading

0 comments on commit 01ccda2

Please sign in to comment.