Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.23.6
- Fixed card modifications added to a card's base ice cube card via CardInfo.SetIceCube being ignored
- Added additional methods for adding specific types of resources to the ResourceBank

# 2.23.5
- Fixed cards appearing as blank outside Act 1
- Added extension methods for FullAbility that mirror AbilityInfo extension methods
Expand Down
40 changes: 33 additions & 7 deletions InscryptionAPI/Card/AbilityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using InscryptionAPI.Helpers;
using InscryptionAPI.Helpers.Extensions;
using InscryptionAPI.RuleBook;
using Sirenix.Utilities;
using System.Collections;
using System.Collections.ObjectModel;
using System.Reflection;
Expand Down Expand Up @@ -683,6 +684,38 @@ private static void LogAbilityInfo(Ability ability, AbilityInfo abilityInfo, Car
InscryptionAPIPlugin.Logger.LogError("Cannot find ability " + ability + " for " + info.displayedName);
}

[HarmonyPatch(typeof(IceCube), nameof(IceCube.OnDie), MethodType.Enumerator)]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> AddInherentModsToIceCube(IEnumerable<CodeInstruction> instructions) {
List<CodeInstruction> codes = new(instructions);

for (int i = 0; i < codes.Count; i++) {
if (codes[i].opcode == OpCodes.Ldloc_2) {
// this probably belongs in the community patches but this transpiler was already here, so eh
// overrides the transformer icon so it can display numbers
MethodInfo customMethod = AccessTools.Method(typeof(AbilityManager), nameof(AbilityManager.GetIceCubeInfoWithMods),
new Type[] { typeof(IceCube), typeof(string) });

// ldloc_1 <- IceCube
// ldloc_2 <- name
// call (customMethod)
codes[i + 1] = new(OpCodes.Call, customMethod);
codes.Insert(i, new(OpCodes.Ldloc_1));
break;
}
}

return codes;
}

private static CardInfo GetIceCubeInfoWithMods(IceCube instance, string cardName) {
CardInfo info = CardLoader.GetCardByName(cardName);
if (instance.Card.Info.iceCubeParams != null && instance.Card.Info.iceCubeParams.creatureWithin != null && instance.Card.Info.iceCubeParams.creatureWithin.mods != null && instance.Card.Info.iceCubeParams.creatureWithin.mods.Count > 0) {
info.Mods.AddRange(instance.Card.Info.iceCubeParams.creatureWithin.mods);
}
return info;
}

