Skip to content

Commit 186cd59

Browse files
authored
Merge pull request #317 from HumabHatterZed/main
Boss challenge icons fix
2 parents ba391e1 + 8106b43 commit 186cd59

File tree

12 files changed

+144
-58
lines changed

12 files changed

+144
-58
lines changed

CHANGELOG.md

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

4+
# 2.22.2
5+
- Added GetEnergyConfig method to community patch's EnergyDrone class - retrieves the current Act's EnergyConfigInfo
6+
- CommunityPatches: Added community config to move pelt price tags to the right of the card
7+
- Experimental: Changed gemified to only reduce a single cost on a card, with priority of Energy > Bones > Gems > Blood
8+
- Fixed positioning errors caused by having multiple custom boss challenge icons
9+
- EnergyConfigInfo's fields can now be modified when initialising a new instance
10+
- Updated installation guide on the ReadMe to match the wiki, added link to wiki.
11+
412
# 2.22.1
513
- Added IShieldPreventedDamage and IShieldPreventedDamageInHand ability triggers and interfaces
614
- 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/Card/CardExtensionsCosts.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public static int BloodCost(this PlayableCard card)
3535
if (card && card.Info)
3636
{
3737
int originalBloodCost = CostProperties.CostProperties.OriginalBloodCost(card.Info);
38-
39-
if (card.IsUsingBlueGem())
38+
if (card.IsUsingBlueGem() && CostProperties.CostProperties.ReduceGemifiedBlood(card, originalBloodCost))
4039
originalBloodCost--;
4140

4241
// add adjustments from temp mods
@@ -59,7 +58,7 @@ public static int BonesCost(this PlayableCard card)
5958
if (card && card.Info)
6059
{
6160
int originalBonesCost = CostProperties.CostProperties.OriginalBonesCost(card.Info);
62-
if (card.IsUsingBlueGem())
61+
if (card.IsUsingBlueGem() && CostProperties.CostProperties.ReduceGemifiedBones(card, originalBonesCost))
6362
originalBonesCost--;
6463

6564
// add adjustments from temp mods
@@ -98,7 +97,7 @@ public static List<GemType> GemsCost(this PlayableCard card)
9897
}
9998
}
10099

101-
if (gemsCost.Count > 0 && card.IsUsingBlueGem())
100+
if (card.IsUsingBlueGem() && CostProperties.CostProperties.ReduceGemifiedMox(card, gemsCost))
102101
gemsCost.RemoveAt(0);
103102

104103
return gemsCost;

InscryptionAPI/Card/CostProperties.cs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public bool GemsChanged<T>(List<T> a, List<T> b)
7878
[HarmonyReversePatch, HarmonyPatch(typeof(CardInfo), nameof(CardInfo.BloodCost), MethodType.Getter), MethodImpl(MethodImplOptions.NoInlining)]
7979
public static int OriginalBloodCost(CardInfo __instance) { return 0; }
8080

81-
8281
/// <summary>
8382
/// ChangeCardCostGetter patches BoneCost so we can change the cost on the fly
8483
/// This reverse patch gives us access to the original method without any changes.
@@ -87,7 +86,6 @@ public bool GemsChanged<T>(List<T> a, List<T> b)
8786
[HarmonyReversePatch, HarmonyPatch(typeof(CardInfo), nameof(CardInfo.BonesCost), MethodType.Getter), MethodImpl(MethodImplOptions.NoInlining)]
8887
public static int OriginalBonesCost(CardInfo __instance) { return 0; }
8988

90-
9189
/// <summary>
9290
/// ChangeCardCostGetter patches GemsCost so we can change the cost on the fly
9391
/// This reverse patch gives us access to the original method without any changes.
@@ -96,6 +94,11 @@ public bool GemsChanged<T>(List<T> a, List<T> b)
9694
[HarmonyReversePatch, HarmonyPatch(typeof(CardInfo), nameof(CardInfo.GemsCost), MethodType.Getter), MethodImpl(MethodImplOptions.NoInlining)]
9795
public static List<GemType> OriginalGemsCost(CardInfo __instance) { return null; }
9896

97+
/// <summary>
98+
/// Improved version of CardInfo.GemsCost that accounts for addGemCost and RemovedGemsCost().
99+
/// </summary>
100+
/// <remarks>For consistency's sake, it's recommended you use this method over OriginalGemsCost in most cases.</remarks>
101+
/// <param name="instance"></param>
99102
public static List<GemType> ImprovedGemsCost(CardInfo instance)
100103
{
101104
if (instance.Mods.Exists(x => x.nullifyGemsCost))
@@ -123,6 +126,23 @@ public static List<GemType> ImprovedGemsCost(CardInfo instance)
123126
/// </summary>
124127
[HarmonyReversePatch, HarmonyPatch(typeof(CardInfo), nameof(CardInfo.EnergyCost), MethodType.Getter), MethodImpl(MethodImplOptions.NoInlining)]
125128
public static int OriginalEnergyCost(CardInfo __instance) { return 0; }
129+
130+
public static bool ReduceGemifiedBlood(PlayableCard card, int? bloodCost = null)
131+
{
132+
return (bloodCost ?? OriginalBloodCost(card.Info)) > 0 && !ReduceGemifiedMox(card) && !ReduceGemifiedBones(card) && !ReduceGemifiedMox(card);
133+
}
134+
public static bool ReduceGemifiedMox(PlayableCard card, List<GemType> gemsCost = null)
135+
{
136+
return (gemsCost?.Count ?? ImprovedGemsCost(card.Info).Count) > 0 && !ReduceGemifiedBones(card) && !ReduceGemifiedEnergy(card);
137+
}
138+
public static bool ReduceGemifiedBones(PlayableCard card, int? bonesCost = null)
139+
{
140+
return (bonesCost ?? OriginalBonesCost(card.Info)) > 0 && !ReduceGemifiedEnergy(card);
141+
}
142+
public static bool ReduceGemifiedEnergy(PlayableCard card, int? energyCost = null)
143+
{
144+
return (energyCost ?? OriginalEnergyCost(card.Info)) > 0;
145+
}
126146
}
127147

