0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
chomp 49acd11765 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
2023-08-05 17:26:09 +00:00

65 lines
1.6 KiB
C#

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;
}
}
}