Merge branch 'merge/duckietm-main-20260407'

This commit is contained in:
Lorenzune
2026-04-07 17:14:27 +02:00
2 changed files with 65 additions and 3 deletions
@@ -1513,12 +1513,38 @@ export class RoomObjectEventHandler implements IRoomCanvasMouseListener, IRoomOb
return true;
}
private _walkDebounceTimer: ReturnType<typeof setTimeout> = null;
private _lastWalkSentAt: number = 0;
private static readonly WALK_MIN_INTERVAL_MS = 100;
private sendWalkUpdate(x: number, y: number): void
{
if(!this._roomEngine || !GetCommunication().connection) return;
if(this._walkDebounceTimer)
{
clearTimeout(this._walkDebounceTimer);
this._walkDebounceTimer = null;
}
const now = Date.now();
const elapsed = now - this._lastWalkSentAt;
if(elapsed >= RoomObjectEventHandler.WALK_MIN_INTERVAL_MS)
{
this._lastWalkSentAt = now;
GetCommunication().connection.send(new RoomUnitWalkComposer(x, y));
}
else
{
this._walkDebounceTimer = setTimeout(() =>
{
this._walkDebounceTimer = null;
this._lastWalkSentAt = Date.now();
GetCommunication().connection.send(new RoomUnitWalkComposer(x, y));
}, RoomObjectEventHandler.WALK_MIN_INTERVAL_MS - elapsed);
}
}
private handleMouseOverObject(category: number, roomId: number, event: RoomObjectMouseEvent): ObjectTileCursorUpdateMessage
{
+38 -2
View File
@@ -15,12 +15,48 @@ export class TextureUtils
public static async generateImage(options: ExtractImageOptions | Container | Texture): Promise<HTMLImageElement>
{
return this.getExtractor().image(options);
if(!options) return null;
if(options instanceof Texture)
{
if(options.destroyed || !options.source || options.source.destroyed) return null;
}
else if(options instanceof Container)
{
if(options.destroyed) return null;
}
try
{
return await this.getExtractor().image(options);
}
catch(e)
{
return null;
}
}
public static async generateImageUrl(options: ExtractImageOptions | Container | Texture): Promise<string>
{
return this.getExtractor().base64(options);
if(!options) return null;
if(options instanceof Texture)
{
if(options.destroyed || !options.source || options.source.destroyed) return null;
}
else if(options instanceof Container)
{
if(options.destroyed) return null;
}
try
{
return await this.getExtractor().base64(options);
}
catch(e)
{
return null;
}
}
public static generateCanvas(options: ExtractOptions | Container | Texture): ICanvas