mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
using System;
|
|
using BepInEx.Bootstrap;
|
|
using BepInEx.Configuration;
|
|
using BepInEx.Contract;
|
|
using BepInEx.Logging;
|
|
using HarmonyLib;
|
|
|
|
namespace BepInEx.NET.Common
|
|
{
|
|
public abstract class BasePlugin : IPlugin
|
|
{
|
|
protected BasePlugin()
|
|
{
|
|
var metadata = MetadataHelper.GetMetadata(this);
|
|
|
|
HarmonyInstance = new Harmony("BepInEx.Plugin." + metadata.GUID);
|
|
|
|
if (BaseChainloader<BasePlugin>.Instance.Plugins.TryGetValue(metadata.GUID, out var pluginInfo))
|
|
{
|
|
Info = pluginInfo;
|
|
Info.Instance = this;
|
|
}
|
|
else
|
|
{
|
|
throw new InvalidOperationException($"The plugin information for {metadata.GUID} couldn't be found on the chainloader");
|
|
}
|
|
|
|
Log = BepInEx.Logging.Logger.CreateLogSource(metadata.Name);
|
|
|
|
Config = new ConfigFile(Utility.CombinePaths(Paths.ConfigPath, metadata.GUID + ".cfg"), false, metadata);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public PluginInfo Info { get; }
|
|
|
|
/// <inheritdoc />
|
|
public ManualLogSource Log { get; }
|
|
|
|
/// <inheritdoc />
|
|
public ConfigFile Config { get; }
|
|
|
|
public Harmony HarmonyInstance { get; set; }
|
|
|
|
public abstract void Load();
|
|
|
|
public virtual bool Unload() => false;
|
|
}
|
|
}
|