128148
[HarmonyPatch]
@@ -162,12 +182,13 @@ public static bool EnergyCost(CardInfo __instance, ref int __result)
162182
__result = card?.EnergyCost ?? CostProperties.OriginalEnergyCost(__instance);
163183
return false;
164184
}
185+
165186
[HarmonyPatch(typeof(PlayableCard), nameof(PlayableCard.EnergyCost), MethodType.Getter), HarmonyPrefix]
166187
public static bool DisableVanillaEnergyCost(PlayableCard __instance, ref int __result)
167188
{
168189
// patch this to follow the same pattern as the other cost methods
169190
int energyCost = CostProperties.OriginalEnergyCost(__instance.Info);
170-
if (__instance.IsUsingBlueGem())
191+
if (__instance.IsUsingBlueGem() && CostProperties.ReduceGemifiedEnergy(__instance, energyCost))
171192
energyCost--;
172193

173194
foreach (CardModificationInfo mod in __instance.TemporaryMods)

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

InscryptionCommunityPatch/InscryptionCommunityPatch.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1010
<DebugType>full</DebugType>
1111
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
12-
<Version>2.21.0</Version>
12+
<Version>2.22.0</Version>
1313
</PropertyGroup>
1414

1515
<PropertyGroup>

InscryptionCommunityPatch/InscryptionCommunityPatchPlugin.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class PatchPlugin : BaseUnityPlugin
4444
internal static ConfigEntry<bool> configRemovePatches;
4545

4646
internal static ConfigEntry<bool> configSmallPricetags;
47+
internal static ConfigEntry<bool> configMovePricetags;
4748

4849
internal static ConfigEntry<bool> configTestState;
4950

@@ -93,6 +94,7 @@ private void Awake()
9394
configMergeOnBottom = Config.Bind("Sigil Display", "Merge_On_Botom", false, "Makes it so if enabled, merged sigils will display on the bottom of the card instead of on the artwork. In extreme cases, this can cause some visual bugs.");
9495
configRemovePatches = Config.Bind("Sigil Display", "Remove_Patches", false, "Makes it so if enabled, merged sigils will not have a patch behind them anymore and will instead be glowing yellow (only works with Merge_On_Bottom).");
9596
configSmallPricetags = Config.Bind("Act 1", "Smaller Pricetags", false, "If enabled, the price tags placed on cards while buying from the Trapper will be scaled down.");
97+
configMovePricetags = Config.Bind("Act 1", "Move Pricetags", false, "If enabled, the price tags placed on cards while buying from the Trapper will be moved to the right.");
9698
act2StackIconType = Config.Bind("Sigil Display", "Act 2 Sigil icon type", true, "If true, stacking icons are a cream outline with a black center. If false, stacking icons are a black outline with a cream center. Act 2");
9799
act2TutorCenterRows = Config.Bind("Act 2", "Centred Hoarder UI", true, "If true, centres displayed cards in each row during the Hoarder selection sequence.");
98100
configFullDebug = Config.Bind("General", "Full Debug", true, "If true, displays all debug logs in the console.");

InscryptionCommunityPatch/ResourceManagers/ActOneEnergyDrone.cs

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,26 @@ namespace InscryptionCommunityPatch.ResourceManagers;
1111
[HarmonyPatch]
1212
public static class EnergyDrone
1313
{
14+
/// <summary>
15+
/// Class containing information on the resource energy drone. Controls whether the Energy Drone will appear in non-Act 3 acts.
16+
/// </summary>
1417
public class EnergyConfigInfo
1518
{
16-
public bool ConfigEnergy => PoolHasEnergy || PatchPlugin.configEnergy.Value;
17-
public bool ConfigDrone => PoolHasEnergy || ConfigDroneMox || PatchPlugin.configDrone.Value;
18-
public bool ConfigDroneMox => PoolHasGems || PatchPlugin.configDroneMox.Value;
19-
public bool ConfigMox => PoolHasGems || PatchPlugin.configMox.Value;
20-
public bool ConfigDefaultDrone => PatchPlugin.configDefaultDrone.Value;
19+
public bool ConfigEnergy { get; set; } = PoolHasEnergy || PatchPlugin.configEnergy.Value;
20+
public bool ConfigShowDrone { get; set; } = PoolHasEnergy || PatchPlugin.configDrone.Value;
21+
public bool ConfigDroneMox { get; set; } = PoolHasGems || PatchPlugin.configDroneMox.Value;
22+
public bool ConfigMox { get; set; } = PoolHasGems || PatchPlugin.configMox.Value;
23+
public bool ConfigDefaultDrone { get; set; } = PatchPlugin.configDefaultDrone.Value;
24+
25+
/// <summary>
26+
/// Controls whether or not the Drone will appear. By default, will appear if there are obtainable Energy or Mox cards in the card pool (or the corresponding config value has been set).
27+
/// </summary>
28+
public bool ConfigDrone => ConfigShowDrone || ConfigDroneMox;
2129
}
2230

31+
/// <summary>
32+
/// Contains the EnergyConfigInfos for each Act with default settings. If you want to directly alter an Act's drone behaviour, please modify GetEnergyConfig instead.
33+
/// </summary>
2334
public static Dictionary<CardTemple, EnergyConfigInfo> ZoneConfigs = new()
2435
{
2536
{ CardTemple.Nature, new() },
@@ -49,23 +60,28 @@ public static bool CurrentSceneCanHaveEnergyDrone
4960
}
5061
}
5162

52-
private static EnergyConfigInfo EnergyConfig
63+
/// <summary>
64+
/// Returns the EnergyConfigInfo object corresponding to the current Act.
65+
/// </summary>
66+
public static EnergyConfigInfo GetEnergyConfig()
5367
{
54-
get
55-
{
56-
if (SaveManager.SaveFile.IsPart3)
57-
return ZoneConfigs[CardTemple.Tech];
68+
if (SaveManager.SaveFile.IsPart3)
69+
return ZoneConfigs[CardTemple.Tech];
5870

59-
if (SaveManager.SaveFile.IsGrimora)
60-
return ZoneConfigs[CardTemple.Undead];
71+
if (SaveManager.SaveFile.IsGrimora)
72+
return ZoneConfigs[CardTemple.Undead];
6173

62-
if (SaveManager.SaveFile.IsMagnificus)
63-
return ZoneConfigs[CardTemple.Wizard];
74+
if (SaveManager.SaveFile.IsMagnificus)
75+
return ZoneConfigs[CardTemple.Wizard];
6476

65-
return ZoneConfigs[CardTemple.Nature];
66-
}
77+
return ZoneConfigs[CardTemple.Nature];
6778
}
6879

80+
/// <summary>
81+
/// The EnergyConfigInfo for the current Act.
82+
/// </summary>
83+
private static EnergyConfigInfo EnergyConfig => GetEnergyConfig();
84+
6985
public static bool PoolHasEnergy { get; private set; }
7086
public static bool PoolHasGems { get; private set; }
7187

0 commit comments

Comments
 (0)