mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 09:50:43 -05:00
70 lines
1.7 KiB
C#
70 lines
1.7 KiB
C#
using SPT.SinglePlayer.Models.RaidFix;
|
|
using Comfort.Common;
|
|
using EFT;
|
|
using EFT.InventoryLogic;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace SPT.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<SPTInsuredItemClass> GetTrackedItems()
|
|
{
|
|
var itemsToSend = new List<SPTInsuredItemClass>();
|
|
if (_items == null || !_items.Any())
|
|
{
|
|
return itemsToSend;
|
|
}
|
|
|
|
foreach (var item in _items)
|
|
{
|
|
var aki = new SPTInsuredItemClass
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
}
|