Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AdvancedWardenObjective support #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions MTFO.Ext.PartialData/Utils/InjectLibUtil.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using BepInEx.Unity.IL2CPP;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace MTFO.Ext.PartialData.Utils
{
public static class InjectLibUtil
{
public const string PLUGIN_GUID = "GTFO.InjectLib";

public static JsonConverter InjectLibConnector { get; private set; } = null;

public static bool IsLoaded { get; private set; } = false;

static InjectLibUtil()
{
if (IL2CPPChainloader.Instance.Plugins.TryGetValue(PLUGIN_GUID, out var info))
{
try
{
var ddAsm = info?.Instance?.GetType()?.Assembly ?? null;

if (ddAsm is null)
throw new Exception("Assembly is Missing!");

var types = ddAsm.GetTypes();
var converterType = types.First(t => t.Name == "InjectLibConnector");
if (converterType is null)
throw new Exception("Unable to Find InjectLibConnector Class");

InjectLibConnector = (JsonConverter)Activator.CreateInstance(converterType);
IsLoaded = true;
}
catch (Exception e)
{
Logger.Error($"Exception thrown while reading data from GTFO.AWO: {e}");
}
}
}
}
}
6 changes: 4 additions & 2 deletions MTFO.Ext.PartialData/Utils/JSON.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MTFO.Ext.PartialData.JsonConverters;
using InjectLib.JsonNETInjection.Supports;
using MTFO.Ext.PartialData.JsonConverters;
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
Expand Down Expand Up @@ -28,10 +29,11 @@ private static JsonSerializerOptions CreateSetting()
setting.Converters.Add(new ColorConverter());
setting.Converters.Add(new JsonStringEnumConverter());
setting.Converters.Add(new LocalizedTextConverter());
setting.Converters.Add(new InjectLibConnector());

return setting;
}

public static T Deserialize<T>(string json)
{
return JsonSerializer.Deserialize<T>(json, _Setting);
Expand Down