Unblock swapping mods on equipped guns in raid; fixed firearm controller's add-mod operation
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Aki.Reflection.Patching;
|
||||
using Aki.Reflection.Utils;
|
||||
using Comfort.Common;
|
||||
using EFT;
|
||||
using EFT.InventoryLogic;
|
||||
using EFT.UI;
|
||||
@@ -45,6 +46,7 @@ namespace UIFixes
|
||||
new SwapOperationRaiseEventsPatch().Enable();
|
||||
new RememberSwapGridHoverPatch().Enable();
|
||||
new InspectWindowUpdateStatsOnSwapPatch().Enable();
|
||||
new FixAddModFirearmOperationPatch().Enable();
|
||||
}
|
||||
|
||||
private static bool ValidPrerequisites(ItemContextClass itemContext, ItemContextAbstractClass targetItemContext, object operation)
|
||||
@@ -382,17 +384,6 @@ namespace UIFixes
|
||||
return;
|
||||
}
|
||||
|
||||
// Swapping items with each other when both are on an equipped gun in raid doesn't work
|
||||
if (itemController is Player.PlayerInventoryController playerInventoryController)
|
||||
{
|
||||
Item item1 = __instance.Item.GetRootItem();
|
||||
Item item2 = targetItemContext.Item.GetRootItem();
|
||||
if (item1 == item2 && playerInventoryController.IsItemEquipped(item1))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ValidPrerequisites(__instance, targetItemContext, operation))
|
||||
{
|
||||
return;
|
||||
@@ -510,5 +501,54 @@ namespace UIFixes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class FixAddModFirearmOperationPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(Player.FirearmController.Class1015), nameof(Player.FirearmController.Class1015.OnModChanged));
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
public static bool Prefix(
|
||||
Player.FirearmController.Class1015 __instance,
|
||||
bool ___bool_0,
|
||||
FirearmsAnimator ___firearmsAnimator_0,
|
||||
Item ___item_0,
|
||||
GClass1668 ___gclass1668_0,
|
||||
Slot ___slot_0,
|
||||
Weapon ___weapon_0,
|
||||
Callback ___callback_0,
|
||||
Player ___player_0,
|
||||
Player.FirearmController ___firearmController_0)
|
||||
{
|
||||
if (___bool_0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
___bool_0 = true;
|
||||
___firearmsAnimator_0.SetupMod(false);
|
||||
GameObject gameObject = Singleton<PoolManager>.Instance.CreateItem(___item_0, true);
|
||||
___gclass1668_0.SetupMod(___slot_0, gameObject);
|
||||
___firearmsAnimator_0.Fold(___weapon_0.Folded);
|
||||
__instance.State = Player.EOperationState.Finished;
|
||||
|
||||
// Moved from bottom
|
||||
___firearmController_0.InitiateOperation<Player.FirearmController.GClass1608>().Start(null);
|
||||
__instance.method_5(gameObject);
|
||||
|
||||
___callback_0.Succeed();
|
||||
___player_0.BodyAnimatorCommon.SetFloat(PlayerAnimator.WEAPON_SIZE_MODIFIER_PARAM_HASH, (float)___weapon_0.CalculateCellSize().X);
|
||||
___player_0.UpdateFirstPersonGrip(GripPose.EGripType.Common, ___firearmController_0.HandsHierarchy);
|
||||
Mod mod;
|
||||
if ((mod = ___item_0 as Mod) != null && mod.HasLightComponent)
|
||||
{
|
||||
___player_0.SendWeaponLightPacket();
|
||||
}
|
||||
___firearmController_0.WeaponModified();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
113
UIFixes.csproj
113
UIFixes.csproj
@@ -21,66 +21,69 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Aki.Common">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\Aki.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Aki.Reflection">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\Aki.Reflection.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Comfort">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\Comfort.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Comfort.Unity">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\Comfort.Unity.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="CommonExtensions">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\CommonExtensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ItemComponent.Types">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\ItemComponent.Types.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Sirenix.Serialization">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\Sirenix.Serialization.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.TextMeshPro">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\Unity.TextMeshPro.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.IMGUIModule">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.InputLegacyModule">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.TextRenderingModule">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UIModule">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.UIModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Aki.Common">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\Aki.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Aki.Reflection">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\Aki.Reflection.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="AnimationSystem.Types">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\AnimationSystem.Types.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Comfort">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\Comfort.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Comfort.Unity">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\Comfort.Unity.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="CommonExtensions">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\CommonExtensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ItemComponent.Types">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\ItemComponent.Types.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Sirenix.Serialization">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\Sirenix.Serialization.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.TextMeshPro">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\Unity.TextMeshPro.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.IMGUIModule">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.InputLegacyModule">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.TextRenderingModule">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UIModule">
|
||||
<HintPath>$(PathToSPT)\EscapeFromTarkov_Data\Managed\UnityEngine.UIModule.dll</HintPath>
|
||||
</Reference>
|
||||
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" />
|
||||
<PackageReference Include="BepInEx.Core" Version="5.*" />
|
||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" />
|
||||
</ItemGroup>
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||
<Exec Command="if $(ConfigurationName) == Debug (
 xcopy /F /Y "$(TargetPath)" "$(ProjectDir)\$(PathToSPT)\BepInEx\plugins\"
 xcopy /F /Y "$(ProjectDir)$(OutDir)$(TargetName).pdb" "$(ProjectDir)\$(PathToSPT)\BepInEx\plugins\"
) 
if $(ConfigurationName) == Release (
 xcopy /F /Y "$(TargetPath)" "$(ProjectDir)\$(PathToSPT)\BepInEx\plugins\"
)
if $(Configurationname) == Dist (
 mkdir "$(ProjectDir)\dist\BepInEx\plugins"
 xcopy /F /Y "$(TargetPath)" "$(ProjectDir)\dist\BepInEx\plugins\"
 7z a -t7z Tyfon-UIFixes-$(Version).7z $(ProjectDir)\dist\BepInEx $(ProjectDir)\dist\user
 move /Y Tyfon-UIFixes-$(Version).7z dist\
)" />
|
||||
</Target>
|
||||
|
Reference in New Issue
Block a user