Skip to content

Commit 8a4b07d

Browse files
committed
Merge remote-tracking branch 'remotes/origin/dev'
2 parents 07f32c2 + baed403 commit 8a4b07d

11 files changed

Lines changed: 460 additions & 387 deletions

Const.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public static class Const
44
{
55
public const string Name = "RitsuLib";
66
public const string ModId = "com.ritsukage.sts2-RitsuLib";
7-
public const string Version = "0.0.16";
7+
public const string Version = "0.0.17";
88
public const string SettingsKey = "settings";
99
public const string SettingsFileName = "settings.json";
1010
}

Content/ModContentRegistry.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public sealed partial class ModContentRegistry
2525
private static readonly HashSet<Type> RegisteredMonsters = [];
2626
private static readonly HashSet<Type> RegisteredPowers = [];
2727
private static readonly HashSet<Type> RegisteredOrbs = [];
28+
private static readonly HashSet<Type> RegisteredSharedCardPools = [];
2829
private static readonly HashSet<Type> RegisteredSharedEvents = [];
2930
private static readonly HashSet<Type> RegisteredSharedAncients = [];
3031
private static readonly Dictionary<Type, HashSet<Type>> RegisteredActEncounters = [];
@@ -144,6 +145,12 @@ public void RegisterOrb<TOrb>() where TOrb : OrbModel
144145
RegisterStandaloneModel(RegisteredOrbs, typeof(TOrb), typeof(OrbModel), "orb");
145146
}
146147

148+
public void RegisterSharedCardPool<TPool>() where TPool : CardPoolModel
149+
{
150+
RegisterStandaloneModel(RegisteredSharedCardPools, typeof(TPool), typeof(CardPoolModel),
151+
"shared card pool");
152+
}
153+
147154
public void RegisterSharedEvent<TEvent>() where TEvent : EventModel
148155
{
149156
RegisterStandaloneModel(RegisteredSharedEvents, typeof(TEvent), typeof(EventModel), "shared event");
@@ -230,6 +237,11 @@ internal static IEnumerable<OrbModel> AppendOrbs(IEnumerable<OrbModel> source)
230237
return AppendResolved(source, ResolveModels<OrbModel>(RegisteredOrbs));
231238
}
232239

240+
internal static IEnumerable<CardPoolModel> AppendSharedCardPools(IEnumerable<CardPoolModel> source)
241+
{
242+
return AppendResolved(source, ResolveModels<CardPoolModel>(RegisteredSharedCardPools));
243+
}
244+
233245
internal static IEnumerable<EventModel> AppendActEvents(ActModel act, IEnumerable<EventModel> source)
234246
{
235247
return AppendResolved(source, ResolveScopedModels<EventModel>(RegisteredActEvents, act.GetType()));
@@ -265,6 +277,7 @@ internal static void InjectRegisteredModels()
265277
.Concat(RegisteredMonsters)
266278
.Concat(RegisteredPowers)
267279
.Concat(RegisteredOrbs)
280+
.Concat(RegisteredSharedCardPools)
268281
.Concat(RegisteredSharedEvents)
269282
.Concat(RegisteredSharedAncients)
270283
.Concat(RegisteredActEncounters.Values.SelectMany(static set => set))

Content/Patches/ModelDbContentPatches.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,24 @@ public static void Postfix(ref IEnumerable<OrbModel> __result)
9393
}
9494
}
9595

96+
public class AllSharedCardPoolsPatch : IPatchMethod
97+
{
98+
public static string PatchId => "modeldb_all_shared_card_pools";
99+
public static string Description => "Append registered shared card pools to ModelDb.AllSharedCardPools";
100+
public static bool IsCritical => true;
101+
102+
public static ModPatchTarget[] GetTargets()
103+
{
104+
return [new(typeof(ModelDb), "get_AllSharedCardPools")];
105+
}
106+
107+
// ReSharper disable once InconsistentNaming
108+
public static void Postfix(ref IEnumerable<CardPoolModel> __result)
109+
{
110+
__result = ModContentRegistry.AppendSharedCardPools(__result);
111+
}
112+
}
113+
96114
public class AllEventsPatch : IPatchMethod
97115
{
98116
public static string PatchId => "modeldb_all_events";

RitsuLibFramework.PatcherSetup.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ private static void RegisterContentRegistryPatches()
159159
patcher.RegisterPatch<ActsPatch>();
160160
patcher.RegisterPatch<AllPowersPatch>();
161161
patcher.RegisterPatch<AllOrbsPatch>();
162+
patcher.RegisterPatch<AllSharedCardPoolsPatch>();
162163
patcher.RegisterPatch<AllSharedEventsPatch>();
163164
patcher.RegisterPatch<AllEventsPatch>();
164165
patcher.RegisterPatch<AllSharedAncientsPatch>();

STS2-RitsuLib.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<NoWarn>CS0436</NoWarn>
1111
<IsPackable>true</IsPackable>
1212
<PackageId>STS2.RitsuLib</PackageId>
13-
<Version>0.0.16</Version>
13+
<Version>0.0.17</Version>
1414
<Authors>OLC</Authors>
1515
<Description>Shared framework library for Slay the Spire 2 mods.</Description>
1616
<PackageReadmeFile>README.md</PackageReadmeFile>

Scaffolding/Content/ContentRegistrationEntries.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,13 @@ public void Register(ModContentRegistry registry)
6464
registry.RegisterPower<TPower>();
6565
}
6666
}
67+
68+
public sealed class SharedCardPoolRegistrationEntry<TPool> : IContentRegistrationEntry
69+
where TPool : CardPoolModel
70+
{
71+
public void Register(ModContentRegistry registry)
72+
{
73+
registry.RegisterSharedCardPool<TPool>();
74+
}
75+
}
6776
}

Scaffolding/Content/ModCardTemplate.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,20 @@ public abstract class ModCardTemplate(
1111
CardType type,
1212
CardRarity rarity,
1313
TargetType target,
14-
bool showInCardLibrary = true,
15-
bool autoAdd = true) : CardModel(baseCost, type, rarity, target, showInCardLibrary), IModCardAssetOverrides
14+
bool showInCardLibrary = true)
15+
: CardModel(baseCost, type, rarity, target, showInCardLibrary), IModCardAssetOverrides
1616
{
17-
protected bool AutoAddRequested { get; } = autoAdd;
17+
[Obsolete("The autoAdd parameter is no longer used and will be removed in a future version.")]
18+
protected ModCardTemplate(
19+
int baseCost,
20+
CardType type,
21+
CardRarity rarity,
22+
TargetType target,
23+
bool showInCardLibrary,
24+
bool autoAdd) : this(baseCost, type, rarity, target, showInCardLibrary)
25+
{
26+
}
27+
1828
protected virtual IEnumerable<string> RegisteredKeywordIds => [];
1929
protected virtual IEnumerable<IHoverTip> AdditionalHoverTips => [];
2030

Scaffolding/Content/ModContentPackBuilder.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ public ModContentPackBuilder Orb<TOrb>() where TOrb : OrbModel
7474
return AddStep(ctx => ctx.Content.RegisterOrb<TOrb>());
7575
}
7676

77+
public ModContentPackBuilder SharedCardPool<TPool>() where TPool : CardPoolModel
78+
{
79+
return AddStep(ctx => ctx.Content.RegisterSharedCardPool<TPool>());
80+
}
81+
7782
public ModContentPackBuilder SharedEvent<TEvent>() where TEvent : EventModel
7883
{
7984
return AddStep(ctx => ctx.Content.RegisterSharedEvent<TEvent>());

0 commit comments

Comments
 (0)