Start area selector

This commit is contained in:
Bill 2024-06-30 20:57:15 -04:00
parent b87f08d0fd
commit cf8182d471
40 changed files with 1563 additions and 627 deletions

View File

@ -10,6 +10,7 @@ export interface IRoomCreator
updateRoomInstancePlaneVisibility(roomId: number, wallVisible: boolean, floorVisible?: boolean): boolean;
updateRoomInstancePlaneThickness(roomId: number, wallThickness: number, floorThickness: number): boolean;
updateRoomInstancePlaneType(roomId: number, floorType?: string, wallType?: string, landscapeType?: string, _arg_5?: boolean): boolean;
updateAreaHide(roomId: number, furniId: number, on: boolean, rootX: number, rootY: number, width: number, length: number, invert: boolean): boolean;
removeRoomInstance(roomId: number): void;
createRoomInstance(roomId: number, roomMap: IRoomMapData): void;
setRoomSessionOwnUser(roomId: number, objectId: number): void;

View File

@ -24,6 +24,7 @@ export interface IRoomEngine
updateRoomInstancePlaneVisibility(roomId: number, wallVisible: boolean, floorVisible?: boolean): boolean;
updateRoomInstancePlaneThickness(roomId: number, wallThickness: number, floorThickness: number): boolean;
updateRoomInstancePlaneType(roomId: number, floorType?: string, wallType?: string, landscapeType?: string, _arg_5?: boolean): boolean;
updateAreaHide(roomId: number, furniId: number, on: boolean, rootX: number, rootY: number, width: number, length: number, invert: boolean): boolean;
updateObjectRoomColor(k: number, _arg_2: number, _arg_3: number, _arg_4: boolean): boolean;
getRoomInstanceGeometry(roomId: number, canvasId?: number): IRoomGeometry;
getRoomInstanceVariable<T>(roomId: number, key: string): T;
@ -81,9 +82,12 @@ export interface IRoomEngine
saveTextureAsScreenshot(texture: RenderTexture, saveAsThumbnail?: boolean): Promise<void>;
saveBase64AsScreenshot(base64: string, saveAsThumbnail?: boolean): void;
deleteRoomObject(objectId: number, objectCategory: number): boolean;
roomManager: IRoomManager;
objectEventHandler: IRoomObjectEventManager;
activeRoomId: number;
selectedAvatarId: number;
isDecorating: boolean;
readonly roomManager: IRoomManager;
readonly objectEventHandler: IRoomObjectEventManager;
readonly activeRoomId: number;
readonly selectedAvatarId: number;
readonly isDecorating: boolean;
moveBlocked: boolean;
isAreaSelectionMode(): boolean;
whereYouClickIsWhereYouGo(): boolean;
}

View File

@ -2,7 +2,7 @@ import { IRoomInstance, IRoomObjectController, IRoomRenderingCanvas } from '../.
import { IVector3D } from '../../utils';
import { ISelectedRoomObjectData } from './ISelectedRoomObjectData';
import { IObjectData } from './object';
import { IFurnitureStackingHeightMap, ILegacyWallGeometry, ITileObjectMap } from './utils';
import { IFurnitureStackingHeightMap, ILegacyWallGeometry, IRoomAreaSelectionManager, ITileObjectMap } from './utils';
export interface IRoomEngineServices
{
@ -38,4 +38,8 @@ export interface IRoomEngineServices
isPlayingGame(): boolean;
activeRoomId: number;
isDecorating: boolean;
moveBlocked: boolean;
isAreaSelectionMode(): boolean;
whereYouClickIsWhereYouGo(): boolean;
areaSelectionManager: IRoomAreaSelectionManager;
}

View File

@ -62,6 +62,7 @@ export class RoomObjectLogicType
public static FURNITURE_EDITABLE_INTERNAL_LINK = 'furniture_editable_internal_link';
public static FURNITURE_EDITABLE_ROOM_LINK = 'furniture_editable_room_link';
public static FURNITURE_CRAFTING_GIZMO = 'furniture_crafting_gizmo';
public static FURNITURE_AREA_HIDE = 'furniture_area_hide';
public static ROOM = 'room';
public static USER = 'user';
public static BOT = 'bot';
@ -71,4 +72,4 @@ export class RoomObjectLogicType
public static SELECTION_ARROW = 'selection_arrow';
public static GAME_SNOWBALL = 'game_snowball';
public static GAME_SNOWSPLASH = 'game_snowsplash';
}
}

View File

@ -85,6 +85,13 @@ export class RoomObjectVariable
public static FURNITURE_ROOM_BACKGROUND_COLOR_HUE: string = 'furniture_room_background_color_hue';
public static FURNITURE_ROOM_BACKGROUND_COLOR_SATURATION: string = 'furniture_room_background_color_saturation';
public static FURNITURE_ROOM_BACKGROUND_COLOR_LIGHTNESS: string = 'furniture_room_background_color_lightness';
public static FURNITURE_AREA_HIDE_ROOT_X: string = 'furniture_area_hide_root_x';
public static FURNITURE_AREA_HIDE_ROOT_Y: string = 'furniture_area_hide_root_y';
public static FURNITURE_AREA_HIDE_WIDTH: string = 'furniture_area_hide_width';
public static FURNITURE_AREA_HIDE_LENGTH: string = 'furniture_area_hide_length';
public static FURNITURE_AREA_HIDE_INVISIBILITY: string = 'furniture_area_hide_invisibility';
public static FURNITURE_AREA_HIDE_WALL_ITEMS: string = 'furniture_area_hide_wall_items';
public static FURNITURE_AREA_HIDE_INVERT: string = 'furniture_area_hide_invert';
public static FURNITURE_USES_PLANE_MASK: string = 'furniture_uses_plane_mask';
public static FURNITURE_PLANE_MASK_TYPE: string = 'furniture_plane_mask_type';
public static FURNITURE_IS_VARIABLE_HEIGHT: string = 'furniture_is_variable_height';

View File

@ -0,0 +1,12 @@
import { INitroEvent } from '../../../common';
export interface IRoomAreaSelectionManager
{
startSelecting(): void;
handleTileMouseEvent(event: INitroEvent): void;
finishSelecting(): boolean;
activate(callback: (rootX: number, rootY: number, width: number, height: number) => void, highlightType: string): boolean;
deactivate(): void;
setHighlight(rootX: number, rootY: number, width: number, height: number): void;
readonly areaSelectionState: number;
}

View File

@ -1,4 +1,5 @@
export * from './IFurnitureStackingHeightMap';
export * from './ILegacyWallGeometry';
export * from './IRoomAreaSelectionManager';
export * from './ITileObjectMap';
export * from './ObjectRolling';

View File

