feat: 项目初始化 + 3D方块世界原型 + AI助搭系统
CI / Go Backend (push) Canceled after 0s

初始化 monorepo: Go后端(7微服务) + Unity客户端(9模块) + 启动器

HTML5原型: Three.js 3D体素世界, Perlin噪声地形, 原版材质, 22种方块

Minecraft创造模式背包: 双栏布局, 拖拽移动物品, 方向性元件引脚

AI助搭策划文档 + 客户端/服务端骨架 + Docker Compose + CI
This commit is contained in:
xyou
2026-08-08 14:07:56 +08:00
parent 9500c4c80a
commit f70b061d1a
1972 changed files with 159760 additions and 6 deletions
@@ -0,0 +1,15 @@
using System;
namespace PCL.Core.Utils.WinRT;
/// <summary>
/// 表示一个 WinRT HSTRING 句柄的只读包装。
/// </summary>
/// <param name="Value">HSTRING 的底层指针句柄(<see cref="nint"/>)。</param>
public readonly record struct HString(IntPtr Value)
{
public readonly IntPtr Value = Value;
public bool IsNull => Value == IntPtr.Zero;
public static implicit operator IntPtr(HString h) => h.Value;
public static explicit operator HString(IntPtr ptr) => new(ptr);
}
@@ -0,0 +1,59 @@
using System;
using System.Runtime.InteropServices;
namespace PCL.Core.Utils.WinRT;
public class HStringHelper
{
public static unsafe HString ToHString(string? value)
{
if (value is null)
{
return new HString(IntPtr.Zero);
}
IntPtr handle;
fixed (char* lpValue = value)
{
Marshal.ThrowExceptionForHR(
WinRTInterop.WindowsCreateString((ushort*)lpValue, value.Length, &handle));
}
return new HString(handle);
}
public static unsafe string ToManagedString(HString value)
{
if (value == IntPtr.Zero)
return "";
uint length;
var buffer = WinRTInterop.WindowsGetStringRawBuffer(value, &length);
return length != 0 ? new string(buffer, 0, (int)length) : string.Empty;
}
public static void DeleteHString(HString value)
{
if (!value.IsNull)
WinRTInterop.WindowsDeleteString(value);
}
public static unsafe void WithReference(
ReadOnlySpan<char> value,
Action<HString> action)
{
fixed (char* p = value)
{
WinRTInterop.HStringHeader header;
IntPtr hstring;
Marshal.ThrowExceptionForHR(
WinRTInterop.WindowsCreateStringReference(
(ushort*)p,
value.Length,
(IntPtr*)&header,
&hstring));
action((HString)hstring);
}
}
}
@@ -0,0 +1,21 @@
using System;
namespace PCL.Core.Utils.WinRT.Interface;
public unsafe struct IInspectable
{
public IInspectableVtbl* lpVtbl;
}
public unsafe struct IInspectableVtbl
{
// IUnknown
public delegate* unmanaged<void*, Guid*, void**, int> QueryInterface;
public delegate* unmanaged<void*, uint> AddRef;
public delegate* unmanaged<void*, uint> Release;
// IInspectable
public delegate* unmanaged<void*, uint*, Guid**, int> GetIids;
public delegate* unmanaged<void*, IntPtr*, int> GetRuntimeClassName;
public delegate* unmanaged<void*, int*, int> GetTrustLevel;
}
@@ -0,0 +1,44 @@
using System;
namespace PCL.Core.Utils.WinRT.Interface.Windows.Data.Xml.Dom;
public static class IXmlDocumentIOInfo
{
public static readonly string ActivatableClassId = "Windows.Data.Xml.Dom.XmlDocument";
public static readonly Guid Iid = new("6cd0e74e-ee65-4489-9ebf-ca43e87ba637");
}
public unsafe struct IXmlDocumentIO
{
public IXmlDocumentIOVtbl* lpVtbl;
}
public unsafe struct IXmlDocumentIOVtbl
{
// IUnknown
public delegate* unmanaged<void*, Guid*, void**, int> QueryInterface;
public delegate* unmanaged<void*, uint> AddRef;
public delegate* unmanaged<void*, uint> Release;
// IInspectable
public delegate* unmanaged<void*, uint*, Guid**, int> GetIids;
public delegate* unmanaged<void*, IntPtr*, int> GetRuntimeClassName;
public delegate* unmanaged<void*, int*, int> GetTrustLevel;
// IXmlDocumentIO
/// <summary>
/// void LoadXml(string xml)
/// </summary>
public delegate* unmanaged<void*, IntPtr, int> LoadXml;
/// <summary>
/// void LoadXml(string xml, XmlLoadSettings settings)
/// </summary>
public delegate* unmanaged<void*, IntPtr, void*, int> LoadXmlWithSettings;
/// <summary>
/// IAsyncAction SaveToFileAsync(IStorageFile file)
/// </summary>
public delegate* unmanaged<void*, void*, void**, int> SaveToFileAsync;
}
@@ -0,0 +1,34 @@
using System;
namespace PCL.Core.Utils.WinRT.Interface.Windows.UI.Notifications;
public static class IToastNotificationFactoryInfo
{
public static readonly string ActivatableClassId = "Windows.UI.Notifications.ToastNotification";
public static readonly Guid Iid = new("04124b20-82c6-4229-b109-fd9ed4662b53");
}
public unsafe struct IToastNotificationFactory
{
public IToastNotificationFactoryVtbl* lpVtbl;
}
public unsafe struct IToastNotificationFactoryVtbl
{
// IUnknown
public delegate* unmanaged<void*, Guid*, void**, int> QueryInterface;
public delegate* unmanaged<void*, uint> AddRef;
public delegate* unmanaged<void*, uint> Release;
// IInspectable
public delegate* unmanaged<void*, uint*, Guid**, int> GetIids;
public delegate* unmanaged<void*, IntPtr*, int> GetRuntimeClassName;
public delegate* unmanaged<void*, int*, int> GetTrustLevel;
// IToastNotificationFactory
/// <summary>
/// ToastNotification CreateToastNotification(XmlDocument content)
/// </summary>
public delegate* unmanaged<void*, void*, void**, int> CreateToastNotification;
}
@@ -0,0 +1,44 @@
using System;
namespace PCL.Core.Utils.WinRT.Interface.Windows.UI.Notifications;
public static class IToastNotificationManagerStaticsInfo
{
public static readonly string ActivatableClassId = "Windows.UI.Notifications.ToastNotificationManager";
public static readonly Guid Iid = new("50ac103f-d235-4598-bbef-98fe4d1a3ad4");
}
public unsafe struct IToastNotificationManagerStatics
{
public IToastNotificationManagerStaticsVtbl* lpVtbl;
}
public unsafe struct IToastNotificationManagerStaticsVtbl
{
// IUnknown
public delegate* unmanaged<void*, Guid*, void**, int> QueryInterface;
public delegate* unmanaged<void*, uint> AddRef;
public delegate* unmanaged<void*, uint> Release;
// IInspectable
public delegate* unmanaged<void*, uint*, Guid**, int> GetIids;
public delegate* unmanaged<void*, IntPtr*, int> GetRuntimeClassName;
public delegate* unmanaged<void*, int*, int> GetTrustLevel;
// IToastNotificationManagerStatics
/// <summary>
/// ToastNotifier CreateToastNotifier()
/// </summary>
public delegate* unmanaged<void*, void**, int> CreateToastNotifier;
/// <summary>
/// ToastNotifier CreateToastNotifier(string applicationId)
/// </summary>
public delegate* unmanaged<void*, IntPtr, void**, int> CreateToastNotifierWithId;
/// <summary>
/// XmlDocument GetTemplateContent(ToastTemplateType type)
/// </summary>
public delegate* unmanaged<void*, int, void**, int> GetTemplateContent;
}
@@ -0,0 +1,59 @@
using System;
namespace PCL.Core.Utils.WinRT.Interface.Windows.UI.Notifications;
public static class IToastNotifierInfo
{
public static readonly string ActivatableClassId = "Windows.UI.Notifications.ToastNotifier";
public static readonly Guid Iid = new("75927b93-03f3-41ec-91d3-6e5bac1b38e7");
}
public unsafe struct IToastNotifier
{
public IToastNotifierVtbl* lpVtbl;
}
public unsafe struct IToastNotifierVtbl
{
// IUnknown
public delegate* unmanaged<void*, Guid*, void**, int> QueryInterface;
public delegate* unmanaged<void*, uint> AddRef;
public delegate* unmanaged<void*, uint> Release;
// IInspectable
public delegate* unmanaged<void*, uint*, Guid**, int> GetIids;
public delegate* unmanaged<void*, IntPtr*, int> GetRuntimeClassName;
public delegate* unmanaged<void*, int*, int> GetTrustLevel;
// IToastNotifier
/// <summary>
/// void Show(ToastNotification notification)
/// </summary>
public delegate* unmanaged<void*, void*, int> Show;
/// <summary>
/// void Hide(ToastNotification notification)
/// </summary>
public delegate* unmanaged<void*, void*, int> Hide;
/// <summary>
/// NotificationSetting Setting { get; }
/// </summary>
public delegate* unmanaged<void*, int, int> get_Setting;
/// <summary>
/// void AddToSchedule(ScheduledToastNotification scheduledToast)
/// </summary>
public delegate* unmanaged<void*, void*, int> AddToSchedule;
/// <summary>
/// void RemoveFromSchedule(ScheduledToastNotification scheduledToast)
/// </summary>
public delegate* unmanaged<void*, void*, int> RemoveFromSchedule;
/// <summary>
/// IVectorView&lt;ScheduledToastNotification&gt; GetScheduledToastNotifications()
/// </summary>
public delegate* unmanaged<void*, void**, int> GetScheduledToastNotifications;
}
@@ -0,0 +1,82 @@
using System;
using System.Runtime.InteropServices;
namespace PCL.Core.Utils.WinRT;
public static partial class WinRTInterop
{
// roapi.h
[LibraryImport("combase.dll")]
private static unsafe partial int RoGetActivationFactory(IntPtr activatableClassId, Guid* iid, IntPtr* factory);
[LibraryImport("combase.dll")]
private static unsafe partial int RoActivateInstance(IntPtr activatableClassId, IntPtr* instance);
public static unsafe IntPtr ActivateInstance(ReadOnlySpan<char> activatableClassId)
{
var instance = IntPtr.Zero;
fixed (char* pName = activatableClassId)
{
HStringHeader header;
IntPtr hstring;
Marshal.ThrowExceptionForHR(
WindowsCreateStringReference(
(ushort*)pName,
activatableClassId.Length,
(IntPtr*)&header,
&hstring));
Marshal.ThrowExceptionForHR(
RoActivateInstance(
hstring,
&instance));
}
return instance;
}
public static unsafe IntPtr GetActivationFactory(ReadOnlySpan<char> activatableClassId, Guid iid)
{
var factory = IntPtr.Zero;
fixed (char* pName = activatableClassId)
{
HStringHeader header;
IntPtr hstring;
Marshal.ThrowExceptionForHR(
WindowsCreateStringReference(
(ushort*)pName,
activatableClassId.Length,
(IntPtr*)&header,
&hstring));
Marshal.ThrowExceptionForHR(
RoGetActivationFactory(
hstring,
&iid,
&factory));
}
return factory;
}
// winstring.h
[LibraryImport("combase.dll")]
internal static unsafe partial int WindowsCreateString(ushort* sourceString, int length, IntPtr* hstring);
[LibraryImport("combase.dll")]
internal static unsafe partial int WindowsCreateStringReference(ushort* sourceString, int length,
IntPtr* hstringHeader, IntPtr* hstring);
[LibraryImport("combase.dll")]
internal static unsafe partial int WindowsDeleteString(IntPtr hstring);
[LibraryImport("combase.dll")]
internal static unsafe partial char* WindowsGetStringRawBuffer(IntPtr hstring, uint* length);
// hstring.h
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct HStringHeader
{
private fixed byte _data[24];
}
}