feat: 50 игр на Lua + импорт Roblox для всех + поддержка Lua в плеере #39
@ -1606,6 +1606,17 @@ export class GameRuntime {
|
||||
routeEvent(target, eventType, extra = {}) {
|
||||
if (!target || !eventType) return;
|
||||
for (const sb of this.sandboxes) {
|
||||
// LuaSharedSandbox = один sandbox на все Lua-скрипты, target=null.
|
||||
// Шлём ему ВСЕ события — shim сам найдёт соответствующий Part
|
||||
// через partById и сфейерит Touched на нужной части.
|
||||
if (sb.constructor?.name === 'LuaSharedSandbox' || sb._luaShared) {
|
||||
const kind = eventType === 'touch' ? 'touched'
|
||||
: eventType === 'untouch' ? 'untouched'
|
||||
: eventType;
|
||||
const primId = target.id ?? target.ref ?? null;
|
||||
sb.sendEvent({ kind, primId, target, ...extra });
|
||||
continue;
|
||||
}
|
||||
if (!sb.target) continue;
|
||||
if (!this._targetMatches(sb.target, target)) continue;
|
||||
sb.sendEvent({ type: eventType, ...extra });
|
||||
|
||||
@ -36,6 +36,9 @@ export class LuaSharedSandbox {
|
||||
this._guiTree = null;
|
||||
this._loopHandle = null;
|
||||
this._lastTickAt = 0;
|
||||
// Маркер для GameRuntime.routeEvent — этот sandbox принимает все
|
||||
// события и сам маршрутизирует через shim.fireTargetEvent.
|
||||
this._luaShared = true;
|
||||
}
|
||||
|
||||
setOnCommand(cb) { this._onCommand = cb; }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user