@ -29,4 +29,5 @@ export interface IRoomObjectSprite
alphaTolerance: number;
filters: Filter[];
updateCounter: number;
skipMouseHandling: boolean;
}

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,9 @@
export class IncomingHeader
{
// These packets do not belong to this revision, so these are custom packet ids
public static AREA_HIDE = 6001;
// Original packets
public static ACHIEVEMENT_LIST = 305;
public static AUTHENTICATED = 2491;
public static AUTHENTICATION = -1;

View File

@ -0,0 +1,16 @@
import { IMessageEvent } from '@nitrots/api';
import { MessageEvent } from '@nitrots/events';
import { AreaHideMessageParser } from '../../../parser';
export class AreaHideMessageEvent extends MessageEvent implements IMessageEvent
{
constructor(callBack: Function)
{
super(callBack, AreaHideMessageParser);
}
public getParser(): AreaHideMessageParser
{
return this.parser as AreaHideMessageParser;
}
}

View File

@ -1,6 +1,6 @@
export * from './AreaHideMessageEvent';
export * from './CustomUserNotificationMessageEvent';
export * from './DiceValueMessageEvent';
export * from './floor';
export * from './FurniRentOrBuyoutOfferMessageEvent';
export * from './FurnitureAliasesEvent';
export * from './FurnitureDataEvent';
@ -17,6 +17,7 @@ export * from './RentableSpaceStatusMessageEvent';
export * from './RequestSpamWallPostItMessageEvent';
export * from './RoomDimmerPresetsMessageEvent';
export * from './RoomMessageNotificationMessageEvent';
export * from './wall';
export * from './WelcomeGiftStatusEvent';
export * from './floor';
export * from './wall';
export * from './youtube';

View File

@ -1,5 +1,8 @@
export class OutgoingHeader
{
// These packets do not belong to this revision, so these are custom packet ids
public static CLICK_FURNI = 6002;
public static ACHIEVEMENT_LIST = 219;
public static AUTHENTICATION = -1;
public static BOT_CONFIGURATION = 1986;

View File

@ -0,0 +1,21 @@
import { IMessageComposer } from '@nitrots/api';
export class ClickFurniMessageComposer implements IMessageComposer<ConstructorParameters<typeof ClickFurniMessageComposer>>
{
private _data: ConstructorParameters<typeof ClickFurniMessageComposer>;
constructor(id: number, category: number)
{
this._data = [id, category];
}
public getMessageArray()
{
return this._data;
}
public dispose(): void
{
return;
}
}

View File

@ -1,6 +1,7 @@
export * from './BotPlaceComposer';
export * from './BotRemoveComposer';
export * from './BotSkillSaveComposer';
export * from './ClickFurniMessageComposer';
export * from './CompostPlantMessageComposer';
export * from './GetItemDataComposer';
export * from './HarvestPetMessageComposer';

View File

@ -0,0 +1,58 @@
import { IMessageDataWrapper } from '@nitrots/api';
export class AreaHideMessageData
{
private _furniId: number;
private _on: boolean;
private _rootX: number;
private _rootY: number;
private _width: number;
private _length: number;
private _invert: boolean;
constructor(wrapper: IMessageDataWrapper)
{
this._furniId = wrapper.readInt();
this._on = wrapper.readBoolean();
this._rootX = wrapper.readInt();
this._rootY = wrapper.readInt();
this._width = wrapper.readInt();
this._length = wrapper.readInt();
this._invert = wrapper.readBoolean();
}
public get furniId(): number
{
return this._furniId;
}
public get on(): boolean
{
return this._on;
}
public get rootX(): number
{
return this._rootX;
}
public get rootY(): number
{
return this._rootY;
}
public get width(): number
{
return this._width;
}
public get length(): number
{
return this._length;
}
public get invert(): boolean
{
return this._invert;
}
}

View File

@ -1,3 +1,4 @@
export * from './AreaHideMessageData';
export * from './FavoriteMembershipUpdateMessageParser';
export * from './ObjectData';
export * from './ObjectsDataUpdateParser';

View File

@ -0,0 +1,28 @@
import { IMessageDataWrapper, IMessageParser } from '@nitrots/api';
import { AreaHideMessageData } from '../engine';
export class AreaHideMessageParser implements IMessageParser
{
private _areaData: AreaHideMessageData;
public flush(): boolean
{
this._areaData = null;
return true;
}
public parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return false;
this._areaData = new AreaHideMessageData(wrapper);
return true;
}
public get areaData(): AreaHideMessageData
{
return this._areaData;
}
}

View File

@ -1,6 +1,6 @@
export * from './AreaHideMessageParser';
export * from './CustomUserNotificationMessageParser';
export * from './DiceValueMessageParser';
export * from './floor';
export * from './FurniRentOrBuyoutOfferMessageParser';
export * from './FurnitureAliasesParser';
export * from './FurnitureDataParser';
@ -18,6 +18,7 @@ export * from './RequestSpamWallPostItMessageParser';
export * from './RoomDimmerPresetsMessageData';
export * from './RoomDimmerPresetsMessageParser';
export * from './RoomMessageNotificationMessageParser';
export * from './wall';
export * from './WelcomeGiftStatusParser';
export * from './floor';
export * from './wall';
export * from './youtube';

View File

@ -0,0 +1,20 @@
import { RoomEngineTriggerWidgetEvent } from './RoomEngineTriggerWidgetEvent';
export class RoomEngineAreaHideStateEvent extends RoomEngineTriggerWidgetEvent
{
public static UPDATE_STATE_AREA_HIDE: string = 'REAHSE_UPDATE_STATE_AREA_HIDE';
private _isOn: boolean;
constructor(roomId: number, furniId: number, category: number, on: boolean)
{
super(RoomEngineAreaHideStateEvent.UPDATE_STATE_AREA_HIDE, roomId, furniId, category);
this._isOn = on;
}
public get isOn(): boolean
{
return this._isOn;
}
}

View File

@ -23,6 +23,7 @@ export class RoomEngineTriggerWidgetEvent extends RoomEngineObjectEvent
public static REQUEST_MONSTERPLANT_SEED_PLANT_CONFIRMATION_DIALOG: string = 'ROWRE_REQUEST_MONSTERPLANT_SEED_PLANT_CONFIRMATION_DIALOG';
public static REQUEST_PURCHASABLE_CLOTHING_CONFIRMATION_DIALOG: string = 'ROWRE_REQUEST_PURCHASABLE_CLOTHING_CONFIRMATION_DIALOG';
public static REQUEST_BACKGROUND_COLOR: string = 'RETWE_REQUEST_BACKGROUND_COLOR';
public static REQUEST_AREA_HIDE: string = 'RETWE_REQUEST_AREA_HIDE';
public static REQUEST_MYSTERYBOX_OPEN_DIALOG: string = 'RETWE_REQUEST_MYSTERYBOX_OPEN_DIALOG';
public static REQUEST_EFFECTBOX_OPEN_DIALOG: string = 'RETWE_REQUEST_EFFECTBOX_OPEN_DIALOG';
public static REQUEST_MYSTERYTROPHY_OPEN_DIALOG: string = 'RETWE_REQUEST_MYSTERYTROPHY_OPEN_DIALOG';

View File

@ -26,6 +26,7 @@ export class RoomObjectWidgetRequestEvent extends RoomObjectEvent
public static MONSTERPLANT_SEED_PLANT_CONFIRMATION_DIALOG: string = 'ROWRE_MONSTERPLANT_SEED_PLANT_CONFIRMATION_DIALOG';
public static PURCHASABLE_CLOTHING_CONFIRMATION_DIALOG: string = 'ROWRE_PURCHASABLE_CLOTHING_CONFIRMATION_DIALOG';
public static BACKGROUND_COLOR: string = 'ROWRE_BACKGROUND_COLOR';
public static AREA_HIDE: string = 'ROWRE_AREA_HIDE';
public static MYSTERYBOX_OPEN_DIALOG: string = 'ROWRE_MYSTERYBOX_OPEN_DIALOG';
public static EFFECTBOX_OPEN_DIALOG: string = 'ROWRE_EFFECTBOX_OPEN_DIALOG';
public static MYSTERYTROPHY_OPEN_DIALOG: string = 'ROWRE_MYSTERYTROPHY_OPEN_DIALOG';

View File

@ -1,6 +1,7 @@
export * from './RoomBackgroundColorEvent';
export * from './RoomContentLoadedEvent';
export * from './RoomDragEvent';
export * from './RoomEngineAreaHideStateEvent';
export * from './RoomEngineDimmerStateEvent';
export * from './RoomEngineEvent';
export * from './RoomEngineObjectEvent';

View File

@ -1,7 +1,7 @@
import { IFurnitureStackingHeightMap, IGetImageListener, IImageResult, ILegacyWallGeometry, IObjectData, IPetColorResult, IPetCustomPart, IRoomContentListener, IRoomContentLoader, IRoomCreator, IRoomEngine, IRoomEngineServices, IRoomGeometry, IRoomInstance, IRoomManager, IRoomManagerListener, IRoomObject, IRoomObjectController, IRoomRenderer, IRoomRenderingCanvas, IRoomSessionManager, ISelectedRoomObjectData, ISessionDataManager, ITileObjectMap, IUpdateReceiver, IVector3D, LegacyDataType, MouseEventType, ObjectDataFactory, PetFigureData, RoomControllerLevel, RoomObjectCategory, RoomObjectUserType, RoomObjectVariable, ToolbarIconEnum } from '@nitrots/api';
import { IFurnitureStackingHeightMap, IGetImageListener, IImageResult, ILegacyWallGeometry, IObjectData, IPetColorResult, IPetCustomPart, IRoomAreaSelectionManager, IRoomContentListener, IRoomContentLoader, IRoomCreator, IRoomEngine, IRoomEngineServices, IRoomGeometry, IRoomInstance, IRoomManager, IRoomManagerListener, IRoomObject, IRoomObjectController, IRoomRenderer, IRoomRenderingCanvas, IRoomSessionManager, ISelectedRoomObjectData, ISessionDataManager, ITileObjectMap, IUpdateReceiver, IVector3D, LegacyDataType, MouseEventType, ObjectDataFactory, PetFigureData, RoomControllerLevel, RoomObjectCategory, RoomObjectUserType, RoomObjectVariable, ToolbarIconEnum } from '@nitrots/api';
import { GetCommunication, RenderRoomMessageComposer, RenderRoomThumbnailMessageComposer } from '@nitrots/communication';
import { GetConfiguration } from '@nitrots/configuration';
import { BadgeImageReadyEvent, GetEventDispatcher, NitroToolbarAnimateIconEvent, RoomBackgroundColorEvent, RoomDragEvent, RoomEngineEvent, RoomEngineObjectEvent, RoomObjectEvent, RoomObjectFurnitureActionEvent, RoomObjectMouseEvent, RoomSessionEvent, RoomToObjectOwnAvatarMoveEvent } from '@nitrots/events';
import { BadgeImageReadyEvent, GetEventDispatcher, NitroToolbarAnimateIconEvent, RoomBackgroundColorEvent, RoomDragEvent, RoomEngineAreaHideStateEvent, RoomEngineEvent, RoomEngineObjectEvent, RoomObjectEvent, RoomObjectFurnitureActionEvent, RoomObjectMouseEvent, RoomSessionEvent, RoomToObjectOwnAvatarMoveEvent } from '@nitrots/events';
import { GetRoomSessionManager, GetSessionDataManager } from '@nitrots/session';
import { FurniId, GetTickerTime, NitroLogger, NumberBank, TextureUtils, Vector3d } from '@nitrots/utils';
import { Container, Matrix, Point, Rectangle, RenderTexture, Sprite, Texture, Ticker } from 'pixi.js';
@ -17,6 +17,7 @@ import { ObjectAvatarCarryObjectUpdateMessage, ObjectAvatarChatUpdateMessage, Ob
import { RoomLogic, RoomMapData } from './object';
import { RoomRenderer } from './renderer';
import { RoomCamera, RoomData, RoomEnterEffect, RoomFurnitureData, RoomGeometry, RoomInstanceData, RoomObjectBadgeImageAssetListener } from './utils';
import { RoomAreaSelectionManager } from './utils/RoomAreaSelectionManager';
export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineServices, IRoomManagerListener, IRoomContentListener, IUpdateReceiver
{
@ -55,6 +56,7 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService
private _activeRoomDragStartY: number = 0;
private _activeRoomDragX: number = 0;
private _activeRoomDragY: number = 0;
private _moveBlocked: boolean = false;
private _roomDraggingAlwaysCenters: boolean = false;
private _roomAllowsDragging: boolean = true;
private _roomDatas: Map<number, RoomData> = new Map();
@ -62,6 +64,7 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService
private _skipFurnitureCreationForNextFrame: boolean = false;
private _mouseCursorUpdate: boolean = false;
private _badgeListenerObjects: Map<string, RoomObjectBadgeImageAssetListener[]> = new Map();
private _areaSelectionManager: IRoomAreaSelectionManager = new RoomAreaSelectionManager(this);
public async init(): Promise<void>
{
@ -543,6 +546,24 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService
return true;
}
public updateAreaHide(roomId: number, furniId: number, on: boolean, rootX: number, rootY: number, width: number, length: number, invert: boolean): boolean
{
const roomObject = this.getRoomOwnObject(roomId);
if(!roomObject || !roomObject.logic) return false;
GetEventDispatcher().dispatchEvent(new RoomEngineAreaHideStateEvent(roomId, furniId, RoomObjectCategory.FLOOR, on));
if(on)
{
roomObject.logic.processUpdateMessage(new ObjectRoomFloorHoleUpdateMessage(ObjectRoomFloorHoleUpdateMessage.ADD, furniId, rootX, rootY, width, length, invert));
}
else
{
roomObject.logic.processUpdateMessage(new ObjectRoomFloorHoleUpdateMessage(ObjectRoomFloorHoleUpdateMessage.REMOVE, furniId));
}
}
public updateObjectRoomColor(roomId: number, color: number, light: number, backgroundOnly: boolean): boolean
{
const roomObject = this.getRoomOwnObject(roomId);
@ -680,7 +701,7 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService
while((pendingData = instanceData.getNextPendingFurnitureFloor()))
{
furnitureAdded = this.processPendingFurnitureFloor(instanceData.roomId, pendingData.id, pendingData);
furnitureAdded = this.addObjectFurnitureFromData(instanceData.roomId, pendingData.id, pendingData);
if(hasTickLimit)
{
@ -700,7 +721,7 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService
while(!this._skipFurnitureCreationForNextFrame && (pendingData = instanceData.getNextPendingFurnitureWall()))
{
furnitureAdded = this.processPendingFurnitureWall(instanceData.roomId, pendingData.id, pendingData);
furnitureAdded = this.addObjectWallItemFromData(instanceData.roomId, pendingData.id, pendingData);
if(hasTickLimit)
{
@ -729,7 +750,7 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService
}
}
private processPendingFurnitureFloor(roomId: number, id: number, data: RoomFurnitureData): boolean
private addObjectFurnitureFromData(roomId: number, id: number, data: RoomFurnitureData): boolean
{
if(!data)
{
@ -790,7 +811,7 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService
return true;
}
private processPendingFurnitureWall(roomId: number, id: number, data: RoomFurnitureData): boolean
private addObjectWallItemFromData(roomId: number, id: number, data: RoomFurnitureData): boolean
{
if(!data)
{
@ -1435,12 +1456,12 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService
switch(category)
{
case RoomObjectCategory.FLOOR:
this.processPendingFurnitureFloor(this.getRoomIdFromString(roomId), objectId, null);
this.addObjectFurnitureFromData(this.getRoomIdFromString(roomId), objectId, null);
roomObject = (roomInstance.getRoomObject(objectId, category) as IRoomObjectController);
break;
case RoomObjectCategory.WALL:
this.processPendingFurnitureWall(this.getRoomIdFromString(roomId), objectId, null);
this.addObjectWallItemFromData(this.getRoomIdFromString(roomId), objectId, null);
roomObject = (roomInstance.getRoomObject(objectId, category) as IRoomObjectController);
break;
@ -2168,33 +2189,37 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService
sprite.y = (y - (rectangle.height / 2));
}
if(!this.handleRoomDragging(canvas, x, y, type, altKey, ctrlKey, shiftKey))
if(type === MouseEventType.MOUSE_CLICK && this._areaSelectionManager.finishSelecting())
{
if(!canvas.handleMouseEvent(x, y, type, altKey, ctrlKey, shiftKey, buttonDown))
this._areaSelectionManager.finishSelecting();
}
else
{
if(!this.handleRoomDragging(canvas, x, y, type, altKey, ctrlKey, shiftKey))
{
let eventType: string = null;
if(type === MouseEventType.MOUSE_CLICK)
if(!canvas.handleMouseEvent(x, y, type, altKey, ctrlKey, shiftKey, buttonDown))
{
if(GetEventDispatcher())
let eventType: string = null;
if(type === MouseEventType.MOUSE_CLICK)
{
GetEventDispatcher().dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.DESELECTED, this._activeRoomId, -1, RoomObjectCategory.MINIMUM));
eventType = RoomObjectMouseEvent.CLICK;
}
else
{
if(type === MouseEventType.MOUSE_MOVE) eventType = RoomObjectMouseEvent.MOUSE_MOVE;
else if(type === MouseEventType.MOUSE_DOWN) eventType = RoomObjectMouseEvent.MOUSE_DOWN;
else if(type === MouseEventType.MOUSE_DOWN_LONG) eventType = RoomObjectMouseEvent.MOUSE_DOWN_LONG;
else if(type === MouseEventType.MOUSE_UP) eventType = RoomObjectMouseEvent.MOUSE_UP;
}
eventType = RoomObjectMouseEvent.CLICK;
this._roomObjectEventHandler.handleRoomObjectEvent(new RoomObjectMouseEvent(eventType, this.getRoomObject(this._activeRoomId, RoomEngine.ROOM_OBJECT_ID, RoomObjectCategory.ROOM), null, altKey), this._activeRoomId);
}
else
{
if(type === MouseEventType.MOUSE_MOVE) eventType = RoomObjectMouseEvent.MOUSE_MOVE;
else if(type === MouseEventType.MOUSE_DOWN) eventType = RoomObjectMouseEvent.MOUSE_DOWN;
else if(type === MouseEventType.MOUSE_DOWN_LONG) eventType = RoomObjectMouseEvent.MOUSE_DOWN_LONG;
else if(type === MouseEventType.MOUSE_UP) eventType = RoomObjectMouseEvent.MOUSE_UP;
}
this._roomObjectEventHandler.handleRoomObjectEvent(new RoomObjectMouseEvent(eventType, this.getRoomObject(this._activeRoomId, RoomEngine.ROOM_OBJECT_ID, RoomObjectCategory.ROOM), null, altKey), this._activeRoomId);
}
}
@ -2205,6 +2230,16 @@ 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;
this._activeRoomWasDragged = false;
return false;
};
let offsetX = (x - this._activeRoomActiveCanvasMouseX);
let offsetY = (y - this._activeRoomActiveCanvasMouseY);
@ -3223,6 +3258,11 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService
this._roomManager = manager;
}
public get areaSelectionManager(): IRoomAreaSelectionManager
{
return this._areaSelectionManager;
}
public get objectEventHandler(): RoomObjectEventHandler
{
return this._roomObjectEventHandler;
@ -3258,4 +3298,24 @@ export class RoomEngine implements IRoomEngine, IRoomCreator, IRoomEngineService
return this._roomManager.getRoomInstance(roomId.toString()).getRoomObjectsForCategory(categoryId).length;
}
public get moveBlocked(): boolean
{
return this._moveBlocked;
}
public set moveBlocked(flag: boolean)
{
this._moveBlocked = flag;
}
public isAreaSelectionMode(): boolean
{
return this._areaSelectionManager.areaSelectionState !== RoomAreaSelectionManager.NOT_ACTIVE;
}
public whereYouClickIsWhereYouGo(): boolean
{
return !this.isAreaSelectionMode();
}
}

View File

@ -1,5 +1,5 @@
import { AvatarGuideStatus, IConnection, IRoomCreator, IVector3D, LegacyDataType, ObjectRolling, PetType, RoomObjectType, RoomObjectUserType, RoomObjectVariable } from '@nitrots/api';
import { DiceValueMessageEvent, FloorHeightMapEvent, FurnitureAliasesComposer, FurnitureAliasesEvent, FurnitureDataEvent, FurnitureFloorAddEvent, FurnitureFloorDataParser, FurnitureFloorEvent, FurnitureFloorRemoveEvent, FurnitureFloorUpdateEvent, FurnitureWallAddEvent, FurnitureWallDataParser, FurnitureWallEvent, FurnitureWallRemoveEvent, FurnitureWallUpdateEvent, GetCommunication, GetRoomEntryDataMessageComposer, GuideSessionEndedMessageEvent, GuideSessionErrorMessageEvent, GuideSessionStartedMessageEvent, IgnoreResultEvent, ItemDataUpdateMessageEvent, ObjectsDataUpdateEvent, ObjectsRollingEvent, OneWayDoorStatusMessageEvent, PetExperienceEvent, PetFigureUpdateEvent, RoomEntryTileMessageEvent, RoomEntryTileMessageParser, RoomHeightMapEvent, RoomHeightMapUpdateEvent, RoomPaintEvent, RoomReadyMessageEvent, RoomUnitChatEvent, RoomUnitChatShoutEvent, RoomUnitChatWhisperEvent, RoomUnitDanceEvent, RoomUnitEffectEvent, RoomUnitEvent, RoomUnitExpressionEvent, RoomUnitHandItemEvent, RoomUnitIdleEvent, RoomUnitInfoEvent, RoomUnitNumberEvent, RoomUnitRemoveEvent, RoomUnitStatusEvent, RoomUnitTypingEvent, RoomVisualizationSettingsEvent, UserInfoEvent, YouArePlayingGameEvent } from '@nitrots/communication';
import { AreaHideMessageEvent, DiceValueMessageEvent, FloorHeightMapEvent, FurnitureAliasesComposer, FurnitureAliasesEvent, FurnitureDataEvent, FurnitureFloorAddEvent, FurnitureFloorDataParser, FurnitureFloorEvent, FurnitureFloorRemoveEvent, FurnitureFloorUpdateEvent, FurnitureWallAddEvent, FurnitureWallDataParser, FurnitureWallEvent, FurnitureWallRemoveEvent, FurnitureWallUpdateEvent, GetCommunication, GetRoomEntryDataMessageComposer, GuideSessionEndedMessageEvent, GuideSessionErrorMessageEvent, GuideSessionStartedMessageEvent, IgnoreResultEvent, ItemDataUpdateMessageEvent, ObjectsDataUpdateEvent, ObjectsRollingEvent, OneWayDoorStatusMessageEvent, PetExperienceEvent, PetFigureUpdateEvent, RoomEntryTileMessageEvent, RoomEntryTileMessageParser, RoomHeightMapEvent, RoomHeightMapUpdateEvent, RoomPaintEvent, RoomReadyMessageEvent, RoomUnitChatEvent, RoomUnitChatShoutEvent, RoomUnitChatWhisperEvent, RoomUnitDanceEvent, RoomUnitEffectEvent, RoomUnitEvent, RoomUnitExpressionEvent, RoomUnitHandItemEvent, RoomUnitIdleEvent, RoomUnitInfoEvent, RoomUnitNumberEvent, RoomUnitRemoveEvent, RoomUnitStatusEvent, RoomUnitTypingEvent, RoomVisualizationSettingsEvent, UserInfoEvent, YouArePlayingGameEvent } from '@nitrots/communication';
import { GetRoomSessionManager, GetSessionDataManager } from '@nitrots/session';
import { Vector3d } from '@nitrots/utils';
import { GetRoomEngine } from './GetRoomEngine';
@ -47,6 +47,7 @@ export class RoomMessageHandler
this._connection.addMessageEvent(new FurnitureDataEvent(this.onFurnitureDataEvent.bind(this)));
this._connection.addMessageEvent(new ItemDataUpdateMessageEvent(this.onItemDataUpdateMessageEvent.bind(this)));
this._connection.addMessageEvent(new OneWayDoorStatusMessageEvent(this.onOneWayDoorStatusMessageEvent.bind(this)));
this._connection.addMessageEvent(new AreaHideMessageEvent(this.onAreaHideMessageEvent.bind(this)));
this._connection.addMessageEvent(new RoomUnitDanceEvent(this.onRoomUnitDanceEvent.bind(this)));
this._connection.addMessageEvent(new RoomUnitEffectEvent(this.onRoomUnitEffectEvent.bind(this)));
this._connection.addMessageEvent(new RoomUnitEvent(this.onRoomUnitEvent.bind(this)));
@ -555,6 +556,16 @@ export class RoomMessageHandler
this._roomEngine.updateRoomObjectFloor(this._currentRoomId, parser.itemId, null, null, parser.state, new LegacyDataType());
}
private onAreaHideMessageEvent(event: AreaHideMessageEvent): void
{
if(!(event instanceof AreaHideMessageEvent) || !event.connection || !this._roomEngine) return;
const parser = event.getParser();
const areaData = parser.areaData;
this._roomEngine.updateAreaHide(this._currentRoomId, areaData.furniId, areaData.on, areaData.rootX, areaData.rootY, areaData.width, areaData.length, areaData.invert);
}
private onDiceValueMessageEvent(event: DiceValueMessageEvent): void
{
if(!(event instanceof DiceValueMessageEvent) || !event.connection || !this._roomEngine) return;

View File

@ -1,5 +1,5 @@
import { IFurnitureStackingHeightMap, ILegacyWallGeometry, IObjectData, IRoomCanvasMouseListener, IRoomEngineServices, IRoomGeometry, IRoomObject, IRoomObjectController, IRoomObjectEventManager, ISelectedRoomObjectData, IVector3D, MouseEventType, RoomObjectCategory, RoomObjectOperationType, RoomObjectPlacementSource, RoomObjectType, RoomObjectUserType, RoomObjectVariable } from '@nitrots/api';
import { BotPlaceComposer, FurnitureColorWheelComposer, FurnitureDiceActivateComposer, FurnitureDiceDeactivateComposer, FurnitureFloorUpdateComposer, FurnitureGroupInfoComposer, FurnitureMultiStateComposer, FurnitureOneWayDoorComposer, FurniturePickupComposer, FurniturePlaceComposer, FurniturePostItPlaceComposer, FurnitureRandomStateComposer, FurnitureWallMultiStateComposer, FurnitureWallUpdateComposer, GetCommunication, GetItemDataComposer, GetResolutionAchievementsMessageComposer, PetMoveComposer, PetPlaceComposer, RemoveWallItemComposer, RoomUnitLookComposer, RoomUnitWalkComposer, SetItemDataMessageComposer, SetObjectDataMessageComposer } from '@nitrots/communication';
import { BotPlaceComposer, ClickFurniMessageComposer, FurnitureColorWheelComposer, FurnitureDiceActivateComposer, FurnitureDiceDeactivateComposer, FurnitureFloorUpdateComposer, FurnitureGroupInfoComposer, FurnitureMultiStateComposer, FurnitureOneWayDoorComposer, FurniturePickupComposer, FurniturePlaceComposer, FurniturePostItPlaceComposer, FurnitureRandomStateComposer, FurnitureWallMultiStateComposer, FurnitureWallUpdateComposer, GetCommunication, GetItemDataComposer, GetResolutionAchievementsMessageComposer, PetMoveComposer, PetPlaceComposer, RemoveWallItemComposer, RoomUnitLookComposer, RoomUnitWalkComposer, SetItemDataMessageComposer, SetObjectDataMessageComposer } from '@nitrots/communication';
import { GetConfiguration } from '@nitrots/configuration';
import { GetEventDispatcher, RoomEngineDimmerStateEvent, RoomEngineObjectEvent, RoomEngineObjectPlacedEvent, RoomEngineObjectPlacedOnUserEvent, RoomEngineObjectPlaySoundEvent, RoomEngineRoomAdEvent, RoomEngineSamplePlaybackEvent, RoomEngineTriggerWidgetEvent, RoomEngineUseProductEvent, RoomObjectBadgeAssetEvent, RoomObjectDataRequestEvent, RoomObjectDimmerStateUpdateEvent, RoomObjectEvent, RoomObjectFloorHoleEvent, RoomObjectFurnitureActionEvent, RoomObjectHSLColorEnableEvent, RoomObjectHSLColorEnabledEvent, RoomObjectMouseEvent, RoomObjectMoveEvent, RoomObjectPlaySoundIdEvent, RoomObjectRoomAdEvent, RoomObjectSamplePlaybackEvent, RoomObjectSoundMachineEvent, RoomObjectStateChangedEvent, RoomObjectTileMouseEvent, RoomObjectWallMouseEvent, RoomObjectWidgetRequestEvent, RoomSpriteMouseEvent } from '@nitrots/events';
import { GetRoomSessionManager, GetSessionDataManager } from '@nitrots/session';
@ -185,6 +185,7 @@ export class RoomObjectEventHandler implements IRoomCanvasMouseListener, IRoomOb
case RoomObjectWidgetRequestEvent.MONSTERPLANT_SEED_PLANT_CONFIRMATION_DIALOG:
case RoomObjectWidgetRequestEvent.PURCHASABLE_CLOTHING_CONFIRMATION_DIALOG:
case RoomObjectWidgetRequestEvent.BACKGROUND_COLOR:
case RoomObjectWidgetRequestEvent.AREA_HIDE:
case RoomObjectWidgetRequestEvent.MYSTERYBOX_OPEN_DIALOG:
case RoomObjectWidgetRequestEvent.EFFECTBOX_OPEN_DIALOG:
case RoomObjectWidgetRequestEvent.MYSTERYTROPHY_OPEN_DIALOG:
@ -265,6 +266,11 @@ export class RoomObjectEventHandler implements IRoomCanvasMouseListener, IRoomOb
{
if(!event || !event.type) return;
if(event instanceof RoomObjectTileMouseEvent)
{
this._roomEngine.areaSelectionManager.handleTileMouseEvent(event);
}
switch(event.type)
{
case RoomObjectMouseEvent.CLICK:
@ -291,10 +297,36 @@ export class RoomObjectEventHandler implements IRoomCanvasMouseListener, IRoomOb
}
}
private clickRoomObject(event: RoomObjectMouseEvent): void
{
if(!event || event.altKey || event.ctrlKey || event.shiftKey) return;
const objectId = event.objectId;
const objectType = event.objectType;
const category = this._roomEngine.getRoomObjectCategoryForType(objectType);
if(category === RoomObjectCategory.FLOOR)
{
GetCommunication().connection.send(new ClickFurniMessageComposer(objectId, category));
return;
}
if(category === RoomObjectCategory.WALL)
{
// This packet only sends a negative number to tell the server that its a wall item
GetCommunication().connection.send(new ClickFurniMessageComposer(-Math.abs(objectId), category));
return;
}
}
private handleRoomObjectMouseClickEvent(event: RoomObjectMouseEvent, roomId: number): void
{
if(!event) return;
this.clickRoomObject(event);
let operation = RoomObjectOperationType.OBJECT_UNDEFINED;
const selectedData = this.getSelectedRoomObjectData(roomId);
@ -304,7 +336,7 @@ export class RoomObjectEventHandler implements IRoomCanvasMouseListener, IRoomOb
let didWalk = false;
let didMove = false;
if(this._whereYouClickIsWhereYouGo)
if(this.whereYouClickIsWhereYouGo())
{
if(!operation || (operation === RoomObjectOperationType.OBJECT_UNDEFINED))
{
@ -370,11 +402,20 @@ export class RoomObjectEventHandler implements IRoomCanvasMouseListener, IRoomOb
case RoomObjectOperationType.OBJECT_UNDEFINED:
if(category === RoomObjectCategory.ROOM)
{
if(!didWalk && (event instanceof RoomObjectTileMouseEvent)) this.onRoomObjectTileMouseEvent(roomId, event);
if(!didWalk && (event instanceof RoomObjectTileMouseEvent)) this.handleClickOnTile(roomId, event);
}
else
{
this.setSelectedObject(roomId, event.objectId, category);
if(!this._roomEngine.isAreaSelectionMode() || (category === RoomObjectCategory.UNIT))
{
this.setSelectedObject(roomId, event.objectId, category);
}
else
{
this.deselectObject(roomId);
GetEventDispatcher().dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.DESELECTED, roomId, -1, RoomObjectCategory.MINIMUM));
}
didMove = false;
@ -507,7 +548,7 @@ export class RoomObjectEventHandler implements IRoomCanvasMouseListener, IRoomOb
else if(event.object && (event.object.id !== -1))
{
if(this._whereYouClickIsWhereYouGo)
if(this.whereYouClickIsWhereYouGo())
{
newEvent = this.handleMouseOverObject(category, roomId, event);
}
@ -758,6 +799,9 @@ export class RoomObjectEventHandler implements IRoomCanvasMouseListener, IRoomOb
case RoomObjectWidgetRequestEvent.BACKGROUND_COLOR:
GetEventDispatcher().dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_BACKGROUND_COLOR, roomId, objectId, objectCategory));
return;
case RoomObjectWidgetRequestEvent.AREA_HIDE:
GetEventDispatcher().dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_AREA_HIDE, roomId, objectId, objectCategory));
return;
case RoomObjectWidgetRequestEvent.MYSTERYBOX_OPEN_DIALOG:
GetEventDispatcher().dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_MYSTERYBOX_OPEN_DIALOG, roomId, objectId, objectCategory));
return;
@ -1017,13 +1061,15 @@ export class RoomObjectEventHandler implements IRoomCanvasMouseListener, IRoomOb
}
}
private onRoomObjectTileMouseEvent(roomId: number, event: RoomObjectTileMouseEvent): void
private handleClickOnTile(roomId: number, event: RoomObjectTileMouseEvent): void
{
if(!this._roomEngine || this._roomEngine.isDecorating) return;
const session = GetRoomSessionManager().getSession(roomId);
if(!session || session.isSpectator) return;
this.sendWalkUpdate(event.tileXAsInt, event.tileYAsInt);
if(!this._roomEngine.moveBlocked) this.sendWalkUpdate(event.tileXAsInt, event.tileYAsInt);
}
private handleObjectMove(event: RoomObjectMouseEvent, roomId: number): void
@ -1480,14 +1526,12 @@ export class RoomObjectEventHandler implements IRoomCanvasMouseListener, IRoomOb
private handleMoveTargetFurni(k: number, _arg_2: RoomObjectMouseEvent): boolean
{
if((_arg_2.objectType === RoomObjectUserType.USER) || (_arg_2.objectType === RoomObjectUserType.PET) || (_arg_2.objectType === RoomObjectUserType.BOT) || (_arg_2.objectType === RoomObjectUserType.RENTABLE_BOT) || (_arg_2.objectType === RoomObjectUserType.MONSTER_PLANT)) return;
const roomObject = this._roomEngine.getRoomObject(k, _arg_2.objectId, RoomObjectCategory.FLOOR);
const point = this.getActiveSurfaceLocation(roomObject, _arg_2);
const _local_3 = this._roomEngine.getRoomObject(k, _arg_2.objectId, RoomObjectCategory.FLOOR);
const _local_4 = this.getActiveSurfaceLocation(_local_3, _arg_2);
if(_local_4)
if(point && !this._roomEngine.moveBlocked)
{
this.sendWalkUpdate(_local_4.x, _local_4.y);
this.sendWalkUpdate(point.x, point.y);
return true;
}
@ -1548,7 +1592,7 @@ export class RoomObjectEventHandler implements IRoomCanvasMouseListener, IRoomOb
private handleMouseOverTile(k: RoomObjectTileMouseEvent, roomId: number): ObjectTileCursorUpdateMessage
{
if(this._whereYouClickIsWhereYouGo)
if(this.whereYouClickIsWhereYouGo())
{
return new ObjectTileCursorUpdateMessage(new Vector3d(k.tileXAsInt, k.tileYAsInt, k.tileZAsInt), 0, true, k.eventId);
}
@ -2187,4 +2231,9 @@ export class RoomObjectEventHandler implements IRoomCanvasMouseListener, IRoomOb
{
return this._selectedAvatarId;
}
public whereYouClickIsWhereYouGo(): boolean
{
return this._roomEngine.whereYouClickIsWhereYouGo();
}
}

View File

@ -2,7 +2,7 @@ import { IEventDispatcher, IRoomObjectEventHandler, IRoomObjectLogicFactory, Roo
import { GetEventDispatcher, RoomObjectEvent } from '@nitrots/events';
import { NitroLogger } from '@nitrots/utils';
import { RoomObjectLogicBase } from '../../room';
import { AvatarLogic, FurnitureAchievementResolutionLogic, FurnitureBadgeDisplayLogic, FurnitureChangeStateWhenStepOnLogic, FurnitureClothingChangeLogic, FurnitureCounterClockLogic, FurnitureCrackableLogic, FurnitureCraftingGizmoLogic, FurnitureCreditLogic, FurnitureCuckooClockLogic, FurnitureCustomStackHeightLogic, FurnitureDiceLogic, FurnitureEcotronBoxLogic, FurnitureEditableInternalLinkLogic, FurnitureEditableRoomLinkLogic, FurnitureEffectBoxLogic, FurnitureExternalImageLogic, FurnitureFireworksLogic, FurnitureFloorHoleLogic, FurnitureGroupForumTerminalLogic, FurnitureGuildCustomizedLogic, FurnitureHabboWheelLogic, FurnitureHighScoreLogic, FurnitureHockeyScoreLogic, FurnitureHweenLovelockLogic, FurnitureIceStormLogic, FurnitureInternalLinkLogic, FurnitureJukeboxLogic, FurnitureLogic, FurnitureLoveLockLogic, FurnitureMannequinLogic, FurnitureMonsterplantSeedLogic, FurnitureMultiHeightLogic, FurnitureMultiStateLogic, FurnitureMysteryBoxLogic, FurnitureMysteryTrophyLogic, FurnitureOneWayDoorLogic, FurniturePetCustomizationLogic, FurniturePlaceholderLogic, FurniturePlanetSystemLogic, FurniturePresentLogic, FurniturePurchaseableClothingLogic, FurniturePushableLogic, FurnitureRandomStateLogic, FurnitureRandomTeleportLogic, FurnitureRentableSpaceLogic, FurnitureRoomBackgroundColorLogic, FurnitureRoomBackgroundLogic, FurnitureRoomBillboardLogic, FurnitureRoomDimmerLogic, FurnitureScoreLogic, FurnitureSongDiskLogic, FurnitureSoundBlockLogic, FurnitureSoundMachineLogic, FurnitureStickieLogic, FurnitureTrophyLogic, FurnitureVoteCounterLogic, FurnitureVoteMajorityLogic, FurnitureWelcomeGiftLogic, FurnitureWindowLogic, FurnitureYoutubeLogic, PetLogic, RoomLogic, SelectionArrowLogic, TileCursorLogic } from './object';
import { AvatarLogic, FurnitureAchievementResolutionLogic, FurnitureAreaHideLogic, FurnitureBadgeDisplayLogic, FurnitureChangeStateWhenStepOnLogic, FurnitureClothingChangeLogic, FurnitureCounterClockLogic, FurnitureCrackableLogic, FurnitureCraftingGizmoLogic, FurnitureCreditLogic, FurnitureCuckooClockLogic, FurnitureCustomStackHeightLogic, FurnitureDiceLogic, FurnitureEcotronBoxLogic, FurnitureEditableInternalLinkLogic, FurnitureEditableRoomLinkLogic, FurnitureEffectBoxLogic, FurnitureExternalImageLogic, FurnitureFireworksLogic, FurnitureFloorHoleLogic, FurnitureGroupForumTerminalLogic, FurnitureGuildCustomizedLogic, FurnitureHabboWheelLogic, FurnitureHighScoreLogic, FurnitureHockeyScoreLogic, FurnitureHweenLovelockLogic, FurnitureIceStormLogic, FurnitureInternalLinkLogic, FurnitureJukeboxLogic, FurnitureLogic, FurnitureLoveLockLogic, FurnitureMannequinLogic, FurnitureMonsterplantSeedLogic, FurnitureMultiHeightLogic, FurnitureMultiStateLogic, FurnitureMysteryBoxLogic, FurnitureMysteryTrophyLogic, FurnitureOneWayDoorLogic, FurniturePetCustomizationLogic, FurniturePlaceholderLogic, FurniturePlanetSystemLogic, FurniturePresentLogic, FurniturePurchaseableClothingLogic, FurniturePushableLogic, FurnitureRandomStateLogic, FurnitureRandomTeleportLogic, FurnitureRentableSpaceLogic, FurnitureRoomBackgroundColorLogic, FurnitureRoomBackgroundLogic, FurnitureRoomBillboardLogic, FurnitureRoomDimmerLogic, FurnitureScoreLogic, FurnitureSongDiskLogic, FurnitureSoundBlockLogic, FurnitureSoundMachineLogic, FurnitureStickieLogic, FurnitureTrophyLogic, FurnitureVoteCounterLogic, FurnitureVoteMajorityLogic, FurnitureWelcomeGiftLogic, FurnitureWindowLogic, FurnitureYoutubeLogic, PetLogic, RoomLogic, SelectionArrowLogic, TileCursorLogic } from './object';
export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
{
@ -293,6 +293,9 @@ export class RoomObjectLogicFactory implements IRoomObjectLogicFactory
case RoomObjectLogicType.FURNITURE_HABBOWHEEL:
logic = FurnitureHabboWheelLogic;
break;
case RoomObjectLogicType.FURNITURE_AREA_HIDE:
logic = FurnitureAreaHideLogic;
break;
default:
logic = FurnitureLogic;
break;

View File

@ -11,8 +11,9 @@ export class ObjectRoomFloorHoleUpdateMessage extends RoomObjectUpdateMessage
private _y: number;
private _width: number;
private _height: number;
private _invert: boolean;
constructor(type: string, id: number, x: number = 0, y: number = 0, width: number = 0, height: number = 0)
constructor(type: string, id: number, x: number = 0, y: number = 0, width: number = 0, height: number = 0, invert: boolean = false)
{
super(null, null);
@ -22,6 +23,7 @@ export class ObjectRoomFloorHoleUpdateMessage extends RoomObjectUpdateMessage
this._y = y;
this._width = width;
this._height = height;
this._invert = invert;
}
public get type(): string
@ -53,4 +55,9 @@ export class ObjectRoomFloorHoleUpdateMessage extends RoomObjectUpdateMessage
{
return this._height;
}
public get invert(): boolean
{
return this._invert;
}
}

View File

@ -7,7 +7,7 @@ export class RoomMapData implements IRoomMapData
private _wallHeight: number;
private _fixedWallsHeight: number;
private _tileMap: { height: number }[][];
private _holeMap: { id: number, x: number, y: number, width: number, height: number }[];
private _holeMap: { id: number, x: number, y: number, width: number, height: number, invert: boolean }[];
private _doors: { x: number, y: number, z: number, dir: number }[];
private _dimensions: { minX: number, maxX: number, minY: number, maxY: number };
@ -73,7 +73,7 @@ export class RoomMapData implements IRoomMapData
return this._tileMap;
}
public get holeMap(): { id: number, x: number, y: number, width: number, height: number }[]
public get holeMap(): { id: number, x: number, y: number, width: number, height: number, invert: boolean }[]
{
return this._holeMap;
}

File diff suppressed because it is too large Load Diff

View File

@ -413,12 +413,14 @@ export class RoomLogic extends RoomObjectLogicBase
let eventType: string = null;
if((event.type === MouseEventType.MOUSE_MOVE) || (event.type === MouseEventType.ROLL_OVER)) eventType = RoomObjectMouseEvent.MOUSE_MOVE;
else if((event.type === MouseEventType.MOUSE_CLICK)) eventType = RoomObjectMouseEvent.CLICK;
else if(event.type === MouseEventType.MOUSE_CLICK) eventType = RoomObjectMouseEvent.CLICK;
else if(event.type === MouseEventType.MOUSE_DOWN) eventType = RoomObjectMouseEvent.MOUSE_DOWN;
switch(event.type)
{
case MouseEventType.MOUSE_MOVE:
case MouseEventType.ROLL_OVER:
case MouseEventType.MOUSE_DOWN:
case MouseEventType.MOUSE_CLICK: {
let newEvent: RoomObjectEvent = null;

View File

@ -0,0 +1,96 @@
import { IRoomGeometry, MouseEventType, NumberDataType, RoomObjectVariable } from '@nitrots/api';
import { RoomObjectEvent, RoomObjectStateChangedEvent, RoomObjectWidgetRequestEvent, RoomSpriteMouseEvent } from '@nitrots/events';
import { ObjectDataUpdateMessage, RoomObjectUpdateMessage } from '../../../messages';
import { FurnitureMultiStateLogic } from './FurnitureMultiStateLogic';
export class FurnitureAreaHideLogic extends FurnitureMultiStateLogic
{
public getEventTypes(): string[]
{
const types = [RoomObjectWidgetRequestEvent.AREA_HIDE];
return this.mergeTypes(super.getEventTypes(), types);
}
public processUpdateMessage(message: RoomObjectUpdateMessage): void
{
super.processUpdateMessage(message);
if(!this.object) return;
if(message instanceof ObjectDataUpdateMessage)
{
message.data.writeRoomObjectModel(this.object.model);
if(this.object.model.getValue<number>(RoomObjectVariable.FURNITURE_REAL_ROOM_OBJECT) === 1)
{
this.setupObject();
}
}
}
private setupObject(): void
{
if(!this.object || !this.object.model) return;
const numberData = new NumberDataType();
numberData.initializeFromRoomObjectModel(this.object.model);
const state = numberData.getValue(0);
const rootX = numberData.getValue(1);
const rootY = numberData.getValue(2);
const width = numberData.getValue(3);
const length = numberData.getValue(4);
const invisibility = (numberData.getValue(5) === 1);
const wallItems = (numberData.getValue(6) === 1);
const invert = (numberData.getValue(7) === 1);
this.object.model.setValue(RoomObjectVariable.FURNITURE_AREA_HIDE_ROOT_X, rootX);
this.object.model.setValue(RoomObjectVariable.FURNITURE_AREA_HIDE_ROOT_Y, rootY);
this.object.model.setValue(RoomObjectVariable.FURNITURE_AREA_HIDE_WIDTH, width);
this.object.model.setValue(RoomObjectVariable.FURNITURE_AREA_HIDE_LENGTH, length);
this.object.model.setValue(RoomObjectVariable.FURNITURE_AREA_HIDE_INVISIBILITY, ((invisibility) ? 1 : 0));
this.object.model.setValue(RoomObjectVariable.FURNITURE_AREA_HIDE_WALL_ITEMS, ((wallItems) ? 1 : 0));
this.object.model.setValue(RoomObjectVariable.FURNITURE_AREA_HIDE_INVERT, ((invert) ? 1 : 0));
this.object.setState(state, 0);
}
public useObject(): void
{
if(!this.object || !this.eventDispatcher) return;
this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.AREA_HIDE, this.object));
}
public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void
{
if(!event || !geometry || !this.object) return;
let objectEvent: RoomObjectEvent = null;
switch(event.type)
{
case MouseEventType.DOUBLE_CLICK: {
if((event.spriteTag === 'turn_on') || (event.spriteTag === 'turn_off'))
{
objectEvent = new RoomObjectStateChangedEvent(RoomObjectStateChangedEvent.STATE_CHANGE, this.object);
}
else
{
objectEvent = new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.AREA_HIDE, this.object);
}
if(this.eventDispatcher && objectEvent)
{
this.eventDispatcher.dispatchEvent(objectEvent);
return;
}
break;
}
}
super.mouseEvent(event, geometry);
}
}

