2022-11-20 02:37:52 +03:00
|
|
|
|
using System.Reflection;
|
|
|
|
|
using Aki.Common.Utils;
|
2023-02-06 23:13:20 +03:00
|
|
|
|
using Aki.Custom.Models;
|
|
|
|
|
using Aki.Custom.Utils;
|
2022-11-20 02:37:52 +03:00
|
|
|
|
using Aki.Reflection.Patching;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
|
|
|
|
namespace SamSWAT.ReflexSightsRework
|
|
|
|
|
{
|
|
|
|
|
public class BundleLoader : ModulePatch
|
|
|
|
|
{
|
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
|
{
|
|
|
|
|
return typeof(BundleManager).GetMethod(nameof(BundleManager.GetBundles));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[PatchPostfix]
|
|
|
|
|
private static void PatchPostfix()
|
|
|
|
|
{
|
|
|
|
|
var json = VFS.ReadTextFile(Plugin.Directory + "bundles.json");
|
|
|
|
|
var jArray = JArray.Parse(json);
|
2022-11-22 22:00:26 +03:00
|
|
|
|
var bundles = BundleManager.Bundles;
|
2022-11-20 02:37:52 +03:00
|
|
|
|
|
|
|
|
|
foreach (var jObj in jArray)
|
|
|
|
|
{
|
|
|
|
|
var key = jObj["key"].ToString();
|
|
|
|
|
var path = jObj["path"].ToString();
|
|
|
|
|
var bundle = new BundleInfo(key, path, jObj["dependencyKeys"].ToObject<string[]>());
|
2022-11-22 22:00:26 +03:00
|
|
|
|
|
|
|
|
|
if (bundles.ContainsKey(key))
|
|
|
|
|
bundles.Remove(key);
|
|
|
|
|
|
|
|
|
|
bundles.Add(key, bundle);
|
2022-11-20 02:37:52 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|