SDM_LethalCompany_Mod/MimicsPatch/ScarletMansionMimicsPatch/Plugin.cs

66 lines
1.9 KiB
C#

using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using ScarletMansion;
using ScarletMansion.DunGenPatch;
using ScarletMansion.GamePatch.Managers;
using ScarletMansion.GamePatch;
using ScarletMansion.ModPatch;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using Mimics.API;
using BepInEx.Bootstrap;
namespace ScarletMansionMimicsPatch {
[BepInPlugin(modGUID, modName, modVersion)]
[BepInDependency("dev.ladyalice.scarletmansion", "1.3.22")]
[BepInDependency(targetModGUID, BepInDependency.DependencyFlags.SoftDependency)]
public class Plugin : BaseUnityPlugin {
public const string modGUID = "dev.ladyalice.scarletmansion.mimicspatch";
private const string modName = "Scarlet Mansion Mimics Patch";
private const string modVersion = "1.0.0";
public const string targetModGUID = "x753.Mimics";
public const string targetModVersion = "2.6.0";
public readonly Harmony harmony = new Harmony(modGUID);
public static Plugin Instance {get; private set;}
public static ManualLogSource logger { get; internal set; }
void Awake(){
if (Instance == null) Instance = this;
logger = BepInEx.Logging.Logger.CreateLogSource(modGUID);
var modLoaded = Chainloader.PluginInfos.ContainsKey(targetModGUID);
if (!modLoaded) return;
bool validVersion;
var pluginInfo = Chainloader.PluginInfos[targetModGUID];
var loadedVersion = pluginInfo.Metadata.Version;
if (string.IsNullOrWhiteSpace(targetModVersion)){
validVersion = true;
} else {
var requiredVersion = new Version(targetModVersion);
validVersion = loadedVersion >= requiredVersion;
}
if (validVersion){
logger.LogInfo($"Plugin {modName} has been added!");
Patch.Activate();
}
}
}
}