embed plugin loader directly into the launcher
This commit is contained in:
45
PluginLoader/Data/SEPMPlugin.cs
Normal file
45
PluginLoader/Data/SEPMPlugin.cs
Normal 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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user