#region Evolve Changes
[HarmonyPatch(typeof(Evolve), nameof(Evolve.OnUpkeep), MethodType.Enumerator)]
[HarmonyTranspiler]
Expand Down Expand Up @@ -734,13 +767,6 @@ private static bool OverrideTransformIcon(ref Texture __result, AbilityIconInter
}
return true;
}
//[HarmonyPrefix, HarmonyPatch(typeof(AbilitiesUtil), nameof(AbilitiesUtil.LoadAbilityIcon))]
//private static bool OverrideEvolveAndTransformerIcon(ref Texture __result, string abilityName) {
// if (abilityName.StartsWith("Evolve") || abilityName.StartsWith("Transformer")) {
// return false;
// }
// return true;
//}
private static void OverrideEvolveDerivedIcon(Evolve evolve, int turnsLeftToEvolve)
{
if (evolve.Ability == Ability.Evolve)
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.23.5</Version>
<Version>2.23.6</Version>
</PropertyGroup>

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

public static string Directory = "";

Expand Down
93 changes: 84 additions & 9 deletions InscryptionAPI/ResourceBank/ResourceBankManager.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using DiskCardGame;
using HarmonyLib;
using UnityEngine;

Expand All @@ -14,15 +15,6 @@ public class ResourceData

private static readonly List<ResourceData> CustomResources = new();

public static ResourceData AddDecal(string pluginGUID, string resourceName, Texture decalTexture, bool overrideExistingAsset = false)
{
return Add(pluginGUID, new ResourceBank.Resource()
{
path = $"Art/Cards/Decals/{resourceName}",
asset = decalTexture
}, overrideExistingAsset);
}

public static ResourceData Add(string pluginGUID, string path, UnityObject unityObject, bool overrideExistingAsset = false)
{
return Add(pluginGUID, new ResourceBank.Resource()
Expand Down Expand Up @@ -56,6 +48,89 @@ public static ResourceData Add(string pluginGUID, ResourceBank.Resource resource
return resourceData;
}

/// <summary>
/// Adds a custom GameObject resource located at the path Inscryption uses to retrieve Prefabs when instantiating weights for the scales.
/// </summary>
/// <param name="pluginGUID">The GUID of the plugin adding the resource.</param>
/// <param name="resourceName">The name used to identify the resource. Used when retrieving it from the ResourceBank</param>
/// <param name="eventPrefab">The scales weight GameObject.</param>
/// <param name="overrideExistingAsset">If we should override any existing asset that shares this resource's path.</param>
public static ResourceData AddScaleWeightPrefab(string pluginGUID, string resourceName, GameObject prefab, bool overrideExistingAsset = false) {
return Add(pluginGUID, "Prefabs/Environment/ScaleWeights/" + resourceName, prefab, overrideExistingAsset);
}

/// <summary>
/// Adds a custom GameObject resource located at the path Inscryption uses to retrieve Prefabs when instantiating card battle idle events, eg, the spider.
/// </summary>
/// <remarks>
/// Note: Object must have a CardBattleIdleEvent component attached.
/// </remarks>
/// <param name="pluginGUID">The GUID of the plugin adding the resource.</param>
/// <param name="resourceName">The name used to identify the resource. Used when retrieving it from the ResourceBank</param>
/// <param name="eventPrefab">The GameObject for the CardBattleIdleEvent.</param>
/// <param name="overrideExistingAsset">If we should override any existing asset that shares this resource's path.</param>
public static ResourceData AddCardBattleIdleEvent(string pluginGUID, string resourceName, GameObject eventPrefab, bool overrideExistingAsset = false) {
return Add(pluginGUID, "Prefabs/Environment/CardBattleIdleEvents/" + resourceName, eventPrefab, overrideExistingAsset);
}

/// <summary>
/// Adds a custom GameObject resource located at the path Inscryption uses to retrieve Prefabs when instantiating first person animations.
/// </summary>
/// <remarks>
/// Note: The game checks the Prefab's children for the Animator and FirstPersonAnimatorObject.
/// </remarks>
/// <param name="pluginGUID">The GUID of the plugin adding the resource.</param>
/// <param name="resourceName">The name used to identify the resource. Used when retrieving it from the ResourceBank</param>
/// <param name="animPrefab">The table effect GameObject.</param>
/// <param name="overrideExistingAsset">If we should override any existing asset that shares this resource's path.</param>
public static ResourceData AddFirstPersonAnimation(string pluginGUID, string resourceName, GameObject animPrefab, bool overrideExistingAsset = false) {
return Add(pluginGUID, "Prefabs/FirstPersonAnimations/" + resourceName, animPrefab, overrideExistingAsset);
}

/// <summary>
/// Adds a custom GameObject resource located at the path Inscryption uses to retrieve Prefabs when instantiating table effects, ie, during boss fights.
/// </summary>
/// <param name="pluginGUID">The GUID of the plugin adding the resource.</param>
/// <param name="resourceName">The name used to identify the resource. Used when retrieving it from the ResourceBank</param>
/// <param name="tableEffectPrefab">The table effect GameObject.</param>
/// <param name="overrideExistingAsset">If we should override any existing asset that shares this resource's path.</param>
public static ResourceData AddTableEffect(string pluginGUID, string resourceName, GameObject tableEffectPrefab, bool overrideExistingAsset = false) {
return Add(pluginGUID, "Prefabs/Environment/TableEffects/" + resourceName, tableEffectPrefab, overrideExistingAsset);
}

/// <summary>
/// Adds a custom GameObject resource located at the path Inscryption uses to retrieve Prefabs when generating map scenery.
/// </summary>
/// <param name="pluginGUID">The GUID of the plugin adding the resource.</param>
/// <param name="resourceName">The name used to identify the resource. Used when retrieving it from the ResourceBank</param>
/// <param name="sceneryPrefab">The map scenery GameObject.</param>
/// <param name="overrideExistingAsset">If we should override any existing asset that shares this resource's path.</param>
public static ResourceData AddMapScenery(string pluginGUID, string resourceName, GameObject sceneryPrefab, bool overrideExistingAsset = false) {
return Add(pluginGUID, SceneryData.PREFABS_ROOT + resourceName, sceneryPrefab, overrideExistingAsset);
}

/// <summary>
/// Adds a custom Texture resource located at the path Inscryption uses to retrieve ability icons.
/// </summary>
/// <param name="pluginGUID">The GUID of the plugin adding the resource.</param>
/// <param name="resourceName">The name used to identify the resource. Used when retrieving it from the ResourceBank</param>
/// <param name="iconTexture">The ability icon's texture.</param>
/// <param name="overrideExistingAsset">If we should override any existing asset that shares this resource's path.</param>
public static ResourceData AddAbilityIcon(string pluginGUID, string resourceName, Texture iconTexture, bool overrideExistingAsset = false) {
return Add(pluginGUID, "Art/Cards/AbilityIcons/" + resourceName, iconTexture, overrideExistingAsset);
}

/// <summary>
/// Adds a custom Texture resource located at the path Inscryption uses to retrieve card decal textures.
/// </summary>
/// <param name="pluginGUID">The GUID of the plugin adding the resource.</param>
/// <param name="resourceName">The name used to identify the resource. Used when retrieving it from the ResourceBank</param>
/// <param name="decalTexture">The decal texture.</param>
/// <param name="overrideExistingAsset">If we should override any existing asset that shares this resource's path.</param>
public static ResourceData AddDecal(string pluginGUID, string resourceName, Texture decalTexture, bool overrideExistingAsset = false) {
return Add(pluginGUID, "Art/Cards/Decals/" + resourceName, decalTexture, overrideExistingAsset);
}

[HarmonyPatch(typeof(ResourceBank), "Awake", new Type[] { })]
internal class ResourceBank_Awake
{
Expand Down
Loading