embed plugin loader directly into the launcher

This commit is contained in:
zznty
2022-10-29 01:50:14 +07:00
parent 7204815c0c
commit 66d3dc2ead
53 changed files with 5689 additions and 10 deletions

View File

@@ -0,0 +1,45 @@
using System.IO.Compression;
using ProtoBuf;
namespace PluginLoader.Data;
[ProtoContract]
public class SEPMPlugin : SteamPlugin
{
private const string NameFile = "name.txt";
private string dataFolder;
protected SEPMPlugin()
{
}
public override string Source => "SEPM";
protected override string HashFile => "sepm-plugin.txt";
protected override void CheckForUpdates()
{
dataFolder = Path.Combine(root, "sepm-plugin");
if (Directory.Exists(dataFolder))
base.CheckForUpdates();
else
Status = PluginStatus.PendingUpdate;
}
protected override void ApplyUpdate()
{
if (Directory.Exists(dataFolder))
Directory.Delete(dataFolder, true);
ZipFile.ExtractToDirectory(sourceFile, dataFolder);
}
protected override string GetAssemblyFile()
{
if (!Directory.Exists(dataFolder))
return null;
return Directory.EnumerateFiles(dataFolder, "*.dll")
.Where(s => !s.Equals("0Harmony.dll", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
}
}