Skip to content
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
8 changes: 4 additions & 4 deletions PIRM.csproj → MIR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<ProjectGuid>{A4E590D6-3C04-419D-A00D-B0A7E6C9BD7D}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>dvize.PIRM</RootNamespace>
<AssemblyName>dvize.PIRM</AssemblyName>
<RootNamespace>dvize.MIR</RootNamespace>
<AssemblyName>dvize.MIR</AssemblyName>
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
Expand Down Expand Up @@ -109,8 +109,8 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="PIRMPatcher.cs" />
<Compile Include="PIRMPlugin.cs" />
<Compile Include="MIRPatcher.cs" />
<Compile Include="MIRPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ConfigurationManagerAttributes.cs" />
</ItemGroup>
Expand Down
150 changes: 58 additions & 92 deletions PIRMPatcher.cs → MIRPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
using EFT.UI.DragAndDrop;
using HarmonyLib;

namespace PIRM
namespace MIR
{
public class PIRMMethod17Patch : ModulePatch
public class MIRMethod21Patch : ModulePatch
{
protected override MethodBase GetTargetMethod() => AccessTools.Method(typeof(ItemSpecificationPanel), "method_17");
protected override MethodBase GetTargetMethod() => AccessTools.Method(typeof(ItemSpecificationPanel), "method_21");

[PatchPrefix]
public static bool PatchPrefix(ref KeyValuePair<EModLockedState, ModSlotView.GStruct398> __result, Slot slot)
public static bool PatchPrefix(ref KeyValuePair<EModLockedState, ModSlotView.GStruct430> __result, Slot slot)
{
string itemName = slot.ContainedItem != null ? slot.ContainedItem.Name.Localized() : string.Empty;
ModSlotView.GStruct398 structValue = new ModSlotView.GStruct398
ModSlotView.GStruct430 structValue = new ModSlotView.GStruct430
{
ItemName = itemName,
Error = string.Empty
};

__result = new KeyValuePair<EModLockedState, ModSlotView.GStruct398>(EModLockedState.Unlocked, structValue);
__result = new KeyValuePair<EModLockedState, ModSlotView.GStruct430>(EModLockedState.Unlocked, structValue);

return false;
}
Expand All @@ -36,14 +36,13 @@ public class InteractionsHandlerPatch : ModulePatch
protected override MethodBase GetTargetMethod() => AccessTools.Method(typeof(InteractionsHandlerClass), "smethod_1");

[PatchPrefix]
public static bool Prefix(Item item, ItemAddress to, TraderControllerClass itemController, ref GStruct416<GClass3372> __result)
public static bool Prefix(Item item, ItemAddress to, TraderControllerClass itemController, ref GStruct448<GClass3759> __result)
{
if (GClass1864.InRaid)
if (GClass2064.InRaid)
{
__result = GClass3372._;
__result = GClass3759._;
return false;
}

return true;
}
}
Expand All @@ -53,12 +52,11 @@ public class ItemCheckAction : ModulePatch
protected override MethodBase GetTargetMethod() => AccessTools.Method(typeof(EFT.InventoryLogic.Item), "CheckAction");

[PatchPrefix]
public static bool Prefix(ItemAddress location, ref bool __result)
public static GStruct447 Prefix(ItemAddress location, ref GStruct447 __result, Item __instance)
{
__result = true;
return false;
__result = default(GStruct447);
return new InteractionsHandlerClass.GClass3736(null);
}

}


Expand All @@ -68,15 +66,15 @@ public class EFTInventoryLogicModPatch : ModulePatch
protected override MethodBase GetTargetMethod() => AccessTools.Method(typeof(EFT.InventoryLogic.Mod), "CanBeMoved");

