diff --git a/src/nitro/communication/NitroMessages.ts b/src/nitro/communication/NitroMessages.ts index b2b6c1a7..f35011ce 100644 --- a/src/nitro/communication/NitroMessages.ts +++ b/src/nitro/communication/NitroMessages.ts @@ -151,6 +151,7 @@ import { RoomUsersWithRightsEvent } from './messages/incoming/room/data/RoomUser import { ObjectsDataUpdateEvent } from './messages/incoming/room/engine/ObjectsDataUpdateEvent'; import { ObjectsRollingEvent } from './messages/incoming/room/engine/ObjectsRollingEvent'; import { RoomCreatedEvent } from './messages/incoming/room/engine/RoomCreatedEvent'; +import { DiceValueMessageEvent } from './messages/incoming/room/furniture/DiceValueMessageEvent'; import { FurnitureFloorAddEvent } from './messages/incoming/room/furniture/floor/FurnitureFloorAddEvent'; import { FurnitureFloorEvent } from './messages/incoming/room/furniture/floor/FurnitureFloorEvent'; import { FurnitureFloorRemoveEvent } from './messages/incoming/room/furniture/floor/FurnitureFloorRemoveEvent'; @@ -160,7 +161,6 @@ import { FurnitureDataEvent } from './messages/incoming/room/furniture/Furniture import { FurnitureItemDataEvent } from './messages/incoming/room/furniture/FurnitureItemDataEvent'; import { FurniturePostItStickyPoleOpenEvent } from './messages/incoming/room/furniture/FurniturePostItStickyPoleOpenEvent'; import { FurnitureStackHeightEvent } from './messages/incoming/room/furniture/FurnitureStackHeightEvent'; -import { FurnitureState2Event } from './messages/incoming/room/furniture/FurnitureState2Event'; import { FurnitureStateEvent } from './messages/incoming/room/furniture/FurnitureStateEvent'; import { GroupFurniContextMenuInfoMessageEvent } from './messages/incoming/room/furniture/GroupFurniContextMenuInfoMessageEvent'; import { LoveLockFurniFinishedEvent } from './messages/incoming/room/furniture/LoveLockFurniFinishedEvent'; @@ -753,7 +753,7 @@ export class NitroMessages implements IMessageConfiguration this._events.set(IncomingHeader.ITEM_STACK_HELPER, FurnitureStackHeightEvent); this._events.set(IncomingHeader.FURNITURE_STATE, FurnitureStateEvent); this._events.set(IncomingHeader.ITEM_DIMMER_SETTINGS, RoomDimmerPresetsEvent); - this._events.set(IncomingHeader.FURNITURE_STATE_2, FurnitureState2Event); + this._events.set(IncomingHeader.FURNITURE_STATE_2, DiceValueMessageEvent); this._events.set(IncomingHeader.LOVELOCK_FURNI_FINISHED, LoveLockFurniFinishedEvent); this._events.set(IncomingHeader.LOVELOCK_FURNI_FRIEND_COMFIRMED, LoveLockFurniFriendConfirmedEvent); this._events.set(IncomingHeader.LOVELOCK_FURNI_START, LoveLockFurniStartEvent); diff --git a/src/nitro/communication/messages/incoming/room/furniture/FurnitureState2Event.ts b/src/nitro/communication/messages/incoming/room/furniture/DiceValueMessageEvent.ts similarity index 85% rename from src/nitro/communication/messages/incoming/room/furniture/FurnitureState2Event.ts rename to src/nitro/communication/messages/incoming/room/furniture/DiceValueMessageEvent.ts index 799edab6..4b331398 100644 --- a/src/nitro/communication/messages/incoming/room/furniture/FurnitureState2Event.ts +++ b/src/nitro/communication/messages/incoming/room/furniture/DiceValueMessageEvent.ts @@ -2,7 +2,7 @@ import { IMessageEvent } from '../../../../../../core/communication/messages/IMe import { MessageEvent } from '../../../../../../core/communication/messages/MessageEvent'; import { FurnitureState2Parser } from '../../../parser/room/furniture/FurnitureState2Parser'; -export class FurnitureState2Event extends MessageEvent implements IMessageEvent +export class DiceValueMessageEvent extends MessageEvent implements IMessageEvent { constructor(callBack: Function) { diff --git a/src/nitro/communication/messages/incoming/room/furniture/index.ts b/src/nitro/communication/messages/incoming/room/furniture/index.ts index 83bfaddb..be7d5cb1 100644 --- a/src/nitro/communication/messages/incoming/room/furniture/index.ts +++ b/src/nitro/communication/messages/incoming/room/furniture/index.ts @@ -1,10 +1,10 @@ +export * from './DiceValueMessageEvent'; export * from './floor'; export * from './FurnitureAliasesEvent'; export * from './FurnitureDataEvent'; export * from './FurnitureItemDataEvent'; export * from './FurniturePostItStickyPoleOpenEvent'; export * from './FurnitureStackHeightEvent'; -export * from './FurnitureState2Event'; export * from './FurnitureStateEvent'; export * from './GroupFurniContextMenuInfoMessageEvent'; export * from './LoveLockFurniFinishedEvent'; diff --git a/src/nitro/room/RoomMessageHandler.ts b/src/nitro/room/RoomMessageHandler.ts index 6c81e86a..d7477081 100644 --- a/src/nitro/room/RoomMessageHandler.ts +++ b/src/nitro/room/RoomMessageHandler.ts @@ -5,6 +5,7 @@ import { Vector3d } from '../../room/utils/Vector3d'; import { PetType } from '../avatar/pets/PetType'; import { ObjectsDataUpdateEvent, PetExperienceEvent } from '../communication'; import { ObjectsRollingEvent } from '../communication/messages/incoming/room/engine/ObjectsRollingEvent'; +import { DiceValueMessageEvent } from '../communication/messages/incoming/room/furniture/DiceValueMessageEvent'; import { FurnitureFloorAddEvent } from '../communication/messages/incoming/room/furniture/floor/FurnitureFloorAddEvent'; import { FurnitureFloorEvent } from '../communication/messages/incoming/room/furniture/floor/FurnitureFloorEvent'; import { FurnitureFloorRemoveEvent } from '../communication/messages/incoming/room/furniture/floor/FurnitureFloorRemoveEvent'; @@ -12,7 +13,6 @@ import { FurnitureFloorUpdateEvent } from '../communication/messages/incoming/ro import { FurnitureAliasesEvent } from '../communication/messages/incoming/room/furniture/FurnitureAliasesEvent'; import { FurnitureDataEvent } from '../communication/messages/incoming/room/furniture/FurnitureDataEvent'; import { FurnitureItemDataEvent } from '../communication/messages/incoming/room/furniture/FurnitureItemDataEvent'; -import { FurnitureState2Event } from '../communication/messages/incoming/room/furniture/FurnitureState2Event'; import { FurnitureStateEvent } from '../communication/messages/incoming/room/furniture/FurnitureStateEvent'; import { FurnitureWallAddEvent } from '../communication/messages/incoming/room/furniture/wall/FurnitureWallAddEvent'; import { FurnitureWallEvent } from '../communication/messages/incoming/room/furniture/wall/FurnitureWallEvent'; @@ -144,7 +144,7 @@ export class RoomMessageHandler extends Disposable this._connection.addMessageEvent(new PetFigureUpdateEvent(this.onPetFigureUpdateEvent.bind(this))); this._connection.addMessageEvent(new PetExperienceEvent(this.onPetExperienceEvent.bind(this))); this._connection.addMessageEvent(new YouArePlayingGameEvent(this.onYouArePlayingGameEvent.bind(this))); - this._connection.addMessageEvent(new FurnitureState2Event(this.onFurnitureState2Event.bind(this))); + this._connection.addMessageEvent(new DiceValueMessageEvent(this.onDiceValueMessageEvent.bind(this))); this._connection.addMessageEvent(new IgnoreResultEvent(this.onIgnoreResultEvent.bind(this))); } @@ -645,9 +645,9 @@ export class RoomMessageHandler extends Disposable this._roomCreator.updateRoomObjectFloor(this._currentRoomId, parser.itemId, null, null, parser.state, new LegacyDataType()); } - private onFurnitureState2Event(event: FurnitureState2Event): void + private onDiceValueMessageEvent(event: DiceValueMessageEvent): void { - if(!(event instanceof FurnitureState2Event) || !event.connection || !this._roomCreator) return; + if(!(event instanceof DiceValueMessageEvent) || !event.connection || !this._roomCreator) return; const parser = event.getParser(); diff --git a/src/room/utils/ColorConverter.ts b/src/room/utils/ColorConverter.ts index 2c86a4dd..88c80b68 100644 --- a/src/room/utils/ColorConverter.ts +++ b/src/room/utils/ColorConverter.ts @@ -14,11 +14,26 @@ export class ColorConverter return out; } + public static hex2rgba(hex: number, out: Array | Float32Array = []): Array | Float32Array + { + out[0] = ((hex >> 16) & 0xFF) / 255; + out[1] = ((hex >> 8) & 0xFF) / 255; + out[2] = (hex & 0xFF) / 255; + out[3] = (hex & 0xFF); + + return out; + } + public static rgb2hex(rgb: number[] | Float32Array): number { return (((rgb[0] * 255) << 16) + ((rgb[1] * 255) << 8) + (rgb[2] * 255 | 0)); } + public static rgba2hex(rgb: number[] | Float32Array): number + { + return (((rgb[0] * 255) << 16) + ((rgb[1] * 255) << 8) + (rgb[2] * 255 | 0) + (rgb[3] | 0)); + } + public static rgbStringToHex(rgb: string): string { const extracted = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);