Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ContentFileBridge.cs
浏览该文件的文档.
1using System.Runtime.CompilerServices;
2using System.Runtime.InteropServices;
3
4namespace Game {
5 public static unsafe class ContentFileBridge {
6 static byte* _sharedPtr;
7
8 public static IntPtr Initialize() {
9 nuint length = (nuint)(ContentFileInfo.FileSize + 8);
10 void* ptr = NativeMemory.AlignedAlloc(length, 16);
11 NativeMemory.Clear(ptr, length);
12 _sharedPtr = (byte*)ptr;
13 return (IntPtr)ptr;
14 }
15
16 public static UnmanagedMemoryStream GetStream() => new(_sharedPtr + 8, ContentFileInfo.FileSize);
17
18 public static bool GetIsDownloaded() => Volatile.Read(ref Unsafe.AsRef<byte>(_sharedPtr)) == 1;
19 }
20}
unsafe
定义 Main.cs:15
static UnmanagedMemoryStream GetStream()