54 lines
1.6 KiB
C#
54 lines
1.6 KiB
C#
using System;
|
|
using HarmonyLib;
|
|
using Vintagestory.API.Server;
|
|
using Vintagestory.API.Common;
|
|
using Vintagestory.API.Config;
|
|
|
|
namespace TemporalTempestLight;
|
|
|
|
public class TemporalTempestLightModSystem : ModSystem
|
|
{
|
|
private Harmony Patcher { get; set; }
|
|
|
|
public ModConfig Config { get; private set; }
|
|
|
|
private ICoreServerAPI Api { get; set; }
|
|
|
|
public bool IsStormInitialized
|
|
{
|
|
get => Api.WorldManager.SaveGame.GetData<bool>("temporaltempestlight:IsStormInitialized");
|
|
set => Api.WorldManager.SaveGame.StoreData("temporaltempestlight:IsStormInitialized", value);
|
|
}
|
|
|
|
public double CurrentStormDurationReduction
|
|
{
|
|
get => Api.WorldManager.SaveGame.GetData<double>("temporaltempestlight:CurrentStormDurationReduction");
|
|
set => Api.WorldManager.SaveGame.StoreData("temporaltempestlight:CurrentStormDurationReduction", value);
|
|
}
|
|
|
|
public override void StartServerSide(ICoreServerAPI api)
|
|
{
|
|
Api = api;
|
|
|
|
if (Harmony.HasAnyPatches(Mod.Info.ModID)) return;
|
|
|
|
Patcher = new Harmony(Mod.Info.ModID);
|
|
Patcher.PatchCategory(Mod.Info.ModID);
|
|
|
|
TryToLoadConfig(api);
|
|
}
|
|
|
|
private void TryToLoadConfig(ICoreServerAPI api)
|
|
{
|
|
try
|
|
{
|
|
Config = api.LoadModConfig<ModConfig>("TemporalTempestLightConfig.json") ?? new ModConfig();
|
|
api.StoreModConfig(Config, "TemporalTempestLightConfig.json");
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Mod.Logger.Error(e);
|
|
Config = new ModConfig();
|
|
}
|
|
}
|
|
} |