70 lines
2.2 KiB
C#
Raw Normal View History

2023-10-06 18:46:03 +01:00
using System;
2023-10-18 13:04:15 +01:00
using System.Linq;
2023-10-06 18:46:03 +01:00
using Aki.Reflection.Patching;
2023-08-03 10:01:46 +01:00
using EFT.InventoryLogic;
using EFT.UI.DragAndDrop;
using System.Reflection;
2023-10-18 13:04:15 +01:00
using Aki.Reflection.Utils;
2023-10-06 18:46:03 +01:00
using EFT.UI;
2023-08-03 10:01:46 +01:00
using UnityEngine;
2023-10-06 18:46:03 +01:00
using Newtonsoft.Json;
2023-08-03 10:01:46 +01:00
2023-10-06 18:46:03 +01:00
namespace Test_layout
2023-08-03 10:01:46 +01:00
{
2023-10-06 18:46:03 +01:00
public class Test_layoutPatch : ModulePatch
2023-08-03 10:01:46 +01:00
{
protected override MethodBase GetTargetMethod()
{
2023-10-18 13:04:15 +01:00
var typesToCheck = PatchConstants.EftTypes;
var afterChecks = typesToCheck.First(IsTargetType);
Debug.LogError($"AfterChecks: {afterChecks.Name}");
var methodToCheck = afterChecks.GetMethod("OnModChanged", PatchConstants.PublicFlags);
Debug.LogError($"methodName: {methodToCheck.Name}");
return methodToCheck;
}
private bool IsTargetType(Type type)
{
Debug.LogError($"type name: {type.Name}");
var fieldsToCheck = type.GetFields();
if (fieldsToCheck.Length == 4 && fieldsToCheck.Any(x => x.Name == "item_0") &&
fieldsToCheck.Any(x => x.Name == "slot_0") && fieldsToCheck.Any(x => x.Name == "callback_0"))
{
Debug.LogError("type found mother fucker");
return true;
}
return false;
2023-08-03 10:01:46 +01:00
}
2023-10-06 18:46:03 +01:00
[PatchPostfix]
2023-10-08 22:01:21 +01:00
private static void PatchPostfix(ref ContainedGridsView __result, Item item, ContainedGridsView containedGridsTemplate)
2023-08-03 10:01:46 +01:00
{
Debug.LogError(item.TemplateId);
2023-10-08 22:01:21 +01:00
if (item.TemplateId != "5648a69d4bdc2ded0b8b457b") return;
2023-10-06 18:46:03 +01:00
Debug.LogError("Test!");
2023-08-03 10:01:46 +01:00
2023-10-06 18:46:03 +01:00
foreach (var gridView in __result.GridViews)
{
Debug.LogError(JsonConvert.SerializeObject(gridView));
2023-08-03 10:01:46 +01:00
}
2023-10-06 18:46:03 +01:00
var test = new GridView();
test.enabled = true;
test.Grid = new GClass2317("1", 1, 2, false, false, Array.Empty<ItemFilter>(),
new LootItemClass("test", new GClass2348()));
test.IsMagnified = false;
test.name = "GridView 1";
test.tag = "Untagged";
__result.GridViews = new[] { test };
2023-08-03 10:01:46 +01:00
}
}
}