From 9454310988278c061cffd9625d152fc5ed9686e6 Mon Sep 17 00:00:00 2001 From: routersys Date: Sat, 4 Jul 2026 23:18:37 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=8D=E3=82=A4=E3=83=86=E3=82=A3=E3=83=96?= =?UTF-8?q?=E3=83=9B=E3=82=B9=E3=83=88=E3=81=AEgetobject=E3=81=B8=E3=83=A1?= =?UTF-8?q?=E3=82=BF=E3=83=87=E3=83=BC=E3=82=BF=E3=82=92=E9=85=8D=E7=B7=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaScript.Runtime/Engine/LuaJitWorker.cs | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/LuaScript.Runtime/Engine/LuaJitWorker.cs b/LuaScript.Runtime/Engine/LuaJitWorker.cs index 4821a6a..b5c2323 100644 --- a/LuaScript.Runtime/Engine/LuaJitWorker.cs +++ b/LuaScript.Runtime/Engine/LuaJitWorker.cs @@ -37,6 +37,7 @@ namespace LuaScript.Engine private readonly Dictionary _stringNameBytes = new(StringComparer.Ordinal); private byte[] _stringValueBytes = new byte[256]; private byte[] _sceneValueBytes = new byte[256]; + private byte[] _objectMetaBytes = new byte[256]; private static readonly byte[] s_shaderTransparentPixel = new byte[4]; private readonly PixelShaderInput[] _shaderInputs = new PixelShaderInput[NativeProtocol.ShaderResourcesMax]; @@ -657,6 +658,9 @@ namespace LuaScript.Engine view.Write(result + NativeProtocol.CbRz * 8, value.Rz); view.Write(result + NativeProtocol.CbAlpha * 8, value.Alpha); view.Write(result + NativeProtocol.CbLayer * 8, (double)value.Layer); + view.Write(result + NativeProtocol.CbVolume * 8, value.Volume); + view.Write(result + NativeProtocol.CbLength * 8, (double)value.Length); + WriteObjectMeta(view, value.Character, value.Text, value.Kind); view.Write(NativeProtocol.OffCallbackFound, 1); } else @@ -665,6 +669,27 @@ namespace LuaScript.Engine } } + private void WriteObjectMeta(MemoryMappedViewAccessor view, string character, string text, string kind) + { + character ??= string.Empty; + text ??= string.Empty; + kind ??= string.Empty; + int maxBytes = Encoding.UTF8.GetMaxByteCount(character.Length + text.Length + kind.Length) + 2; + if (_objectMetaBytes.Length < maxBytes) + _objectMetaBytes = new byte[Math.Max(maxBytes, _objectMetaBytes.Length * 2)]; + + int length = Encoding.UTF8.GetBytes(character, 0, character.Length, _objectMetaBytes, 0); + _objectMetaBytes[length++] = 0; + length += Encoding.UTF8.GetBytes(text, 0, text.Length, _objectMetaBytes, length); + _objectMetaBytes[length++] = 0; + length += Encoding.UTF8.GetBytes(kind, 0, kind.Length, _objectMetaBytes, length); + if (length > NativeProtocol.CallbackTagMax) + length = NativeProtocol.CallbackTagMax; + + view.WriteArray(NativeProtocol.CallbackTagOffset, _objectMetaBytes, 0, length); + view.Write(NativeProtocol.OffCallbackTagLen, length); + } + private void ResolveLoadFigureCallback( MemoryMappedViewAccessor view, Func loadFigure)