Files
AquaDX/AquaMai/AquaMai.Mods/GameSettings/CreditConfig.cs
Menci 37044dae01 [RF] AquaMai configuration refactor (#82)
更新了配置文件格式,原有的配置文件将被自动无缝迁移,详情请见新的配置文件中的注释(例外:`SlideJudgeTweak` 不再默认启用)
旧配置文件将被重命名备份,如果更新到此版本遇到 Bug 请联系我们

Updated configuration file schema. The old config file will be migrated automatically and seamlessly. See the comments in the new configuration file for details. (Except for `SlideJudgeTweak` is no longer enabled by default)
Your old configuration file will be renamed as a backup. If you encounter any bug with this version, please contact us.
2024-11-25 01:25:19 +08:00

50 lines
1.5 KiB
C#

using AquaMai.Config.Attributes;
using AquaMai.Core.Attributes;
using HarmonyLib;
namespace AquaMai.Mods.GameSettings;
[ConfigSection(
en: "Set the game to Paid Play (lock credits) or Free Play.",
zh: "设置游戏为付费游玩(锁定可用点数)或免费游玩")]
public class CreditConfig
{
[ConfigEntry(
en: "Set to Free Play (set to false for Paid Play).",
zh: "是否免费游玩(设为 false 时为付费游玩)")]
private static readonly bool isFreePlay = true;
[HarmonyPrefix]
[HarmonyPatch(typeof(Manager.Credit), "IsFreePlay")]
private static bool PreIsFreePlay(ref bool __result)
{
__result = isFreePlay;
return false;
}
[ConfigEntry(
en: "Lock credits amount (only valid in Paid Play). Set to 0 to disable.",
zh: "锁定可用点数数量(仅在付费游玩时有效),设为 0 以禁用")]
private static readonly uint lockCredits = 24;
private static bool ShouldLockCredits => !isFreePlay && lockCredits > 0;
[EnableIf(nameof(ShouldLockCredits))]
[HarmonyPrefix]
[HarmonyPatch(typeof(Manager.Credit), "IsGameCostEnough")]
private static bool PreIsGameCostEnough(ref bool __result)
{
__result = true;
return false;
}
[EnableIf(nameof(ShouldLockCredits))]
[HarmonyPrefix]
[HarmonyPatch(typeof(AMDaemon.CreditUnit), "Credit", MethodType.Getter)]
private static bool PreCredit(ref uint __result)
{
__result = 24;
return false;
}
}