com.wallstop-studios.unity-helpers 2.0.0-rc79 → 2.0.0-rc79.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/Runtime/Core/Helper/FormattingHelpers.cs +7 -1
  2. package/Runtime/Protobuf-Net/System.Collections.Immutable.dll +0 -0
  3. package/Runtime/Protobuf-Net/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  4. package/Runtime/Protobuf-Net/protobuf-net.Core.dll +0 -0
  5. package/Runtime/Protobuf-Net/protobuf-net.dll +0 -0
  6. package/Runtime/Utils/Buffers.cs +4 -0
  7. package/Runtime/Utils/CircleLineRenderer.cs +11 -1
  8. package/Runtime/Utils/LZMA.cs +53 -0
  9. package/Runtime/Utils/LZMA.cs.meta +3 -0
  10. package/Runtime/Utils/SevenZip/Common/CRC.cs +61 -0
  11. package/Runtime/Utils/SevenZip/Common/CRC.cs.meta +11 -0
  12. package/Runtime/Utils/SevenZip/Common/InBuffer.cs +71 -0
  13. package/Runtime/Utils/SevenZip/Common/InBuffer.cs.meta +11 -0
  14. package/Runtime/Utils/SevenZip/Common/OutBuffer.cs +65 -0
  15. package/Runtime/Utils/SevenZip/Common/OutBuffer.cs.meta +11 -0
  16. package/Runtime/Utils/SevenZip/Common.meta +3 -0
  17. package/Runtime/Utils/SevenZip/Compress/LZ/IMatchFinder.cs +28 -0
  18. package/Runtime/Utils/SevenZip/Compress/LZ/IMatchFinder.cs.meta +11 -0
  19. package/Runtime/Utils/SevenZip/Compress/LZ/LzBinTree.cs +404 -0
  20. package/Runtime/Utils/SevenZip/Compress/LZ/LzBinTree.cs.meta +11 -0
  21. package/Runtime/Utils/SevenZip/Compress/LZ/LzInWindow.cs +153 -0
  22. package/Runtime/Utils/SevenZip/Compress/LZ/LzInWindow.cs.meta +11 -0
  23. package/Runtime/Utils/SevenZip/Compress/LZ/LzOutWindow.cs +110 -0
  24. package/Runtime/Utils/SevenZip/Compress/LZ/LzOutWindow.cs.meta +11 -0
  25. package/Runtime/{Protobuf-Net/System.Collections.Immutable.xml.meta → Utils/SevenZip/Compress/LZ.meta} +3 -2
  26. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaBase.cs +101 -0
  27. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaBase.cs.meta +11 -0
  28. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaDecoder.cs +464 -0
  29. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaDecoder.cs.meta +11 -0
  30. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaEncoder.cs +1669 -0
  31. package/Runtime/Utils/SevenZip/Compress/LZMA/LzmaEncoder.cs.meta +11 -0
  32. package/Runtime/Utils/SevenZip/Compress/LZMA.meta +8 -0
  33. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoder.cs +233 -0
  34. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoder.cs.meta +11 -0
  35. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBit.cs +137 -0
  36. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBit.cs.meta +11 -0
  37. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBitTree.cs +170 -0
  38. package/Runtime/Utils/SevenZip/Compress/RangeCoder/RangeCoderBitTree.cs.meta +11 -0
  39. package/Runtime/Utils/SevenZip/Compress/RangeCoder.meta +8 -0
  40. package/Runtime/{Protobuf-Net/System.Runtime.CompilerServices.Unsafe.xml.meta → Utils/SevenZip/Compress.meta} +3 -2
  41. package/Runtime/Utils/SevenZip/ICoder.cs +177 -0
  42. package/Runtime/Utils/SevenZip/ICoder.cs.meta +11 -0
  43. package/Runtime/Utils/SevenZip.meta +3 -0
  44. package/package.json +3 -1
  45. package/Runtime/Protobuf-Net/System.Buffers.dll +0 -0
  46. package/Runtime/Protobuf-Net/System.Buffers.dll.meta +0 -33
  47. package/Runtime/Protobuf-Net/System.Collections.Immutable.xml +0 -6812
  48. package/Runtime/Protobuf-Net/System.Numerics.Vectors.dll +0 -0
  49. package/Runtime/Protobuf-Net/System.Numerics.Vectors.dll.meta +0 -33
  50. package/Runtime/Protobuf-Net/System.Runtime.CompilerServices.Unsafe.xml +0 -342