View File

@ -1,4 +1,5 @@
export * from './FurnitureAchievementResolutionLogic';
export * from './FurnitureAreaHideLogic';
export * from './FurnitureBadgeDisplayLogic';
export * from './FurnitureChangeStateWhenStepOnLogic';
export * from './FurnitureClothingChangeLogic';

View File

@ -26,6 +26,7 @@ export class RoomObjectSprite implements IRoomObjectSprite
private _varyingDepth: boolean = false;
private _libraryAssetName: string = '';
private _clickHandling: boolean = false;
private _skipMouseHandling: boolean = false;
private _visible: boolean = true;
private _tag: string = '';
private _posture: string = null;
@ -352,4 +353,14 @@ export class RoomObjectSprite implements IRoomObjectSprite
{
return this._updateCounter;
}
public get skipMouseHandling(): boolean
{
return this._skipMouseHandling;
}
public set skipMouseHandling(flag: boolean)
{
this._skipMouseHandling = flag;
}
}

View File

@ -1,5 +1,5 @@
import { AlphaTolerance, IGraphicAsset, IObjectVisualizationData, IRoomGeometry, IRoomObjectSprite, RoomObjectVariable, RoomObjectVisualizationType } from '@nitrots/api';
import { BLEND_MODES, Texture } from 'pixi.js';
import { BLEND_MODES, Filter, Texture } from 'pixi.js';
import { RoomObjectSpriteVisualization } from '../RoomObjectSpriteVisualization';
import { ColorData, LayerData } from '../data';
import { FurnitureVisualizationData } from './FurnitureVisualizationData';
@ -38,8 +38,11 @@ export class FurnitureVisualization extends RoomObjectSpriteVisualization
protected _spriteXOffsets: number[];
protected _spriteYOffsets: number[];
protected _spriteZOffsets: number[];
protected _filters: Filter[] = [];
private _animationNumber: number;
private _lookThrough: boolean;
private _needsLookThroughUpdate: boolean;
constructor()
{
@ -75,6 +78,7 @@ export class FurnitureVisualization extends RoomObjectSpriteVisualization
this._spriteZOffsets = [];
this._animationNumber = 0;
this._lookThrough = false;
}
public initialize(data: IObjectVisualizationData): boolean
@ -104,6 +108,7 @@ export class FurnitureVisualization extends RoomObjectSpriteVisualization
this._spriteXOffsets = null;
this._spriteYOffsets = null;
this._spriteZOffsets = null;
this._filters = [];
}
protected reset(): void
@ -160,6 +165,12 @@ export class FurnitureVisualization extends RoomObjectSpriteVisualization
if(this.updateModel(scale)) updateSprites = true;
if(this._needsLookThroughUpdate)
{
updateSprites = true;
this._needsLookThroughUpdate = false;
}
let number = 0;
if(skipUpdate)
@ -313,11 +324,15 @@ export class FurnitureVisualization extends RoomObjectSpriteVisualization
relativeDepth = 1;
}
if(this._lookThrough) sprite.alpha *= 0.2;
sprite.relativeDepth = (relativeDepth * FurnitureVisualization.DEPTH_MULTIPLIER);
sprite.name = assetName;
sprite.libraryAssetName = this.getLibraryAssetNameForSprite(assetData, sprite);
sprite.posture = this.getPostureForAsset(scale, assetData.source);
sprite.clickHandling = this._clickHandling;
if(sprite.blendMode !== 'add') sprite.filters = this._filters;
}
else
{
@ -582,6 +597,14 @@ export class FurnitureVisualization extends RoomObjectSpriteVisualization
return asset?.texture ?? null;
}
public set lookThrough(flag: boolean)
{
if(this._lookThrough == flag) return;
this._lookThrough = flag;
this._needsLookThroughUpdate = true;
}
protected get direction(): number
{
return this._direction;

View File

@ -50,6 +50,8 @@ export class RoomPlane implements IRoomPlane
private _hasTexture: boolean = true;
private _canBeVisible: boolean = true;
private _geometryUpdateId: number = -1;
private _extraDepth: number = 0;
private _isHighlighter: boolean = false;
private _useMask: boolean;
private _bitmapMasks: RoomPlaneBitmapMask[] = [];
@ -569,7 +571,12 @@ export class RoomPlane implements IRoomPlane
public get relativeDepth(): number
{
return this._relativeDepth;
return (this._relativeDepth + this._extraDepth);
}
public set extraDepth(value: number)
{
this._extraDepth = value;
}
public get color(): number
@ -633,4 +640,14 @@ export class RoomPlane implements IRoomPlane
{
this._hasTexture = flag;
}
public get isHighlighter(): boolean
{
return this._isHighlighter;
}
public set isHighlighter(flag: boolean)
{
this._isHighlighter = flag;
}
}

