Ship the WeChat hot-update catalogs and the camp, TideWhale T2, UI atlas, and animation-lab work.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
mergeInto(LibraryManager.library, {
|
||||
$AIGameSockets: { nextId: 1, sockets: {} },
|
||||
|
||||
AIGame_WsCreate__deps: ['$AIGameSockets'],
|
||||
AIGame_WsCreate: function (urlPointer) {
|
||||
var id = AIGameSockets.nextId++;
|
||||
var entry = { events: [], socket: null, disposed: false, terminal: false, wechat: false };
|
||||
AIGameSockets.sockets[id] = entry;
|
||||
var finish = function (kind, reason) {
|
||||
if (entry.disposed || entry.terminal) return;
|
||||
entry.terminal = true;
|
||||
entry.events.push(kind + (reason || 'closed'));
|
||||
};
|
||||
var closeSocket = function () {
|
||||
if (!entry.socket) return;
|
||||
try {
|
||||
if (entry.wechat) entry.socket.close({ code: 1000, reason: 'client close' });
|
||||
else entry.socket.close(1000, 'client close');
|
||||
} catch (ignored) {}
|
||||
};
|
||||
var opened = function () {
|
||||
// WeChat may finish opening after a close requested while connecting.
|
||||
if (entry.disposed || entry.terminal) { closeSocket(); return; }
|
||||
entry.events.push('O');
|
||||
};
|
||||
var message = function (event) {
|
||||
if (!entry.disposed && !entry.terminal && typeof event.data === 'string')
|
||||
entry.events.push('M' + event.data);
|
||||
};
|
||||
try {
|
||||
var url = UTF8ToString(urlPointer);
|
||||
var api = typeof wx !== 'undefined' ? wx :
|
||||
(typeof GameGlobal !== 'undefined' ? GameGlobal.wx : null);
|
||||
if (api && api.connectSocket) {
|
||||
entry.wechat = true;
|
||||
var task = api.connectSocket({ url: url,
|
||||
fail: function (error) { finish('E', error.errMsg || 'connectSocket failed'); } });
|
||||
entry.socket = task;
|
||||
task.onOpen(opened);
|
||||
task.onMessage(message);
|
||||
task.onError(function (error) { finish('E', error.errMsg || 'socket error'); });
|
||||
task.onClose(function (event) { finish('C', String(event.code || '') + ' ' + (event.reason || 'closed')); });
|
||||
} else {
|
||||
var socket = new WebSocket(url);
|
||||
entry.socket = socket;
|
||||
socket.onopen = opened;
|
||||
socket.onmessage = message;
|
||||
socket.onerror = function () { finish('E', 'WebSocket connection failed'); };
|
||||
socket.onclose = function (event) { finish('C', String(event.code) + ' ' + (event.reason || 'closed')); };
|
||||
}
|
||||
} catch (error) { finish('E', error.message || String(error)); }
|
||||
return id;
|
||||
},
|
||||
|
||||
AIGame_WsPoll__deps: ['$AIGameSockets'],
|
||||
AIGame_WsPoll: function (id) {
|
||||
var entry = AIGameSockets.sockets[id];
|
||||
if (!entry || !entry.events.length) return 0;
|
||||
var text = entry.events.shift();
|
||||
var size = lengthBytesUTF8(text) + 1;
|
||||
var pointer = _malloc(size);
|
||||
stringToUTF8(text, pointer, size);
|
||||
// IL2CPP frees the native buffer for a marshalled string return value.
|
||||
return pointer;
|
||||
},
|
||||
|
||||
AIGame_WsSend__deps: ['$AIGameSockets'],
|
||||
AIGame_WsSend: function (id, textPointer) {
|
||||
var entry = AIGameSockets.sockets[id];
|
||||
if (!entry || entry.disposed || entry.terminal) return;
|
||||
var fail = function (error) {
|
||||
if (entry.disposed || entry.terminal) return;
|
||||
entry.terminal = true;
|
||||
entry.events.push('E' + (error.errMsg || error.message || 'send failed'));
|
||||
};
|
||||
try {
|
||||
var text = UTF8ToString(textPointer);
|
||||
if (entry.wechat) entry.socket.send({ data: text, fail: fail });
|
||||
else entry.socket.send(text);
|
||||
} catch (error) { fail(error); }
|
||||
},
|
||||
|
||||
AIGame_WsDispose__deps: ['$AIGameSockets'],
|
||||
AIGame_WsDispose: function (id) {
|
||||
var entry = AIGameSockets.sockets[id];
|
||||
if (!entry) return;
|
||||
entry.disposed = true;
|
||||
entry.events.length = 0;
|
||||
delete AIGameSockets.sockets[id];
|
||||
try {
|
||||
if (entry.socket) {
|
||||
if (entry.wechat) entry.socket.close({ code: 1000, reason: 'client close' });
|
||||
else entry.socket.close(1000, 'client close');
|
||||
}
|
||||
} catch (ignored) {}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4fdc7412860dec242824dd7d76a7634a
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
WebGL: WebGL
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
mergeInto(LibraryManager.library, {
|
||||
AIGame_GetUiSafeInsets: function (pointer) {
|
||||
try {
|
||||
var api = typeof wx !== 'undefined' ? wx :
|
||||
(typeof GameGlobal !== 'undefined' ? GameGlobal.wx : null);
|
||||
if (!api) return 0;
|
||||
var info = null;
|
||||
try { if (api.getWindowInfo) info = api.getWindowInfo(); } catch (ignored) {}
|
||||
if (!info && api.getSystemInfoSync) info = api.getSystemInfoSync();
|
||||
if (!info) return 0;
|
||||
var width = info.windowWidth || info.screenWidth;
|
||||
var height = info.windowHeight || info.screenHeight;
|
||||
if (!(width > 0 && height > 0)) return 0;
|
||||
var safe = info.safeArea;
|
||||
var left = 0, bottom = 0, right = 0, top = 0;
|
||||
if (safe && safe.width > 0 && safe.height > 0) {
|
||||
left = safe.left / width;
|
||||
right = 1 - safe.right / width;
|
||||
bottom = 1 - safe.bottom / height;
|
||||
top = safe.top / height;
|
||||
}
|
||||
// Both APIs use logical pixels with a top-left origin, independent of Unity DPR.
|
||||
var menu = null;
|
||||
try { if (api.getMenuButtonBoundingClientRect) menu = api.getMenuButtonBoundingClientRect(); }
|
||||
catch (ignored) {}
|
||||
if (menu && menu.width > 0 && menu.height > 0 && menu.bottom > 0 && menu.top < height / 2) {
|
||||
top = Math.max(top, (menu.bottom + 8) / height);
|
||||
} else {
|
||||
// Older clients may omit the menu API; reserve one capsule row below the notch.
|
||||
top = Math.max(top, ((safe && safe.top > 0 ? safe.top : info.statusBarHeight || 0) + 40) / height);
|
||||
}
|
||||
var values = [left, bottom, right, top];
|
||||
for (var i = 0; i < 4; i++) HEAPF32[(pointer >> 2) + i] =
|
||||
isFinite(values[i]) ? Math.max(0, Math.min(.35, values[i])) : 0;
|
||||
return 1;
|
||||
} catch (ignored) { return 0; }
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7fba9ecd719c66f41971c06df6cc806f
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
WebGL: WebGL
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user