@@ -1,6 +1,8 @@
1
1
  namespace WallstopStudios.UnityHelpers.Core.Helper
2
2
  {
3
3
  using System;
4
+ using System.Text;
5
+ using WallstopStudios.UnityHelpers.Utils;
4
6
 
5
7
  public static class FormattingHelpers
6
8
  {
@@ -26,7 +28,11 @@
26
28
  }
27
29
  }
28
30
 
29
- return $"{len:0.##} {ByteSizes[order]}";
31
+ StringBuilder stringBuilder = Buffers.StringBuilder;
32
+ stringBuilder.Clear();
33
+ stringBuilder.AppendFormat("{0:0.##} ", len);
34
+ stringBuilder.Append(ByteSizes[order]);
35
+ return stringBuilder.ToString();
30
36
  }
31
37
  }
32
38
  }
@@ -1,6 +1,7 @@
1
1
  namespace WallstopStudios.UnityHelpers.Utils
2
2
  {
3
3
  using System.Collections.Generic;
4
+ using System.Text;
4
5
  using UnityEngine;
5
6
 
6
7
  public static class Buffers
@@ -20,10 +21,13 @@
20
21
  public static readonly System.Random Random = new();
21
22
  public static readonly WaitForFixedUpdate WaitForFixedUpdate = new();
22
23
  public static readonly WaitForEndOfFrame WaitForEndOfFrame = new();
24
+
25
+ public static readonly StringBuilder StringBuilder = new();
23
26
  }
24
27
 
25
28
  public static class Buffers<T>
