Skip to content

Commit 2e6c2fe

Browse files
authored
Merge pull request #313 from HumabHatterZed/main
2.20.1
2 parents ac5c452 + f0fbe44 commit 2e6c2fe

18 files changed

Lines changed: 939 additions & 197 deletions

CHANGELOG.md

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

4+
# 2.21.0
5+
- Fixed ability stacks not rendering
6+
- Fixed rendering error when displaying a card with tribes outside of Act 1
7+
- Fixed ResetShields not re-setting lostShield to false under certain conditions
8+
- Fixed RemoveMaxEnergy not working as intended
9+
- Fixed custom AudioClips not loading correctly on Mac OSX
10+
- Added RuleBookManager for adding custom rulebook sections (see wiki for more info)
11+
- Added AllModificationInfos, AllModificationTypes, and modification syncing to SlotModificationManager
12+
- Added additional functionality to SlotModificationManager - Infos now store name and GUID
13+
- Added rulebook entry support for slot modifications - use extension method .SetRulebook() when adding your slot modification
14+
- Added more shield-related extensions
15+
- Added some AbilityInfo-related extensions
16+
- Added ShieldManager.AllShieldAbilities and ShieldManager.AllShieldInfos for easier tracking of custom shield abilities
17+
- Added config to the community patches to add a forced red emission to Undead Cat
18+
- Modified Obsolete warning for Helpers.CustomLine to point to Dialogue.CustomLine
19+
420
# 2.20.0
521
- Updated wiki sections for Adding Map Nodes, and Conditional Map Nodes; moved Special Sequencers section to Opponents
622
- Fixed issues related to challlenge icon sorting when a boss icon is present

InscryptionAPI/Boons/BoonManager.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,19 +291,18 @@ private static void LoadBoons(DeckInfo __instance)
291291
}
292292

