Skip to content

Commit 65f901a

Browse files
Add config option to prevent Act 1 card emissions from rendering above the play costs
1 parent 2e9caa6 commit 65f901a

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using DiskCardGame;
2+
using HarmonyLib;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Text;
6+
using UnityEngine;
7+
8+
namespace InscryptionCommunityPatch.Card;
9+
10+
[HarmonyPatch]
11+
public class Part1CostEmissionMaskRender {
12+
public static readonly Dictionary<CardDisplayer3D, SpriteRenderer> CostEmissionMaskRenderers = new();
13+
14+
public static SpriteRenderer Verify3DCostEmissionMaskRenderer(CardDisplayer3D cardDisplayer, bool emissionEnabled) {
15+
// add entry for new CardDisplayer3D's
16+
if (!CostEmissionMaskRenderers.TryGetValue(cardDisplayer, out SpriteRenderer result)) {
17+
//PatchPlugin.Logger.LogDebug("[Verify3DCostEmissionMaskRenderer] Add cost mask renderer to CardDisplay3D");
18+
GameObject obj = GameObject.Instantiate(cardDisplayer.costRenderer.gameObject, cardDisplayer.transform);
19+
obj.name = "CostEmissionMask";
20+
obj.layer = cardDisplayer.emissivePortraitRenderer.gameObject.layer;
21+
result = obj.GetComponent<SpriteRenderer>();
22+
result.color = Color.black;
23+
result.sortingOrder = 100;
24+
CostEmissionMaskRenderers.Add(cardDisplayer, result);
25+
}
26+
27+
if (result == null) {
28+
PatchPlugin.Logger.LogWarning("[Verify3DCostEmissionMaskRenderer] Could not find/create SpriteRenderer for CardDisplayer3D instance");
29+
}
30+
else {
31+
// disable if config is false ; otherwise toggle based on appearance of emissive portrait
32+
result.gameObject.SetActive(PatchPlugin.configCostMask.Value && emissionEnabled);
33+
}
34+
35+
return result;
36+
}
37+
38+
[HarmonyPrefix, HarmonyPatch(typeof(CardDisplayer3D), nameof(CardDisplayer3D.Awake))]
39+
private static void AddCostEmissionMaskOnAwake(CardDisplayer3D __instance) {
40+
Verify3DCostEmissionMaskRenderer(__instance, false);
41+
}
42+
43+
[HarmonyPriority(Priority.Last), HarmonyPostfix, HarmonyPatch(typeof(CardDisplayer3D), nameof(CardDisplayer3D.DisplayInfo))]
44+
private static void UpdateCostEmissionMask(CardDisplayer3D __instance) {
45+
SpriteRenderer rend = Verify3DCostEmissionMaskRenderer(__instance, __instance.emissivePortraitRenderer.gameObject.activeSelf);
46+
if (rend != null) {
47+
//PatchPlugin.Logger.LogDebug("[UpdateCostEmissionMask] Update Cost emission mask");
48+
rend.sprite = __instance.costRenderer.sprite;
49+
}
50+
}
51+
}

InscryptionCommunityPatch/InscryptionCommunityPatchPlugin.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class PatchPlugin : BaseUnityPlugin
3131
internal static ConfigEntry<bool> configShowSquirrelTribeOnCards;
3232
internal static ConfigEntry<bool> configAct3Bones;
3333

34+
internal static ConfigEntry<bool> configCostMask;
3435
internal static ConfigEntry<bool> configResetEyes;
3536
internal static ConfigEntry<bool> undeadCatEmission;
3637

@@ -107,6 +108,7 @@ private void Awake()
107108
configFullDebug = Config.Bind("General", "Full Debug", true, "If true, displays all debug logs in the console.");
108109
configTestState = Config.Bind("General", "Test Mode", false, "Puts the game into test mode. This will cause (among potentially other things) a new run to spawn a number of cards into your opening deck that will demonstrate card behaviors.");
109110
configResetEyes = Config.Bind("Act 1", "Reset Red Eyes", false, "Resets Leshy's eyes to normal if they were turned red due to a boss fight's grizzly bear sequence.");
111+
configCostMask = Config.Bind("Act 1", "Render Costs Above Emission", true, "Applies a mask to card emissions that prevents them from covering play costs when rendering in-game.");
110112
undeadCatEmission = Config.Bind("General", "Undead Cat Emission", false, "If true, Undead Cat will have a forced red emission.");
111113
}
112114

0 commit comments

Comments
 (0)