Skip to content
Merged
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
25 changes: 24 additions & 1 deletion Abstracts/CustomPotionModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using BaseLib.Patches;
using HarmonyLib;
using BaseLib.Patches.Content;
using MegaCrit.Sts2.Core.Helpers;
using MegaCrit.Sts2.Core.Models;

namespace BaseLib.Abstracts;
Expand All @@ -11,4 +12,26 @@ public CustomPotionModel()
{
if (AutoAdd) CustomContentDictionary.AddModel(GetType());
}

public virtual string? PackedImagePath => null;
public virtual string? PackedOutlinePath => null;

[HarmonyPatch(typeof(PotionModel), nameof(CustomPotionModel.PackedImagePath), MethodType.Getter)]
private static class ImagePatch {
static bool Prefix(PotionModel __instance, ref string __result) {
if (__instance is not CustomPotionModel model || model.PackedImagePath is not string path)
return true;
__result = path;
return false;
}
}
[HarmonyPatch(typeof(PotionModel), nameof(CustomPotionModel.PackedOutlinePath), MethodType.Getter)]
private static class OutlinePatch {
static bool Prefix(PotionModel __instance, ref string __result) {
if (__instance is not CustomPotionModel model || model.PackedOutlinePath is not string path)
return true;
__result = path;
return false;
}
}
}