Moved ItemSize into modules section, changed to record

Updated `GetItemSize` to accept `ICollection` instead of list
This commit is contained in:
Chomp
2025-05-21 11:34:02 +01:00
parent 8b3a5bbb90
commit d88db583c1
2 changed files with 22 additions and 19 deletions
@@ -1,9 +1,9 @@
using System.Collections.Frozen;
using System.Text.Json.Serialization;
using SPTarkov.DI.Annotations;
using SPTarkov.Server.Core.Models.Eft.Common;
using SPTarkov.Server.Core.Models.Eft.Common.Tables;
using SPTarkov.Server.Core.Models.Enums;
using SPTarkov.Server.Core.Models.Spt.Inventory;
using SPTarkov.Server.Core.Models.Utils;
using SPTarkov.Server.Core.Services;
using SPTarkov.Server.Core.Utils;
@@ -1431,7 +1431,7 @@ public class ItemHelper(
/// <param name="items">Item with children</param>
/// <param name="rootItemId">The base items root id</param>
/// <returns>ItemSize object (width and height)</returns>
public ItemSize GetItemSize(List<Item> items, string rootItemId)
public ItemSize GetItemSize(ICollection<Item> items, string rootItemId)
{
var rootTemplate = GetItem(items.Where(x => x.Id.Equals(rootItemId, StringComparison.OrdinalIgnoreCase)).ToList()[0].Template).Value;
var width = rootTemplate.Properties.Width;
@@ -2244,20 +2244,3 @@ public class ItemHelper(
.ToArray();
}
}
public class ItemSize
{
[JsonPropertyName("width")]
public int Width
{
get;
set;
}
[JsonPropertyName("height")]
public int Height
{
get;
set;
}
}
@@ -0,0 +1,20 @@
using System.Text.Json.Serialization;
namespace SPTarkov.Server.Core.Models.Spt.Inventory;
public record ItemSize
{
[JsonPropertyName("width")]
public int Width
{
get;
set;
}
[JsonPropertyName("height")]
public int Height
{
get;
set;
}
}