[PatchPrefix]
public static bool Prefix(IContainer toContainer, ref GStruct416<bool> __result)
public static bool Prefix(IContainer toContainer, ref GStruct448<bool> __result)
{
__result = true;
return false;
}
}
public class CanAcceptRaidPatch : ModulePatch
{
protected override MethodBase GetTargetMethod() => AccessTools.Method(typeof(GClass2525), (nameof(GClass2525.CanAcceptRaid)));
protected override MethodBase GetTargetMethod() => AccessTools.Method(typeof(GClass2862), (nameof(GClass2862.CanAcceptRaid)));

[PatchPostfix]
public static void Postfix(ref bool __result, ref InventoryError error)
Expand All @@ -86,18 +84,17 @@ public static void Postfix(ref bool __result, ref InventoryError error)
}
}


//Gets rid of the compatibility check (even when ui highlights the slot as incompatible)
public class SlotMethod4Patch : ModulePatch
public class SlotMethod5Patch : ModulePatch
{
protected override MethodBase GetTargetMethod() => AccessTools.Method(typeof(Slot), (nameof(Slot.method_4)));
protected override MethodBase GetTargetMethod() => AccessTools.Method(typeof(EFT.InventoryLogic.Slot), (nameof(Slot.method_5)));

[PatchPrefix]
public static bool Prefix(Item item, bool ignoreRestrictions, bool ignoreMalfunction, ref GStruct416<bool> __result, Slot __instance)
public static bool Prefix(Item item, bool ignoreRestrictions, bool ignoreMalfunction, ref GStruct448<bool> __result, Slot __instance)
{
if (__instance.ContainedItem != null)
{
__result = new Slot.GClass3339(item, __instance);
__result = new Slot.GClass3722(item, __instance);
return false;
}
if (ignoreRestrictions)
Expand All @@ -107,7 +104,7 @@ public static bool Prefix(Item item, bool ignoreRestrictions, bool ignoreMalfunc
}
if (__instance.Locked)
{
__result = new Slot.GClass3332(__instance);
__result = new Slot.GClass3715(__instance);
return false;
}
InventoryError inventoryError;
Expand All @@ -116,37 +113,37 @@ public static bool Prefix(Item item, bool ignoreRestrictions, bool ignoreMalfunc
__result = inventoryError;
return false;
}
if (!__instance.Examined(item) && !(item is BulletClass))
if (!__instance.method_2(item) && !(item is AmmoItemClass))
{
__result = new Slot.GClass3336(item, __instance);
__result = new Slot.GClass3719(item, __instance);
return false;
}
if (__instance.BlockerSlots.Count > 0)
{
__result = new Slot.GClass3333(item, __instance);
__result = new Slot.GClass3716(item, __instance);
return false;
}
GStruct416<bool> gstruct = __instance.method_3(item);
GStruct448<bool> gstruct = __instance.method_4(item);
if (gstruct.Failed)
{
__result = gstruct.Error;
return false;
}
if (item.IsSpecialSlotOnly && !__instance.IsSpecial)
{
__result = new Slot.GClass3340(item, __instance);
__result = new Slot.GClass3723(item, __instance);
return false;
}
if (__instance.ConflictingSlots != null)
{
using (IEnumerator<Slot> enumerator = __instance.method_2(item).GetEnumerator())
using (IEnumerator<Slot> enumerator = __instance.method_3(item).GetEnumerator())
{
while (enumerator.MoveNext())
{
Slot slot = enumerator.Current;
if (slot.ContainedItem != null)
{
__result = new Slot.GClass3334(item, __instance, slot);
__result = new Slot.GClass3717(item, __instance, slot);
return false;
}
}
Expand All @@ -163,7 +160,7 @@ public static bool Prefix(Item item, bool ignoreRestrictions, bool ignoreMalfunc
{
if (!__instance.CheckCompatibility(item))
{
__result = new Slot.GClass3340(item, __instance);
__result = new Slot.GClass3723(item, __instance);
return false;
}
}
Expand Down Expand Up @@ -192,7 +189,7 @@ public static bool Prefix(Item item, bool ignoreRestrictions, bool ignoreMalfunc
{
if (!__instance.CheckCompatibility(item))
{
__result = new Slot.GClass3340(item, __instance);
__result = new Slot.GClass3723(item, __instance);
return false;
}
}
Expand All @@ -202,94 +199,77 @@ public static bool Prefix(Item item, bool ignoreRestrictions, bool ignoreMalfunc
Weapon weapon;
if (!ignoreMalfunction && (weapon = __instance.ParentItem.GetRootItem() as Weapon) != null && weapon.IncompatibleByMalfunction(item))
{
__result = new InteractionsHandlerClass.GClass3352(item, weapon);
__result = new InteractionsHandlerClass.GClass3734(item, weapon);
return false;
}
Weapon weapon2;
if ((weapon2 = item as Weapon) != null && __instance.Id != "BuildSlot")
if ((weapon2 = item as Weapon) != null && __instance.ID != "BuildSlot")
{
List<Slot> list = weapon2.MissingVitalParts.ToList<Slot>();
if (list.Any<Slot>())
{
__result = new Slot.GClass3338(weapon2, __instance, list);
__result = new Slot.GClass3721(weapon2, __instance, list);
return false;
}
}
__result = true;
return false;
}
}

public class IsModSuitablePatch : ModulePatch
{
protected override MethodBase GetTargetMethod() => AccessTools.Method(typeof(ArmorHolderComponent), (nameof(ArmorHolderComponent.IsModSuitable)));

[PatchPrefix]
public static bool Prefix(Item item, ArmorHolderComponent __instance, ref bool __result, LootItemClass ___lootItemClass)
public static bool Prefix(Item item, ArmorHolderComponent __instance, ref bool __result, CompoundItem ___compoundItem_0)
{
//if armormod and PIRMPlugin.AllowSwapAnyArmorPlate is true then assume its suitable
if (item.IsArmorMod() && PIRMPlugin.AllowSwapAnyArmorPlate.Value)
//if armormod and MIRPlugin.AllowSwapAnyArmorPlate is true then assume its suitable
if (item.IsArmorMod() && MIRPlugin.AllowSwapAnyArmorPlate.Value)
{
__result = true;
return false;
}

//return true to check the original logic
return true;
}

}


public class SlotRemoveItemPatch : ModulePatch
{
protected override MethodBase GetTargetMethod() => AccessTools.Method(typeof(Slot), nameof(Slot.RemoveItem));

[PatchPrefix]
public static bool Prefix(ref GStruct416<bool> __result, Slot __instance)
protected override MethodBase GetTargetMethod() => AccessTools.Method(typeof(EFT.InventoryLogic.Slot), "RemoveItemInternal");
private static bool Prefix(ref Slot __instance, ref GStruct446<GClass3134> __result, bool simulate, bool ignoreRestrictions)
{
//display parent of item for logging purposes
/* if (__instance.ContainedItem != null)
{
UnityEngine.Debug.LogWarning($"Parent of item: {__instance.ContainedItem.Parent}");
}*/

//Seems if its unlocked then we can't restore the default when toggled. decided not to use dictionary to restore since slots for every item? too much shit
if (PIRMPlugin.AllowSwapAnyArmorPlate.Value)
{
if (__instance.Locked)
{
__instance.Locked = false;
}
}

return true;
return true;
}
}

public class LootItemApplyPatch : ModulePatch
{
protected override MethodBase GetTargetMethod() => AccessTools.Method(typeof(LootItemClass), "Apply");
protected override MethodBase GetTargetMethod() => AccessTools.Method(typeof(CompoundItem), "Apply");

[PatchPrefix]
private static bool Prefix(ref LootItemClass __instance, ref GStruct413 __result, TraderControllerClass itemController, Item item, int count, bool simulate)
private static bool Prefix(ref CompoundItem __instance, ref GStruct445 __result, TraderControllerClass itemController, Item item, int count, bool simulate) /// GStruct425 >> GStruct445
{
if (!item.ParentRecursiveCheck(__instance))
{
__result = new GClass3324(item, __instance);
__result = new GClass3701(item, __instance);
return false;
}
//bool inRaid = GClass1849.InRaid;
//bool inRaid = GClass1849.InRaid; /// GClass1849 >> GClass2064
bool inRaid = false;

Error error = null;
Error error2 = null;

Mod mod = item as Mod;
Slot[] array = ((mod != null && inRaid) ? __instance.VitalParts.ToArray<Slot>() : null);
Slot.GClass3338 gclass;
Slot.GClass3721 gclass;

if (inRaid && mod != null && !mod.RaidModdable)
{
error2 = new GClass3321(mod);
error2 = new GClass3698(mod);
}
else if (!InteractionsHandlerClass.CheckMissingParts(mod, __instance.CurrentAddress, itemController, out gclass))
{
Expand All @@ -303,34 +283,34 @@ private static bool Prefix(ref LootItemClass __instance, ref GStruct413 __result
{
if (error2 != null)
{
Slot.GClass3338 gclass2;
if ((gclass2 = error2 as Slot.GClass3338) != null)
Slot.GClass3721 gclass2;
if ((gclass2 = error2 as Slot.GClass3721) != null)
{
error2 = new Slot.GClass3338(gclass2.Item, slot, gclass2.MissingParts);
error2 = new Slot.GClass3721(gclass2.Item, slot, gclass2.MissingParts);
}
flag = true;
}
else if (array != null && array.Contains(slot))
{
error = new GClass3322(mod);
error = new GClass3699(mod);
}
else
{
GClass2783 gclass3 = new GClass2783(slot);
GStruct414<GClass2802> gstruct = InteractionsHandlerClass.Move(item, gclass3, itemController, simulate);
ItemAddress to = slot.CreateItemAddress();
GStruct446<GClass3132> gstruct = InteractionsHandlerClass.Move(item, to, itemController, simulate);
if (gstruct.Succeeded)
{
__result = gstruct;
return false;
}
GStruct414<GClass2811> gstruct2 = InteractionsHandlerClass.SplitMax(item, int.MaxValue, gclass3, itemController, itemController, simulate);
GStruct446<GClass3145> gstruct2 = InteractionsHandlerClass.SplitMax(item, int.MaxValue, to, itemController, itemController, simulate);
if (gstruct2.Succeeded)
{
__result = gstruct2;
return false;
}
error = gstruct.Error;
if (!GClass748.DisabledForNow && GClass2791.CanSwap(item, slot))
if (!GClass810.DisabledForNow && GClass3117.CanSwap(item, slot))
{
__result = null;
return false;
Expand All @@ -342,37 +322,23 @@ private static bool Prefix(ref LootItemClass __instance, ref GStruct413 __result
{
error2 = null;
}
GStruct414<GInterface339> gstruct3 = InteractionsHandlerClass.QuickFindAppropriatePlace(item, itemController, __instance.ToEnumerable<LootItemClass>(), InteractionsHandlerClass.EMoveItemOrder.Apply, simulate);
GStruct446<GInterface385> gstruct3 = InteractionsHandlerClass.QuickFindAppropriatePlace(item, itemController, __instance.ToEnumerable<CompoundItem>(), InteractionsHandlerClass.EMoveItemOrder.Apply, simulate);
if (gstruct3.Succeeded)
{
__result = gstruct3;
return false;
}
if (!(gstruct3.Error is GClass3317))
if (!(gstruct3.Error is GClass3601))
{
error = gstruct3.Error;
}
Error error3;
if ((error3 = error2) == null)
{
error3 = error ?? new GClass3324(item, __instance);
error3 = error ?? new GClass3701(item, __instance);
}
__result = error3;
return false;
}

}

}












}
Loading