diff --git a/src/nitro/room/RoomMessageHandler.ts b/src/nitro/room/RoomMessageHandler.ts index b15dbc45..7e73fb53 100644 --- a/src/nitro/room/RoomMessageHandler.ts +++ b/src/nitro/room/RoomMessageHandler.ts @@ -2,8 +2,12 @@ import { Disposable } from '../../core/common/disposable/Disposable'; import { IConnection } from '../../core/communication/connections/IConnection'; import { IVector3D } from '../../room/utils/IVector3D'; import { Vector3d } from '../../room/utils/Vector3d'; +import { AvatarGuideStatus } from '../avatar/enum/AvatarGuideStatus'; import { PetType } from '../avatar/pets/PetType'; import { ObjectsDataUpdateEvent, PetExperienceEvent } from '../communication'; +import { GuideSessionEndedMessageEvent } from '../communication/messages/incoming/help/GuideSessionEndedMessageEvent'; +import { GuideSessionErrorMessageEvent } from '../communication/messages/incoming/help/GuideSessionErrorMessageEvent'; +import { GuideSessionStartedMessageEvent } from '../communication/messages/incoming/help/GuideSessionStartedMessageEvent'; 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'; @@ -48,6 +52,7 @@ import { GetRoomEntryDataMessageComposer } from '../communication/messages/outgo import { FurnitureFloorDataParser } from '../communication/messages/parser/room/furniture/floor/FurnitureFloorDataParser'; import { FurnitureWallDataParser } from '../communication/messages/parser/room/furniture/wall/FurnitureWallDataParser'; import { RoomEntryTileMessageParser } from '../communication/messages/parser/room/mapping/RoomEntryTileMessageParser'; +import { RoomObjectType } from '../room/object/RoomObjectType'; import { IRoomCreator } from './IRoomCreator'; import { LegacyDataType } from './object/data/type/LegacyDataType'; import { RoomObjectUserType } from './object/RoomObjectUserType'; @@ -68,6 +73,8 @@ export class RoomMessageHandler extends Disposable private _currentRoomId: number; private _ownUserId: number; private _initialConnection: boolean; + private _guideId: number; + private _requesterId: number; constructor(roomCreator: IRoomCreator) { @@ -81,6 +88,8 @@ export class RoomMessageHandler extends Disposable this._currentRoomId = 0; this._ownUserId = 0; this._initialConnection = true; + this._guideId = -1; + this._requesterId = -1; } protected onDispose(): void @@ -146,6 +155,9 @@ export class RoomMessageHandler extends Disposable this._connection.addMessageEvent(new YouArePlayingGameEvent(this.onYouArePlayingGameEvent.bind(this))); this._connection.addMessageEvent(new DiceValueMessageEvent(this.onDiceValueMessageEvent.bind(this))); this._connection.addMessageEvent(new IgnoreResultEvent(this.onIgnoreResultEvent.bind(this))); + this._connection.addMessageEvent(new GuideSessionStartedMessageEvent(this.onGuideSessionStartedMessageEvent.bind(this))); + this._connection.addMessageEvent(new GuideSessionEndedMessageEvent(this.onGuideSessionEndedMessageEvent.bind(this))); + this._connection.addMessageEvent(new GuideSessionErrorMessageEvent(this.onGuideSessionErrorMessageEvent.bind(this))); } public setRoomId(id: number): void @@ -949,6 +961,58 @@ export class RoomMessageHandler extends Disposable } } + private onGuideSessionStartedMessageEvent(event: GuideSessionStartedMessageEvent): void + { + const parser = event.getParser(); + + this._guideId = parser.guideUserId; + this._requesterId = parser.requesterUserId; + + this.updateGuideMarker(); + } + + private onGuideSessionEndedMessageEvent(k: GuideSessionEndedMessageEvent): void + { + this.removeGuideMarker(); + } + + private onGuideSessionErrorMessageEvent(k: GuideSessionErrorMessageEvent): void + { + this.removeGuideMarker(); + } + + private updateGuideMarker():void + { + const userId = this._roomCreator.sessionDataManager.userId; + + this.setUserGuideStatus(this._guideId, ((this._requesterId === userId) ? AvatarGuideStatus.GUIDE : AvatarGuideStatus.NONE)); + this.setUserGuideStatus(this._requesterId, ((this._guideId === userId) ? AvatarGuideStatus.REQUESTER : AvatarGuideStatus.NONE)); + } + + private removeGuideMarker():void + { + this.setUserGuideStatus(this._guideId, AvatarGuideStatus.NONE); + this.setUserGuideStatus(this._requesterId, AvatarGuideStatus.NONE); + + this._guideId = -1; + this._requesterId = -1; + } + + private setUserGuideStatus(userId: number, status: number):void + { + if(!this._roomCreator || !this._roomCreator.roomSessionManager) return; + + const roomSession = this._roomCreator.roomSessionManager.getSession(this._currentRoomId); + + if(!roomSession) return; + + const userData = roomSession.userDataManager.getDataByType(userId, RoomObjectType.USER); + + if(!userData) return; + + this._roomCreator.updateRoomObjectUserAction(this._currentRoomId, userData.roomIndex, RoomObjectVariable.FIGURE_GUIDE_STATUS, status); + } + // public _SafeStr_10580(event:_SafeStr_2242): void // { // var arrayIndex: number; diff --git a/src/nitro/room/object/visualization/avatar/AvatarVisualization.ts b/src/nitro/room/object/visualization/avatar/AvatarVisualization.ts index 036054a9..e761affb 100644 --- a/src/nitro/room/object/visualization/avatar/AvatarVisualization.ts +++ b/src/nitro/room/object/visualization/avatar/AvatarVisualization.ts @@ -10,14 +10,16 @@ import { RoomObjectSpriteVisualization } from '../../../../../room/object/visual import { IGraphicAsset } from '../../../../../room/object/visualization/utils/IGraphicAsset'; import { IRoomGeometry } from '../../../../../room/utils/IRoomGeometry'; import { AvatarAction } from '../../../../avatar/enum/AvatarAction'; +import { AvatarGuideStatus } from '../../../../avatar/enum/AvatarGuideStatus'; import { AvatarSetType } from '../../../../avatar/enum/AvatarSetType'; import { IAvatarEffectListener } from '../../../../avatar/IAvatarEffectListener'; import { IAvatarImage } from '../../../../avatar/IAvatarImage'; import { IAvatarImageListener } from '../../../../avatar/IAvatarImageListener'; -import { Nitro } from '../../../../Nitro'; import { RoomObjectVariable } from '../../RoomObjectVariable'; import { ExpressionAdditionFactory } from './additions/ExpressionAdditionFactory'; import { FloatingIdleZAddition } from './additions/FloatingIdleZAddition'; +import { GameClickTargetAddition } from './additions/GameClickTargetAddition'; +import { GuideStatusBubbleAddition } from './additions/GuideStatusBubbleAddition'; import { IAvatarAddition } from './additions/IAvatarAddition'; import { MutedBubbleAddition } from './additions/MutedBubbleAddition'; import { NumberBubbleAddition } from './additions/NumberBubbleAddition'; @@ -31,7 +33,9 @@ export class AvatarVisualization extends RoomObjectSpriteVisualization implement private static TYPING_BUBBLE_ID: number = 2; private static EXPRESSION_ID: number = 3; private static NUMBER_BUBBLE_ID: number = 4; + private static GAME_CLICK_TARGET_ID: number = 5; private static MUTED_BUBBLE_ID: number = 6; + private static GUIDE_BUBBLE_ID: number = 7; private static OWN_USER_ID: number = 4; private static UPDATE_TIME_INCREASER: number = 41; private static AVATAR_LAYER_ID: number = 0; @@ -767,6 +771,40 @@ export class AvatarVisualization extends RoomObjectSpriteVisualization implement } } + const guideStatusValue = (model.getValue(RoomObjectVariable.FIGURE_GUIDE_STATUS) || 0); + + if(guideStatusValue !== AvatarGuideStatus.NONE) + { + this.removeAddition(AvatarVisualization.GUIDE_BUBBLE_ID); + this.addAddition(new GuideStatusBubbleAddition(AvatarVisualization.GUIDE_BUBBLE_ID, this, guideStatusValue)); + + needsUpdate = true; + } + else + { + if(this.getAddition(AvatarVisualization.GUIDE_BUBBLE_ID)) + { + this.removeAddition(AvatarVisualization.GUIDE_BUBBLE_ID); + + needsUpdate = true; + } + } + + const isPlayingGame = (model.getValue(RoomObjectVariable.FIGURE_IS_PLAYING_GAME) > 0); + + let gameClickAddition = this.getAddition(AvatarVisualization.GAME_CLICK_TARGET_ID); + + if(isPlayingGame) + { + if(!gameClickAddition) gameClickAddition = this.addAddition(new GameClickTargetAddition(AvatarVisualization.GAME_CLICK_TARGET_ID)); + + needsUpdate = true; + } + else + { + if(gameClickAddition) this.removeAddition(AvatarVisualization.GAME_CLICK_TARGET_ID); + } + const numberValue = model.getValue(RoomObjectVariable.FIGURE_NUMBER_VALUE); let numberAddition = this.getAddition(AvatarVisualization.NUMBER_BUBBLE_ID); @@ -1093,9 +1131,7 @@ export class AvatarVisualization extends RoomObjectSpriteVisualization implement public getAvatarRenderAsset(name: string): Texture { - const url = (Nitro.instance.getConfiguration('images.url') + '/additions/' + name + '.png'); - - return this._data ? this._data.getAvatarRendererAsset(url) : null; + return this._data ? this._data.getAvatarRendererAsset(name) : null; } public get direction(): number diff --git a/src/nitro/room/object/visualization/avatar/additions/FloatingHeartAddition.ts b/src/nitro/room/object/visualization/avatar/additions/FloatingHeartAddition.ts index 78f95d22..5d45a4cf 100644 --- a/src/nitro/room/object/visualization/avatar/additions/FloatingHeartAddition.ts +++ b/src/nitro/room/object/visualization/avatar/additions/FloatingHeartAddition.ts @@ -1,5 +1,6 @@ import { Resource, Texture } from '@pixi/core'; import { IRoomObjectSprite } from '../../../../../../room/object/visualization/IRoomObjectSprite'; +import { AvatarAction } from '../../../../../avatar/enum/AvatarAction'; import { Nitro } from '../../../../../Nitro'; import { AvatarVisualization } from '../AvatarVisualization'; import { ExpressionAddition } from './ExpressionAddition'; @@ -42,7 +43,7 @@ export class FloatingHeartAddition extends ExpressionAddition if(scale < 48) { - this._asset = this.visualization.getAvatarRenderAsset('user_blowkiss_small'); + this._asset = this.visualization.getAvatarRenderAsset('avatar_addition_user_blowkiss_small'); if((this.visualization.angle === 90) || (this.visualization.angle === 270)) { @@ -62,7 +63,7 @@ export class FloatingHeartAddition extends ExpressionAddition } else { - this._asset = this.visualization.getAvatarRenderAsset('user_blowkiss'); + this._asset = this.visualization.getAvatarRenderAsset('avatar_addition_user_blowkiss'); if((this.visualization.angle === 90) || (this.visualization.angle === 270)) { @@ -79,12 +80,12 @@ export class FloatingHeartAddition extends ExpressionAddition this._offsetY = -70; } - if(this.visualization.posture === 'sit') + if(this.visualization.posture === AvatarAction.POSTURE_SIT) { this._offsetY += (additionScale / 2); } - else if(this.visualization.posture === 'lay') + else if(this.visualization.posture === AvatarAction.POSTURE_LAY) { this._offsetY += additionScale; } diff --git a/src/nitro/room/object/visualization/avatar/additions/FloatingIdleZAddition.ts b/src/nitro/room/object/visualization/avatar/additions/FloatingIdleZAddition.ts index 8e4bd0dd..3abb8141 100644 --- a/src/nitro/room/object/visualization/avatar/additions/FloatingIdleZAddition.ts +++ b/src/nitro/room/object/visualization/avatar/additions/FloatingIdleZAddition.ts @@ -1,5 +1,6 @@ import { Resource, Texture } from '@pixi/core'; import { IRoomObjectSprite } from '../../../../../../room/object/visualization/IRoomObjectSprite'; +import { AvatarAction } from '../../../../../avatar/enum/AvatarAction'; import { Nitro } from '../../../../../Nitro'; import { AvatarVisualization } from '../AvatarVisualization'; import { IAvatarAddition } from './IAvatarAddition'; @@ -43,7 +44,7 @@ export class FloatingIdleZAddition implements IAvatarAddition if((this._visualization.angle === 135) || (this._visualization.angle === 180) || (this._visualization.angle === 225) || (this._visualization.angle === 270)) side = 'right'; - return ('user_idle_' + side + '_' + state + ((this._scale < 48) ? '_small' : '')); + return ('avatar_addition_user_idle_' + side + '_' + state + ((this._scale < 48) ? '_small' : '')); } public update(sprite: IRoomObjectSprite, scale: number): void @@ -85,12 +86,12 @@ export class FloatingIdleZAddition implements IAvatarAddition this._offsetY = -70; } - if(this._visualization.posture === 'sit') + if(this._visualization.posture === AvatarAction.POSTURE_SIT) { this._offsetY += (additionScale / 2); } - else if(this._visualization.posture === 'lay') + else if(this._visualization.posture === AvatarAction.POSTURE_LAY) { this._offsetY += (additionScale - (0.3 * additionScale)); } diff --git a/src/nitro/room/object/visualization/avatar/additions/GameClickTargetAddition.ts b/src/nitro/room/object/visualization/avatar/additions/GameClickTargetAddition.ts new file mode 100644 index 00000000..83a727e6 --- /dev/null +++ b/src/nitro/room/object/visualization/avatar/additions/GameClickTargetAddition.ts @@ -0,0 +1,61 @@ +import { Resource, Texture } from '@pixi/core'; +import { Sprite } from '@pixi/sprite'; +import { AlphaTolerance, TextureUtils } from '../../../../../..'; +import { IRoomObjectSprite } from '../../../../../../room/object/visualization/IRoomObjectSprite'; +import { IAvatarAddition } from './IAvatarAddition'; + +export class GameClickTargetAddition implements IAvatarAddition +{ + private static WIDTH: number = 46; + private static HEIGHT: number = 60; + private static OFFSET_X: number = -23; + private static OFFSET_Y: number = -48; + + private _id: number; + private _asset: Texture; + private _disposed: boolean; + + constructor(id: number) + { + this._id = id; + this._asset = null; + this._disposed = false; + } + + public dispose(): void + { + this._asset = null; + } + + public update(sprite: IRoomObjectSprite, scale: number): void + { + if(!sprite) return; + + if(!this._asset) + { + const newSprite = new Sprite(Texture.WHITE); + + newSprite.alpha = 0; + newSprite.width = GameClickTargetAddition.WIDTH; + newSprite.height = GameClickTargetAddition.HEIGHT; + + this._asset = TextureUtils.generateTexture(newSprite); + } + + sprite.visible = true; + sprite.texture = this._asset; + sprite.offsetX = GameClickTargetAddition.OFFSET_X; + sprite.offsetY = GameClickTargetAddition.OFFSET_Y; + sprite.alphaTolerance = AlphaTolerance.MATCH_ALL_PIXELS; + } + + public animate(sprite: IRoomObjectSprite): boolean + { + return false; + } + + public get id(): number + { + return this._id; + } +} diff --git a/src/nitro/room/object/visualization/avatar/additions/GuideStatusBubbleAddition.ts b/src/nitro/room/object/visualization/avatar/additions/GuideStatusBubbleAddition.ts new file mode 100644 index 00000000..82bcab6c --- /dev/null +++ b/src/nitro/room/object/visualization/avatar/additions/GuideStatusBubbleAddition.ts @@ -0,0 +1,100 @@ +import { Resource, Texture } from '@pixi/core'; +import { IRoomObjectSprite } from '../../../../../../room/object/visualization/IRoomObjectSprite'; +import { AvatarAction } from '../../../../../avatar/enum/AvatarAction'; +import { AvatarGuideStatus } from '../../../../../avatar/enum/AvatarGuideStatus'; +import { AvatarVisualization } from '../AvatarVisualization'; +import { IAvatarAddition } from './IAvatarAddition'; + +export class GuideStatusBubbleAddition implements IAvatarAddition +{ + private _id: number; + private _visualization: AvatarVisualization; + private _asset: Texture; + private _relativeDepth: number; + private _status: number; + + constructor(id: number, visualization: AvatarVisualization, status: number) + { + this._id = id; + this._visualization = visualization; + this._asset = null; + this._relativeDepth = 0; + this._status = status; + } + + public dispose(): void + { + this._visualization = null; + this._asset = null; + } + + public update(sprite: IRoomObjectSprite, scale: number): void + { + if(!sprite) return; + + sprite.visible = true; + sprite.relativeDepth = this._relativeDepth; + sprite.alpha = 255; + + let additionScale = 64; + let offsetX = 0; + let offsetY = 0; + + this._asset = this._visualization.getAvatarRenderAsset((this._status === AvatarGuideStatus.GUIDE) ? 'avatar_addition_user_guide_bubble' : 'avatar_addition_user_guide_requester_bubble'); + + if(scale < 48) + { + offsetX = -19; + offsetY = -80; + additionScale = 32; + } + else + { + offsetX = -19; + offsetY = -120; + } + + if(this._visualization.posture === AvatarAction.POSTURE_SIT) + { + offsetY += (additionScale / 2); + } + + else if(this._visualization.posture === AvatarAction.POSTURE_LAY) + { + offsetY += scale; + } + + if(this._asset) + { + sprite.texture = this._asset; + sprite.offsetX = offsetX; + sprite.offsetY = offsetY; + sprite.relativeDepth = (-0.02 + 0); + } + } + + public animate(sprite: IRoomObjectSprite): boolean + { + if(this._asset && sprite) + { + sprite.texture = this._asset; + } + + return false; + } + + public get id(): number + { + return this._id; + } + + public get relativeDepth(): number + { + return this._relativeDepth; + } + + public set relativeDepth(depth: number) + { + this._relativeDepth = depth; + } +} diff --git a/src/nitro/room/object/visualization/avatar/additions/MutedBubbleAddition.ts b/src/nitro/room/object/visualization/avatar/additions/MutedBubbleAddition.ts index 239643d2..655208b2 100644 --- a/src/nitro/room/object/visualization/avatar/additions/MutedBubbleAddition.ts +++ b/src/nitro/room/object/visualization/avatar/additions/MutedBubbleAddition.ts @@ -1,5 +1,6 @@ import { Resource, Texture } from '@pixi/core'; import { IRoomObjectSprite } from '../../../../../../room/object/visualization/IRoomObjectSprite'; +import { AvatarAction } from '../../../../../avatar/enum/AvatarAction'; import { AvatarVisualization } from '../AvatarVisualization'; import { IAvatarAddition } from './IAvatarAddition'; @@ -32,7 +33,7 @@ export class MutedBubbleAddition implements IAvatarAddition if(scale < 48) { - this._asset = this._visualization.getAvatarRenderAsset('user_muted_small'); + this._asset = this._visualization.getAvatarRenderAsset('avatar_addition_user_muted_small'); additionScale = 32; offsetX = -12; @@ -40,14 +41,14 @@ export class MutedBubbleAddition implements IAvatarAddition } else { - this._asset = this._visualization.getAvatarRenderAsset('user_muted'); + this._asset = this._visualization.getAvatarRenderAsset('avatar_addition_user_muted'); offsetX = -15; offsetY = -110; } - if(this._visualization.posture === 'sit') offsetY += (additionScale / 2); - else if(this._visualization.posture === 'lay') offsetY += scale; + if(this._visualization.posture === AvatarAction.POSTURE_SIT) offsetY += (additionScale / 2); + else if(this._visualization.posture === AvatarAction.POSTURE_LAY) offsetY += scale; if(this._asset) { diff --git a/src/nitro/room/object/visualization/avatar/additions/NumberBubbleAddition.ts b/src/nitro/room/object/visualization/avatar/additions/NumberBubbleAddition.ts index 476d8c34..5ab078c3 100644 --- a/src/nitro/room/object/visualization/avatar/additions/NumberBubbleAddition.ts +++ b/src/nitro/room/object/visualization/avatar/additions/NumberBubbleAddition.ts @@ -1,5 +1,6 @@ import { Resource, Texture } from '@pixi/core'; import { IRoomObjectSprite } from '../../../../../../room/object/visualization/IRoomObjectSprite'; +import { AvatarAction } from '../../../../../avatar/enum/AvatarAction'; import { AvatarVisualization } from '../AvatarVisualization'; import { IAvatarAddition } from './IAvatarAddition'; @@ -46,7 +47,7 @@ export class NumberBubbleAddition implements IAvatarAddition { if(scale < 48) { - this._asset = this._visualization.getAvatarRenderAsset('number_' + this._number + '_small'); + this._asset = this._visualization.getAvatarRenderAsset('avatar_addition_number_' + this._number + '_small'); additionScale = 32; offsetX = -6; @@ -54,18 +55,18 @@ export class NumberBubbleAddition implements IAvatarAddition } else { - this._asset = this._visualization.getAvatarRenderAsset('number_' + this._number); + this._asset = this._visualization.getAvatarRenderAsset('avatar_addition_number_' + this._number); offsetX = -8; offsetY = -105; } - if(this._visualization.posture === 'sit') + if(this._visualization.posture === AvatarAction.POSTURE_SIT) { offsetY += (additionScale / 2); } - else if(this._visualization.posture === 'lay') + else if(this._visualization.posture === AvatarAction.POSTURE_LAY) { offsetY += scale; } diff --git a/src/nitro/room/object/visualization/avatar/additions/TypingBubbleAddition.ts b/src/nitro/room/object/visualization/avatar/additions/TypingBubbleAddition.ts index 585e0de7..acbf28c6 100644 --- a/src/nitro/room/object/visualization/avatar/additions/TypingBubbleAddition.ts +++ b/src/nitro/room/object/visualization/avatar/additions/TypingBubbleAddition.ts @@ -1,5 +1,6 @@ import { Resource, Texture } from '@pixi/core'; import { IRoomObjectSprite } from '../../../../../../room/object/visualization/IRoomObjectSprite'; +import { AvatarAction } from '../../../../../avatar/enum/AvatarAction'; import { AvatarVisualization } from '../AvatarVisualization'; import { IAvatarAddition } from './IAvatarAddition'; @@ -38,7 +39,7 @@ export class TypingBubbleAddition implements IAvatarAddition if(scale < 48) { - this._asset = this._visualization.getAvatarRenderAsset('user_typing_small'); + this._asset = this._visualization.getAvatarRenderAsset('avatar_addition_user_typing_small'); offsetX = 3; offsetY = -42; @@ -47,18 +48,18 @@ export class TypingBubbleAddition implements IAvatarAddition } else { - this._asset = this._visualization.getAvatarRenderAsset('user_typing'); + this._asset = this._visualization.getAvatarRenderAsset('avatar_addition_user_typing'); offsetX = 14; offsetY = -83; } - if(this._visualization.posture === 'sit') + if(this._visualization.posture === AvatarAction.POSTURE_SIT) { offsetY += (additionScale / 2); } - else if(this._visualization.posture === 'lay') + else if(this._visualization.posture === AvatarAction.POSTURE_LAY) { offsetY += scale; } diff --git a/src/nitro/room/object/visualization/avatar/additions/index.ts b/src/nitro/room/object/visualization/avatar/additions/index.ts index 3c3158f7..b2e5dda2 100644 --- a/src/nitro/room/object/visualization/avatar/additions/index.ts +++ b/src/nitro/room/object/visualization/avatar/additions/index.ts @@ -2,6 +2,8 @@ export * from './ExpressionAddition'; export * from './ExpressionAdditionFactory'; export * from './FloatingHeartAddition'; export * from './FloatingIdleZAddition'; +export * from './GameClickTargetAddition'; +export * from './GuideStatusBubbleAddition'; export * from './IAvatarAddition'; export * from './IExpressionAddition'; export * from './MutedBubbleAddition';