26
29
  {
30
+ public static readonly T[] Array = new T[Buffers.BufferSize];
27
31
  public static readonly List<T> List = new();
28
32
  public static readonly HashSet<T> HashSet = new();
29
33
  public static readonly Queue<T> Queue = new();
@@ -1,5 +1,7 @@
1
1
  namespace WallstopStudios.UnityHelpers.Utils
2
2
  {
3
+ using System;
4
+ using System.Collections.Generic;
3
5
  using Core.Attributes;
4
6
  using Core.Extension;
5
7
  using Core.Helper;
@@ -34,6 +36,8 @@
34
36
 
35
37
  private Coroutine _update;
36
38
 
39
+ private readonly Dictionary<int, Vector3[]> _cachedSegments = new();
40
+
37
41
  private void Awake()
38
42
  {
39
43
  this.AssignSiblingComponents();
@@ -114,7 +118,13 @@
114
118
  float angle = 360f / numSegments;
115
119
  float offsetRadians = PRNG.Instance.NextFloat(angle);
116
120
  float currentOffset = offsetRadians;
117
- Vector3[] positions = new Vector3[numSegments];
121
+ if (!_cachedSegments.TryGetValue(numSegments, out Vector3[] positions))
122
+ {
123
+ positions = new Vector3[numSegments];
124
+ _cachedSegments[numSegments] = positions;
125
+ }
126
+
127
+ Array.Clear(positions, 0, numSegments);
118
128
  for (int i = 0; i < numSegments; ++i)
119
129
  {
120
130
  positions[i] =
@@ -0,0 +1,53 @@
1
+ namespace WallstopStudios.UnityHelpers.Utils
2
+ {
3
+ // LzmaHelper.cs - A wrapper for the LZMA SDK
4
+ using System;
5
+ using System.IO;
6
+ using System.Threading;
7
+ using SevenZip.Compression.LZMA;
8
+
9
+ public static class LZMA
10
+ {
11
+ private static readonly ThreadLocal<Decoder> Decoders = new(() => new Decoder());
12
+ private static readonly ThreadLocal<Encoder> Encoders = new(() => new Encoder());
13
+ private static readonly ThreadLocal<byte[]> Properties = new(() => new byte[5]);
14
+ private static readonly ThreadLocal<byte[]> FileLengths = new(() => new byte[8]);
15
+
16
+ public static byte[] Compress(byte[] input)
17
+ {
18
+ Encoder encoder = Encoders.Value;
19
+ using MemoryStream inStream = new(input, writable: false);
20
+ using MemoryStream outStream = new();
21
+ encoder.WriteCoderProperties(outStream);
22
+
23
+ // Write original file size
24
+ outStream.Write(BitConverter.GetBytes(inStream.Length), 0, 8);
25
+
26
+ // Compress the data
27
+ encoder.Code(inStream, outStream, inStream.Length, -1, null);
28
+ return outStream.ToArray();
29
+ }
30
+
31
+ public static byte[] Decompress(byte[] input)
32
+ {
33
+ Decoder decoder = Decoders.Value;
34
+ using MemoryStream inStream = new(input, writable: false);
35
+ using MemoryStream outStream = new();
36
+ // Read decoder properties
37
+ byte[] properties = Properties.Value;
38
+ Array.Clear(properties, 0, properties.Length);
39
+ inStream.Read(properties, 0, properties.Length);
40
+ decoder.SetDecoderProperties(properties);
41
+
42
+ // Read original file size
43
+ byte[] fileLengthBytes = FileLengths.Value;
44
+ Array.Clear(fileLengthBytes, 0, fileLengthBytes.Length);
45
+ inStream.Read(fileLengthBytes, 0, 8);
46
+ long fileLength = BitConverter.ToInt64(fileLengthBytes, 0);
47
+
48
+ // Decompress the data
49
+ decoder.Code(inStream, outStream, inStream.Length, fileLength, null);
50
+ return outStream.ToArray();
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: a40192abcf3c407080bcba2fc551e225
3
+ timeCreated: 1756402526
@@ -0,0 +1,61 @@
1
+ // Common/CRC.cs
2
+
3
+ namespace SevenZip
4
+ {
5
+ class CRC
6
+ {
7
+ public static readonly uint[] Table;
8
+
9
+ static CRC()
10
+ {
11
+ Table = new uint[256];
12
+ const uint kPoly = 0xEDB88320;
13
+ for (uint i = 0; i < 256; i++)
14
+ {
15
+ uint r = i;
16
+ for (int j = 0; j < 8; j++)
17
+ if ((r & 1) != 0)
18
+ r = (r >> 1) ^ kPoly;
19
+ else
20
+ r >>= 1;
21
+ Table[i] = r;
22
+ }
23
+ }
24
+
25
+ uint _value = 0xFFFFFFFF;
26
+
27
+ public void Init()
28
+ {
29
+ _value = 0xFFFFFFFF;
30
+ }
31
+
32
+ public void UpdateByte(byte b)
33
+ {
34
+ _value = Table[(((byte)(_value)) ^ b)] ^ (_value >> 8);
35
+ }
36
+
37
+ public void Update(byte[] data, uint offset, uint size)
38
+ {
39
+ for (uint i = 0; i < size; i++)
40
+ _value = Table[(((byte)(_value)) ^ data[offset + i])] ^ (_value >> 8);
41
+ }
42
+
43
+ public uint GetDigest()
44
+ {
45
+ return _value ^ 0xFFFFFFFF;
46
+ }
47
+
48
+ static uint CalculateDigest(byte[] data, uint offset, uint size)
49
+ {
50
+ CRC crc = new CRC();
51
+ // crc.Init();
52
+ crc.Update(data, offset, size);
53
+ return crc.GetDigest();
54
+ }
55
+
56
+ static bool VerifyDigest(uint digest, byte[] data, uint offset, uint size)
57
+ {
58
+ return (CalculateDigest(data, offset, size) == digest);
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 3dc8670f79b8cc04ebf2dc9503c3b212
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,71 @@
1
+ // InBuffer.cs
2
+
3
+ namespace SevenZip.Buffer
4
+ {
5
+ public class InBuffer
6
+ {
7
+ byte[] m_Buffer;
8
+ uint m_Pos;
9
+ uint m_Limit;
10
+ uint m_BufferSize;
11
+ System.IO.Stream m_Stream;
12
+ bool m_StreamWasExhausted;
13
+ ulong m_ProcessedSize;
14
+
15
+ public InBuffer(uint bufferSize)
16
+ {
17
+ m_Buffer = new byte[bufferSize];
18
+ m_BufferSize = bufferSize;
19
+ }
20
+
21
+ public void Init(System.IO.Stream stream)
22
+ {
23
+ m_Stream = stream;
24
+ m_ProcessedSize = 0;
25
+ m_Limit = 0;
26
+ m_Pos = 0;
27
+ m_StreamWasExhausted = false;
28
+ }
29
+
30
+ public bool ReadBlock()
31
+ {
32
+ if (m_StreamWasExhausted)
33
+ return false;
34
+ m_ProcessedSize += m_Pos;
35
+ int aNumProcessedBytes = m_Stream.Read(m_Buffer, 0, (int)m_BufferSize);
36
+ m_Pos = 0;
37
+ m_Limit = (uint)aNumProcessedBytes;
38
+ m_StreamWasExhausted = (aNumProcessedBytes == 0);
39
+ return (!m_StreamWasExhausted);
40
+ }
41
+
42
+ public void ReleaseStream()
43
+ {
44
+ // m_Stream.Close();
45
+ m_Stream = null;
46
+ }
47
+
48
+ public bool ReadByte(byte b) // check it
49
+ {
50
+ if (m_Pos >= m_Limit)
51
+ if (!ReadBlock())
52
+ return false;
53
+ b = m_Buffer[m_Pos++];
54
+ return true;
55
+ }
56
+
57
+ public byte ReadByte()
58
+ {
59
+ // return (byte)m_Stream.ReadByte();
60
+ if (m_Pos >= m_Limit)
61
+ if (!ReadBlock())
62
+ return 0xFF;
63
+ return m_Buffer[m_Pos++];
64
+ }
65
+
66
+ public ulong GetProcessedSize()
67
+ {
68
+ return m_ProcessedSize + m_Pos;
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: d9ac1800f49f3ef49b15cedc6801f985
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,65 @@
1
+ // OutBuffer.cs
2
+
3
+ namespace SevenZip.Buffer
4
+ {
5
+ public class OutBuffer
6
+ {
7
+ byte[] m_Buffer;
8
+ uint m_Pos;
9
+ uint m_BufferSize;
10
+ System.IO.Stream m_Stream;
11
+ ulong m_ProcessedSize;
12
+
13
+ public OutBuffer(uint bufferSize)
14
+ {
15
+ m_Buffer = new byte[bufferSize];
16
+ m_BufferSize = bufferSize;
17
+ }
18
+
19
+ public void SetStream(System.IO.Stream stream)
20
+ {
21
+ m_Stream = stream;
22
+ }
23
+
24
+ public void FlushStream()
25
+ {
26
+ m_Stream.Flush();
27
+ }
28
+
29
+ public void CloseStream()
30
+ {
31
+ m_Stream.Close();
32
+ }
33
+
34
+ public void ReleaseStream()
35
+ {
36
+ m_Stream = null;
37
+ }
38
+
39
+ public void Init()
40
+ {
41
+ m_ProcessedSize = 0;
42
+ m_Pos = 0;
43
+ }
44
+
45
+ public void WriteByte(byte b)
46
+ {
47
+ m_Buffer[m_Pos++] = b;
48
+ if (m_Pos >= m_BufferSize)
49
+ FlushData();
50
+ }
51
+
52
+ public void FlushData()
53
+ {
54
+ if (m_Pos == 0)
55
+ return;
56
+ m_Stream.Write(m_Buffer, 0, (int)m_Pos);
57
+ m_Pos = 0;
58
+ }
59
+
60
+ public ulong GetProcessedSize()
61
+ {
62
+ return m_ProcessedSize + m_Pos;
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 694fae53bf0755f4daf26b34bc69017c
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 1aabbf2e9b0c44cab7a350196de304ee
3
+ timeCreated: 1756403037
@@ -0,0 +1,28 @@
1
+ // IMatchFinder.cs
2
+
3
+ using System;
4
+
5
+ namespace SevenZip.Compression.LZ
6
+ {
7
+ interface IInWindowStream
8
+ {
9
+ void SetStream(System.IO.Stream inStream);
10
+ void Init();
11
+ void ReleaseStream();
12
+ Byte GetIndexByte(Int32 index);
13
+ UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit);
14
+ UInt32 GetNumAvailableBytes();
15
+ }
16
+
17
+ interface IMatchFinder : IInWindowStream
18
+ {
19
+ void Create(
20
+ UInt32 historySize,
21
+ UInt32 keepAddBufferBefore,
22
+ UInt32 matchMaxLen,
23
+ UInt32 keepAddBufferAfter
24
+ );
25
+ UInt32 GetMatches(UInt32[] distances);
26
+ void Skip(UInt32 num);
27
+ }
28
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: faf30c7802a24124cb5e5942544e622c
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: