You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-19 15:06:20 +00:00
fix(room): support wired click-user controls
This commit is contained in:
@@ -2285,8 +2285,6 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService
|
||||
|
||||
private handleRoomDragging(canvas: IRoomRenderingCanvas, x: number, y: number, type: string, altKey: boolean, ctrlKey: boolean, shiftKey: boolean): boolean
|
||||
{
|
||||
if(this.isPlayingGame()) return false;
|
||||
|
||||
if(this._areaSelectionManager.areaSelectionState === RoomAreaSelectionManager.SELECTING)
|
||||
{
|
||||
this._activeRoomIsDragged = false;
|
||||
@@ -2521,11 +2519,18 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService
|
||||
|
||||
public setSelectedAvatar(roomId: number, objectId: number): void
|
||||
{
|
||||
if(this._roomObjectEventHandler) return;
|
||||
if(!this._roomObjectEventHandler) return;
|
||||
|
||||
this._roomObjectEventHandler.setSelectedAvatar(roomId, objectId, true);
|
||||
}
|
||||
|
||||
public clearSelectedAvatar(roomId: number): void
|
||||
{
|
||||
if(!this._roomObjectEventHandler) return;
|
||||
|
||||
this._roomObjectEventHandler.clearSelectedAvatar(roomId);
|
||||
}
|
||||
|
||||
public cancelRoomObjectInsert(): void
|
||||
{
|
||||
if(!this._roomObjectEventHandler) return;
|
||||
|
||||
@@ -10,6 +10,7 @@ import { SelectedRoomObjectData } from './utils';
|
||||
|
||||
export class RoomObjectEventHandler implements IRoomCanvasMouseListener, IRoomObjectEventManager
|
||||
{
|
||||
private static readonly CLICK_USER_LOOK_DELAY_MS = 120;
|
||||
private _eventIds: Map<number, Map<string, string>> = new Map();
|
||||
|
||||
private _selectedAvatarId: number = -1;
|
||||
@@ -17,6 +18,7 @@ export class RoomObjectEventHandler implements IRoomCanvasMouseListener, IRoomOb
|
||||
private _selectedObjectCategory: number = -2;
|
||||
private _whereYouClickIsWhereYouGo: boolean = true;
|
||||
private _objectPlacementSource: string = null;
|
||||
private _pendingAvatarLookTimeout: ReturnType<typeof setTimeout> = null;
|
||||
|
||||
constructor(
|
||||
private readonly _roomEngine: IRoomEngineServices)
|
||||
@@ -2080,6 +2082,8 @@ export class RoomObjectEventHandler implements IRoomCanvasMouseListener, IRoomOb
|
||||
{
|
||||
if(!this._roomEngine) return;
|
||||
|
||||
this.clearPendingAvatarLook();
|
||||
|
||||
const _local_4 = RoomObjectCategory.UNIT;
|
||||
const _local_5 = this._roomEngine.getRoomObject(k, this._selectedAvatarId, _local_4);
|
||||
|
||||
@@ -2100,15 +2104,26 @@ export class RoomObjectEventHandler implements IRoomCanvasMouseListener, IRoomOb
|
||||
{
|
||||
_local_5.logic.processUpdateMessage(new ObjectAvatarSelectedMessage(true));
|
||||
|
||||
_local_6 = true;
|
||||
_local_6 = true;
|
||||
|
||||
this._selectedAvatarId = _arg_2;
|
||||
this._selectedAvatarId = _arg_2;
|
||||
|
||||
const location = _local_5.getLocation();
|
||||
const location = _local_5.getLocation();
|
||||
|
||||
if(location) GetCommunication().connection.send(new RoomUnitLookComposer(~~(location.x), ~~(location.y)));
|
||||
}
|
||||
}
|
||||
if(location)
|
||||
{
|
||||
this._pendingAvatarLookTimeout = setTimeout(() =>
|
||||
{
|
||||
this._pendingAvatarLookTimeout = null;
|
||||
|
||||
if(this.shouldSuppressAvatarLook()) return;
|
||||
if(this._selectedAvatarId !== _arg_2) return;
|
||||
|
||||
GetCommunication().connection.send(new RoomUnitLookComposer(~~(location.x), ~~(location.y)));
|
||||
}, RoomObjectEventHandler.CLICK_USER_LOOK_DELAY_MS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const selectionArrow = this._roomEngine.getRoomObjectSelectionArrow(k);
|
||||
|
||||
@@ -2119,6 +2134,26 @@ export class RoomObjectEventHandler implements IRoomCanvasMouseListener, IRoomOb
|
||||
}
|
||||
}
|
||||
|
||||
public clearSelectedAvatar(roomId: number): void
|
||||
{
|
||||
this.setSelectedAvatar(roomId, 0, false);
|
||||
}
|
||||
|
||||
private clearPendingAvatarLook(): void
|
||||
{
|
||||
if(!this._pendingAvatarLookTimeout) return;
|
||||
|
||||
clearTimeout(this._pendingAvatarLookTimeout);
|
||||
this._pendingAvatarLookTimeout = null;
|
||||
}
|
||||
|
||||
private shouldSuppressAvatarLook(): boolean
|
||||
{
|
||||
const control = (globalThis as any).__nitroAvatarClickControl;
|
||||
|
||||
return !!control && (control.suppressRotateUntil > Date.now());
|
||||
}
|
||||
|
||||
private resetSelectedObjectData(roomId: number): void
|
||||
{
|
||||
if(!this._roomEngine) return;
|
||||
|
||||
Reference in New Issue
Block a user