0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/Aki.Custom/Patches/RagfairFeePatch.cs
DrakiaXYZ e3bdf9c1fd Update for 28375 + fixes (!47)
- Update GClass references
- Fix incorrect method in InsuranceScreenPatch (Makes insurance screen actually show)
- Fix incorrect method in Scav offline raid screen patch (Makes "Ready" from the practice screen start the raid)
- Update hollowed.dll with one provided by Chomp

Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: SPT-AKI/Modules#47
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
2023-12-29 09:43:15 +00:00

49 lines
1.8 KiB
C#

using Aki.Common.Http;
using Aki.Reflection.Patching;
using Aki.Reflection.Utils;
using EFT.InventoryLogic;
using EFT.UI.Ragfair;
using System.Reflection;
using UnityEngine;
namespace Aki.Custom.Patches
{
/// <summary>
/// Send the tax amount for listing an item for sale on flea by player to server for later use when charging player
/// Client doesnt send this data and calculating it server-side isn't accurate
/// </summary>
public class RagfairFeePatch : ModulePatch
{
public RagfairFeePatch()
{
// Remember to update prefix parameter if below lines are broken
_ = nameof(GClass3067.IsAllSelectedItemSame);
_ = nameof(GClass3067.AutoSelectSimilar);
}
protected override MethodBase GetTargetMethod()
{
return typeof(AddOfferWindow).GetMethod("method_1", PatchConstants.PrivateFlags);
}
/// <summary>
/// Calculate tax to charge player and send to server before the offer is sent
/// </summary>
/// <param name="___item_0">Item sold</param>
/// <param name="___gclass3067_0">OfferItemCount</param>
/// <param name="___double_0">RequirementsPrice</param>
/// <param name="___bool_0">SellInOnePiece</param>
[PatchPrefix]
private static void PatchPrefix(ref Item ___item_0, ref GClass3067 ___gclass3067_0, ref double ___double_0, ref bool ___bool_0)
{
RequestHandler.PutJson("/client/ragfair/offerfees", new
{
id = ___item_0.Id,
tpl = ___item_0.TemplateId,
count = ___gclass3067_0.OfferItemCount,
fee = Mathf.CeilToInt((float)GClass2084.CalculateTaxPrice(___item_0, ___gclass3067_0.OfferItemCount, ___double_0, ___bool_0))
}
.ToJson());
}
}
}