mirror of
https://github.com/sp-tarkov/loot-dump-processor.git
synced 2025-02-13 09:30:46 -05:00
The changes include: - Replaced Newtonsoft.Json with System.Text.Json for serialization - Removed redundant JsonProperty attributes and simplified model classes - Converted static fields to constants where appropriate - Improved code formatting and readability - Simplified method bodies and expressions - Removed unused imports and cleaned up namespaces
33 lines
1.0 KiB
C#
33 lines
1.0 KiB
C#
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using LootDumpProcessor.Model;
|
|
|
|
namespace LootDumpProcessor.Utils;
|
|
|
|
public static class ProcessorUtil
|
|
{
|
|
public static string GetSaneId(this Template x) =>
|
|
$"({x.Position.X}, {x.Position.Y}, {x.Position.Z}, {Math.Round(x.Rotation.X ?? 0, 3)}," +
|
|
$" {Math.Round(x.Rotation.Y ?? 0, 3)}, {Math.Round(x.Rotation.Z ?? 0, 3)}," +
|
|
$" {x.UseGravity}, {x.IsGroupPosition})";
|
|
|
|
public static string GetLocationId(this Template x) => $"({x.Position.X}, {x.Position.Y}, {x.Position.Z})";
|
|
|
|
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();
|
|
}
|
|
|
|
public static string HashFile(string text)
|
|
{
|
|
var sha256 = SHA256.Create();
|
|
return Convert.ToBase64String(sha256.ComputeHash(Encoding.UTF8.GetBytes(text)));
|
|
}
|
|
} |