View File

@ -1,6 +1,6 @@
import { AlphaTolerance, IObjectVisualizationData, IPlaneVisualization, IRoomGeometry, IRoomObjectModel, IRoomObjectSprite, IRoomPlane, RoomObjectSpriteType, RoomObjectVariable } from '@nitrots/api';
import { ToInt32, Vector3d } from '@nitrots/utils';
import { Rectangle, Texture } from 'pixi.js';
import { Filter, Rectangle, Texture } from 'pixi.js';
import { RoomMapData } from '../../RoomMapData';
import { RoomMapMaskData } from '../../RoomMapMaskData';
import { RoomPlaneBitmapMaskData } from '../../RoomPlaneBitmapMaskData';
@ -54,6 +54,13 @@ export class RoomVisualization extends RoomObjectSpriteVisualization implements
private _maskData: RoomMapMaskData = null;
private _isPlaneSet: boolean = false;
private _highlightAreaX: number = 0;
private _highlightAreaY: number = 0;
private _highlightAreaWidth: number = 0;
private _highlightAreaHeight: number = 0;
private _highlightFilter: Filter = null;
private _highlightPlaneOffsets: number[] = [];
constructor()
{
super();
@ -86,6 +93,7 @@ export class RoomVisualization extends RoomObjectSpriteVisualization implements
this._planes = null;
this._visiblePlanes = null;
this._visiblePlaneSpriteNumbers = null;
this._highlightPlaneOffsets = [];
if(this._roomPlaneParser)
{
@ -321,6 +329,7 @@ export class RoomVisualization extends RoomObjectSpriteVisualization implements
}
this._planes = [];
this._highlightPlaneOffsets = [];
}
this._isPlaneSet = false;
@ -336,19 +345,29 @@ export class RoomVisualization extends RoomObjectSpriteVisualization implements
if(!isNaN(this._floorThickness)) this._roomPlaneParser.floorThicknessMultiplier = this._floorThickness;
if(!isNaN(this._wallThickness)) this._roomPlaneParser.wallThicknessMultiplier = this._wallThickness;
this._roomPlaneParser.clearHighlightArea();
const mapData = this.object.model.getValue<RoomMapData>(RoomObjectVariable.ROOM_MAP_DATA);
if(!this._roomPlaneParser.initializeFromMapData(mapData)) return;
this._roomPlaneParser.initializeHighlightArea(this._highlightAreaX, this._highlightAreaY, this._highlightAreaWidth, this._highlightAreaHeight);
this.createPlanesAndSprites();
}
private createPlanesAndSprites(offset: number = 0): void
{
const maxX = this.getLandscapeWidth();
const maxY = this.getLandscapeHeight();
let landscapeOffsetX = 0;
let randomSeed = this.object.model.getValue<number>(RoomObjectVariable.ROOM_RANDOM_SEED);
let index = 0;
let index = offset;
while(index < this._roomPlaneParser.planeCount)
{
this._highlightPlaneOffsets[index] = -1;
const location = this._roomPlaneParser.getPlaneLocation(index);
const leftSide = this._roomPlaneParser.getPlaneLeftSide(index);
const rightSide = this._roomPlaneParser.getPlaneRightSide(index);
@ -414,6 +433,7 @@ export class RoomVisualization extends RoomObjectSpriteVisualization implements
i++;
}
this._highlightPlaneOffsets[index] = this._planes.length;
this._planes.push(plane);
}
}
@ -429,6 +449,53 @@ export class RoomVisualization extends RoomObjectSpriteVisualization implements
this.defineSprites();
}
public initializeHighlightArea(highlightAreaX: number, highlightAreaY: number, highlightAreaWidth: number, highlightAreaHeight: number, highlightFilter: Filter): void
{
this.clearHighlightArea();
this._highlightAreaX = highlightAreaX;
this._highlightAreaY = highlightAreaY;
this._highlightAreaWidth = highlightAreaWidth;
this._highlightAreaHeight = highlightAreaHeight;
this._highlightFilter = highlightFilter;
this._roomPlaneParser.initializeHighlightArea(highlightAreaX, highlightAreaY, highlightAreaWidth, highlightAreaHeight);
this.createPlanesAndSprites(this._planes.length);
this.reset();
}
public clearHighlightArea(): void
{
this._highlightAreaX = 0;
this._highlightAreaY = 0;
this._highlightAreaWidth = 0;
this._highlightAreaHeight = 0;
const totalHighlightedPlanes = this._roomPlaneParser.clearHighlightArea();
let _local_4 = 0;
let _local_1 = this._roomPlaneParser.planeCount;
while(_local_1 < (this._roomPlaneParser.planeCount + totalHighlightedPlanes))
{
const _local_2 = this._highlightPlaneOffsets[_local_1];
if(_local_2 !== -1)
{
_local_4 = (_local_4 + 1);
this._highlightPlaneOffsets[_local_1] = -1;
};
_local_1 = (_local_1 + 1);
};
this._planes = this._planes.slice(0, (this._planes.length - _local_4));
this.createSprites(this._planes.length);
this.reset();
}
protected defineSprites(): void
{
this.createSprites(this._planes.length);
@ -467,6 +534,22 @@ export class RoomVisualization extends RoomObjectSpriteVisualization implements
}
sprite.spriteType = RoomObjectSpriteType.ROOM_PLANE;
if(this._roomPlaneParser.isPlaneTemporaryHighlighter(planeIndex))
{
if(this._highlightFilter) sprite.filters = [ this._highlightFilter ];
sprite.skipMouseHandling = true;
plane.extraDepth = -100;
plane.isHighlighter = true;
}
else
{
sprite.filters = [];
sprite.skipMouseHandling = false;
plane.extraDepth = 0;
plane.isHighlighter = false;
}
}
planeIndex++;

