0
0
mirror of https://github.com/sp-tarkov/loot-dump-processor.git synced 2025-02-13 09:50:44 -05:00

30 lines
1.1 KiB
C#
Raw Normal View History

2023-08-12 19:08:38 +01:00
using System.Security.Cryptography;
using System.Text;
using LootDumpProcessor.Model;
namespace LootDumpProcessor.Utils;
2023-08-12 19:08:38 +01:00
public static class ProcessorUtil
{
public static string GetSaneId(this Template x) =>
$"({x.Position.GetValueOrDefault().X}, {x.Position.GetValueOrDefault().Y}, {x.Position.GetValueOrDefault().Z}, {Math.Round(x.Rotation.GetValueOrDefault().X, 3)}," +
$" {Math.Round(x.Rotation.GetValueOrDefault().Y, 3)}, {Math.Round(x.Rotation.GetValueOrDefault().Z, 3)}," +
$" {x.UseGravity}, {x.IsGroupPosition})";
2023-08-12 19:08:38 +01:00
public static string GetLocationId(this Template x) =>
$"({x.Position.GetValueOrDefault().X}, {x.Position.GetValueOrDefault().Y}, {x.Position.GetValueOrDefault().Z})";
2023-08-12 19:08:38 +01:00
public static T? Copy<T>(T? obj) where T : ICloneable
{
if (obj == null)
return default;
return (T)obj.Clone();
}
public static List<T>? Copy<T>(List<T>? obj) where T : ICloneable
{
return obj?.Select(o => o.Clone()).Cast<T>().ToList();
2023-08-12 19:08:38 +01:00
}
public static string HashFile(string text) => Convert.ToBase64String(SHA256.HashData(Encoding.UTF8.GetBytes(text)));
2023-08-12 19:08:38 +01:00
}