mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 03:10:45 -05:00
Track insured item values to be used post-raid by server (!16)
Co-authored-by: CWX <CWX@noreply.dev.sp-tarkov.com> Co-authored-by: Dev <dev@dev.sp-tarkov.com> Reviewed-on: SPT-AKI/Modules#16
This commit is contained in:
parent
37e356c430
commit
49acd11765
@ -51,6 +51,7 @@ namespace Aki.SinglePlayer
|
||||
new PlayerToggleSoundFixPatch().Enable();
|
||||
new PluginErrorNotifierPatch().Enable();
|
||||
new SpawnProcessNegativeValuePatch().Enable();
|
||||
new InsuredItemManagerStartPatch().Enable();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -1,6 +1,8 @@
|
||||
using Aki.SinglePlayer.Models.Healing;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
using EFT;
|
||||
using System.Collections.Generic;
|
||||
using Aki.SinglePlayer.Models.Healing;
|
||||
using Aki.SinglePlayer.Models.RaidFix;
|
||||
|
||||
namespace Aki.SinglePlayer.Models.Progression
|
||||
{
|
||||
@ -18,6 +20,9 @@ namespace Aki.SinglePlayer.Models.Progression
|
||||
[JsonProperty("health")]
|
||||
public PlayerHealth Health;
|
||||
|
||||
[JsonProperty("insurance")]
|
||||
public List<AkiInsuredItemClass> Insurance;
|
||||
|
||||
public SaveProfileRequest()
|
||||
{
|
||||
Exit = "left";
|
||||
|
@ -0,0 +1,10 @@
|
||||
namespace Aki.SinglePlayer.Models.RaidFix
|
||||
{
|
||||
public class AkiInsuredItemClass
|
||||
{
|
||||
public string id;
|
||||
public float? durability = null;
|
||||
public float? maxDurability = null;
|
||||
public byte? hits = null;
|
||||
}
|
||||
}
|
@ -63,6 +63,7 @@ namespace Aki.SinglePlayer.Patches.Progression
|
||||
Exit = result.Value0.ToString().ToLowerInvariant(),
|
||||
Profile = profile,
|
||||
Health = Utils.Healing.HealthListener.Instance.CurrentHealth,
|
||||
Insurance = Utils.Insurance.InsuredItemManager.Instance.GetTrackedItems(),
|
||||
IsPlayerScav = ____raidSettings.IsScav
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,21 @@
|
||||
using Aki.Reflection.Patching;
|
||||
using EFT;
|
||||
using System.Reflection;
|
||||
using Aki.SinglePlayer.Utils.Insurance;
|
||||
|
||||
namespace Aki.SinglePlayer.Patches.RaidFix
|
||||
{
|
||||
public class InsuredItemManagerStartPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return typeof(GameWorld).GetMethod(nameof(GameWorld.OnGameStarted));
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
public static void PatchPostFix()
|
||||
{
|
||||
InsuredItemManager.Instance.Init();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
using Aki.SinglePlayer.Models.RaidFix;
|
||||
using Comfort.Common;
|
||||
using EFT;
|
||||
using EFT.InventoryLogic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Aki.SinglePlayer.Utils.Insurance
|
||||
{
|
||||
public class InsuredItemManager
|
||||
{
|
||||
private static InsuredItemManager _instance;
|
||||
private List<Item> items;
|
||||
|
||||
public static InsuredItemManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new InsuredItemManager();
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
items = Singleton<GameWorld>.Instance?.MainPlayer?.Profile?.Inventory?.AllRealPlayerItems.ToList();
|
||||
}
|
||||
|
||||
public List<AkiInsuredItemClass> GetTrackedItems()
|
||||
{
|
||||
var itemsToSend = new List<AkiInsuredItemClass>();
|
||||
foreach (var item in items)
|
||||
{
|
||||
var aki = new AkiInsuredItemClass
|
||||
{
|
||||
id = item.Id
|
||||
};
|
||||
|
||||
var dura = item.GetItemComponent<RepairableComponent>();
|
||||
|
||||
if (dura != null)
|
||||
{
|
||||
aki.durability = dura.Durability;
|
||||
aki.maxDurability = dura.MaxDurability;
|
||||
}
|
||||
|
||||
var faceshield = item.GetItemComponent<FaceShieldComponent>();
|
||||
|
||||
if (faceshield != null)
|
||||
{
|
||||
aki.hits = faceshield.Hits;
|
||||
}
|
||||
|
||||
itemsToSend.Add(aki);
|
||||
}
|
||||
|
||||
return itemsToSend;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user