2024-05-21 19:10:17 +01:00
|
|
|
|
using SPT.SinglePlayer.Models.RaidFix;
|
2023-08-05 17:26:09 +00:00
|
|
|
|
using Comfort.Common;
|
|
|
|
|
using EFT;
|
|
|
|
|
using EFT.InventoryLogic;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2024-05-22 19:57:31 +00:00
|
|
|
|
using EFT.UI;
|
2023-08-05 17:26:09 +00:00
|
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
|
namespace SPT.SinglePlayer.Utils.Insurance
|
2023-08-05 17:26:09 +00:00
|
|
|
|
{
|
|
|
|
|
public class InsuredItemManager
|
|
|
|
|
{
|
|
|
|
|
private static InsuredItemManager _instance;
|
2023-08-07 19:46:12 +01:00
|
|
|
|
private List<Item> _items;
|
2024-05-22 19:57:31 +00:00
|
|
|
|
private List<string> _placedItems = new List<string>();
|
2023-08-05 17:26:09 +00:00
|
|
|
|
|
|
|
|
|
public static InsuredItemManager Instance
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_instance == null)
|
|
|
|
|
{
|
|
|
|
|
_instance = new InsuredItemManager();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _instance;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Init()
|
|
|
|
|
{
|
2023-08-07 19:47:22 +01:00
|
|
|
|
_items = Singleton<GameWorld>.Instance?.MainPlayer?.Profile?.Inventory?.AllRealPlayerItems?.ToList();
|
2023-08-05 17:26:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
|
public List<SPTInsuredItemClass> GetTrackedItems()
|
2023-08-05 17:26:09 +00:00
|
|
|
|
{
|
2024-05-21 19:10:17 +01:00
|
|
|
|
var itemsToSend = new List<SPTInsuredItemClass>();
|
2024-01-13 22:08:29 +00:00
|
|
|
|
if (_items == null || !_items.Any())
|
2023-08-07 19:46:12 +01:00
|
|
|
|
{
|
|
|
|
|
return itemsToSend;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var item in _items)
|
2023-08-05 17:26:09 +00:00
|
|
|
|
{
|
2024-05-21 19:18:57 +01:00
|
|
|
|
var spt = new SPTInsuredItemClass
|
2023-08-05 17:26:09 +00:00
|
|
|
|
{
|
|
|
|
|
id = item.Id
|
|
|
|
|
};
|
|
|
|
|
|
2024-05-22 19:57:31 +00:00
|
|
|
|
if (_placedItems.Contains(item.Id))
|
|
|
|
|
{
|
|
|
|
|
spt.usedInQuest = true;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-05 17:26:09 +00:00
|
|
|
|
var dura = item.GetItemComponent<RepairableComponent>();
|
|
|
|
|
|
|
|
|
|
if (dura != null)
|
|
|
|
|
{
|
2024-05-21 19:18:57 +01:00
|
|
|
|
spt.durability = dura.Durability;
|
|
|
|
|
spt.maxDurability = dura.MaxDurability;
|
2023-08-05 17:26:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var faceshield = item.GetItemComponent<FaceShieldComponent>();
|
|
|
|
|
|
|
|
|
|
if (faceshield != null)
|
|
|
|
|
{
|
2024-05-21 19:18:57 +01:00
|
|
|
|
spt.hits = faceshield.Hits;
|
2023-08-05 17:26:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-21 19:18:57 +01:00
|
|
|
|
itemsToSend.Add(spt);
|
2023-08-05 17:26:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return itemsToSend;
|
|
|
|
|
}
|
2024-05-22 19:57:31 +00:00
|
|
|
|
|
|
|
|
|
public void SetPlacedItem(Item topLevelItem)
|
|
|
|
|
{
|
|
|
|
|
// Includes Parent and Children items
|
|
|
|
|
foreach (var item in topLevelItem.GetAllItems())
|
|
|
|
|
{
|
|
|
|
|
_placedItems.Add(item.Id);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-05 17:26:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|