2023-08-12 19:08:38 +01:00
|
|
|
using System.Security.Cryptography;
|
|
|
|
using System.Text;
|
|
|
|
using LootDumpProcessor.Model;
|
|
|
|
|
2024-04-16 18:29:40 +00:00
|
|
|
namespace LootDumpProcessor.Utils;
|
2023-08-12 19:08:38 +01:00
|
|
|
|
|
|
|
public static class ProcessorUtil
|
|
|
|
{
|
2025-01-11 10:52:23 +03:00
|
|
|
public static string GetSaneId(this Template x) =>
|
2025-01-11 12:15:01 +03:00
|
|
|
$"({x.Position.X}, {x.Position.Y}, {x.Position.Z}, {Math.Round(x.Rotation.X, 3)}," +
|
|
|
|
$" {Math.Round(x.Rotation.Y, 3)}, {Math.Round(x.Rotation.Z, 3)}," +
|
2025-01-11 10:52:23 +03:00
|
|
|
$" {x.UseGravity}, {x.IsGroupPosition})";
|
2023-08-12 19:08:38 +01:00
|
|
|
|
2025-01-11 10:52:23 +03:00
|
|
|
public static string GetLocationId(this Template x) => $"({x.Position.X}, {x.Position.Y}, {x.Position.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
|
|
|
|
{
|
2024-04-16 18:29:40 +00:00
|
|
|
return obj?.Select(o => o.Clone()).Cast<T>().ToList();
|
2023-08-12 19:08:38 +01:00
|
|
|
}
|
|
|
|
|
2025-01-11 12:15:01 +03:00
|
|
|
public static string HashFile(string text) => Convert.ToBase64String(SHA256.HashData(Encoding.UTF8.GetBytes(text)));
|
2023-08-12 19:08:38 +01:00
|
|
|
}
|