Skip to content

Commit

Permalink
Merge pull request #297 from HumabHatterZed/main
Browse files Browse the repository at this point in the history
Fixed activated sigils not working in act 3
  • Loading branch information
IngoHHacks authored Jan 22, 2024
2 parents 9275a9e + 1ccb82d commit 2bbb57d
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 33 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<details>
<summary>View Changelog</summary>

# 2.19.2
- Fixed activated abilities not being interactable in Act 3
- Fixed cards with costs above vanilla defaults not displaying
- Added debug logs to AddCustomTribesToList (used to add custom Tribes to the list of obtainable Totem tops)

# 2.19.1
- Fixed API not retrieving pixel card costs above 5

Expand Down
9 changes: 9 additions & 0 deletions InscryptionAPI/Card/TribeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,15 @@ public static Texture2D GetTribeIcon(Tribe tribe, bool useMissingIconIfNull = tr
return texture2D;
}

/// <summary>
/// The internal object used to store all relevant info about a Tribe.
/// guid - The mod GUID that added the Tribe.
/// name - The internal name of the Tribe.
/// tribe - The enum value corresponding to this Tribe.
/// icon - The sprite displayed on cards with this Tribe.
/// tribeChoice - Whether or not this Tribe can appear at card tribe choice nodes.
/// cardBack - The texture displayed at card tribe choice nodes. If null, the API will create one using the icon Sprite.
/// </summary>
public class TribeInfo
{
public string guid;
Expand Down
2 changes: 1 addition & 1 deletion InscryptionAPI/InscryptionAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<DebugType>full</DebugType>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<Version>2.19.1</Version>
<Version>2.19.2</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion InscryptionAPI/InscryptionAPIPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class InscryptionAPIPlugin : BaseUnityPlugin
{
public const string ModGUID = "cyantist.inscryption.api";
public const string ModName = "InscryptionAPI";
public const string ModVer = "2.19.1";
public const string ModVer = "2.19.2";

public static string Directory = "";

Expand Down
44 changes: 16 additions & 28 deletions InscryptionAPI/Totems/TotemManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,20 @@ public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructio

public static void AddCustomTribesToList(List<Tribe> list)
{
// get a list of all cards with a tribe
List<CardInfo> tribedCards = CardManager.AllCardsCopy.FindAll(x => x.tribes.Count > 0);
list.AddRange(TribeManager.NewTribes.Where(x => x.tribeChoice).Select(x => x.tribe));
InscryptionAPIPlugin.Logger.LogDebug($"Total Tribes: {list.Count}");

List<CardInfo> cardsWithTribes = CardManager.AllCardsCopy.FindAll(x => x.tribes.Count > 0);
list.RemoveAll(x => !cardsWithTribes.Exists(ci => ci.IsOfTribe(x)));

// iterate across all custom tribes that are obtainable as tribe choices
foreach (TribeManager.TribeInfo tribeInfo in TribeManager.NewTribes.Where(x => x.tribeChoice))
{
// Only add if we have at least 1 card of it
if (tribedCards.Exists(ci => ci.IsOfTribe(tribeInfo.tribe)))
list.Add(tribeInfo.tribe);
}

// remove tribes without any cards
list.RemoveAll(x => !tribedCards.Exists(ci => ci.IsOfTribe(x)));
InscryptionAPIPlugin.Logger.LogDebug($"Tribes with 1 Card: {list.Count}");
}
}

[HarmonyPatch(typeof(ResourceBank), "Awake", new Type[] { })]
private class ResourceBank_Awake
{
public static void Postfix(ResourceBank __instance)
private static void Postfix(ResourceBank __instance)
{
// The resource bank has been cleared. refill it
if (ResourceBank.Get<GameObject>(CustomTotemTopResourcePath) == null)
Expand All @@ -110,21 +104,14 @@ public static void Postfix(ResourceBank __instance)
[HarmonyPatch(typeof(Totem), "GetTopPiecePrefab", new Type[] { typeof(TotemTopData) })]
private class Totem_GetTopPiecePrefab
{
public static bool Prefix(Totem __instance, TotemTopData data, ref GameObject __result)
private static bool Prefix(TotemTopData data, ref GameObject __result)
{
if (TribeManager.IsCustomTribe(data.prerequisites.tribe))
{
CustomTotemTop customTribeTotem = totemTops.Find((a) => a.Tribe == data.prerequisites.tribe);
if (customTribeTotem != null)
{
// Get custom totem model
__result = customTribeTotem.Prefab;
}
else
{
// No custom totem model - use default model
__result = defaultTotemTop.Prefab;
}

// use the custom Totem top if it exists; otherwise use the default
__result = customTribeTotem?.Prefab ?? defaultTotemTop.Prefab;
return false;
}
else if (InscryptionAPIPlugin.configCustomTotemTopTypes.Value == TotemTopState.AllTribes)
Expand All @@ -140,7 +127,7 @@ public static bool Prefix(Totem __instance, TotemTopData data, ref GameObject __
[HarmonyPatch(typeof(Totem), "SetData", new Type[] { typeof(ItemData) })]
private class Totem_SetData
{
public static void Postfix(Totem __instance, ItemData data)
private static void Postfix(Totem __instance, ItemData data)
{
__instance.topPieceParent.GetComponentInChildren<CompositeTotemPiece>().SetData(__instance.TotemItemData.top);
}
Expand All @@ -149,7 +136,7 @@ public static void Postfix(Totem __instance, ItemData data)
[HarmonyPatch(typeof(TotemTopData), "PrefabId", MethodType.Getter)]
private class TotemTopData_PrefabId
{
public static bool Prefix(TotemTopData __instance, ref string __result)
private static bool Prefix(TotemTopData __instance, ref string __result)
{
// Custom totem tops will always use the fallback UNLESS there is an override
if (TribeManager.IsCustomTribe(__instance.prerequisites.tribe))
Expand Down Expand Up @@ -211,13 +198,14 @@ public static bool Prefix(Ability x, ref bool __result)
[HarmonyPatch]
private class FixMissingAbilityInfo2
{
// think this could be simplified but I ain't touching it
public static IEnumerable<MethodBase> TargetMethods()
{
var innerClass = Type.GetType("DiskCardGame.BuildTotemSequencer+<>c__DisplayClass26_0, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
yield return AccessTools.Method(innerClass, "<GenerateTotemChoices>b__1");
}

public static bool Prefix(Ability x)
private static bool Prefix(Ability x)
{
return AbilitiesUtil.GetInfo(x) != null;
}
Expand Down Expand Up @@ -246,7 +234,7 @@ public static CustomTotemTop NewTopPiece<T>(string name, string guid, Tribe trib
{
if (prefab == null)
{
InscryptionAPIPlugin.Logger.LogError($"Cannot load NewTopPiece for {guid}.{name}. Prefab is null!");
InscryptionAPIPlugin.Logger.LogError($"Cannot load NewTopPiece for {guid}.{name}; prefab is null!");
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion InscryptionCommunityPatch/Card/ActivatedAbilityIconFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static bool HasActivatedAbility(this PlayableCard card)
[HarmonyPostfix, HarmonyPatch(typeof(ActivatedAbilityBehaviour), nameof(ActivatedAbilityBehaviour.RespondsToResolveOnBoard))]
private static void RespondsToResolveOnBoard_PostFix(ref bool __result)
{
__result &= SaveManager.saveFile.IsPart2;
__result &= SaveManager.SaveFile.IsPart2;
}

[HarmonyPostfix, HarmonyPatch(typeof(PlayableCard), nameof(PlayableCard.OnStatsChanged))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal class BoxColliderNegativeScalingLogSpamFix
[HarmonyPrefix, HarmonyPatch(typeof(AbilityIconInteractable), nameof(AbilityIconInteractable.SetFlippedY))]
private static void ReplaceBoxColliderWithMeshColliderIfIconIsFlippedY(AbilityIconInteractable __instance, bool flippedY)
{
if (!flippedY && !SaveManager.SaveFile.IsPart3)
if (!flippedY && !SaveManager.SaveFile.IsPart3) // change to mesh only if we're flipped or in Act 3
return;

MeshCollider collider = __instance.gameObject.GetComponent<MeshCollider>();
Expand All @@ -42,7 +42,7 @@ private static void ReplaceBoxColliderWithMeshColliderIfIconIsFlippedY(AbilityIc
[HarmonyPostfix, HarmonyPatch(typeof(AbilityIconInteractable), nameof(AbilityIconInteractable.SetFlippedY))]
private static void OffsetFlippedColliderPositionY(AbilityIconInteractable __instance, bool flippedY)
{
if (!flippedY || SaveManager.SaveFile.IsPart3)
if (!flippedY && !SaveManager.SaveFile.IsPart3)
return;

MeshCollider collider = __instance.gameObject.GetComponent<MeshCollider>();
Expand Down
12 changes: 12 additions & 0 deletions InscryptionCommunityPatch/Card/CardCostRender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,16 @@ private static void CreateFullCostSprite(CardDisplayer __instance, CardRenderInf
PatchPlugin.rightAct2Cost.Value ? TextureHelper.SpriteType.Act2CostDecalRight : TextureHelper.SpriteType.Act2CostDecalLeft, 8);
}
}

[HarmonyPrefix, HarmonyPatch(typeof(CardDisplayer), nameof(CardDisplayer.GetCostSpriteForCard))]
private static bool Part1CardCostDisplayerPatch(CardDisplayer __instance)
{
//Make sure we are in Leshy's Cabin
// prevents indexing error when a card has a cost greater than the vanilla limits
if (__instance is CardDisplayer3D && SceneLoader.ActiveSceneName.StartsWith("Part1"))
return false;


return true;
}
}

0 comments on commit 2bbb57d

Please sign in to comment.