Skip to content

Commit fcc2efe

Browse files
committed
Fix for JSONLoader
1 parent 36a5c62 commit fcc2efe

File tree

7 files changed

+18
-56
lines changed

7 files changed

+18
-56
lines changed

API.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<TargetFramework>netstandard2.0</TargetFramework>
44
<AssemblyName>API</AssemblyName>
55
<Description>An API for inscryption</Description>
6-
<Version>1.13.0.0</Version>
6+
<Version>1.13.1.0</Version>
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
<LangVersion>9.0</LangVersion>
99
<DebugType>full</DebugType>

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Changelog
2+
3+
## v1.13.1-nonkc
4+
- Fix for JSONLoader cards
5+
26
## v1.13.0
37
- Added support for custom card backgrounds, dialogs, encounters and talking cards
48
- Fixes to abilities loading and stackable custom abilities

Patches/ChapterSelectMenu_OnChapterConfirmed.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class ChapterSelectMenu_OnChapterConfirmed
1111
{
1212
public static void Prefix()
1313
{
14-
if (ScriptableObjectLoader<CardInfo>.allData == null)
14+
if (!Plugin.CardsLoaded)
1515
{
1616
List<CardInfo> official = ScriptableObjectLoader<CardInfo>.AllData;
1717
foreach (CustomCard card in CustomCard.cards)

Patches/LoadingScreenManager_LoadGameData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class LoadingScreenManager_LoadGameData
1111
{
1212
public static void Prefix()
1313
{
14-
if (ScriptableObjectLoader<CardInfo>.allData == null)
14+
if (!Plugin.CardsLoaded)
1515
{
1616
List<CardInfo> official = ScriptableObjectLoader<CardInfo>.AllData;
1717
foreach (CustomCard card in CustomCard.cards)
@@ -32,7 +32,7 @@ public static void Prefix()
3232
Plugin.Log.LogInfo($"Loaded {NewCard.cards.Count} custom cards into data");
3333
}
3434

35-
if (ScriptableObjectLoader<AbilityInfo>.allData == null)
35+
if (!Plugin.AbilitiesLoaded)
3636
{
3737
List<AbilityInfo> official = ScriptableObjectLoader<AbilityInfo>.AllData;
3838
foreach (NewAbility newAbility in NewAbility.abilities)

Plugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public partial class Plugin : BaseUnityPlugin
1313
{
1414
private const string PluginGuid = "cyantist.inscryption.api";
1515
private const string PluginName = "API";
16-
private const string PluginVersion = "1.13.0.0";
16+
private const string PluginVersion = "1.13.1.0";
1717

1818
internal static ManualLogSource Log;
1919
internal static ConfigEntry<bool> configEnergy;

Utils/IdentifierHandlers.cs

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@ namespace APIPlugin
66
{
77
public partial class Plugin
88
{
9+
private static bool cardsLoaded = false;
10+
11+
public static bool CardsLoaded { get => cardsLoaded; set => cardsLoaded = value; }
12+
13+
private static bool abilitiesLoaded = false;
14+
15+
public static bool AbilitiesLoaded { get => abilitiesLoaded; set => abilitiesLoaded = value; }
16+
917
private void SetAbilityIdentifiers()
1018
{
11-
ImportCustomAbilities();
12-
1319
Log.LogDebug($"Number of ability IDs to set from NewCard.abilityIds: [{NewCard.abilityIds.Count}]");
1420
foreach(var item in NewCard.abilityIds)
1521
{
@@ -49,54 +55,6 @@ private void SetAbilityIdentifiers()
4955
}
5056
}
5157
}
52-
53-
ImportCustomCards();
54-
}
55-
56-
private static void ImportCustomAbilities()
57-
{
58-
Plugin.Log.LogDebug($"Starting pre-emptive data load for AbilityInfo before adding custom abilities...");
59-
List<AbilityInfo> officialAbilityInfo = ScriptableObjectLoader<AbilityInfo>.AllData;
60-
61-
foreach (NewAbility newAbility in NewAbility.abilities)
62-
{
63-
officialAbilityInfo.Add(newAbility.info);
64-
Plugin.Log.LogDebug($"Official ability list now contains [{newAbility.info.rulebookName}]!");
65-
}
66-
67-
ScriptableObjectLoader<AbilityInfo>.allData = officialAbilityInfo;
68-
Plugin.Log.LogInfo($"Loaded {NewAbility.abilities.Count} custom abilities into data! " +
69-
$"Total of [{ScriptableObjectLoader<AbilityInfo>.allData.Count}]");
70-
}
71-
72-
private static void ImportCustomCards()
73-
{
74-
Plugin.Log.LogDebug($"Starting pre-emptive data load for CardInfo before adding modified and new cards...");
75-
List<CardInfo> officialCardInfo = ScriptableObjectLoader<CardInfo>.AllData;
76-
Plugin.Log.LogDebug($"CustomCards count [{CustomCard.cards.Count}] NewCard.cards count [{NewCard.cards.Count}]");
77-
foreach (CustomCard card in CustomCard.cards)
78-
{
79-
int index = officialCardInfo.FindIndex((CardInfo x) => x.name == card.name);
80-
if (index == -1)
81-
{
82-
Plugin.Log.LogWarning($"Could not find card {card.name} to modify");
83-
}
84-
else
85-
{
86-
officialCardInfo[index] = card.AdjustCard(officialCardInfo[index]);
87-
Plugin.Log.LogInfo($"Loaded modified [{card.name}] into data");
88-
}
89-
}
90-
91-
ScriptableObjectLoader<CardInfo>.allData = officialCardInfo.Concat(
92-
NewCard.cards.Select(cardInfo =>
93-
{
94-
Log.LogInfo($"Loaded custom card to card pool: [{cardInfo.name}]");
95-
return cardInfo;
96-
}
97-
)
98-
).ToList();
99-
Plugin.Log.LogInfo($"Loaded {NewCard.cards.Count} custom cards into data");
10058
}
10159

10260
private void SetSpecialAbilityIdentifiers()

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "API",
3-
"version_number": "1.13.0",
3+
"version_number": "1.13.1",
44
"website_url": "https://github.com/ScottWilson0903/InscryptionAPI",
55
"description": "This plugin is a BepInEx plugin made for Inscryption as an API. It can currently create custom cards and abilities and inject them into the data pool, or modify existing cards in the card pool.",
66
"dependencies": [

0 commit comments

Comments
 (0)