Files
probably-decentralized/src/Decentralized/ModEntry.cs
T

43 lines
1.4 KiB
C#

namespace Decentralized
{
/// <summary>
/// mod 入口(游戏自带 mod 系统)。Init / OnEnable 在主菜单阶段调用:这里只订阅钩子、登记物品和人脉升级,
/// 不碰存档和店里的东西(那些在读档 / 新游戏的钩子里做)。
/// </summary>
public class ModEntry : IMod
{
public void Init(ModManifest manifest) { }
public void OnEnable()
{
Items.Subscribe();
Items.OpenTerminal = TerminalWindow.Open;
Unlock.Register();
Night.Subscribe();
DealerStock.Subscribe();
UsedDealerClient.Subscribe();
CoinCustomers.Subscribe();
BlackDelivery.Subscribe();
GpuInspectView.Ensure();
ModHook.OnGameLoadedLate += Session.Load;
ModHook.OnNewGameStarted += OnNewGame;
Log.Info($"{ModInfo.Name} {ModInfo.Version} 已启用");
}
public void OnDisable()
{
Items.Unsubscribe();
Night.Unsubscribe();
DealerStock.Unsubscribe();
UsedDealerClient.Unsubscribe();
CoinCustomers.Unsubscribe();
BlackDelivery.Unsubscribe();
GpuInspectView.Remove();
ModHook.OnGameLoadedLate -= Session.Load;
ModHook.OnNewGameStarted -= OnNewGame;
}
private static void OnNewGame(string scenarioId) => Session.Load();
}
}