293293
[HarmonyPatch(typeof(RuleBookInfo), nameof(RuleBookInfo.ConstructPageData))]
294-
[HarmonyPostfix]
294+
[HarmonyPostfix, HarmonyPriority(100)]
295295
private static void ConstructPageData(ref List<RuleBookPageInfo> __result, RuleBookInfo __instance, AbilityMetaCategory metaCategory)
296296
{
297297
if (NewBoons.Count > 0 && metaCategory == AbilityMetaCategory.Part1Rulebook)
298298
{
299299
foreach (PageRangeInfo pageRangeInfo in __instance.pageRanges)
300300
{
301-
// regular abilities
302301
if (pageRangeInfo.type == PageRangeType.Boons)
303302
{
304303
int insertPosition = __result.FindLastIndex(rbi => rbi.pagePrefab == pageRangeInfo.rangePrefab) + 1;
305304
int curPageNum = (int)Ability.NUM_ABILITIES;
306-
List<FullBoon> abilitiesToAdd = NewBoons.Where(x => x != null && x.boon != null && BoonsUtil.GetData(x.boon.type)?.icon != null).ToList();
305+
List<FullBoon> abilitiesToAdd = NewBoons.Where(x => x?.boon != null && BoonsUtil.GetData(x.boon.type)?.icon != null).ToList();
307306
//InscryptionAPIPlugin.Logger.LogInfo($"Adding {abilitiesToAdd.Count} out of {NewAbilities.Count} abilities to rulebook");
308307
foreach (FullBoon fboo in abilitiesToAdd)
309308
{

InscryptionAPI/Card/AbilityExtensions.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,16 @@ public static AbilityInfo SetPowerlevel(this AbilityInfo abilityInfo, int powerL
334334
abilityInfo.powerLevel = powerLevel;
335335
return abilityInfo;
336336
}
337+
public static AbilityInfo SetRulebookDescription(this AbilityInfo abilityInfo, string description)
338+
{
339+
abilityInfo.rulebookDescription = description;
340+
return abilityInfo;
341+
}
342+
public static AbilityInfo SetRulebookName(this AbilityInfo abilityInfo, string name)
343+
{
344+
abilityInfo.rulebookName = name;
345+
return abilityInfo;
346+
}
337347
/// <summary>
338348
/// Sets whether or not the ability is an activated ability.
339349
/// </summary>
@@ -454,6 +464,20 @@ public static AbilityInfo ResetDescription(this AbilityInfo abilityInfo)
454464
return abilityInfo;
455465
}
456466

467+
public static bool HasMetaCategories(this AbilityInfo info, params AbilityMetaCategory[] categories)
468+
{
469+
foreach (AbilityMetaCategory app in categories)
470+
if (!info.HasMetaCategory(app))
471+
return false;
472+
473+
return true;
474+
}
475+
476+
public static bool HasMetaCategory(this AbilityInfo info, AbilityMetaCategory category)
477+
{
478+
return info.metaCategories.Contains(category);
479+
}
480+
457481
#region TriggersOncePerStack
458482
/// <summary>
459483
/// Sets the ability to only ever trigger once per stack. This prevents abilities from triggering twice per stack after a card evolves.

InscryptionAPI/Card/AbilityManager.cs

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -402,17 +402,18 @@ private static bool GetLearnedAbilitesReplacement(bool opponentUsable, int minPo
402402
}
403403

404404
#region Rulebook Description
405+
public const string SIGILCOST = "[sigilcost:";
405406
[HarmonyPostfix, HarmonyPatch(typeof(AbilityInfo), nameof(AbilityInfo.ParseAndTranslateDescription))]
406407
private static void CleanUpParsedDescription(ref string __result)
407408
{
408-
while (__result.Contains("[sigilcost:"))
409+
while (__result.Contains(SIGILCOST))
409410
{
410-
string textToCheck = __result.Substring(__result.IndexOf("[sigilcost:"));
411+
string textToCheck = __result.Substring(__result.IndexOf(SIGILCOST));
411412
if (!textToCheck.Contains("]"))
412413
break;
413414

414415
textToCheck = textToCheck.Substring(0, textToCheck.IndexOf("]") + 1);
415-
__result = __result.Replace(textToCheck, textToCheck.Replace("[sigilcost:", "").Replace("]", ""));
416+
__result = __result.Replace(textToCheck, textToCheck.Replace(SIGILCOST, "").Replace("]", ""));
416417
}
417418
}
418419

@@ -449,9 +450,9 @@ private static bool ResetAlteredDescriptions(bool shown)
449450

450451
internal static string ParseAndUpdateDescription(string description, ExtendedActivatedAbilityBehaviour ability)
451452
{
452-
while (description.Contains("[sigilcost:"))
453+
while (description.Contains(SIGILCOST))
453454
{
454-
int startIndex = description.IndexOf("[sigilcost:");
455+
int startIndex = description.IndexOf(SIGILCOST);
455456
string textToChange = description.Substring(startIndex);
456457
if (!textToChange.Contains("]"))
457458
break;
@@ -537,34 +538,30 @@ internal static string ParseAndUpdateDescription(string description, ExtendedAct
537538
}
538539

539540
[HarmonyPatch(typeof(RuleBookInfo), "ConstructPageData", new Type[] { typeof(AbilityMetaCategory) })]
540-
[HarmonyPostfix]
541+
[HarmonyPostfix, HarmonyPriority(100)]
541542
private static void FixRulebook(AbilityMetaCategory metaCategory, RuleBookInfo __instance, ref List<RuleBookPageInfo> __result)
542543
{
543544
//InscryptionAPIPlugin.Logger.LogInfo($"In rulebook patch: I see {NewAbilities.Count}");
544-
if (NewAbilities.Count <= 0)
545-
return;
546-
547-
foreach (PageRangeInfo pageRangeInfo in __instance.pageRanges)
545+
if (NewAbilities.Count > 0)
548546
{
549-
// regular abilities
550-
if (pageRangeInfo.type != PageRangeType.Abilities)
551-
continue;
552-
553-
int insertPosition = __result.FindLastIndex(rbi => rbi.pagePrefab == pageRangeInfo.rangePrefab) + 1;
554-
int curPageNum = (int)Ability.NUM_ABILITIES;
555-
List<FullAbility> abilitiesToAdd = NewAbilities.Where(x => __instance.AbilityShouldBeAdded((int)x.Id, metaCategory)).ToList();
556-
//InscryptionAPIPlugin.Logger.LogInfo($"Adding {abilitiesToAdd.Count} out of {NewAbilities.Count} abilities to rulebook");
557-
foreach (FullAbility fab in abilitiesToAdd)
547+
foreach (PageRangeInfo pageRangeInfo in __instance.pageRanges)
558548
{
559-
RuleBookPageInfo info = new()
549+
if (pageRangeInfo.type == PageRangeType.Abilities) // regular abilities
560550
{
561-
pagePrefab = pageRangeInfo.rangePrefab,
562-
headerText = string.Format(Localization.Translate("APPENDIX XII, SUBSECTION I - MOD ABILITIES {0}"), curPageNum)
563-
};
564-
__instance.FillAbilityPage(info, pageRangeInfo, (int)fab.Id);
565-
__result.Insert(insertPosition, info);
566-
curPageNum += 1;
567-
insertPosition += 1;
551+
int curPageNum = (int)Ability.NUM_ABILITIES;
552+
int insertPosition = __result.FindLastIndex(rbi => rbi.pagePrefab == pageRangeInfo.rangePrefab) + 1;
553+
List<FullAbility> abilitiesToAdd = NewAbilities.Where(x => __instance.AbilityShouldBeAdded((int)x.Id, metaCategory)).ToList();
554+
foreach (FullAbility fab in abilitiesToAdd)
555+
{
556+
RuleBookPageInfo info = new();
557+
info.pagePrefab = pageRangeInfo.rangePrefab;
558+
info.headerText = string.Format(Localization.Translate("APPENDIX XII, SUBSECTION I - MOD ABILITIES {0}"), curPageNum);
559+
__instance.FillAbilityPage(info, pageRangeInfo, (int)fab.Id);
560+
__result.Insert(insertPosition, info);
561+
curPageNum++;
562+
insertPosition++;
563+
}
564+
}
568565
}
569566
}
570567
}

InscryptionAPI/Card/SpecialStatIconManager.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,13 @@ private static void AbilityLoadPrefix()
116116
}
117117

118118
[HarmonyPatch(typeof(RuleBookInfo), "ConstructPageData", new Type[] { typeof(AbilityMetaCategory) })]
119-
[HarmonyPostfix]
119+
[HarmonyPostfix, HarmonyPriority(100)]
120120
private static void FixRulebook(AbilityMetaCategory metaCategory, RuleBookInfo __instance, ref List<RuleBookPageInfo> __result)
121121
{
122122
if (NewStatIcons.Count > 0)
123123
{
124124
foreach (PageRangeInfo pageRangeInfo in __instance.pageRanges)
125125
{
126-
// regular abilities
127126
if (pageRangeInfo.type == PageRangeType.StatIcons)
128127
{
129128
int insertPosition = __result.FindLastIndex(rbi => rbi.pagePrefab == pageRangeInfo.rangePrefab) + 1;
@@ -133,7 +132,7 @@ private static void FixRulebook(AbilityMetaCategory metaCategory, RuleBookInfo _
133132
RuleBookPageInfo info = new();
134133
info.pagePrefab = pageRangeInfo.rangePrefab;
135134
info.headerText = string.Format(Localization.Translate("APPENDIX XII, SUBSECTION VII - VARIABLE STATS {0}"), curPageNum);
136-
__instance.FillAbilityPage(info, pageRangeInfo, (int)fab.Id);
135+
__instance.FillStatIconPage(info, pageRangeInfo, (int)fab.Id);
137136
__result.Insert(insertPosition, info);
138137
curPageNum += 1;
139138
insertPosition += 1;

InscryptionAPI/Compatibility/CustomLine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace InscryptionAPI.Helpers;
44

55

6-
[Obsolete("Use DialogueManager.GenerateEvent instead")]
6+
[Obsolete("Use DialogueManager.GenerateEvent or InscryptionAPI.Dialogue.CustomLine instead.")]
77
public struct CustomLine
88
{
99
public CustomLine() { }

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.20.0</Version>
13+
<Version>2.21.0</Version>
1414
</PropertyGroup>
1515

1616
<PropertyGroup>

InscryptionAPI/InscryptionAPIPlugin.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using InscryptionAPI.Pelts;
1414
using InscryptionAPI.PixelCard;
1515
using InscryptionAPI.Regions;
16+
using InscryptionAPI.Slots;
1617
using InscryptionAPI.Totems;
1718
using System.Runtime.CompilerServices;
1819

@@ -28,7 +29,7 @@ public class InscryptionAPIPlugin : BaseUnityPlugin
2829
{
2930
public const string ModGUID = "cyantist.inscryption.api";
3031
public const string ModName = "InscryptionAPI";
31-
public const string ModVer = "2.20.0";
32+
public const string ModVer = "2.21.0";
3233

3334
public static string Directory = "";
3435

@@ -79,6 +80,7 @@ internal static void ResyncAll()
7980
CardCostManager.SyncCustomCostList();
8081
CardModificationInfoManager.SyncCardMods();
8182
AbilityManager.SyncAbilityList();
83+
SlotModificationManager.SyncSlotModificationList();
8284
EncounterManager.SyncEncounterList();
8385
RegionManager.SyncRegionList();
8486
}

0 commit comments

Comments
 (0)