View File

@ -528,6 +528,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
extendedSprite.label = sprite.name;
extendedSprite.varyingDepth = objectSprite.varyingDepth;
extendedSprite.clickHandling = objectSprite.clickHandling;
extendedSprite.skipMouseHandling = objectSprite.skipMouseHandling;
extendedSprite.filters = objectSprite.filters;
const alpha = (objectSprite.alpha / 255);
@ -604,6 +605,7 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
extendedSprite.label = sprite.name;
extendedSprite.varyingDepth = sprite.varyingDepth;
extendedSprite.clickHandling = sprite.clickHandling;
extendedSprite.skipMouseHandling = sprite.skipMouseHandling;
extendedSprite.blendMode = sprite.blendMode;
extendedSprite.filters = sprite.filters;
@ -757,61 +759,64 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
if(extendedSprite && extendedSprite.containsPoint(new Point((x - extendedSprite.x), (y - extendedSprite.y))))
{
if(extendedSprite.clickHandling && ((type === MouseEventType.MOUSE_CLICK) || (type === MouseEventType.DOUBLE_CLICK)))
if(!extendedSprite.skipMouseHandling)
{
//
}
else
{
const identifier = this.getExtendedSpriteIdentifier(extendedSprite);
if(checkedSprites.indexOf(identifier) === -1)
if(extendedSprite.clickHandling && ((type === MouseEventType.MOUSE_CLICK) || (type === MouseEventType.DOUBLE_CLICK)))
{
const tag = extendedSprite.tag;
//
}
else
{
const identifier = this.getExtendedSpriteIdentifier(extendedSprite);
let mouseData = this._mouseActiveObjects.get(identifier);
if(mouseData)
if(checkedSprites.indexOf(identifier) === -1)
{
if(mouseData.spriteTag !== tag)
{
mouseEvent = this.createMouseEvent(0, 0, 0, 0, MouseEventType.ROLL_OUT, mouseData.spriteTag, altKey, ctrlKey, shiftKey, buttonDown);
const tag = extendedSprite.tag;
let mouseData = this._mouseActiveObjects.get(identifier);
if(mouseData)
{
if(mouseData.spriteTag !== tag)
{
mouseEvent = this.createMouseEvent(0, 0, 0, 0, MouseEventType.ROLL_OUT, mouseData.spriteTag, altKey, ctrlKey, shiftKey, buttonDown);
this.bufferMouseEvent(mouseEvent, identifier);
}
}
if((type === MouseEventType.MOUSE_MOVE) && (!mouseData || (mouseData.spriteTag !== tag)))
{
mouseEvent = this.createMouseEvent(x, y, (x - extendedSprite.x), (y - extendedSprite.y), MouseEventType.ROLL_OVER, tag, altKey, ctrlKey, shiftKey, buttonDown);
}
else
{
mouseEvent = this.createMouseEvent(x, y, (x - extendedSprite.x), (y - extendedSprite.y), type, tag, altKey, ctrlKey, shiftKey, buttonDown);
mouseEvent.spriteOffsetX = extendedSprite.offsetX;
mouseEvent.spriteOffsetY = extendedSprite.offsetY;
}
if(!mouseData)
{
mouseData = new ObjectMouseData();
mouseData.objectId = identifier;
this._mouseActiveObjects.set(identifier, mouseData);
}
mouseData.spriteTag = tag;
if(((type !== MouseEventType.MOUSE_MOVE) || (x !== this._mouseOldX)) || (y !== this._mouseOldY))
{
this.bufferMouseEvent(mouseEvent, identifier);
}
checkedSprites.push(identifier);
}
if((type === MouseEventType.MOUSE_MOVE) && (!mouseData || (mouseData.spriteTag !== tag)))
{
mouseEvent = this.createMouseEvent(x, y, (x - extendedSprite.x), (y - extendedSprite.y), MouseEventType.ROLL_OVER, tag, altKey, ctrlKey, shiftKey, buttonDown);
}
else
{
mouseEvent = this.createMouseEvent(x, y, (x - extendedSprite.x), (y - extendedSprite.y), type, tag, altKey, ctrlKey, shiftKey, buttonDown);
mouseEvent.spriteOffsetX = extendedSprite.offsetX;
mouseEvent.spriteOffsetY = extendedSprite.offsetY;
}
if(!mouseData)
{
mouseData = new ObjectMouseData();
mouseData.objectId = identifier;
this._mouseActiveObjects.set(identifier, mouseData);
}
mouseData.spriteTag = tag;
if(((type !== MouseEventType.MOUSE_MOVE) || (x !== this._mouseOldX)) || (y !== this._mouseOldY))
{
this.bufferMouseEvent(mouseEvent, identifier);
}
checkedSprites.push(identifier);
didHitSprite = true;
}
didHitSprite = true;
}
}

View File

@ -12,6 +12,7 @@ export class ExtendedSprite extends Sprite
private _alphaTolerance: number = AlphaTolerance.MATCH_OPAQUE_PIXELS;
private _varyingDepth: boolean = false;
private _clickHandling: boolean = false;
private _skipMouseHandling: boolean = false;
private _updateId1: number = -1;
private _updateId2: number = -1;
@ -43,7 +44,7 @@ export class ExtendedSprite extends Sprite
public containsPoint(point: Point): boolean
{
if(!point || (this.alphaTolerance > 255) || !this.texture || (this.texture === Texture.EMPTY) || (this.blendMode !== 'normal')) return false;
if(!point || (this.alphaTolerance > 255) || !this.texture || (this.texture === Texture.EMPTY)) return false;
point = new Point((point.x * this.scale.x), (point.y * this.scale.y));
@ -181,4 +182,14 @@ export class ExtendedSprite extends Sprite
{
this._clickHandling = flag;
}
public get skipMouseHandling(): boolean
{
return this._skipMouseHandling;
}
public set skipMouseHandling(flag: boolean)
{
this._skipMouseHandling = flag;
}
}

View File

@ -0,0 +1,233 @@
import { IRoomAreaSelectionManager, IRoomEngine, IRoomObject } from '@nitrots/api';
import { GetEventDispatcher, RoomEngineObjectEvent, RoomObjectMouseEvent, RoomObjectTileMouseEvent } from '@nitrots/events';
import { ColorMatrixFilter } from 'pixi.js';
import { FurnitureVisualization, RoomVisualization } from '../object';
export class RoomAreaSelectionManager implements IRoomAreaSelectionManager
{
public static NOT_ACTIVE: number = 0;
public static NOT_SELECTING_AREA: number = 1;
public static AWAITING_MOUSE_DOWN: number = 2;
public static SELECTING: number = 3;
public static HIGHLIGHT_DARKEN = 'highlight_darken';
public static HIGHLIGHT_BRIGHTEN = 'highlight_brighten';
public static HIGHLIGHT_BLUE = 'highlight_blue';
private static HIGHLIGHT_FILTERS: { [key: string]: ColorMatrixFilter } = {};
private _roomEngine: IRoomEngine = null;
private _state: number = RoomAreaSelectionManager.NOT_ACTIVE;
private _tileXInit: number = 0;
private _tileYInit: number = 0;
private _tileXEnd: number = 0;
private _tileYEnd: number = 0;
private _highlightRootX: number = 0;
private _highlightRootY: number = 0;
private _highlightWidth: number = 0;
private _highlightHeight: number = 0;
private _callback: (rootX: number, rootY: number, width: number, height: number) => void;
private _highlightType: string = RoomAreaSelectionManager.HIGHLIGHT_BRIGHTEN;
constructor(roomEngine: IRoomEngine)
{
this._roomEngine = roomEngine;
GetEventDispatcher().addEventListener<RoomEngineObjectEvent>(RoomEngineObjectEvent.ADDED, event =>
{
if(this._state === RoomAreaSelectionManager.NOT_ACTIVE) return;
if(event.roomId !== this._roomEngine.activeRoomId) return;
if(event.category !== 10 && event.category !== 20) return;
const roomObject = this._roomEngine.getRoomObject(event.roomId, event.objectId, event.category);
if(roomObject.visualization instanceof FurnitureVisualization) roomObject.visualization.lookThrough = true;
});
const brightenFilter = new ColorMatrixFilter();
brightenFilter.matrix = [1.5, 0, 0, 0, 0, 0, 1.5, 0, 0, 20, 0, 0, 1.5, 0, 20, 0, 0, 0, 1, 0];
const blueFilter = new ColorMatrixFilter();
brightenFilter.matrix = [1.05, 0, 0, 0, 0, 0, 1.3, 0, 0, 8, 0, 0, 1.8, 0, 20, 0, 0, 0, 1, 0];
const darkenFilter = new ColorMatrixFilter();
brightenFilter.matrix = [0.55, 0, 0, 0, -10, 0, 0.55, 0, 0, -10, 0, 0, 0.55, 0, -10, 0, 0, 0, 1, 0];
RoomAreaSelectionManager.HIGHLIGHT_FILTERS[RoomAreaSelectionManager.HIGHLIGHT_DARKEN] = darkenFilter;
RoomAreaSelectionManager.HIGHLIGHT_FILTERS[RoomAreaSelectionManager.HIGHLIGHT_BRIGHTEN] = brightenFilter;
RoomAreaSelectionManager.HIGHLIGHT_FILTERS[RoomAreaSelectionManager.HIGHLIGHT_BLUE] = blueFilter;
}
private getAllFurniture(): IRoomObject[]
{
return this._roomEngine.getRoomObjects(this._roomEngine.activeRoomId, 20).concat(this._roomEngine.getRoomObjects(this._roomEngine.activeRoomId, 10));
}
public startSelecting(): void
{
if(this._state !== RoomAreaSelectionManager.NOT_SELECTING_AREA) return;
this.clearHighlightSilent();
this._state = RoomAreaSelectionManager.AWAITING_MOUSE_DOWN;
this._roomEngine.moveBlocked = true;
}
public handleTileMouseEvent(event: RoomObjectTileMouseEvent): void
{
let isWaitingForMouseDown = ((this._state === RoomAreaSelectionManager.AWAITING_MOUSE_DOWN) && (event.type == RoomObjectMouseEvent.MOUSE_DOWN));
if(event.shiftKey && (this._state === RoomAreaSelectionManager.NOT_SELECTING_AREA) && (event.type == RoomObjectMouseEvent.MOUSE_DOWN))
{
this.startSelecting();
isWaitingForMouseDown = true;
};
if(isWaitingForMouseDown)
{
this._state = RoomAreaSelectionManager.SELECTING;
this._tileXInit = event.tileXAsInt;
this._tileYInit = event.tileYAsInt;
this._tileXEnd = event.tileXAsInt;
this._tileYEnd = event.tileYAsInt;
this.setHighlight(this._tileXInit, this._tileYInit, 1, 1);
return;
}
if((this._state === RoomAreaSelectionManager.SELECTING) && (event.type === RoomObjectMouseEvent.MOUSE_MOVE))
{
if((event.tileXAsInt !== this._tileXEnd) || (event.tileYAsInt !== this._tileYEnd))
{
let rootX: number = 0;
let rootY: number = 0;
let width: number = 0;
let height: number = 0;
this._tileXEnd = event.tileXAsInt;
this._tileYEnd = event.tileYAsInt;
if(this._tileXEnd > this._tileXInit)
{
rootX = this._tileXInit;
width = ((this._tileXEnd - this._tileXInit) + 1);
}
else
{
rootX = this._tileXEnd;
width = ((this._tileXInit - this._tileXEnd) + 1);
};
if(this._tileYEnd > this._tileYInit)
{
rootY = this._tileYInit;
height = ((this._tileYEnd - this._tileYInit) + 1);
}
else
{
rootY = this._tileYEnd;
height = ((this._tileYInit - this._tileYEnd) + 1);
};
this.setHighlight(rootX, rootY, width, height);
};
};
}
public finishSelecting(): boolean
{
if(this._state !== RoomAreaSelectionManager.SELECTING) return false;
this._state = RoomAreaSelectionManager.NOT_SELECTING_AREA;
this._roomEngine.moveBlocked = false;
if(this._callback) this._callback(this._highlightRootX, this._highlightRootY, this._highlightWidth, this._highlightHeight);
return true;
}
private clearHighlightSilent():void
{
const roomObject = this._roomEngine.getRoomObject(this._roomEngine.activeRoomId, -1, 0);
if(!roomObject) return;
(roomObject.visualization as RoomVisualization)?.clearHighlightArea();
}
public clearHighlight(): void
{
if(this._state === RoomAreaSelectionManager.NOT_ACTIVE) return;
this.clearHighlightSilent();
this._state = RoomAreaSelectionManager.NOT_SELECTING_AREA;
this._roomEngine.moveBlocked = false;
if(this._callback) this._callback(0, 0, 0, 0);
}
public setHighlight(rootX: number, rootY: number, width: number, height: number): void
{
if(this._state === RoomAreaSelectionManager.NOT_ACTIVE) return;
this._highlightRootX = rootX;
this._highlightRootY = rootY;
this._highlightWidth = width;
this._highlightHeight = height;
const roomObject = this._roomEngine.getRoomObject(this._roomEngine.activeRoomId, -1, 0);
if(!roomObject) return;
(roomObject.visualization as RoomVisualization)?.initializeHighlightArea(rootX, rootY, width, height, RoomAreaSelectionManager.HIGHLIGHT_FILTERS[this._highlightType]);
}
public activate(callback: (rootX: number, rootY: number, width: number, height: number) => void, highlightType: string): boolean
{
if(this._state !== RoomAreaSelectionManager.NOT_ACTIVE) return false;
this._callback = callback;
this._highlightType = highlightType;
for(const roomObject of this.getAllFurniture())
{
const visualization = (roomObject.visualization as FurnitureVisualization);
if(visualization) visualization.lookThrough = true;
};
this._state = RoomAreaSelectionManager.NOT_SELECTING_AREA;
return true;
}
public deactivate(): void
{
if(this._state === RoomAreaSelectionManager.NOT_ACTIVE) return;
this._callback = null;
for(const roomObject of this.getAllFurniture())
{
const visualization = (roomObject.visualization as FurnitureVisualization);
if(visualization) visualization.lookThrough = false;
};
this.clearHighlight();
this._state = RoomAreaSelectionManager.NOT_ACTIVE;
}
public get areaSelectionState(): number
{
return this._state;
}
}