Phase 2: mixer (Web3 tab in the network, terminal page, sanctions, night return), unlock registration per upgrade
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
133367b58d
commit
09a5cae69c
11 files changed
+290
-16
No files matched your search
+19
-13
@@ -8,24 +8,30 @@ namespace Decentralized
|
||||
public const string Id = "PD_WEB3_COMMUNITY";
|
||||
public const int Price = 400;
|
||||
private const string Card = "Service";
|
||||
/// <summary>人脉网络里本 mod 自己的一页:入口、混币器等 Web3 相关升级都放在这里。</summary>
|
||||
public const string Tab = "PD_WEB3";
|
||||
|
||||
public const string MixerId = "PD_MIXER";
|
||||
public const int MixerPrice = 700;
|
||||
public static bool MixerUnlocked => PlayerStore.Instance != null && ModHelper.IsNetworkUpgradeUnlocked(MixerId);
|
||||
|
||||
public static bool IsUnlocked => PlayerStore.Instance != null && ModHelper.IsNetworkUpgradeUnlocked(Id);
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 分类用游戏自己的 "Service" 键,和 Probably Automated 一样归进现有的"服务"栏;
|
||||
// 标题和说明用回调:OnEnable 时 mod 本地化表还没加载
|
||||
ModHelper.AddNetworkUpgrade(ModInfo.Id, Id, Price, Card,
|
||||
() => L.T("upgrade.title"), () => L.T("upgrade.desc"), OnPurchased,
|
||||
iconKey: ModInfo.Id + ":terminal");
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
// 登记定义后游戏会访问 PlayerStore.Instance,主菜单阶段为空会抛异常;定义已登记,读档时游戏会把升级补进这一局。
|
||||
Log.Info("人脉升级已登记(主菜单阶段访问 PlayerStore 失败,已忽略)");
|
||||
}
|
||||
// 分类用游戏自己的 "Service" 键,和 Probably Automated 一样归进现有的"服务"栏;
|
||||
// 标题和说明用回调:OnEnable 时 mod 本地化表还没加载
|
||||
ModHelper.SetNetworkTabLabel(Tab, () => L.T("upgrade.tab"));
|
||||
// 登记定义后游戏会访问 PlayerStore.Instance,主菜单阶段为空会抛异常;定义已登记,读档时游戏会把升级补进这一局。
|
||||
// 每个升级单独 try,免得前一个抛异常时后面的没登记上。
|
||||
Add(Id, Price, () => L.T("upgrade.title"), () => L.T("upgrade.desc"), OnPurchased, "terminal", null);
|
||||
Add(MixerId, MixerPrice, () => L.T("mixer.upgrade.title"), () => L.T("mixer.upgrade.desc"), () => Log.Info("混币器已解锁"), "ui_web3", new[] { Id });
|
||||
}
|
||||
|
||||
private static void Add(string id, int price, Func<string> title, Func<string> desc, Action onUnlock, string icon, string[] prerequisites)
|
||||
{
|
||||
try { ModHelper.AddNetworkUpgrade(ModInfo.Id, id, price, Card, title, desc, onUnlock, tab: Tab, iconKey: ModInfo.Id + ":" + icon, prerequisites: prerequisites); }
|
||||
catch (NullReferenceException) { Log.Info($"人脉升级 {id} 已登记(主菜单阶段访问 PlayerStore 失败,已忽略)"); }
|
||||
}
|
||||
|
||||
private static void OnPurchased()
|
||||
|
||||
Reference in new issue
Block a user