Change so many things

This commit is contained in:
Bill 2022-07-18 20:48:54 -04:00
parent 2b0088e384
commit 640b92c615
307 changed files with 3807 additions and 6416 deletions

View File

@ -1,10 +1,10 @@
import { ConfigurationEvent, HabboWebTools, LegacyExternalInterface, Nitro, NitroCommunicationDemoEvent, NitroEvent, NitroLocalizationEvent, NitroVersion, RoomEngineEvent, WebGL } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react';
import { GetCommunication, GetConfiguration, GetNitroInstance, GetUIVersion } from './api';
import { DispatchUiEvent, GetCommunication, GetConfiguration, GetNitroInstance, GetUIVersion } from './api';
import { Base, TransitionAnimation, TransitionAnimationTypes } from './common';
import { LoadingView } from './components/loading/LoadingView';
import { MainView } from './components/main/MainView';
import { DispatchUiEvent, UseConfigurationEvent, UseLocalizationEvent, UseMainEvent, UseRoomEngineEvent } from './hooks';
import { useConfigurationEvent, useLocalizationEvent, useMainEvent, useRoomEngineEvent } from './hooks';
import IntervalWebWorker from './workers/IntervalWebWorker';
import { WorkerBuilder } from './workers/WorkerBuilder';
@ -107,17 +107,17 @@ export const App: FC<{}> = props =>
}
}, []);
UseMainEvent(Nitro.WEBGL_UNAVAILABLE, handler);
UseMainEvent(Nitro.WEBGL_CONTEXT_LOST, handler);
UseMainEvent(NitroCommunicationDemoEvent.CONNECTION_HANDSHAKING, handler);
UseMainEvent(NitroCommunicationDemoEvent.CONNECTION_HANDSHAKE_FAILED, handler);
UseMainEvent(NitroCommunicationDemoEvent.CONNECTION_AUTHENTICATED, handler);
UseMainEvent(NitroCommunicationDemoEvent.CONNECTION_ERROR, handler);
UseMainEvent(NitroCommunicationDemoEvent.CONNECTION_CLOSED, handler);
UseRoomEngineEvent(RoomEngineEvent.ENGINE_INITIALIZED, handler);
UseLocalizationEvent(NitroLocalizationEvent.LOADED, handler);
UseConfigurationEvent(ConfigurationEvent.LOADED, handler);
UseConfigurationEvent(ConfigurationEvent.FAILED, handler);
useMainEvent(Nitro.WEBGL_UNAVAILABLE, handler);
useMainEvent(Nitro.WEBGL_CONTEXT_LOST, handler);
useMainEvent(NitroCommunicationDemoEvent.CONNECTION_HANDSHAKING, handler);
useMainEvent(NitroCommunicationDemoEvent.CONNECTION_HANDSHAKE_FAILED, handler);
useMainEvent(NitroCommunicationDemoEvent.CONNECTION_AUTHENTICATED, handler);
useMainEvent(NitroCommunicationDemoEvent.CONNECTION_ERROR, handler);
useMainEvent(NitroCommunicationDemoEvent.CONNECTION_CLOSED, handler);
useRoomEngineEvent(RoomEngineEvent.ENGINE_INITIALIZED, handler);
useLocalizationEvent(NitroLocalizationEvent.LOADED, handler);
useConfigurationEvent(ConfigurationEvent.LOADED, handler);
useConfigurationEvent(ConfigurationEvent.FAILED, handler);
useEffect(() =>
{

View File

@ -1,6 +1,5 @@
import { AchievementData } from '@nitrots/nitro-renderer';
import { GetAchievementCategoryProgress } from '.';
import { GetAchievementCategoryMaxProgress } from './GetAchievementCategoryMaxProgress';
import { AchievementUtilities } from './AchievementUtilities';
import { IAchievementCategory } from './IAchievementCategory';
export class AchievementCategory implements IAchievementCategory
@ -16,12 +15,12 @@ export class AchievementCategory implements IAchievementCategory
public getProgress(): number
{
return GetAchievementCategoryProgress(this);
return AchievementUtilities.getAchievementCategoryProgress(this);
}
public getMaxProgress(): number
{
return GetAchievementCategoryMaxProgress(this);
return AchievementUtilities.getAchievementCategoryMaxProgress(this);
}
public get code(): string

View File

@ -0,0 +1,97 @@
import { AchievementData } from '@nitrots/nitro-renderer';
import { GetConfiguration, GetLocalization } from '../nitro';
import { IAchievementCategory } from './IAchievementCategory';
export class AchievementUtilities
{
public static getAchievementBadgeCode(achievement: AchievementData): string
{
if(!achievement) return null;
let badgeId = achievement.badgeId;
if(!achievement.finalLevel) badgeId = GetLocalization().getPreviousLevelBadgeId(badgeId);
return badgeId;
}
public static getAchievementCategoryImageUrl(category: IAchievementCategory, progress: number = null, icon: boolean = false): string
{
const imageUrl = GetConfiguration<string>('achievements.images.url');
let imageName = icon ? 'achicon_' : 'achcategory_';
imageName += category.code;
if(progress !== null) imageName += `_${ ((progress > 0) ? 'active' : 'inactive') }`;
return imageUrl.replace('%image%', imageName);
}
public static getAchievementCategoryMaxProgress(category: IAchievementCategory): number
{
if(!category) return 0;
let progress = 0;
for(const achievement of category.achievements)
{
progress += achievement.levelCount;
}
return progress;
}
public static getAchievementCategoryProgress(category: IAchievementCategory): number
{
if(!category) return 0;
let progress = 0;
for(const achievement of category.achievements) progress += (achievement.finalLevel ? achievement.level : (achievement.level - 1));
return progress;
}
public static getAchievementCategoryTotalUnseen(category: IAchievementCategory): number
{
if(!category) return 0;
let unseen = 0;
for(const achievement of category.achievements) ((achievement.unseen > 0) && unseen++);
return unseen;
}
public static getAchievementHasStarted(achievement: AchievementData): boolean
{
if(!achievement) return false;
if(achievement.finalLevel || ((achievement.level - 1) > 0)) return true;
return false;
}
public static getAchievementIsIgnored(achievement: AchievementData): boolean
{
if(!achievement) return false;
const ignored = GetConfiguration<string[]>('achievements.unseen.ignored');
const value = achievement.badgeId.replace(/[0-9]/g, '');
const index = ignored.indexOf(value);
if(index >= 0) return true;
return false;
}
public static getAchievementLevel(achievement: AchievementData): number
{
if(!achievement) return 0;
if(achievement.finalLevel) return achievement.level;
return (achievement.level - 1);
}
}

View File

@ -1,13 +0,0 @@
import { AchievementData } from '@nitrots/nitro-renderer';
import { GetLocalization } from '..';
export const GetAchievementBadgeCode = (achievement: AchievementData) =>
{
if(!achievement) return null;
let badgeId = achievement.badgeId;
if(!achievement.finalLevel) badgeId = GetLocalization().getPreviousLevelBadgeId(badgeId);
return badgeId;
}

View File

@ -1,14 +0,0 @@
import { GetConfiguration, IAchievementCategory } from '..';
export const GetAchievementCategoryImageUrl = (category: IAchievementCategory, progress: number = null, icon: boolean = false) =>
{
const imageUrl = GetConfiguration<string>('achievements.images.url');
let imageName = icon ? 'achicon_' : 'achcategory_';
imageName += category.code;
if(progress !== null) imageName += `_${ ((progress > 0) ? 'active' : 'inactive') }`;
return imageUrl.replace('%image%', imageName);
}

View File

@ -1,15 +0,0 @@
import { IAchievementCategory } from '.';
export const GetAchievementCategoryMaxProgress = (category: IAchievementCategory) =>
{
if(!category) return 0;
let progress = 0;
for(const achievement of category.achievements)
{
progress += achievement.levelCount;
}
return progress;
}

View File

@ -1,12 +0,0 @@
import { IAchievementCategory } from '.';
export const GetAchievementCategoryProgress = (category: IAchievementCategory) =>
{
if(!category) return 0;
let progress = 0;
for(const achievement of category.achievements) progress += (achievement.finalLevel ? achievement.level : (achievement.level - 1));
return progress;
}

View File

@ -1,12 +0,0 @@
import { IAchievementCategory } from '.';
export const GetAchievementCategoryTotalUnseen = (category: IAchievementCategory) =>
{
if(!category) return 0;
let unseen = 0;
for(const achievement of category.achievements) ((achievement.unseen > 0) && unseen++);
return unseen;
}

View File

@ -1,10 +0,0 @@
import { AchievementData } from '@nitrots/nitro-renderer';
export const GetAchievementHasStarted = (achievement: AchievementData) =>
{
if(!achievement) return false;
if(achievement.finalLevel || ((achievement.level - 1) > 0)) return true;
return false;
}

View File

@ -1,15 +0,0 @@
import { AchievementData } from '@nitrots/nitro-renderer';
import { GetConfiguration } from '..';
export const GetAchievementIsIgnored = (achievement: AchievementData) =>
{
if(!achievement) return false;
const ignored = GetConfiguration<string[]>('achievements.unseen.ignored');
const value = achievement.badgeId.replace(/[0-9]/g, '');
const index = ignored.indexOf(value);
if(index >= 0) return true;
return false;
}

View File

@ -1,10 +0,0 @@
import { AchievementData } from '@nitrots/nitro-renderer';
export const GetAchievementLevel = (achievement: AchievementData) =>
{
if(!achievement) return 0;
if(achievement.finalLevel) return achievement.level;
return (achievement.level - 1);
}

View File

@ -1,10 +1,3 @@
export * from './AchievementCategory';
export * from './GetAchievementBadgeCode';
export * from './GetAchievementCategoryImageUrl';
export * from './GetAchievementCategoryMaxProgress';
export * from './GetAchievementCategoryProgress';
export * from './GetAchievementCategoryTotalUnseen';
export * from './GetAchievementHasStarted';
export * from './GetAchievementIsIgnored';
export * from './GetAchievementLevel';
export * from './AchievementUtilities';
export * from './IAchievementCategory';

View File

@ -0,0 +1,3 @@
import { IEventDispatcher, NitroEvent } from '@nitrots/nitro-renderer';
export const DispatchEvent = (eventDispatcher: IEventDispatcher, event: NitroEvent) => eventDispatcher.dispatchEvent(event);

View File

@ -0,0 +1,5 @@
import { NitroEvent } from '@nitrots/nitro-renderer';
import { GetNitroInstance } from '../nitro';
import { DispatchEvent } from './DispatchEvent';
export const DispatchMainEvent = (event: NitroEvent) => DispatchEvent(GetNitroInstance().events, event);

View File

@ -0,0 +1,5 @@
import { NitroEvent } from '@nitrots/nitro-renderer';
import { DispatchEvent } from './DispatchEvent';
import { UI_EVENT_DISPATCHER } from './UI_EVENT_DISPATCHER';
export const DispatchUiEvent = (event: NitroEvent) => DispatchEvent(UI_EVENT_DISPATCHER, event);

4
src/api/events/index.ts Normal file
View File

@ -0,0 +1,4 @@
export * from './DispatchEvent';
export * from './DispatchMainEvent';
export * from './DispatchUiEvent';
export * from './UI_EVENT_DISPATCHER';

View File

@ -1,23 +1,19 @@
export * from './achievements';
export * from './campaign';
export * from './catalog';
export * from './core';
export * from './events';
export * from './friends';
export * from './GetRendererVersion';
export * from './GetUIVersion';
export * from './groups';
export * from './hc-center';
export * from './inventory';
export * from './inventory/unseen';
export * from './navigator';
export * from './nitro';
export * from './nitro/avatar';
export * from './nitro/camera';
export * from './nitro/core';
export * from './nitro/room';
export * from './nitro/room/widgets';
export * from './nitro/room/widgets/events';
export * from './nitro/room/widgets/handlers';
export * from './nitro/room/widgets/messages';
export * from './nitro/session';
export * from './notification';
export * from './purse';

View File

@ -1,6 +1,6 @@
import { IFurnitureItemData, IObjectData } from '@nitrots/nitro-renderer';
import { IFurnitureItem } from '.';
import { GetNitroInstance } from '..';
import { GetNitroInstance } from '../nitro';
import { IFurnitureItem } from './IFurnitureItem';
export class FurnitureItem implements IFurnitureItem
{

View File

@ -1,5 +1,5 @@
import { IObjectData, IRoomEngine } from '@nitrots/nitro-renderer';
import { LocalizeText } from '..';
import { LocalizeText } from '../utils';
import { FurniCategory } from './FurniCategory';
import { FurnitureItem } from './FurnitureItem';
import { IFurnitureItem } from './IFurnitureItem';

View File

@ -1,6 +1,7 @@
import { FurniturePlacePaintComposer, RoomObjectCategory, RoomObjectPlacementSource, RoomObjectType } from '@nitrots/nitro-renderer';
import { FurniCategory, GroupItem } from '.';
import { CreateLinkEvent, GetRoomEngine, GetRoomSessionManager, SendMessageComposer } from '..';
import { CreateLinkEvent, GetRoomEngine, GetRoomSessionManager, SendMessageComposer } from '../nitro';
import { FurniCategory } from './FurniCategory';
import { GroupItem } from './GroupItem';
import { IBotItem } from './IBotItem';
import { IPetItem } from './IPetItem';

View File

@ -2,7 +2,7 @@ import { PetData } from '@nitrots/nitro-renderer';
import { CreateLinkEvent } from '../nitro';
import { cancelRoomObjectPlacement, getPlacingItemId } from './InventoryUtilities';
import { IPetItem } from './IPetItem';
import { UnseenItemCategory } from './unseen';
import { UnseenItemCategory } from './UnseenItemCategory';
export const getAllPetIds = (petItems: IPetItem[]) => petItems.map(item => item.petData.id);

View File

@ -1,4 +1,5 @@
import { LocalizeText, NotificationUtilities } from '..';
import { NotificationUtilities } from '../notification';
import { LocalizeText } from '../utils';
import { TradingNotificationType } from './TradingNotificationType';
export const TradingNotificationMessage = (type: number, otherUsername: string = '') =>

View File

@ -6,10 +6,11 @@ export * from './IBotItem';
export * from './IFurnitureItem';
export * from './InventoryUtilities';
export * from './IPetItem';
export * from './IUnseenItemTracker';
export * from './PetUtilities';
export * from './TradeState';
export * from './TradeUserData';
export * from './TradingNotificationMessage';
export * from './TradingNotificationType';
export * from './TradingUtilities';
export * from './unseen';
export * from './UnseenItemCategory';

View File

@ -1,2 +0,0 @@
export * from './IUnseenItemTracker';
export * from './UnseenItemCategory';

View File

@ -1,5 +1,5 @@
import { INitroCore } from '@nitrots/nitro-renderer';
import { GetNitroInstance } from '../nitro';
import { GetNitroInstance } from '..';
export function GetNitroCore(): INitroCore
{

View File

@ -2,6 +2,7 @@ export * from './AddLinkEventTracker';
export * from './AddWorkerEventTracker';
export * from './avatar';
export * from './camera';
export * from './core';
export * from './CreateLinkEvent';
export * from './GetCommunication';
export * from './GetConfiguration';
@ -12,10 +13,6 @@ export * from './GetTicker';
export * from './RemoveLinkEventTracker';
export * from './RemoveWorkerEventTracker';
export * from './room';
export * from './room/widgets';
export * from './room/widgets/events';
export * from './room/widgets/handlers';
export * from './room/widgets/messages';
export * from './SendMessageComposer';
export * from './SendWorkerEvent';
export * from './session';

View File

@ -8,4 +8,3 @@ export * from './InitializeRoomInstanceRenderingCanvas';
export * from './IsFurnitureSelectionDisabled';
export * from './ProcessRoomObjectOperation';
export * from './SetActiveRoomId';
export * from './widgets';

View File

@ -1,48 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetAvatarInfoEvent extends RoomWidgetUpdateEvent
{
public static AVATAR_INFO: string = 'RWAIE_AVATAR_INFO';
private _userId: number;
private _userName: string;
private _userType: number;
private _roomIndex: number;
private _allowNameChange: boolean;
constructor(userId: number, userName: string, userType: number, roomIndex: number, allowNameChange: boolean)
{
super(RoomWidgetAvatarInfoEvent.AVATAR_INFO);
this._userId = userId;
this._userName = userName;
this._userType = userType;
this._roomIndex = roomIndex;
this._allowNameChange = allowNameChange;
}
public get userId(): number
{
return this._userId;
}
public get userName(): string
{
return this._userName;
}
public get userType(): number
{
return this._userType;
}
public get roomIndex(): number
{
return this._roomIndex;
}
public get allowNameChange(): boolean
{
return this._allowNameChange;
}
}

View File

@ -1,20 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetFloodControlEvent extends RoomWidgetUpdateEvent
{
public static FLOOD_CONTROL: string = 'RWFCE_FLOOD_CONTROL';
private _seconds: number = 0;
constructor(seconds: number)
{
super(RoomWidgetFloodControlEvent.FLOOD_CONTROL);
this._seconds = seconds;
}
public get seconds(): number
{
return this._seconds;
}
}

View File

@ -1,48 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetObjectNameEvent extends RoomWidgetUpdateEvent
{
public static TYPE: string = 'RWONE_TYPE';
private _roomIndex: number;
private _category: number;
private _id: number;
private _name: string;
private _userType: number;
constructor(type: string, roomIndex: number, category: number, id: number, name: string, userType: number)
{
super(type);
this._roomIndex = roomIndex;
this._category = category;
this._id = id;
this._name = name;
this._userType = userType;
}
public get roomIndex(): number
{
return this._roomIndex;
}
public get category(): number
{
return this._category;
}
public get id(): number
{
return this._id;
}
public get name(): string
{
return this._name;
}
public get userType(): number
{
return this._userType;
}
}

View File

@ -1,124 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetUpdateChatEvent extends RoomWidgetUpdateEvent
{
public static CHAT_EVENT: string = 'RWUCE_CHAT_EVENT';
public static CHAT_TYPE_SPEAK: number = 0;
public static CHAT_TYPE_WHISPER: number = 1;
public static CHAT_TYPE_SHOUT: number = 2;
public static CHAT_TYPE_RESPECT: number = 3;
public static CHAT_TYPE_PETRESPECT: number = 4;
public static CHAT_TYPE_NOTIFY: number = 5;
public static CHAT_TYPE_PETTREAT: number = 6;
public static CHAT_TYPE_PETREVIVE: number = 7;
public static CHAT_TYPE_PET_REBREED_FERTILIZE: number = 8;
public static CHAT_TYPE_PET_SPEED_FERTILIZE: number = 9;
public static CHAT_TYPE_BOT_SPEAK: number = 10;
public static CHAT_TYPE_BOT_SHOUT: number = 11;
public static CHAT_TYPE_BOT_WHISPER: number = 12;
private _userId: number;
private _text: string;
private _chatType: number;
private _userName: string;
private _links: string[];
private _userX: number;
private _userY: number;
private _userImage: string;
private _userColor: number;
private _roomId: number;
private _userCategory: number;
private _userType: number;
private _petType: number;
private _styleId: number;
constructor(type: string, userId: number, text: string, userName: string, userCategory: number, userType: number, petType: number, userX: number, userY: number, userImage: string, userColor: number, roomId: number, chatType: number = 0, styleId: number = 0, links: string[] = null)
{
super(type);
this._userId = userId;
this._text = text;
this._chatType = chatType;
this._userName = userName;
this._userCategory = userCategory;
this._userType = userType;
this._petType = petType;
this._links = links;
this._userX = userX;
this._userY = userY;
this._userImage = userImage;
this._userColor = userColor;
this._roomId = roomId;
this._styleId = styleId;
}
public get userId(): number
{
return this._userId;
}
public get text(): string
{
return this._text;
}
public get chatType(): number
{
return this._chatType;
}
public get userName(): string
{
return this._userName;
}
public get userCategory(): number
{
return this._userCategory;
}
public get userType(): number
{
return this._userType;
}
public get petType(): number
{
return this._petType;
}
public get links(): string[]
{
return this._links;
}
public get userX(): number
{
return this._userX;
}
public get userY(): number
{
return this._userY;
}
public get userImage(): string
{
return this._userImage;
}
public get userColor(): number
{
return this._userColor;
}
public get roomId(): number
{
return this._roomId;
}
public get styleId(): number
{
return this._styleId;
}
}

View File

@ -1,34 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetUpdateCreditFurniEvent extends RoomWidgetUpdateEvent
{
public static CREDIT_FURNI_UPDATE: string = 'RWUCFE_CREDIT_FURNI_UPDATE';
private _objectId: number;
private _value: number;
private _furniType: string;
constructor(type: string, objectId: number, value: number, furniType: string)
{
super(type);
this._objectId = objectId;
this._value = value;
this._furniType = furniType;
}
public get objectId(): number
{
return this._objectId;
}
public get value(): number
{
return this._value;
}
public get furniType(): string
{
return this._furniType;
}
}

View File

@ -1,20 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetUpdateDanceStatusEvent extends RoomWidgetUpdateEvent
{
public static UPDATE_DANCE: string = 'RWUDSE_UPDATE_DANCE';
private _isDancing: boolean;
constructor(isDancing: boolean)
{
super(RoomWidgetUpdateDanceStatusEvent.UPDATE_DANCE);
this._isDancing = isDancing;
}
public get isDancing(): boolean
{
return this._isDancing;
}
}

View File

@ -1,20 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetUpdateDecorateModeEvent extends RoomWidgetUpdateEvent
{
public static UPDATE_DECORATE: string = 'RWUDME_UPDATE_DECORATE';
private _isDecorating: boolean;
constructor(isDecorating: boolean)
{
super(RoomWidgetUpdateDecorateModeEvent.UPDATE_DECORATE);
this._isDecorating = isDecorating;
}
public get isDecorating(): boolean
{
return this._isDecorating;
}
}

View File

@ -1,50 +0,0 @@
import { RoomDimmerPreset } from './RoomDimmerPreset';
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetUpdateDimmerEvent extends RoomWidgetUpdateEvent
{
public static PRESETS: string = 'RWUDE_PRESETS';
public static HIDE: string = 'RWUDE_HIDE';
private _selectedPresetId: number = 0;
private _presets: RoomDimmerPreset[];
constructor(type: string)
{
super(type);
this._presets = [];
}
public get presetCount(): number
{
return this._presets.length;
}
public get presets(): RoomDimmerPreset[]
{
return this._presets;
}
public get selectedPresetId(): number
{
return this._selectedPresetId;
}
public set selectedPresetId(k: number)
{
this._selectedPresetId = k;
}
public setPresetValues(id: number, type: number, color: number, brightness: number): void
{
const preset = new RoomDimmerPreset(id, type, color, brightness);
this._presets[(id - 1)] = preset;
}
public getPresetNumber(id: number): RoomDimmerPreset
{
return this._presets[id];
}
}

View File

@ -1,48 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetUpdateDimmerStateEvent extends RoomWidgetUpdateEvent
{
public static DIMMER_STATE: string = 'RWUDSE_DIMMER_STATE';
private _state: number;
private _presetId: number;
private _effectId: number;
private _color: number;
private _brightness: number;
constructor(state: number, presetId: number, effectId: number, color: number, brightness: number)
{
super(RoomWidgetUpdateDimmerStateEvent.DIMMER_STATE);
this._state = state;
this._presetId = presetId;
this._effectId = effectId;
this._color = color;
this._brightness = brightness;
}
public get state(): number
{
return this._state;
}
public get presetId(): number
{
return this._presetId;
}
public get effectId(): number
{
return this._effectId;
}
public get color(): number
{
return this._color;
}
public get brightness(): number
{
return this._brightness;
}
}

View File

@ -1,4 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetUpdateInfostandEvent extends RoomWidgetUpdateEvent
{}

View File

@ -1,21 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetUpdateRoomEngineEvent extends RoomWidgetUpdateEvent
{
public static GAME_MODE: string = 'RWUREE_GAME_MODE';
public static NORMAL_MODE: string = 'RWUREE_NORMAL_MODE';
private _roomId: number = 0;
constructor(type: string, roomId: number)
{
super(type);
this._roomId = roomId;
}
public get roomId(): number
{
return this._roomId;
}
}

View File

@ -1,35 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetUpdateSongEvent extends RoomWidgetUpdateEvent
{
public static PLAYING_CHANGED: string = 'RWUSE_PLAYING_CHANGED';
public static DATA_RECEIVED: string = 'RWUSE_DATA_RECEIVED';
private _songId: number;
private _songName: string;
private _songAuthor: string;
constructor(type: string, songId: number, songName: string, songAuthor: string)
{
super(type);
this._songId = songId;
this._songName = songName;
this._songAuthor = songAuthor;
}
public get songId(): number
{
return this._songId;
}
public get songName(): string
{
return this._songName;
}
public get songAuthor(): string
{
return this._songAuthor;
}
}

View File

@ -1,48 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetUpdateTrophyEvent extends RoomWidgetUpdateEvent
{
public static TROPHY_UPDATE: string = 'RWUTE_TROPHY_UPDATE';
private _color: number;
private _name: string;
private _date: string;
private _message: string;
private _extra: number;
constructor(type: string, color: number, name: string, date: string, message: string, extra: number)
{
super(type);
this._color = color;
this._name = name;
this._date = date;
this._message = message;
this._extra = extra;
}
public get color(): number
{
return this._color;
}
public get name(): string
{
return this._name;
}
public get date(): string
{
return this._date;
}
public get message(): string
{
return this._message;
}
public get extra(): number
{
return this._extra;
}
}

View File

@ -1,11 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetUpdateUserDataEvent extends RoomWidgetUpdateEvent
{
public static USER_DATA_UPDATED: string = 'RWUUDE_USER_DATA_UPDATED';
constructor()
{
super(RoomWidgetUpdateUserDataEvent.USER_DATA_UPDATED);
}
}

View File

@ -1,21 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
import { UseProductItem } from './UseProductItem';
export class RoomWidgetUseProductBubbleEvent extends RoomWidgetUpdateEvent
{
public static USE_PRODUCT_BUBBLES: string = 'RWUPBE_USE_PRODUCT_BUBBLES';
private _items: UseProductItem[];
constructor(type: string, items: UseProductItem[])
{
super(type);
this._items = items;
}
public get items(): UseProductItem[]
{
return this._items;
}
}

View File

@ -1,110 +0,0 @@
import { IQuestion } from '@nitrots/nitro-renderer';
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetWordQuizUpdateEvent extends RoomWidgetUpdateEvent
{
public static readonly NEW_QUESTION = 'RWPUW_NEW_QUESTION';
public static readonly QUESTION_FINISHED = 'RWPUW_QUESION_FINSIHED';
public static readonly QUESTION_ANSWERED = 'RWPUW_QUESTION_ANSWERED';
private _id: number = -1;
private _pollType: string = null;
private _pollId: number = -1;
private _questionId: number = -1;
private _duration: number = -1;
private _question: IQuestion = null;
private _userId: number = -1;
private _value: string;
private _answerCounts: Map<string, number>;
constructor(type: string, id: number)
{
super(type);
this._id = id;
}
public get id(): number
{
return this._id;
}
public get pollType(): string
{
return this._pollType;
}
public set pollType(k: string)
{
this._pollType = k;
}
public get pollId(): number
{
return this._pollId;
}
public set pollId(k: number)
{
this._pollId = k;
}
public get questionId(): number
{
return this._questionId;
}
public set questionId(k: number)
{
this._questionId = k;
}
public get duration(): number
{
return this._duration;
}
public set duration(k: number)
{
this._duration = k;
}
public get question(): IQuestion
{
return this._question;
}
public set question(k: IQuestion)
{
this._question = k;
}
public get userId(): number
{
return this._userId;
}
public set userId(k: number)
{
this._userId = k;
}
public get value(): string
{
return this._value;
}
public set value(k: string)
{
this._value = k;
}
public get answerCounts(): Map<string, number>
{
return this._answerCounts;
}
public set answerCounts(k: Map<string, number>)
{
this._answerCounts = k;
}
}

View File

@ -1,50 +0,0 @@
export class UseProductItem
{
private _id: number;
private _category: number;
private _name: string;
private _requestRoomObjectId: number;
private _targetRoomObjectId: number;
private _requestInventoryStripId: number;
private _replace: boolean;
constructor(id: number, category: number, name: string, requestRoomObjectId: number, targetRoomObjectId: number, requestInventoryStripId: number, replace: boolean)
{
this._id = id;
this._category = category;
this._name = name;
this._requestRoomObjectId = requestRoomObjectId;
this._requestInventoryStripId = requestInventoryStripId;
this._replace = replace;
}
public get id(): number
{
return this._id;
}
public get category(): number
{
return this._category;
}
public get name(): string
{
return this._name;
}
public get requestRoomObjectId(): number
{
return this._requestRoomObjectId;
}
public get requestInventoryStripId(): number
{
return this._requestInventoryStripId;
}
public get replace(): boolean
{
return this._replace;
}
}

View File

@ -1,30 +0,0 @@
export * from './IPhotoData';
export * from './RoomDimmerPreset';
export * from './RoomObjectItem';
export * from './RoomWidgetAvatarInfoEvent';
export * from './RoomWidgetFloodControlEvent';
export * from './RoomWidgetObjectNameEvent';
export * from './RoomWidgetPollUpdateEvent';
export * from './RoomWidgetUpdateBackgroundColorPreviewEvent';
export * from './RoomWidgetUpdateChatEvent';
export * from './RoomWidgetUpdateChatInputContentEvent';
export * from './RoomWidgetUpdateCreditFurniEvent';
export * from './RoomWidgetUpdateDanceStatusEvent';
export * from './RoomWidgetUpdateDecorateModeEvent';
export * from './RoomWidgetUpdateDimmerEvent';
export * from './RoomWidgetUpdateDimmerStateEvent';
export * from './RoomWidgetUpdateEvent';
export * from './RoomWidgetUpdateInfostandEvent';
export * from './RoomWidgetUpdateInfostandFurniEvent';
export * from './RoomWidgetUpdateInfostandPetEvent';
export * from './RoomWidgetUpdateInfostandRentableBotEvent';
export * from './RoomWidgetUpdateInfostandUserEvent';
export * from './RoomWidgetUpdateRentableBotChatEvent';
export * from './RoomWidgetUpdateRoomEngineEvent';
export * from './RoomWidgetUpdateRoomObjectEvent';
export * from './RoomWidgetUpdateSongEvent';
export * from './RoomWidgetUpdateTrophyEvent';
export * from './RoomWidgetUpdateUserDataEvent';
export * from './RoomWidgetUseProductBubbleEvent';
export * from './RoomWidgetWordQuizUpdateEvent';
export * from './UseProductItem';

View File

@ -1,45 +0,0 @@
import { NitroEvent, RoomEngineTriggerWidgetEvent, RoomWidgetEnum } from '@nitrots/nitro-renderer';
import { RoomWidgetUpdateEvent } from '../events';
import { RoomWidgetMessage, RoomWidgetUseProductMessage } from '../messages';
import { RoomWidgetHandler } from './RoomWidgetHandler';
export class FurnitureContextMenuWidgetHandler extends RoomWidgetHandler
{
public processEvent(event: NitroEvent): void
{
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
switch(message.type)
{
case RoomWidgetUseProductMessage.MONSTERPLANT_SEED:
const productMessage = (message as RoomWidgetUseProductMessage);
this.container.roomSession.useMultistateItem(productMessage.objectId);
break;
}
return null;
}
public get type(): string
{
return RoomWidgetEnum.FURNITURE_CONTEXT_MENU;
}
public get eventTypes(): string[]
{
return [
RoomEngineTriggerWidgetEvent.OPEN_FURNI_CONTEXT_MENU,
RoomEngineTriggerWidgetEvent.CLOSE_FURNI_CONTEXT_MENU
];
}
public get messageTypes(): string[]
{
return [
RoomWidgetUseProductMessage.MONSTERPLANT_SEED
];
}
}

View File

@ -1,14 +0,0 @@
import { NitroEvent } from '@nitrots/nitro-renderer';
import { RoomWidgetUpdateEvent } from '../events';
import { RoomWidgetMessage } from '../messages';
import { IRoomWidgetHandlerManager } from './IRoomWidgetHandlerManager';
export interface IRoomWidgetHandler
{
processEvent: (event: NitroEvent) => void;
processWidgetMessage: (message: RoomWidgetMessage) => RoomWidgetUpdateEvent;
container: IRoomWidgetHandlerManager;
type: string;
eventTypes: string[];
messageTypes: string[];
}

View File

@ -1,13 +0,0 @@
import { IEventDispatcher, IRoomSession, NitroEvent } from '@nitrots/nitro-renderer';
import { RoomWidgetUpdateEvent } from '../events';
import { RoomWidgetMessage } from '../messages';
import { IRoomWidgetHandler } from './IRoomWidgetHandler';
export interface IRoomWidgetHandlerManager
{
registerHandler(handler: IRoomWidgetHandler): void;
processEvent(event: NitroEvent): void;
processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent;
roomSession: IRoomSession;
eventDispatcher: IEventDispatcher;
}

View File

@ -1,73 +0,0 @@
import { NitroEvent, RoomSessionPollEvent, RoomWidgetEnum } from '@nitrots/nitro-renderer';
import { RoomWidgetPollUpdateEvent, RoomWidgetUpdateEvent } from '../events';
import { RoomWidgetMessage, RoomWidgetPollMessage } from '../messages';
import { RoomWidgetHandler } from './RoomWidgetHandler';
export class PollWidgetHandler extends RoomWidgetHandler
{
public processEvent(event: NitroEvent): void
{
const pollEvent = (event as RoomSessionPollEvent);
let widgetEvent: RoomWidgetPollUpdateEvent;
switch(event.type)
{
case RoomSessionPollEvent.OFFER:
widgetEvent = new RoomWidgetPollUpdateEvent(RoomWidgetPollUpdateEvent.OFFER, pollEvent.id);
widgetEvent.summary = pollEvent.summary;
widgetEvent.headline = pollEvent.headline;
break;
case RoomSessionPollEvent.ERROR:
widgetEvent = new RoomWidgetPollUpdateEvent(RoomWidgetPollUpdateEvent.ERROR, pollEvent.id);
widgetEvent.summary = pollEvent.summary;
widgetEvent.headline = pollEvent.headline;
break;
case RoomSessionPollEvent.CONTENT:
widgetEvent = new RoomWidgetPollUpdateEvent(RoomWidgetPollUpdateEvent.CONTENT, pollEvent.id);
widgetEvent.startMessage = pollEvent.startMessage;
widgetEvent.endMessage = pollEvent.endMessage;
widgetEvent.numQuestions = pollEvent.numQuestions;
widgetEvent.questionArray = pollEvent.questionArray;
widgetEvent.npsPoll = pollEvent.npsPoll;
break;
}
if(!widgetEvent) return;
this.container.eventDispatcher.dispatchEvent(widgetEvent);
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
const pollMessage = (message as RoomWidgetPollMessage);
switch(message.type)
{
case RoomWidgetPollMessage.START:
this.container.roomSession.sendPollStartMessage(pollMessage.id);
break;
case RoomWidgetPollMessage.REJECT:
this.container.roomSession.sendPollRejectMessage(pollMessage.id);
break;
case RoomWidgetPollMessage.ANSWER:
this.container.roomSession.sendPollAnswerMessage(pollMessage.id, pollMessage.questionId, pollMessage.answers);
break;
}
return null;
}
public get type(): string
{
return RoomWidgetEnum.ROOM_POLL;
}
public get eventTypes(): string[]
{
return [ RoomSessionPollEvent.OFFER, RoomSessionPollEvent.ERROR, RoomSessionPollEvent.CONTENT ];
}
public get messageTypes(): string[]
{
return [ RoomWidgetPollMessage.ANSWER, RoomWidgetPollMessage.REJECT, RoomWidgetPollMessage.START ];
}
}

View File

@ -1,233 +0,0 @@
import { NitroEvent, RoomEngineUseProductEvent, RoomObjectCategory, RoomObjectType, RoomObjectVariable, RoomSessionDanceEvent, RoomSessionPetStatusUpdateEvent, RoomSessionUserDataUpdateEvent, RoomWidgetEnum, SetRelationshipStatusComposer } from '@nitrots/nitro-renderer';
import { SendMessageComposer } from '../../..';
import { GetRoomEngine, GetSessionDataManager, IsOwnerOfFurniture } from '../../../..';
import { MessengerFriend } from '../../../../friends/MessengerFriend';
import { FurniCategory } from '../../../../inventory/FurniCategory';
import { RoomWidgetAvatarInfoEvent, RoomWidgetUpdateDanceStatusEvent, RoomWidgetUpdateEvent, RoomWidgetUpdateUserDataEvent, RoomWidgetUseProductBubbleEvent, UseProductItem } from '../events';
import { RoomWidgetAvatarExpressionMessage, RoomWidgetChangePostureMessage, RoomWidgetDanceMessage, RoomWidgetMessage, RoomWidgetRoomObjectMessage, RoomWidgetUseProductMessage, RoomWidgetUserActionMessage } from '../messages';
import { RoomWidgetHandler } from './RoomWidgetHandler';
export class RoomWidgetAvatarInfoHandler extends RoomWidgetHandler
{
public processEvent(event: NitroEvent): void
{
switch(event.type)
{
case RoomSessionUserDataUpdateEvent.USER_DATA_UPDATED:
this.container.eventDispatcher.dispatchEvent(new RoomWidgetUpdateUserDataEvent());
return;
case RoomSessionDanceEvent.RSDE_DANCE:
const danceEvent = (event as RoomSessionDanceEvent);
let isDancing = false;
const userData = this.container.roomSession.userDataManager.getUserData(GetSessionDataManager().userId);
if(userData && (userData.roomIndex === danceEvent.roomIndex)) isDancing = (danceEvent.danceId !== 0);
this.container.eventDispatcher.dispatchEvent(new RoomWidgetUpdateDanceStatusEvent(isDancing));
return;
case RoomEngineUseProductEvent.USE_PRODUCT_FROM_INVENTORY:
return;
case RoomEngineUseProductEvent.USE_PRODUCT_FROM_ROOM:
this.processUsableRoomObject((event as RoomEngineUseProductEvent).objectId);
return;
case RoomSessionPetStatusUpdateEvent.PET_STATUS_UPDATE:
this.processRoomSessionPetStatusUpdateEvent((event as RoomSessionPetStatusUpdateEvent));
return;
}
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
let userId = 0;
if(message instanceof RoomWidgetUserActionMessage) userId = message.userId;
switch(message.type)
{
case RoomWidgetRoomObjectMessage.GET_OWN_CHARACTER_INFO:
this.processOwnCharacterInfo();
break;
case RoomWidgetUserActionMessage.START_NAME_CHANGE:
// habbo help - start name change
break;
case RoomWidgetUserActionMessage.REQUEST_PET_UPDATE:
break;
case RoomWidgetUseProductMessage.PET_PRODUCT: {
const productMessage = (message as RoomWidgetUseProductMessage);
this.container.roomSession.usePetProduct(productMessage.objectId, productMessage.petId);
break;
}
case RoomWidgetUserActionMessage.HARVEST_PET:
this.container.roomSession.harvestPet(userId);
break;
case RoomWidgetUserActionMessage.COMPOST_PLANT:
this.container.roomSession.compostPlant(userId);
break;
case RoomWidgetDanceMessage.DANCE: {
const danceMessage = (message as RoomWidgetDanceMessage);
this.container.roomSession.sendDanceMessage(danceMessage.style);
break;
}
case RoomWidgetAvatarExpressionMessage.AVATAR_EXPRESSION: {
const expressionMessage = (message as RoomWidgetAvatarExpressionMessage);
this.container.roomSession.sendExpressionMessage(expressionMessage.animation.ordinal)
break;
}
case RoomWidgetChangePostureMessage.CHANGE_POSTURE: {
const postureMessage = (message as RoomWidgetChangePostureMessage);
this.container.roomSession.sendPostureMessage(postureMessage.posture);
break;
}
case RoomWidgetUserActionMessage.RELATIONSHIP_NONE: {
SendMessageComposer(new SetRelationshipStatusComposer(userId, MessengerFriend.RELATIONSHIP_NONE));
break;
}
case RoomWidgetUserActionMessage.RELATIONSHIP_HEART: {
SendMessageComposer(new SetRelationshipStatusComposer(userId, MessengerFriend.RELATIONSHIP_HEART));
break;
}
case RoomWidgetUserActionMessage.RELATIONSHIP_SMILE: {
SendMessageComposer(new SetRelationshipStatusComposer(userId, MessengerFriend.RELATIONSHIP_SMILE));
break;
}
case RoomWidgetUserActionMessage.RELATIONSHIP_BOBBA: {
SendMessageComposer(new SetRelationshipStatusComposer(userId, MessengerFriend.RELATIONSHIP_BOBBA));
break;
}
}
return null;
}
private processOwnCharacterInfo(): void
{
const userId = GetSessionDataManager().userId;
const userName = GetSessionDataManager().userName;
const allowNameChange = GetSessionDataManager().canChangeName;
const userData = this.container.roomSession.userDataManager.getUserData(userId);
if(!userData) return;
this.container.eventDispatcher.dispatchEvent(new RoomWidgetAvatarInfoEvent(userId, userName, userData.type, userData.roomIndex, allowNameChange));
}
private processUsableRoomObject(objectId: number): void
{
const roomId = this.container.roomSession.roomId;
const roomObject = GetRoomEngine().getRoomObject(roomId, objectId, RoomObjectCategory.FLOOR);
if(!roomObject || !IsOwnerOfFurniture(roomObject)) return;
const ownerId = roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_OWNER_ID);
const typeId = roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_TYPE_ID);
const furniData = GetSessionDataManager().getFloorItemData(typeId);
const parts = furniData.customParams.split(' ');
const part = (parts.length ? parseInt(parts[0]) : -1);
if(part === -1) return;
this.processUseableProduct(roomId, objectId, part, furniData.specialType, ownerId);
}
private processUseableProduct(roomId: number, objectId: number, part: number, specialType: number, ownerId: number, arg6 = -1): void
{
const useProductBubbles: UseProductItem[] = [];
const roomObjects = GetRoomEngine().getRoomObjects(roomId, RoomObjectCategory.UNIT);
for(const roomObject of roomObjects)
{
const userData = this.container.roomSession.userDataManager.getUserDataByIndex(roomObject.id);
let replace = false;
if(!userData || (userData.type !== RoomObjectType.PET))
{
}
else
{
if(userData.ownerId === ownerId)
{
if(userData.hasSaddle && (specialType === FurniCategory.PET_SADDLE)) replace = true;
const figureParts = userData.figure.split(' ');
const figurePart = (figureParts.length ? parseInt(figureParts[0]) : -1);
if(figurePart === part)
{
if(specialType === FurniCategory.MONSTERPLANT_REVIVAL)
{
if(!userData.canRevive) continue;
}
if(specialType === FurniCategory.MONSTERPLANT_REBREED)
{
if((userData.petLevel < 7) || userData.canRevive || userData.canBreed) continue;
}
if(specialType === FurniCategory.MONSTERPLANT_FERTILIZE)
{
if((userData.petLevel >= 7) || userData.canRevive) continue;
}
useProductBubbles.push(new UseProductItem(userData.roomIndex, RoomObjectCategory.UNIT, userData.name, objectId, roomObject.id, arg6, replace));
}
}
}
}
if(useProductBubbles.length) this.container.eventDispatcher.dispatchEvent(new RoomWidgetUseProductBubbleEvent(RoomWidgetUseProductBubbleEvent.USE_PRODUCT_BUBBLES, useProductBubbles));
}
private processRoomSessionPetStatusUpdateEvent(event: RoomSessionPetStatusUpdateEvent): void
{
}
public get type(): string
{
return RoomWidgetEnum.AVATAR_INFO;
}
public get eventTypes(): string[]
{
return [
RoomSessionUserDataUpdateEvent.USER_DATA_UPDATED,
RoomSessionDanceEvent.RSDE_DANCE,
RoomEngineUseProductEvent.USE_PRODUCT_FROM_INVENTORY,
RoomEngineUseProductEvent.USE_PRODUCT_FROM_ROOM,
RoomSessionPetStatusUpdateEvent.PET_STATUS_UPDATE
];
}
// UserNameUpdateEvent.UNUE_NAME_UPDATED
// RoomSessionNestBreedingSuccessEvent.RSPFUE_NEST_BREEDING_SUCCESS
// RoomSessionPetLevelUpdateEvent.RSPLUE_PET_LEVEL_UPDATE
public get messageTypes(): string[]
{
return [
RoomWidgetRoomObjectMessage.GET_OWN_CHARACTER_INFO,
RoomWidgetUserActionMessage.START_NAME_CHANGE,
RoomWidgetUserActionMessage.REQUEST_PET_UPDATE,
RoomWidgetUseProductMessage.PET_PRODUCT,
RoomWidgetUserActionMessage.REQUEST_BREED_PET,
RoomWidgetUserActionMessage.HARVEST_PET,
RoomWidgetUserActionMessage.REVIVE_PET,
RoomWidgetUserActionMessage.COMPOST_PLANT,
RoomWidgetDanceMessage.DANCE,
RoomWidgetAvatarExpressionMessage.AVATAR_EXPRESSION,
RoomWidgetChangePostureMessage.CHANGE_POSTURE,
RoomWidgetUserActionMessage.RELATIONSHIP_NONE,
RoomWidgetUserActionMessage.RELATIONSHIP_HEART,
RoomWidgetUserActionMessage.RELATIONSHIP_SMILE,
RoomWidgetUserActionMessage.RELATIONSHIP_BOBBA
];
}
}

View File

@ -1,210 +0,0 @@
import { AvatarFigurePartType, AvatarScaleType, AvatarSetType, IAvatarImageListener, NitroEvent, PetFigureData, RoomObjectCategory, RoomObjectType, RoomObjectVariable, RoomSessionChatEvent, RoomUserData, RoomWidgetEnum, SystemChatStyleEnum, TextureUtils, Vector3d } from '@nitrots/nitro-renderer';
import { GetAvatarRenderManager, GetConfigurationManager, GetRoomEngine, PlaySound } from '../../../..';
import { LocalizeText } from '../../../../utils/LocalizeText';
import { GetRoomObjectScreenLocation } from '../../GetRoomObjectScreenLocation';
import { RoomWidgetUpdateChatEvent, RoomWidgetUpdateEvent } from '../events';
import { RoomWidgetMessage } from '../messages';
import { RoomWidgetHandler } from './RoomWidgetHandler';
export class RoomWidgetChatHandler extends RoomWidgetHandler implements IAvatarImageListener
{
private _avatarColorCache: Map<string, number> = new Map();
private _avatarImageCache: Map<string, string> = new Map();
private _petImageCache: Map<string, string> = new Map();
public processEvent(event: NitroEvent): void
{
switch(event.type)
{
case RoomSessionChatEvent.CHAT_EVENT: {
const chatEvent = (event as RoomSessionChatEvent);
const roomObject = GetRoomEngine().getRoomObject(chatEvent.session.roomId, chatEvent.objectId, RoomObjectCategory.UNIT);
const objectLocation = roomObject ? roomObject.getLocation() : new Vector3d();
const bubbleLocation = GetRoomObjectScreenLocation(chatEvent.session.roomId, roomObject?.id, RoomObjectCategory.UNIT);
const userData = roomObject ? this.container.roomSession.userDataManager.getUserDataByIndex(chatEvent.objectId) : new RoomUserData(-1);
let username = '';
let avatarColor = 0;
let imageUrl: string = null;
let chatType = chatEvent.chatType;
let styleId = chatEvent.style;
let userType = 0;
let petType = -1;
let text = chatEvent.message;
if(userData)
{
userType = userData.type;
const figure = userData.figure;
switch(userType)
{
case RoomObjectType.PET:
imageUrl = this.getPetImage(figure, 2, true, 64, roomObject.model.getValue<string>(RoomObjectVariable.FIGURE_POSTURE));
petType = new PetFigureData(figure).typeId;
break;
case RoomObjectType.USER:
imageUrl = this.getUserImage(figure);
break;
case RoomObjectType.RENTABLE_BOT:
case RoomObjectType.BOT:
styleId = SystemChatStyleEnum.BOT;
break;
}
avatarColor = this._avatarColorCache.get(figure);
username = userData.name;
}
switch(chatType)
{
case RoomSessionChatEvent.CHAT_TYPE_RESPECT:
text = LocalizeText('widgets.chatbubble.respect', [ 'username' ], [ username ]);
if(GetConfigurationManager().getValue('respect.options')['enabled'])
PlaySound(GetConfigurationManager().getValue('respect.options')['sound'])
break;
case RoomSessionChatEvent.CHAT_TYPE_PETREVIVE:
case RoomSessionChatEvent.CHAT_TYPE_PET_REBREED_FERTILIZE:
case RoomSessionChatEvent.CHAT_TYPE_PET_SPEED_FERTILIZE: {
let textKey = 'widget.chatbubble.petrevived';
if(chatType === RoomSessionChatEvent.CHAT_TYPE_PET_REBREED_FERTILIZE)
{
textKey = 'widget.chatbubble.petrefertilized;';
}
else if(chatType === RoomSessionChatEvent.CHAT_TYPE_PET_SPEED_FERTILIZE)
{
textKey = 'widget.chatbubble.petspeedfertilized';
}
let targetUserName: string = null;
const newRoomObject = GetRoomEngine().getRoomObject(chatEvent.session.roomId, chatEvent.extraParam, RoomObjectCategory.UNIT);
if(newRoomObject)
{
const newUserData = this.container.roomSession.userDataManager.getUserDataByIndex(roomObject.id);
if(newUserData) targetUserName = newUserData.name;
}
text = LocalizeText(textKey, [ 'petName', 'userName' ], [ username, targetUserName ]);
break;
}
case RoomSessionChatEvent.CHAT_TYPE_PETRESPECT:
text = LocalizeText('widget.chatbubble.petrespect', [ 'petname' ], [ username ]);
break;
case RoomSessionChatEvent.CHAT_TYPE_PETTREAT:
text = LocalizeText('widget.chatbubble.pettreat', [ 'petname' ], [ username ]);
break;
case RoomSessionChatEvent.CHAT_TYPE_HAND_ITEM_RECEIVED:
text = LocalizeText('widget.chatbubble.handitem', [ 'username', 'handitem' ], [ username, LocalizeText(('handitem' + chatEvent.extraParam)) ]);
break;
case RoomSessionChatEvent.CHAT_TYPE_MUTE_REMAINING: {
const hours = ((chatEvent.extraParam > 0) ? Math.floor((chatEvent.extraParam / 3600)) : 0).toString();
const minutes = ((chatEvent.extraParam > 0) ? Math.floor((chatEvent.extraParam % 3600) / 60) : 0).toString();
const seconds = (chatEvent.extraParam % 60).toString();
text = LocalizeText('widget.chatbubble.mutetime', [ 'hours', 'minutes', 'seconds' ], [ hours, minutes, seconds ]);
break;
}
}
this.container.eventDispatcher.dispatchEvent(new RoomWidgetUpdateChatEvent(RoomWidgetUpdateChatEvent.CHAT_EVENT, userData.roomIndex, text, username, RoomObjectCategory.UNIT, userType, petType, bubbleLocation.x, bubbleLocation.y, imageUrl, avatarColor, chatEvent.session.roomId, chatType, styleId, []));
return;
}
}
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
return null;
}
public getUserImage(figure: string): string
{
let existing = this._avatarImageCache.get(figure);
if(!existing)
{
existing = this.setFigureImage(figure);
}
return existing;
}
private setFigureImage(figure: string): string
{
const avatarImage = GetAvatarRenderManager().createAvatarImage(figure, AvatarScaleType.LARGE, null, this);
if(!avatarImage) return;
const image = avatarImage.getCroppedImage(AvatarSetType.HEAD);
const color = avatarImage.getPartColor(AvatarFigurePartType.CHEST);
this._avatarColorCache.set(figure, ((color && color.rgb) || 16777215));
avatarImage.dispose();
this._avatarImageCache.set(figure, image.src);
return image.src;
}
private getPetImage(figure: string, direction: number, _arg_3: boolean, scale: number = 64, posture: string = null): string
{
let existing = this._petImageCache.get((figure + posture));
if(existing) return existing;
const figureData = new PetFigureData(figure);
const typeId = figureData.typeId;
const image = GetRoomEngine().getRoomObjectPetImage(typeId, figureData.paletteId, figureData.color, new Vector3d((direction * 45)), scale, null, false, 0, figureData.customParts, posture);
if(image)
{
existing = TextureUtils.generateImageUrl(image.data);
this._petImageCache.set((figure + posture), existing);
}
return existing;
}
public resetFigure(figure: string): void
{
this.setFigureImage(figure);
}
public dispose(): void
{
}
public get disposed(): boolean
{
return false;
}
public get type(): string
{
return RoomWidgetEnum.CHAT_WIDGET;
}
public get eventTypes(): string[]
{
return [
RoomSessionChatEvent.CHAT_EVENT
];
}
public get messageTypes(): string[]
{
return [];
}
}

View File

@ -1,233 +0,0 @@
import { AvatarExpressionEnum, HabboClubLevelEnum, NitroEvent, RoomControllerLevel, RoomRotatingEffect, RoomSessionChatEvent, RoomSettingsComposer, RoomShakingEffect, RoomWidgetEnum, RoomZoomEvent, TextureUtils } from '@nitrots/nitro-renderer';
import { GetClubMemberLevel, GetConfiguration, GetNitroInstance, SendMessageComposer } from '../../..';
import { GetRoomEngine, GetSessionDataManager, LocalizeText, NotificationUtilities } from '../../../..';
import { CreateLinkEvent } from '../../../CreateLinkEvent';
import { RoomWidgetFloodControlEvent, RoomWidgetUpdateEvent } from '../events';
import { RoomWidgetChatMessage, RoomWidgetChatSelectAvatarMessage, RoomWidgetChatTypingMessage, RoomWidgetMessage } from '../messages';
import { RoomWidgetHandler } from './RoomWidgetHandler';
export class RoomWidgetChatInputHandler extends RoomWidgetHandler
{
public processEvent(event: NitroEvent): void
{
switch(event.type)
{
case RoomSessionChatEvent.FLOOD_EVENT: {
const floodEvent = (event as RoomSessionChatEvent);
this.container.eventDispatcher.dispatchEvent(new RoomWidgetFloodControlEvent(parseInt(floodEvent.message)));
}
}
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
switch(message.type)
{
case RoomWidgetChatTypingMessage.TYPING_STATUS: {
const typingMessage = (message as RoomWidgetChatTypingMessage);
this.container.roomSession.sendChatTypingMessage(typingMessage.isTyping);
break;
}
case RoomWidgetChatMessage.MESSAGE_CHAT: {
const chatMessage = (message as RoomWidgetChatMessage);
if(chatMessage.text === '') return null;
let text = chatMessage.text;
const parts = text.split(' ');
if(parts.length > 0)
{
const firstPart = parts[0];
let secondPart = '';
if(parts.length > 1) secondPart = parts[1];
if((firstPart.charAt(0) === ':') && (secondPart === 'x'))
{
const selectedAvatarId = GetRoomEngine().selectedAvatarId;
if(selectedAvatarId > -1)
{
const userData = this.container.roomSession.userDataManager.getUserDataByIndex(selectedAvatarId);
if(userData)
{
secondPart = userData.name;
text = chatMessage.text.replace(' x', (' ' + userData.name));
}
}
}
switch(firstPart.toLowerCase())
{
case ':shake':
RoomShakingEffect.init(2500, 5000);
RoomShakingEffect.turnVisualizationOn();
return null;
case ':rotate':
RoomRotatingEffect.init(2500, 5000);
RoomRotatingEffect.turnVisualizationOn();
return null;
case ':d':
case ';d':
if(GetClubMemberLevel() === HabboClubLevelEnum.VIP)
{
this.container.roomSession.sendExpressionMessage(AvatarExpressionEnum.LAUGH.ordinal);
}
break;
case 'o/':
case '_o/':
this.container.roomSession.sendExpressionMessage(AvatarExpressionEnum.WAVE.ordinal);
return null;
case ':kiss':
if(GetClubMemberLevel() === HabboClubLevelEnum.VIP)
{
this.container.roomSession.sendExpressionMessage(AvatarExpressionEnum.BLOW.ordinal);
return null;
}
break;
case ':jump':
if(GetClubMemberLevel() === HabboClubLevelEnum.VIP)
{
this.container.roomSession.sendExpressionMessage(AvatarExpressionEnum.JUMP.ordinal);
return null;
}
break;
case ':idle':
this.container.roomSession.sendExpressionMessage(AvatarExpressionEnum.IDLE.ordinal);
return null;
case '_b':
this.container.roomSession.sendExpressionMessage(AvatarExpressionEnum.RESPECT.ordinal);
return null;
case ':sign':
this.container.roomSession.sendSignMessage(parseInt(secondPart));
return null;
case ':iddqd':
case ':flip':
GetRoomEngine().events.dispatchEvent(new RoomZoomEvent(this.container.roomSession.roomId, -1, true));
return null;
case ':zoom':
GetRoomEngine().events.dispatchEvent(new RoomZoomEvent(this.container.roomSession.roomId, parseFloat(secondPart), false));
return null;
case ':screenshot':
const texture = GetRoomEngine().createTextureFromRoom(this.container.roomSession.roomId, 1);
const image = new Image();
image.src = TextureUtils.generateImageUrl(texture);
const newWindow = window.open('');
newWindow.document.write(image.outerHTML);
return null;
case ':pickall':
if(this.container.roomSession.isRoomOwner || GetSessionDataManager().isModerator)
{
NotificationUtilities.confirm(LocalizeText('room.confirm.pick_all'), () =>
{
GetSessionDataManager().sendSpecialCommandMessage(':pickall');
},
null, null, null, LocalizeText('generic.alert.title'));
}
return null;
case ':furni':
CreateLinkEvent('furni-chooser/');
return null;
case ':chooser':
CreateLinkEvent('user-chooser/');
return null;
case ':floor':
case ':bcfloor':
if(this.container.roomSession.controllerLevel >= RoomControllerLevel.ROOM_OWNER) CreateLinkEvent('floor-editor/show');
return null;
case ':togglefps': {
if(GetNitroInstance().ticker.maxFPS > 0) GetNitroInstance().ticker.maxFPS = 0;
else GetNitroInstance().ticker.maxFPS = GetConfiguration('system.animation.fps');
return null;
}
case ':client':
case ':nitro':
case ':billsonnn':
NotificationUtilities.showNitroAlert();
return null;
case ':settings':
if(this.container.roomSession.isRoomOwner || GetSessionDataManager().isModerator)
{
SendMessageComposer(new RoomSettingsComposer(this.container.roomSession.roomId));
}
return null;
}
}
const styleId = chatMessage.styleId;
if(this.container && this.container.roomSession)
{
switch(chatMessage.chatType)
{
case RoomWidgetChatMessage.CHAT_DEFAULT:
this.container.roomSession.sendChatMessage(text, styleId);
break;
case RoomWidgetChatMessage.CHAT_SHOUT:
this.container.roomSession.sendShoutMessage(text, styleId);
break;
case RoomWidgetChatMessage.CHAT_WHISPER:
this.container.roomSession.sendWhisperMessage(chatMessage.recipientName, text, styleId);
break;
}
}
break;
}
case RoomWidgetChatSelectAvatarMessage.MESSAGE_SELECT_AVATAR: {
const selectedEvent = (message as RoomWidgetChatSelectAvatarMessage);
GetRoomEngine().setSelectedAvatar(selectedEvent.roomId, selectedEvent.objectId);
break;
}
}
return null;
}
public get type(): string
{
return RoomWidgetEnum.CHAT_INPUT_WIDGET;
}
public get eventTypes(): string[]
{
return [
RoomSessionChatEvent.FLOOD_EVENT
];
}
public get messageTypes(): string[]
{
return [
RoomWidgetChatTypingMessage.TYPING_STATUS,
RoomWidgetChatMessage.MESSAGE_CHAT,
RoomWidgetChatSelectAvatarMessage.MESSAGE_SELECT_AVATAR
];
}
}

View File

@ -1,30 +0,0 @@
import { NitroEvent } from '@nitrots/nitro-renderer';
import { RoomWidgetUpdateEvent } from '../events';
import { RoomWidgetMessage } from '../messages';
import { IRoomWidgetHandler } from './IRoomWidgetHandler';
import { IRoomWidgetHandlerManager } from './IRoomWidgetHandlerManager';
export abstract class RoomWidgetHandler implements IRoomWidgetHandler
{
private _container: IRoomWidgetHandlerManager = null;
public abstract processEvent(event: NitroEvent): void;
public abstract processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent;
public get container(): IRoomWidgetHandlerManager
{
return this._container;
}
public set container(container: IRoomWidgetHandlerManager)
{
this._container = container;
}
public abstract get type(): string;
public abstract get eventTypes(): string[];
public abstract get messageTypes(): string[];
}

View File

@ -1,125 +0,0 @@
import { IEventDispatcher, IRoomSession, NitroEvent, RoomEngineTriggerWidgetEvent } from '@nitrots/nitro-renderer';
import { RoomWidgetUpdateEvent } from '../events';
import { RoomWidgetMessage } from '../messages';
import { IRoomWidgetHandler } from './IRoomWidgetHandler';
import { IRoomWidgetHandlerManager } from './IRoomWidgetHandlerManager';
export class RoomWidgetHandlerManager implements IRoomWidgetHandlerManager
{
private _roomSession: IRoomSession;
private _eventDispatcher: IEventDispatcher;
private _handlers: IRoomWidgetHandler[] = [];
private _eventMap: Map<string, IRoomWidgetHandler[]> = new Map();
private _messageMap: Map<string, IRoomWidgetHandler[]> = new Map();
constructor(roomSession: IRoomSession, eventDispatcher: IEventDispatcher)
{
this._roomSession = roomSession;
this._eventDispatcher = eventDispatcher;
}
public registerHandler(handler: IRoomWidgetHandler): void
{
const eventTypes = handler.eventTypes;
eventTypes.push(RoomEngineTriggerWidgetEvent.OPEN_WIDGET, RoomEngineTriggerWidgetEvent.CLOSE_WIDGET);
if(eventTypes && eventTypes.length)
{
for(const name of eventTypes)
{
if(!name) continue;
let events = this._eventMap.get(name);
if(!events)
{
events = [];
this._eventMap.set(name, events);
}
events.push(handler);
}
}
const messageTypes = handler.messageTypes;
if(messageTypes && messageTypes.length)
{
for(const name of messageTypes)
{
if(!name) continue;
let messages = this._messageMap.get(name);
if(!messages)
{
messages = [];
this._messageMap.set(name, messages);
}
messages.push(handler);
}
}
handler.container = this;
this._handlers.push(handler);
}
public processEvent(event: NitroEvent): void
{
const handlers = this._eventMap.get(event.type);
if(!handlers || !handlers.length) return null;
for(const handler of handlers)
{
if(!handler) continue;
let dispatch = true;
if((event.type === RoomEngineTriggerWidgetEvent.OPEN_WIDGET) || (event.type === RoomEngineTriggerWidgetEvent.CLOSE_WIDGET))
{
if(event instanceof RoomEngineTriggerWidgetEvent)
{
dispatch = (handler.type === event.widget);
}
}
if(dispatch) handler.processEvent(event);
}
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
const handlers = this._messageMap.get(message.type);
if(!handlers || !handlers.length) return null;
for(const handler of handlers)
{
if(!handler) continue;
const update = handler.processWidgetMessage(message);
if(!update) continue;
return update;
}
return null;
}
public get roomSession(): IRoomSession
{
return this._roomSession;
}
public get eventDispatcher(): IEventDispatcher
{
return this._eventDispatcher;
}
}

View File

@ -1,784 +0,0 @@
import { IFurnitureData, NitroEvent, ObjectDataFactory, PetFigureData, PetRespectComposer, PetSupplementComposer, PetType, RoomControllerLevel, RoomModerationSettings, RoomObjectCategory, RoomObjectOperationType, RoomObjectType, RoomObjectVariable, RoomSessionFavoriteGroupUpdateEvent, RoomSessionPetInfoUpdateEvent, RoomSessionUserBadgesEvent, RoomSessionUserFigureUpdateEvent, RoomTradingLevelEnum, RoomUnitDropHandItemComposer, RoomUnitGiveHandItemComposer, RoomUnitGiveHandItemPetComposer, RoomUserData, RoomWidgetEnum, RoomWidgetEnumItemExtradataParameter, TradingOpenComposer, Vector3d } from '@nitrots/nitro-renderer';
import { SendMessageComposer } from '../../..';
import { GetNitroInstance, GetRoomEngine, GetSessionDataManager, IsOwnerOfFurniture } from '../../../..';
import { PetSupplementEnum } from '../../../../../components/room/widgets/avatar-info/common/PetSupplementEnum';
import { HelpReportUserEvent, WiredSelectObjectEvent } from '../../../../../events';
import { DispatchUiEvent } from '../../../../../hooks';
import { LocalizeText } from '../../../../utils/LocalizeText';
import { RoomWidgetObjectNameEvent, RoomWidgetUpdateChatInputContentEvent, RoomWidgetUpdateEvent, RoomWidgetUpdateInfostandFurniEvent, RoomWidgetUpdateInfostandPetEvent, RoomWidgetUpdateInfostandRentableBotEvent, RoomWidgetUpdateInfostandUserEvent } from '../events';
import { RoomWidgetChangeMottoMessage, RoomWidgetFurniActionMessage, RoomWidgetMessage, RoomWidgetRoomObjectMessage, RoomWidgetUserActionMessage } from '../messages';
import { RoomWidgetHandler } from './RoomWidgetHandler';
export class RoomWidgetInfostandHandler extends RoomWidgetHandler
{
public processEvent(event: NitroEvent): void
{
switch(event.type)
{
case RoomSessionPetInfoUpdateEvent.PET_INFO:
this.processPetInfoEvent((event as RoomSessionPetInfoUpdateEvent));
return;
case RoomSessionUserBadgesEvent.RSUBE_BADGES:
this.container.eventDispatcher.dispatchEvent(event);
return;
case RoomSessionUserFigureUpdateEvent.USER_FIGURE:
this.container.eventDispatcher.dispatchEvent(event);
return;
case RoomSessionFavoriteGroupUpdateEvent.FAVOURITE_GROUP_UPDATE:
this.container.eventDispatcher.dispatchEvent(event);
return;
}
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
let userId = 0;
let userData: RoomUserData = null;
let objectId = 0;
let category = 0;
if(message instanceof RoomWidgetUserActionMessage)
{
userId = message.userId;
const petMessages = [
RoomWidgetUserActionMessage.REQUEST_PET_UPDATE,
RoomWidgetUserActionMessage.RESPECT_PET,
RoomWidgetUserActionMessage.PICKUP_PET,
RoomWidgetUserActionMessage.MOUNT_PET,
RoomWidgetUserActionMessage.TOGGLE_PET_RIDING_PERMISSION,
RoomWidgetUserActionMessage.TOGGLE_PET_BREEDING_PERMISSION,
RoomWidgetUserActionMessage.DISMOUNT_PET,
RoomWidgetUserActionMessage.SADDLE_OFF,
RoomWidgetUserActionMessage.GIVE_CARRY_ITEM_TO_PET,
RoomWidgetUserActionMessage.GIVE_WATER_TO_PET,
RoomWidgetUserActionMessage.GIVE_LIGHT_TO_PET,
RoomWidgetUserActionMessage.TREAT_PET
];
if(petMessages.indexOf(message.type) >= 0)
{
userData = this.container.roomSession.userDataManager.getPetData(userId);
}
else
{
userData = this.container.roomSession.userDataManager.getUserData(userId);
}
if(!userData) return null;
}
else if(message instanceof RoomWidgetFurniActionMessage)
{
objectId = message.furniId;
category = message.furniCategory;
}
switch(message.type)
{
case RoomWidgetRoomObjectMessage.GET_OBJECT_NAME:
return this.processObjectNameMessage((message as RoomWidgetRoomObjectMessage));
case RoomWidgetRoomObjectMessage.GET_OBJECT_INFO:
return this.processObjectInfoMessage((message as RoomWidgetRoomObjectMessage));
case RoomWidgetUserActionMessage.RESPECT_USER:
GetSessionDataManager().giveRespect(userId);
break;
case RoomWidgetUserActionMessage.RESPECT_PET:
GetSessionDataManager().givePetRespect(userId);
break;
case RoomWidgetUserActionMessage.WHISPER_USER:
this.container.eventDispatcher.dispatchEvent(new RoomWidgetUpdateChatInputContentEvent(RoomWidgetUpdateChatInputContentEvent.WHISPER, userData.name));
break;
case RoomWidgetUserActionMessage.IGNORE_USER:
GetSessionDataManager().ignoreUser(userData.name);
break;
case RoomWidgetUserActionMessage.UNIGNORE_USER:
GetSessionDataManager().unignoreUser(userData.name);
break;
case RoomWidgetUserActionMessage.KICK_USER:
this.container.roomSession.sendKickMessage((message as RoomWidgetUserActionMessage).userId);
break;
case RoomWidgetUserActionMessage.BAN_USER_DAY:
case RoomWidgetUserActionMessage.BAN_USER_HOUR:
case RoomWidgetUserActionMessage.BAN_USER_PERM:
this.container.roomSession.sendBanMessage((message as RoomWidgetUserActionMessage).userId, message.type);
break;
case RoomWidgetUserActionMessage.MUTE_USER_2MIN:
this.container.roomSession.sendMuteMessage((message as RoomWidgetUserActionMessage).userId, 2);
break;
case RoomWidgetUserActionMessage.MUTE_USER_5MIN:
this.container.roomSession.sendMuteMessage((message as RoomWidgetUserActionMessage).userId, 5);
break;
case RoomWidgetUserActionMessage.MUTE_USER_10MIN:
this.container.roomSession.sendMuteMessage((message as RoomWidgetUserActionMessage).userId, 10);
break;
case RoomWidgetUserActionMessage.GIVE_RIGHTS:
this.container.roomSession.sendGiveRightsMessage((message as RoomWidgetUserActionMessage).userId);
break;
case RoomWidgetUserActionMessage.TAKE_RIGHTS:
this.container.roomSession.sendTakeRightsMessage((message as RoomWidgetUserActionMessage).userId);
break;
case RoomWidgetUserActionMessage.START_TRADING:
SendMessageComposer(new TradingOpenComposer(userData.roomIndex));
break;
// case RoomWidgetUserActionMessage.RWUAM_OPEN_HOME_PAGE:
// this._container.sessionDataManager._Str_21275((message as RoomWidgetUserActionMessage).userId, _local_3.name);
// break;
case RoomWidgetUserActionMessage.PICKUP_PET:
this.container.roomSession.pickupPet(userId);
break;
case RoomWidgetUserActionMessage.MOUNT_PET:
this.container.roomSession.mountPet(userId);
break;
case RoomWidgetUserActionMessage.TOGGLE_PET_RIDING_PERMISSION:
this.container.roomSession.togglePetRiding(userId);
break;
case RoomWidgetUserActionMessage.TOGGLE_PET_BREEDING_PERMISSION:
this.container.roomSession.togglePetBreeding(userId);
break;
case RoomWidgetUserActionMessage.DISMOUNT_PET:
this.container.roomSession.dismountPet(userId);
break;
case RoomWidgetUserActionMessage.SADDLE_OFF:
this.container.roomSession.removePetSaddle(userId);
break;
case RoomWidgetUserActionMessage.PASS_CARRY_ITEM:
SendMessageComposer(new RoomUnitGiveHandItemComposer(userId));
break;
case RoomWidgetUserActionMessage.GIVE_CARRY_ITEM_TO_PET:
SendMessageComposer(new RoomUnitGiveHandItemPetComposer(userId));
break;
case RoomWidgetUserActionMessage.GIVE_WATER_TO_PET:
SendMessageComposer(new PetSupplementComposer(userId, PetSupplementEnum.WATER));
break;
case RoomWidgetUserActionMessage.GIVE_LIGHT_TO_PET:
SendMessageComposer(new PetSupplementComposer(userId, PetSupplementEnum.LIGHT));
break;
case RoomWidgetUserActionMessage.TREAT_PET:
SendMessageComposer(new PetRespectComposer(userId));
break;
case RoomWidgetUserActionMessage.DROP_CARRY_ITEM:
SendMessageComposer(new RoomUnitDropHandItemComposer());
break;
case RoomWidgetUserActionMessage.REQUEST_PET_UPDATE:
this.container.roomSession.userDataManager.requestPetInfo(userId);
return;
case RoomWidgetUserActionMessage.REPORT:
return;
case RoomWidgetUserActionMessage.REPORT_CFH_OTHER:
DispatchUiEvent(new HelpReportUserEvent(userId));
return;
case RoomWidgetUserActionMessage.AMBASSADOR_ALERT_USER:
this.container.roomSession.sendAmbassadorAlertMessage(userId);
return;
case RoomWidgetUserActionMessage.AMBASSADOR_KICK_USER:
this.container.roomSession.sendKickMessage(userId);
return;
case RoomWidgetUserActionMessage.AMBASSADOR_MUTE_USER_2MIN:
this.container.roomSession.sendMuteMessage(userId, 2);
return;
case RoomWidgetUserActionMessage.AMBASSADOR_MUTE_USER_10MIN:
this.container.roomSession.sendMuteMessage(userId, 10);
return;
case RoomWidgetUserActionMessage.AMBASSADOR_MUTE_USER_60MIN:
this.container.roomSession.sendMuteMessage(userId, 60);
return;
case RoomWidgetUserActionMessage.AMBASSADOR_MUTE_USER_18HOUR:
this.container.roomSession.sendMuteMessage(userId, 1080);
return;
case RoomWidgetFurniActionMessage.ROTATE:
GetRoomEngine().processRoomObjectOperation(objectId, category, RoomObjectOperationType.OBJECT_ROTATE_POSITIVE);
return;
case RoomWidgetFurniActionMessage.MOVE:
GetRoomEngine().processRoomObjectOperation(objectId, category, RoomObjectOperationType.OBJECT_MOVE);
return;
case RoomWidgetFurniActionMessage.PICKUP:
GetRoomEngine().processRoomObjectOperation(objectId, category, RoomObjectOperationType.OBJECT_PICKUP);
return;
case RoomWidgetFurniActionMessage.EJECT:
GetRoomEngine().processRoomObjectOperation(objectId, category, RoomObjectOperationType.OBJECT_EJECT);
return;
case RoomWidgetFurniActionMessage.USE:
GetRoomEngine().useRoomObject(objectId, category);
return;
case RoomWidgetFurniActionMessage.SAVE_STUFF_DATA: {
const furniMessage = (message as RoomWidgetFurniActionMessage);
if(!furniMessage.objectData) return;
const mapData = new Map<string, string>();
const dataParts = furniMessage.objectData.split('\t');
if(dataParts)
{
for(const part of dataParts)
{
const [ key, value ] = part.split('=', 2);
mapData.set(key, value);
}
}
GetRoomEngine().modifyRoomObjectDataWithMap(objectId, category, RoomObjectOperationType.OBJECT_SAVE_STUFF_DATA, mapData);
return;
}
case RoomWidgetChangeMottoMessage.CHANGE_MOTTO:
this.container.roomSession.sendMottoMessage((message as RoomWidgetChangeMottoMessage).motto);
return;
}
return null;
}
private processObjectNameMessage(message: RoomWidgetRoomObjectMessage): RoomWidgetUpdateEvent
{
let id = -1;
let name: string = null;
let userType = 0;
switch(message.category)
{
case RoomObjectCategory.FLOOR:
case RoomObjectCategory.WALL: {
const roomObject = GetRoomEngine().getRoomObject(this.container.roomSession.roomId, message.id, message.category);
if(!roomObject) break;
if(roomObject.type.indexOf('poster') === 0)
{
name = LocalizeText('${poster_' + parseInt(roomObject.type.replace('poster', '')) + '_name}');
}
else
{
let furniData: IFurnitureData = null;
const typeId = roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_TYPE_ID);
if(message.category === RoomObjectCategory.FLOOR)
{
furniData = GetSessionDataManager().getFloorItemData(typeId);
}
else if(message.category === RoomObjectCategory.WALL)
{
furniData = GetSessionDataManager().getWallItemData(typeId);
}
if(!furniData) break;
id = furniData.id;
name = furniData.name;
}
break;
}
case RoomObjectCategory.UNIT: {
const userData = this.container.roomSession.userDataManager.getUserDataByIndex(message.id);
if(!userData) break;
id = userData.webID;
name = userData.name;
userType = userData.type;
break;
}
}
if(name) this.container.eventDispatcher.dispatchEvent(new RoomWidgetObjectNameEvent(RoomWidgetObjectNameEvent.TYPE, message.id, message.category, id, name, userType));
return null;
}
private processObjectInfoMessage(message: RoomWidgetRoomObjectMessage): RoomWidgetUpdateEvent
{
const roomId = this.container.roomSession.roomId;
switch(message.category)
{
case RoomObjectCategory.FLOOR:
case RoomObjectCategory.WALL:
this.processFurniInfoMessage(message, roomId);
break;
case RoomObjectCategory.UNIT: {
const userData = this.container.roomSession.userDataManager.getUserDataByIndex(message.id);
if(!userData) break;
switch(userData.type)
{
case RoomObjectType.PET:
this.container.roomSession.userDataManager.requestPetInfo(userData.webID);
break;
case RoomObjectType.USER:
this.processUserInfoMessage(message, roomId, userData);
break;
case RoomObjectType.BOT:
this.processBotInfoMessage(message, roomId, userData);
break;
case RoomObjectType.RENTABLE_BOT:
this.processRentableBotInfoMessage(message, roomId, userData);
break;
}
}
}
return null;
}
private processFurniInfoMessage(message: RoomWidgetRoomObjectMessage, roomId: number): void
{
const event = new RoomWidgetUpdateInfostandFurniEvent(RoomWidgetUpdateInfostandFurniEvent.FURNI);
event.id = message.id;
event.category = message.category;
const roomObject = GetRoomEngine().getRoomObject(roomId, message.id, message.category);
if(!roomObject) return;
const model = roomObject.model;
if(model.getValue<string>(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM))
{
event.extraParam = model.getValue<string>(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM);
}
const dataFormat = model.getValue<number>(RoomObjectVariable.FURNITURE_DATA_FORMAT);
const objectData = ObjectDataFactory.getData(dataFormat);
objectData.initializeFromRoomObjectModel(model);
event.stuffData = objectData;
const objectType = roomObject.type;
if(objectType.indexOf('poster') === 0)
{
const posterId = parseInt(objectType.replace('poster', ''));
event.name = LocalizeText(('${poster_' + posterId) + '_name}');
event.description = LocalizeText(('${poster_' + posterId) + '_desc}');
}
else
{
const typeId = model.getValue<number>(RoomObjectVariable.FURNITURE_TYPE_ID);
let furnitureData: IFurnitureData = null;
if(message.category === RoomObjectCategory.FLOOR)
{
furnitureData = GetSessionDataManager().getFloorItemData(typeId);
}
else if(message.category === RoomObjectCategory.WALL)
{
furnitureData = GetSessionDataManager().getWallItemData(typeId);
}
if(furnitureData)
{
event.name = furnitureData.name;
event.description = furnitureData.description;
event.purchaseOfferId = furnitureData.purchaseOfferId;
event.purchaseCouldBeUsedForBuyout = furnitureData.purchaseCouldBeUsedForBuyout;
event.rentOfferId = furnitureData.rentOfferId;
event.rentCouldBeUsedForBuyout = furnitureData.rentCouldBeUsedForBuyout;
event.availableForBuildersClub = furnitureData.availableForBuildersClub;
event.tileSizeX = furnitureData.tileSizeX;
event.tileSizeY = furnitureData.tileSizeY;
DispatchUiEvent(new WiredSelectObjectEvent(event.id, event.category));
}
}
if(objectType.indexOf('post_it') > -1) event.isStickie = true;
const expiryTime = model.getValue<number>(RoomObjectVariable.FURNITURE_EXPIRY_TIME);
const expiryTimestamp = model.getValue<number>(RoomObjectVariable.FURNITURE_EXPIRTY_TIMESTAMP);
event.expiration = ((expiryTime < 0) ? expiryTime : Math.max(0, (expiryTime - ((GetNitroInstance().time - expiryTimestamp) / 1000))));
let roomObjectImage = GetRoomEngine().getRoomObjectImage(roomId, message.id, message.category, new Vector3d(180), 64, null);
if(!roomObjectImage.data || (roomObjectImage.data.width > 140) || (roomObjectImage.data.height > 200))
{
roomObjectImage = GetRoomEngine().getRoomObjectImage(roomId, message.id, message.category, new Vector3d(180), 1, null);
}
event.image = roomObjectImage.getImage();
event.isWallItem = (message.category === RoomObjectCategory.WALL);
event.isRoomOwner = this.container.roomSession.isRoomOwner;
event.roomControllerLevel = this.container.roomSession.controllerLevel;
event.isAnyRoomController = GetSessionDataManager().isModerator;
event.ownerId = model.getValue<number>(RoomObjectVariable.FURNITURE_OWNER_ID);
event.ownerName = model.getValue<string>(RoomObjectVariable.FURNITURE_OWNER_NAME);
event.usagePolicy = model.getValue<number>(RoomObjectVariable.FURNITURE_USAGE_POLICY);
const guildId = model.getValue<number>(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_GUILD_ID);
if(guildId !== 0)
{
event.groupId = guildId;
//this.container.connection.send(new _Str_2863(guildId, false));
}
if(IsOwnerOfFurniture(roomObject)) event.isOwner = true;
this.container.eventDispatcher.dispatchEvent(event);
}
private processUserInfoMessage(message: RoomWidgetRoomObjectMessage, roomId: number, userData: RoomUserData): void
{
let eventType = RoomWidgetUpdateInfostandUserEvent.OWN_USER;
if(userData.webID !== GetSessionDataManager().userId) eventType = RoomWidgetUpdateInfostandUserEvent.PEER;
const event = new RoomWidgetUpdateInfostandUserEvent(eventType);
event.isSpectatorMode = this.container.roomSession.isSpectator;
event.name = userData.name;
event.motto = userData.custom;
event.achievementScore = userData.activityPoints;
event.webID = userData.webID;
event.roomIndex = userData.roomIndex;
event.userType = RoomObjectType.USER;
const roomObject = GetRoomEngine().getRoomObject(roomId, userData.roomIndex, message.category);
if(roomObject) event.carryItem = (roomObject.model.getValue<number>(RoomObjectVariable.FIGURE_CARRY_OBJECT) || 0);
if(eventType === RoomWidgetUpdateInfostandUserEvent.OWN_USER) event.allowNameChange = GetSessionDataManager().canChangeName;
event.amIOwner = this.container.roomSession.isRoomOwner;
event.isGuildRoom = this.container.roomSession.isGuildRoom;
event.roomControllerLevel = this.container.roomSession.controllerLevel;
event.amIAnyRoomController = GetSessionDataManager().isModerator;
event.isAmbassador = GetSessionDataManager().isAmbassador;
if(eventType === RoomWidgetUpdateInfostandUserEvent.PEER)
{
if(roomObject)
{
const flatControl = roomObject.model.getValue<number>(RoomObjectVariable.FIGURE_FLAT_CONTROL);
if(flatControl !== null) event.targetRoomControllerLevel = flatControl;
event.canBeMuted = this.canBeMuted(event);
event.canBeKicked = this.canBeKicked(event);
event.canBeBanned = this.canBeBanned(event);
}
event.isIgnored = GetSessionDataManager().isUserIgnored(userData.name);
event.respectLeft = GetSessionDataManager().respectsLeft;
const isShuttingDown = GetSessionDataManager().isSystemShutdown;
const tradeMode = this.container.roomSession.tradeMode;
if(isShuttingDown)
{
event.canTrade = false;
}
else
{
switch(tradeMode)
{
case RoomTradingLevelEnum.ROOM_CONTROLLER_REQUIRED: {
const roomController = ((event.roomControllerLevel !== RoomControllerLevel.NONE) && (event.roomControllerLevel !== RoomControllerLevel.GUILD_MEMBER));
const targetController = ((event.targetRoomControllerLevel !== RoomControllerLevel.NONE) && (event.targetRoomControllerLevel !== RoomControllerLevel.GUILD_MEMBER));
event.canTrade = (roomController || targetController);
break;
}
case RoomTradingLevelEnum.NO_TRADING:
event.canTrade = true;
break;
default:
event.canTrade = false;
break;
}
}
event.canTradeReason = RoomWidgetUpdateInfostandUserEvent.TRADE_REASON_OK;
if(isShuttingDown) event.canTradeReason = RoomWidgetUpdateInfostandUserEvent.TRADE_REASON_SHUTDOWN;
if(tradeMode !== RoomTradingLevelEnum.FREE_TRADING) event.canTradeReason = RoomWidgetUpdateInfostandUserEvent.TRADE_REASON_NO_TRADING;
// const _local_12 = GetSessionDataManager().userId;
// _local_13 = GetSessionDataManager()._Str_18437(_local_12);
// this._Str_16287(_local_12, _local_13);
}
event.groupId = userData.groupId;
event.groupBadgeId = GetSessionDataManager().getGroupBadge(event.groupId);
event.groupName = userData.groupName;
event.badges = this.container.roomSession.userDataManager.getUserBadges(userData.webID);
event.figure = userData.figure;
//var _local_8:Array = GetSessionDataManager()._Str_18437(userData.webID);
//this._Str_16287(userData._Str_2394, _local_8);
//this._container._Str_8097._Str_14387(userData.webID);
//this._container.connection.send(new _Str_8049(userData._Str_2394));
this.container.eventDispatcher.dispatchEvent(event);
}
private processBotInfoMessage(message: RoomWidgetRoomObjectMessage, roomId: number, userData: RoomUserData): void
{
const event = new RoomWidgetUpdateInfostandUserEvent(RoomWidgetUpdateInfostandUserEvent.BOT);
event.name = userData.name;
event.motto = userData.custom;
event.webID = userData.webID;
event.roomIndex = userData.roomIndex;
event.userType = userData.type;
const roomObject = GetRoomEngine().getRoomObject(roomId, userData.roomIndex, message.category);
if(roomObject) event.carryItem = (roomObject.model.getValue<number>(RoomObjectVariable.FIGURE_CARRY_OBJECT) || 0);
event.amIOwner = this.container.roomSession.isRoomOwner;
event.isGuildRoom = this.container.roomSession.isGuildRoom;
event.roomControllerLevel = this.container.roomSession.controllerLevel;
event.amIAnyRoomController = GetSessionDataManager().isModerator;
event.isAmbassador = GetSessionDataManager().isAmbassador;
event.badges = [ RoomWidgetUpdateInfostandUserEvent.DEFAULT_BOT_BADGE_ID ];
event.figure = userData.figure;
this.container.eventDispatcher.dispatchEvent(event);
}
private processRentableBotInfoMessage(message: RoomWidgetRoomObjectMessage, roomId: number, userData: RoomUserData): void
{
const event = new RoomWidgetUpdateInfostandRentableBotEvent(RoomWidgetUpdateInfostandRentableBotEvent.RENTABLE_BOT);
event.name = userData.name;
event.motto = userData.custom;
event.webID = userData.webID;
event.roomIndex = userData.roomIndex;
event.ownerId = userData.ownerId;
event.ownerName = userData.ownerName;
event.botSkills = userData.botSkills;
const roomObject = GetRoomEngine().getRoomObject(roomId, userData.roomIndex, message.category);
if(roomObject) event.carryItem = (roomObject.model.getValue<number>(RoomObjectVariable.FIGURE_CARRY_OBJECT) || 0);
event.amIOwner = this.container.roomSession.isRoomOwner;
event.roomControllerLevel = this.container.roomSession.controllerLevel;
event.amIAnyRoomController = GetSessionDataManager().isModerator;
event.badges = [ RoomWidgetUpdateInfostandUserEvent.DEFAULT_BOT_BADGE_ID ];
event.figure = userData.figure;
this.container.eventDispatcher.dispatchEvent(event);
}
private processPetInfoEvent(event: RoomSessionPetInfoUpdateEvent): void
{
const petData = event.petInfo;
if(!petData) return;
const roomPetData = this.container.roomSession.userDataManager.getPetData(petData.id);
if(!roomPetData) return;
const figure = new PetFigureData(roomPetData.figure);
let posture: string = null;
if(figure.typeId === PetType.MONSTERPLANT)
{
if(petData.level >= petData.adultLevel) posture = 'std';
else posture = ('grw' + petData.level);
}
const isOwner = (petData.ownerId === GetSessionDataManager().userId);
const infostandEvent = new RoomWidgetUpdateInfostandPetEvent(RoomWidgetUpdateInfostandPetEvent.PET_INFO);
infostandEvent.name = roomPetData.name;
infostandEvent.id = petData.id;
infostandEvent.ownerId = petData.ownerId;
infostandEvent.ownerName = petData.ownerName;
infostandEvent.rarityLevel = petData.rarityLevel;
infostandEvent.petType = figure.typeId;
infostandEvent.petBreed = figure.paletteId;
infostandEvent.petFigure = roomPetData.figure;
infostandEvent.posture = posture;
infostandEvent.isOwner = isOwner;
infostandEvent.roomIndex = roomPetData.roomIndex;
infostandEvent.level = petData.level;
infostandEvent.maximumLevel = petData.maximumLevel;
infostandEvent.experience = petData.experience;
infostandEvent.levelExperienceGoal = petData.levelExperienceGoal;
infostandEvent.energy = petData.energy;
infostandEvent.maximumEnergy = petData.maximumEnergy;
infostandEvent.happyness = petData.happyness;
infostandEvent.maximumHappyness = petData.maximumHappyness;
infostandEvent.respect = petData.respect;
infostandEvent.respectsPetLeft = GetSessionDataManager().respectsPetLeft;
infostandEvent.age = petData.age;
infostandEvent.saddle = petData.saddle;
infostandEvent.rider = petData.rider;
infostandEvent.breedable = petData.breedable;
infostandEvent.fullyGrown = petData.fullyGrown;
infostandEvent.dead = petData.dead;
infostandEvent.rarityLevel = petData.rarityLevel;
infostandEvent.skillTresholds = petData.skillTresholds;
infostandEvent.canRemovePet = false;
infostandEvent.publiclyRideable = petData.publiclyRideable;
infostandEvent.maximumTimeToLive = petData.maximumTimeToLive;
infostandEvent.remainingTimeToLive = petData.remainingTimeToLive;
infostandEvent.remainingGrowTime = petData.remainingGrowTime;
infostandEvent.publiclyBreedable = petData.publiclyBreedable;
if(isOwner)
{
infostandEvent.canRemovePet = true;
}
else
{
if(this.container.roomSession.isRoomOwner || GetSessionDataManager().isModerator || (this.container.roomSession.controllerLevel >= RoomControllerLevel.GUEST)) infostandEvent.canRemovePet = true;
}
this.container.eventDispatcher.dispatchEvent(infostandEvent);
}
private checkGuildSetting(event: RoomWidgetUpdateInfostandUserEvent): boolean
{
if(event.isGuildRoom) return (event.roomControllerLevel >= RoomControllerLevel.GUILD_ADMIN);
return (event.roomControllerLevel >= RoomControllerLevel.GUEST);
}
private canBeMuted(event: RoomWidgetUpdateInfostandUserEvent): boolean
{
const checkSetting = (event: RoomWidgetUpdateInfostandUserEvent, moderation: RoomModerationSettings) =>
{
switch(moderation.allowMute)
{
case RoomModerationSettings.MODERATION_LEVEL_USER_WITH_RIGHTS:
return this.checkGuildSetting(event);
default:
return (event.roomControllerLevel >= RoomControllerLevel.ROOM_OWNER);
}
}
return this.isValidSetting(event, checkSetting);
}
private canBeKicked(event: RoomWidgetUpdateInfostandUserEvent): boolean
{
const checkSetting = (event: RoomWidgetUpdateInfostandUserEvent, moderation: RoomModerationSettings) =>
{
switch(moderation.allowKick)
{
case RoomModerationSettings.MODERATION_LEVEL_ALL:
return true;
case RoomModerationSettings.MODERATION_LEVEL_USER_WITH_RIGHTS:
return this.checkGuildSetting(event);
default:
return (event.roomControllerLevel >= RoomControllerLevel.ROOM_OWNER);
}
}
return this.isValidSetting(event, checkSetting);
}
private canBeBanned(event: RoomWidgetUpdateInfostandUserEvent): boolean
{
const checkSetting = (event: RoomWidgetUpdateInfostandUserEvent, moderation: RoomModerationSettings) =>
{
switch(moderation.allowBan)
{
case RoomModerationSettings.MODERATION_LEVEL_USER_WITH_RIGHTS:
return this.checkGuildSetting(event);
default:
return (event.roomControllerLevel >= RoomControllerLevel.ROOM_OWNER);
}
}
return this.isValidSetting(event, checkSetting);
}
private isValidSetting(event: RoomWidgetUpdateInfostandUserEvent, checkSetting: (event: RoomWidgetUpdateInfostandUserEvent, moderation: RoomModerationSettings) => boolean): boolean
{
if(!this.container.roomSession._Str_7411) return false;
const moderation = this.container.roomSession.moderationSettings;
let flag = false;
if(moderation) flag = checkSetting(event, moderation);
return (flag && (event.targetRoomControllerLevel < RoomControllerLevel.ROOM_OWNER));
}
public get type(): string
{
return RoomWidgetEnum.INFOSTAND;
}
public get eventTypes(): string[]
{
return [
RoomSessionPetInfoUpdateEvent.PET_INFO,
RoomSessionUserBadgesEvent.RSUBE_BADGES,
RoomSessionUserFigureUpdateEvent.USER_FIGURE,
RoomSessionFavoriteGroupUpdateEvent.FAVOURITE_GROUP_UPDATE
];
}
public get messageTypes(): string[]
{
return [
RoomWidgetRoomObjectMessage.GET_OBJECT_INFO,
RoomWidgetRoomObjectMessage.GET_OBJECT_NAME,
RoomWidgetUserActionMessage.RESPECT_USER,
RoomWidgetUserActionMessage.WHISPER_USER,
RoomWidgetUserActionMessage.IGNORE_USER,
RoomWidgetUserActionMessage.UNIGNORE_USER,
RoomWidgetUserActionMessage.KICK_USER,
RoomWidgetUserActionMessage.BAN_USER_DAY,
RoomWidgetUserActionMessage.BAN_USER_HOUR,
RoomWidgetUserActionMessage.BAN_USER_PERM,
RoomWidgetUserActionMessage.MUTE_USER_2MIN,
RoomWidgetUserActionMessage.MUTE_USER_5MIN,
RoomWidgetUserActionMessage.MUTE_USER_10MIN,
RoomWidgetUserActionMessage.GIVE_RIGHTS,
RoomWidgetUserActionMessage.TAKE_RIGHTS,
RoomWidgetUserActionMessage.START_TRADING,
RoomWidgetUserActionMessage.OPEN_HOME_PAGE,
RoomWidgetUserActionMessage.PASS_CARRY_ITEM,
RoomWidgetUserActionMessage.GIVE_CARRY_ITEM_TO_PET,
RoomWidgetUserActionMessage.DROP_CARRY_ITEM,
RoomWidgetUserActionMessage.REPORT,
RoomWidgetUserActionMessage.PICKUP_PET,
RoomWidgetUserActionMessage.MOUNT_PET,
RoomWidgetUserActionMessage.TOGGLE_PET_RIDING_PERMISSION,
RoomWidgetUserActionMessage.TOGGLE_PET_BREEDING_PERMISSION,
RoomWidgetUserActionMessage.DISMOUNT_PET,
RoomWidgetUserActionMessage.SADDLE_OFF,
RoomWidgetUserActionMessage.TRAIN_PET,
RoomWidgetUserActionMessage.RESPECT_PET,
RoomWidgetUserActionMessage.REQUEST_PET_UPDATE,
RoomWidgetUserActionMessage.GIVE_LIGHT_TO_PET,
RoomWidgetUserActionMessage.GIVE_WATER_TO_PET,
RoomWidgetUserActionMessage.TREAT_PET,
RoomWidgetUserActionMessage.REPORT_CFH_OTHER,
RoomWidgetUserActionMessage.AMBASSADOR_ALERT_USER,
RoomWidgetUserActionMessage.AMBASSADOR_KICK_USER,
RoomWidgetUserActionMessage.AMBASSADOR_MUTE_USER_2MIN,
RoomWidgetUserActionMessage.AMBASSADOR_MUTE_USER_10MIN,
RoomWidgetUserActionMessage.AMBASSADOR_MUTE_USER_60MIN,
RoomWidgetUserActionMessage.AMBASSADOR_MUTE_USER_18HOUR,
RoomWidgetChangeMottoMessage.CHANGE_MOTTO,
RoomWidgetFurniActionMessage.MOVE,
RoomWidgetFurniActionMessage.ROTATE,
RoomWidgetFurniActionMessage.EJECT,
RoomWidgetFurniActionMessage.PICKUP,
RoomWidgetFurniActionMessage.USE,
RoomWidgetFurniActionMessage.SAVE_STUFF_DATA
];
}
}

View File

@ -1,74 +0,0 @@
import { AvatarAction, NitroEvent, RoomSessionWordQuizEvent, RoomWidgetEnum } from '@nitrots/nitro-renderer';
import { RoomWidgetHandler } from '.';
import { GetRoomEngine } from '../../GetRoomEngine';
import { RoomWidgetUpdateEvent } from '../events';
import { RoomWidgetWordQuizUpdateEvent } from '../events/RoomWidgetWordQuizUpdateEvent';
import { RoomWidgetMessage } from '../messages';
export class WordQuizWidgetHandler extends RoomWidgetHandler
{
public processEvent(event: NitroEvent): void
{
const roomQuizEvent = (event as RoomSessionWordQuizEvent);
let widgetEvent: RoomWidgetWordQuizUpdateEvent;
switch(event.type)
{
case RoomSessionWordQuizEvent.ANSWERED:
const roomId = this.container.roomSession.roomId;
const userData = this.container.roomSession.userDataManager.getUserData(roomQuizEvent.userId);
if(!userData) return;
widgetEvent = new RoomWidgetWordQuizUpdateEvent(RoomWidgetWordQuizUpdateEvent.QUESTION_ANSWERED, roomQuizEvent.id);
widgetEvent.value = roomQuizEvent.value;
widgetEvent.userId = roomQuizEvent.userId;
widgetEvent.answerCounts = roomQuizEvent.answerCounts;
if(widgetEvent.value === '0')
{
GetRoomEngine().updateRoomObjectUserGesture(roomId, userData.roomIndex, AvatarAction.getGestureId(AvatarAction.GESTURE_SAD));
}
else
{
GetRoomEngine().updateRoomObjectUserGesture(roomId, userData.roomIndex, AvatarAction.getGestureId(AvatarAction.GESTURE_SMILE));
}
break;
case RoomSessionWordQuizEvent.FINISHED:
widgetEvent = new RoomWidgetWordQuizUpdateEvent(RoomWidgetWordQuizUpdateEvent.QUESTION_FINISHED, roomQuizEvent.id);
widgetEvent.pollId = roomQuizEvent.pollId;
widgetEvent.questionId = roomQuizEvent.questionId;
widgetEvent.answerCounts = roomQuizEvent.answerCounts;
break;
case RoomSessionWordQuizEvent.QUESTION:
widgetEvent = new RoomWidgetWordQuizUpdateEvent(RoomWidgetWordQuizUpdateEvent.NEW_QUESTION, roomQuizEvent.id);
widgetEvent.question = roomQuizEvent.question;
widgetEvent.duration = roomQuizEvent.duration;
widgetEvent.pollType = roomQuizEvent.pollType;
widgetEvent.questionId = roomQuizEvent.questionId;
widgetEvent.pollId = roomQuizEvent.pollId;
break;
}
if(!widgetEvent) return;
this.container.eventDispatcher.dispatchEvent(widgetEvent);
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
return null;
}
public get type(): string
{
return RoomWidgetEnum.WORD_QUIZZ;
}
public get eventTypes(): string[]
{
return [ RoomSessionWordQuizEvent.ANSWERED, RoomSessionWordQuizEvent.FINISHED, RoomSessionWordQuizEvent.QUESTION ];
}
public get messageTypes(): string[]
{
return [];
}
}

View File

@ -1,11 +0,0 @@
export * from './FurnitureContextMenuWidgetHandler';
export * from './IRoomWidgetHandler';
export * from './IRoomWidgetHandlerManager';
export * from './PollWidgetHandler';
export * from './RoomWidgetAvatarInfoHandler';
export * from './RoomWidgetChatHandler';
export * from './RoomWidgetChatInputHandler';
export * from './RoomWidgetHandler';
export * from './RoomWidgetHandlerManager';
export * from './RoomWidgetInfostandHandler';
export * from './WordQuizWidgetHandler';

View File

@ -1,3 +0,0 @@
export * from './events';
export * from './handlers';
export * from './messages';

View File

@ -1,21 +0,0 @@
import { AvatarExpressionEnum } from '@nitrots/nitro-renderer';
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetAvatarExpressionMessage extends RoomWidgetMessage
{
public static AVATAR_EXPRESSION: string = 'RWAEM_MESSAGE_AVATAR_EXPRESSION';
private _animation: AvatarExpressionEnum;
constructor(animation: AvatarExpressionEnum)
{
super(RoomWidgetAvatarExpressionMessage.AVATAR_EXPRESSION);
this._animation = animation;
}
public get animation(): AvatarExpressionEnum
{
return this._animation;
}
}

View File

@ -1,20 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetChangeMottoMessage extends RoomWidgetMessage
{
public static CHANGE_MOTTO: string = 'RWCMM_CHANGE_MOTTO';
private _motto: string;
constructor(motto: string)
{
super(RoomWidgetChangeMottoMessage.CHANGE_MOTTO);
this._motto = motto;
}
public get motto(): string
{
return this._motto;
}
}

View File

@ -1,22 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetChangePostureMessage extends RoomWidgetMessage
{
public static CHANGE_POSTURE: string = 'RWCPM_MESSAGE_CHANGE_POSTURE';
public static POSTURE_STAND: number = 0;
public static POSTURE_SIT: number = 1;
private _posture: number;
constructor(posture: number)
{
super(RoomWidgetChangePostureMessage.CHANGE_POSTURE);
this._posture = posture;
}
public get posture(): number
{
return this._posture;
}
}

View File

@ -1,44 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetChatMessage extends RoomWidgetMessage
{
public static MESSAGE_CHAT: string = 'RWCM_MESSAGE_CHAT';
public static CHAT_DEFAULT: number = 0;
public static CHAT_WHISPER: number = 1;
public static CHAT_SHOUT: number = 2;
private _chatType: number;
private _text: string;
private _recipientName: string;
private _styleId: number;
constructor(type: string, text: string, chatType: number, recipientName: string, styleId: number)
{
super(type);
this._text = text;
this._chatType = chatType;
this._recipientName = recipientName;
this._styleId = styleId;
}
public get text(): string
{
return this._text;
}
public get chatType(): number
{
return this._chatType;
}
public get recipientName(): string
{
return this._recipientName;
}
public get styleId(): number
{
return this._styleId;
}
}

View File

@ -1,34 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetChatSelectAvatarMessage extends RoomWidgetMessage
{
public static MESSAGE_SELECT_AVATAR: string = 'RWCSAM_MESSAGE_SELECT_AVATAR';
private _objectId: number;
private _userName: string;
private _roomId: number;
constructor(type: string, objectId: number, userName: string, roomId: number)
{
super(type);
this._objectId = objectId;
this._userName = userName;
this._roomId = roomId;
}
public get objectId(): number
{
return this._objectId;
}
public get userName(): string
{
return this._userName;
}
public get roomId(): number
{
return this._roomId;
}
}

View File

@ -1,20 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetChatTypingMessage extends RoomWidgetMessage
{
public static TYPING_STATUS: string = 'RWCTM_TYPING_STATUS';
private _isTyping: boolean;
constructor(isTyping: boolean)
{
super(RoomWidgetChatTypingMessage.TYPING_STATUS);
this._isTyping = isTyping;
}
public get isTyping(): boolean
{
return this._isTyping;
}
}

View File

@ -1,20 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetCreditFurniRedeemMessage extends RoomWidgetMessage
{
public static REDEEM: string = 'RWCFRM_REDEEM';
private _objectId: number;
constructor(type: string, objectId: number)
{
super(type);
this._objectId = objectId;
}
public get objectId(): number
{
return this._objectId;
}
}

View File

@ -1,22 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetDanceMessage extends RoomWidgetMessage
{
public static DANCE: string = 'RWDM_MESSAGE_DANCE';
public static NORMAL_STYLE: number = 0;
public static CLUB_STYLE: number[] = [ 2, 3, 4 ];
private _style: number = 0;
constructor(style: number)
{
super(RoomWidgetDanceMessage.DANCE);
this._style = style;
}
public get style(): number
{
return this._style;
}
}

View File

@ -1,47 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetFurniActionMessage extends RoomWidgetMessage
{
public static ROTATE: string = 'RWFAM_ROTATE';
public static MOVE: string = 'RWFAM_MOVE';
public static PICKUP: string = 'RWFAM_PICKUP';
public static EJECT: string = 'RWFAM_EJECT';
public static USE: string = 'RWFAM_USE';
public static OPEN_WELCOME_GIFT: string = 'RWFAM_OPEN_WELCOME_GIFT';
public static SAVE_STUFF_DATA: string = 'RWFAM_SAVE_STUFF_DATA';
private _furniId: number;
private _furniCategory: number;
private _offerId: number;
private _objectData: string;
constructor(type: string, id: number, category: number, offerId: number =- 1, objectData: string = null)
{
super(type);
this._furniId = id;
this._furniCategory = category;
this._offerId = offerId;
this._objectData = objectData;
}
public get furniId(): number
{
return this._furniId;
}
public get furniCategory(): number
{
return this._furniCategory;
}
public get objectData(): string
{
return this._objectData;
}
public get offerId(): number
{
return this._offerId;
}
}

View File

@ -1,38 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetFurniToWidgetMessage extends RoomWidgetMessage
{
public static REQUEST_TEASER: string = 'RWFWM_MESSAGE_REQUEST_TEASER';
public static REQUEST_ECOTRONBOX: string = 'RWFWM_MESSAGE_REQUEST_ECOTRONBOX';
public static REQUEST_PLACEHOLDER: string = 'RWFWM_MESSAGE_REQUEST_PLACEHOLDER';
public static REQUEST_CLOTHING_CHANGE: string = 'RWFWM_MESSAGE_REQUEST_CLOTHING_CHANGE';
public static REQUEST_PLAYLIST_EDITOR: string = 'RWFWM_MESSAGE_REQUEST_PLAYLIST_EDITOR';
private _objectId: number;
private _category: number;
private _roomId: number;
constructor(type: string, objectId: number, category: number, roomId: number)
{
super(type);
this._objectId = objectId;
this._category = category;
this._roomId = roomId;
}
public get objectId(): number
{
return this._objectId;
}
public get category(): number
{
return this._category;
}
public get roomId(): number
{
return this._roomId;
}
}

View File

@ -1,14 +0,0 @@
export class RoomWidgetMessage
{
private _type: string;
constructor(type: string)
{
this._type = type;
}
public get type(): string
{
return this._type;
}
}

View File

@ -1,44 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetPollMessage extends RoomWidgetMessage
{
public static readonly START = 'RWPM_START';
public static readonly REJECT = 'RWPM_REJECT';
public static readonly ANSWER = 'RWPM_ANSWER';
private _id = -1;
private _questionId = 0;
private _answers: string[] = null;
constructor(type: string, id: number)
{
super(type);
this._id = id;
}
public get id(): number
{
return this._id;
}
public get questionId(): number
{
return this._questionId;
}
public set questionId(k: number)
{
this._questionId = k;
}
public get answers(): string[]
{
return this._answers;
}
public set answers(k: string[])
{
this._answers = k;
}
}

View File

@ -1,8 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetRequestWidgetMessage extends RoomWidgetMessage
{
public static ME_MENU: string = 'RWRWM_ME_MENU';
public static EFFECTS: string = 'RWRWM_EFFECTS';
public static FLOOR_EDITOR: string = 'RWRWM_FLOOR_EDITOR';
}

View File

@ -1,31 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetRoomObjectMessage extends RoomWidgetMessage
{
public static GET_OBJECT_INFO: string = 'RWROM_GET_OBJECT_INFO';
public static GET_OBJECT_NAME: string = 'RWROM_GET_OBJECT_NAME';
public static SELECT_OBJECT: string = 'RWROM_SELECT_OBJECT';
public static GET_OWN_CHARACTER_INFO: string = 'RWROM_GET_OWN_CHARACTER_INFO';
public static GET_AVATAR_LIST: string = 'RWROM_GET_AVATAR_LIST';
private _id: number;
private _category: number;
constructor(type: string, id: number, category: number)
{
super(type);
this._id = id;
this._category = category;
}
public get id(): number
{
return this._id;
}
public get category(): number
{
return this._category;
}
}

View File

@ -1,28 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetUseProductMessage extends RoomWidgetMessage
{
public static PET_PRODUCT: string = 'RWUPM_PET_PRODUCT';
public static MONSTERPLANT_SEED: string = 'RWUPM_MONSTERPLANT_SEED';
private _objectId: number;
public _petId: number;
constructor(type: string, objectId: number, petId: number = -1)
{
super(type);
this._objectId = objectId;
this._petId = petId;
}
public get objectId(): number
{
return this._objectId;
}
public get petId(): number
{
return this._petId;
}
}

View File

@ -1,69 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetUserActionMessage extends RoomWidgetMessage
{
public static WHISPER_USER: string = 'RWUAM_WHISPER_USER';
public static IGNORE_USER: string = 'RWUAM_IGNORE_USER';
public static IGNORE_USER_BUBBLE: string = 'RWUAM_IGNORE_USER_BUBBLE';
public static UNIGNORE_USER: string = 'RWUAM_UNIGNORE_USER';
public static KICK_USER: string = 'RWUAM_KICK_USER';
public static BAN_USER_HOUR: string = 'RWUAM_BAN_USER_HOUR';
public static BAN_USER_DAY: string = 'RWUAM_BAN_USER_DAY';
public static BAN_USER_PERM: string = 'RWUAM_BAN_USER_PERM';
public static MUTE_USER_2MIN: string = 'RWUAM_MUTE_USER_2MIN';
public static MUTE_USER_5MIN: string = 'RWUAM_MUTE_USER_5MIN';
public static MUTE_USER_10MIN: string = 'RWUAM_MUTE_USER_10MIN';
public static RESPECT_USER: string = 'RWUAM_RESPECT_USER';
public static GIVE_RIGHTS: string = 'RWUAM_GIVE_RIGHTS';
public static TAKE_RIGHTS: string = 'RWUAM_TAKE_RIGHTS';
public static START_TRADING: string = 'RWUAM_START_TRADING';
public static OPEN_HOME_PAGE: string = 'RWUAM_OPEN_HOME_PAGE';
public static REPORT: string = 'RWUAM_REPORT';
public static PICKUP_PET: string = 'RWUAM_PICKUP_PET';
public static MOUNT_PET: string = 'RWUAM_MOUNT_PET';
public static TOGGLE_PET_RIDING_PERMISSION: string = 'RWUAM_TOGGLE_PET_RIDING_PERMISSION';
public static TOGGLE_PET_BREEDING_PERMISSION: string = 'RWUAM_TOGGLE_PET_BREEDING_PERMISSION';
public static DISMOUNT_PET: string = 'RWUAM_DISMOUNT_PET';
public static SADDLE_OFF: string = 'RWUAM_SADDLE_OFF';
public static TRAIN_PET: string = 'RWUAM_TRAIN_PET';
public static RESPECT_PET: string = ' RWUAM_RESPECT_PET';
public static TREAT_PET: string = 'RWUAM_TREAT_PET';
public static REQUEST_PET_UPDATE: string = 'RWUAM_REQUEST_PET_UPDATE';
public static START_NAME_CHANGE: string = 'RWUAM_START_NAME_CHANGE';
public static PASS_CARRY_ITEM: string = 'RWUAM_PASS_CARRY_ITEM';
public static DROP_CARRY_ITEM: string = 'RWUAM_DROP_CARRY_ITEM';
public static GIVE_CARRY_ITEM_TO_PET: string = 'RWUAM_GIVE_CARRY_ITEM_TO_PET';
public static GIVE_WATER_TO_PET: string = 'RWUAM_GIVE_WATER_TO_PET';
public static GIVE_LIGHT_TO_PET: string = 'RWUAM_GIVE_LIGHT_TO_PET';
public static REQUEST_BREED_PET: string = 'RWUAM_REQUEST_BREED_PET';
public static HARVEST_PET: string = 'RWUAM_HARVEST_PET';
public static REVIVE_PET: string = 'RWUAM_REVIVE_PET';
public static COMPOST_PLANT: string = 'RWUAM_COMPOST_PLANT';
public static GET_BOT_INFO: string = 'RWUAM_GET_BOT_INFO';
public static REPORT_CFH_OTHER: string = 'RWUAM_REPORT_CFH_OTHER';
public static AMBASSADOR_ALERT_USER: string = 'RWUAM_AMBASSADOR_ALERT_USER';
public static AMBASSADOR_KICK_USER: string = 'RWUAM_AMBASSADOR_KICK_USER';
public static AMBASSADOR_MUTE_USER_2MIN: string = 'RWUAM_AMBASSADOR_MUTE_2MIN';
public static AMBASSADOR_MUTE_USER_10MIN: string = 'RWUAM_AMBASSADOR_MUTE_10MIN';
public static AMBASSADOR_MUTE_USER_60MIN: string = 'RWUAM_AMBASSADOR_MUTE_60MIN';
public static AMBASSADOR_MUTE_USER_18HOUR: string = 'RWUAM_AMBASSADOR_MUTE_18HOUR';
public static RELATIONSHIP_NONE: string = 'RWUAM_RELATIONSHIP_NONE';
public static RELATIONSHIP_HEART: string = 'RWUAM_RELATIONSHIP_HEART';
public static RELATIONSHIP_SMILE: string = 'RWUAM_RELATIONSHIP_SMILE';
public static RELATIONSHIP_BOBBA: string = 'RWUAM_RELATIONSHIP_BOBBA';
private _userId: number;
constructor(type: string, userId: number)
{
super(type);
this._userId = userId;
}
public get userId(): number
{
return this._userId;
}
}

View File

@ -1,16 +0,0 @@
export * from './RoomWidgetAvatarExpressionMessage';
export * from './RoomWidgetChangeMottoMessage';
export * from './RoomWidgetChangePostureMessage';
export * from './RoomWidgetChatMessage';
export * from './RoomWidgetChatSelectAvatarMessage';
export * from './RoomWidgetChatTypingMessage';
export * from './RoomWidgetCreditFurniRedeemMessage';
export * from './RoomWidgetDanceMessage';
export * from './RoomWidgetFurniActionMessage';
export * from './RoomWidgetFurniToWidgetMessage';
export * from './RoomWidgetMessage';
export * from './RoomWidgetPollMessage';
export * from './RoomWidgetRequestWidgetMessage';
export * from './RoomWidgetRoomObjectMessage';
export * from './RoomWidgetUseProductMessage';
export * from './RoomWidgetUserActionMessage';

View File

@ -1,8 +1,9 @@
import { HabboWebTools, RoomEnterEffect } from '@nitrots/nitro-renderer';
import { CreateLinkEvent, GetConfiguration, GetNitroInstance, LocalizeText, PlaySound } from '..';
import { NotificationAlertEvent, NotificationConfirmEvent } from '../../events';
import { NotificationBubbleEvent } from '../../events/notification-center/NotificationBubbleEvent';
import { DispatchUiEvent } from '../../hooks';
import { DispatchUiEvent } from '../events';
import { CreateLinkEvent, GetConfiguration, GetNitroInstance } from '../nitro';
import { LocalizeText, PlaySound } from '../utils';
import { NotificationAlertType } from './NotificationAlertType';
import { NotificationBubbleType } from './NotificationBubbleType';

View File

@ -0,0 +1,6 @@
export * from './RoomWidgetPollUpdateEvent';
export * from './RoomWidgetUpdateBackgroundColorPreviewEvent';
export * from './RoomWidgetUpdateChatInputContentEvent';
export * from './RoomWidgetUpdateEvent';
export * from './RoomWidgetUpdateRentableBotChatEvent';
export * from './RoomWidgetUpdateRoomObjectEvent';

View File

@ -1 +1,2 @@
export * from './events';
export * from './widgets';

View File

@ -1,9 +1,9 @@
import { IObjectData } from '@nitrots/nitro-renderer';
import { RoomWidgetUpdateInfostandEvent } from './RoomWidgetUpdateInfostandEvent';
import { IAvatarInfo } from './IAvatarInfo';
export class RoomWidgetUpdateInfostandFurniEvent extends RoomWidgetUpdateInfostandEvent
export class AvatarInfoFurni implements IAvatarInfo
{
public static FURNI: string = 'RWUIFE_FURNI';
public static FURNI: string = 'IFI_FURNI';
public id: number = 0;
public category: number = 0;
@ -32,4 +32,7 @@ export class RoomWidgetUpdateInfostandFurniEvent extends RoomWidgetUpdateInfosta
public availableForBuildersClub: boolean = false;
public tileSizeX: number = 1;
public tileSizeY: number = 1;
constructor(public readonly type: string)
{}
}

View File

@ -0,0 +1,11 @@
export class AvatarInfoName
{
constructor(
public readonly roomIndex: number,
public readonly category: number,
public readonly id: number,
public readonly name: string,
public readonly userType: number,
public readonly isFriend: boolean = false)
{}
}

View File

@ -1,8 +1,8 @@
import { RoomWidgetUpdateInfostandEvent } from './RoomWidgetUpdateInfostandEvent';
import { IAvatarInfo } from './IAvatarInfo';
export class RoomWidgetUpdateInfostandPetEvent extends RoomWidgetUpdateInfostandEvent
export class AvatarInfoPet implements IAvatarInfo
{
public static PET_INFO: string = 'RWUIPE_PET_INFO';
public static PET_INFO: string = 'IPI_PET_INFO';
public level: number = 0;
public maximumLevel: number = 0;
@ -40,4 +40,7 @@ export class RoomWidgetUpdateInfostandPetEvent extends RoomWidgetUpdateInfostand
public remainingTimeToLive: number = 0;
public remainingGrowTime: number = 0;
public publiclyBreedable: boolean = false;
constructor(public readonly type: string)
{}
}

View File

@ -1,8 +1,8 @@
import { RoomWidgetUpdateInfostandEvent } from './RoomWidgetUpdateInfostandEvent';
import { IAvatarInfo } from './IAvatarInfo';
export class RoomWidgetUpdateInfostandRentableBotEvent extends RoomWidgetUpdateInfostandEvent
export class AvatarInfoRentableBot implements IAvatarInfo
{
public static RENTABLE_BOT: string = 'RWUIRBE_RENTABLE_BOT';
public static RENTABLE_BOT: string = 'IRBI_RENTABLE_BOT';
public name: string = '';
public motto: string = '';
@ -17,4 +17,7 @@ export class RoomWidgetUpdateInfostandRentableBotEvent extends RoomWidgetUpdateI
public ownerId: number = -1;
public ownerName: string = '';
public botSkills: number[] = [];
constructor(public readonly type: string)
{}
}

View File

@ -1,10 +1,10 @@
import { RoomWidgetUpdateInfostandEvent } from './RoomWidgetUpdateInfostandEvent';
import { IAvatarInfo } from './IAvatarInfo';
export class RoomWidgetUpdateInfostandUserEvent extends RoomWidgetUpdateInfostandEvent
export class AvatarInfoUser implements IAvatarInfo
{
public static OWN_USER: string = 'RWUIUE_OWN_USER';
public static PEER: string = 'RWUIUE_PEER';
public static BOT: string = 'RWUIUE_BOT';
public static OWN_USER: string = 'IUI_OWN_USER';
public static PEER: string = 'IUI_PEER';
public static BOT: string = 'IUI_BOT';
public static TRADE_REASON_OK: number = 0;
public static TRADE_REASON_SHUTDOWN: number = 2;
public static TRADE_REASON_NO_TRADING: number = 3;
@ -39,8 +39,11 @@ export class RoomWidgetUpdateInfostandUserEvent extends RoomWidgetUpdateInfostan
public targetRoomControllerLevel: number = 0;
public isAmbassador: boolean = false;
constructor(public readonly type: string)
{}
public get isOwnUser(): boolean
{
return (this.type === RoomWidgetUpdateInfostandUserEvent.OWN_USER);
return (this.type === AvatarInfoUser.OWN_USER);
}
}

View File

@ -0,0 +1,458 @@
import { IFurnitureData, ObjectDataFactory, PetFigureData, PetType, RoomControllerLevel, RoomModerationSettings, RoomObjectCategory, RoomObjectType, RoomObjectVariable, RoomPetData, RoomTradingLevelEnum, RoomUserData, RoomWidgetEnumItemExtradataParameter, Vector3d } from '@nitrots/nitro-renderer';
import { WiredSelectObjectEvent } from '../../../events';
import { DispatchUiEvent } from '../../events';
import { GetNitroInstance, GetRoomEngine, GetRoomSession, GetSessionDataManager, IsOwnerOfFurniture } from '../../nitro';
import { LocalizeText } from '../../utils';
import { AvatarInfoFurni } from './AvatarInfoFurni';
import { AvatarInfoName } from './AvatarInfoName';
import { AvatarInfoPet } from './AvatarInfoPet';
import { AvatarInfoRentableBot } from './AvatarInfoRentableBot';
import { AvatarInfoUser } from './AvatarInfoUser';
export class AvatarInfoUtilities
{
public static getObjectName(objectId: number, category: number): AvatarInfoName
{
const roomSession = GetRoomSession();
let id = -1;
let name: string = null;
let userType = 0;
switch(category)
{
case RoomObjectCategory.FLOOR:
case RoomObjectCategory.WALL: {
const roomObject = GetRoomEngine().getRoomObject(roomSession.roomId, objectId, category);
if(!roomObject) break;
if(roomObject.type.indexOf('poster') === 0)
{
name = LocalizeText('${poster_' + parseInt(roomObject.type.replace('poster', '')) + '_name}');
}
else
{
let furniData: IFurnitureData = null;
const typeId = roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_TYPE_ID);
if(category === RoomObjectCategory.FLOOR)
{
furniData = GetSessionDataManager().getFloorItemData(typeId);
}
else if(category === RoomObjectCategory.WALL)
{
furniData = GetSessionDataManager().getWallItemData(typeId);
}
if(!furniData) break;
id = furniData.id;
name = furniData.name;
}
break;
}
case RoomObjectCategory.UNIT: {
const userData = roomSession.userDataManager.getUserDataByIndex(objectId);
if(!userData) break;
id = userData.webID;
name = userData.name;
userType = userData.type;
break;
}
}
if(!name || !name.length) return null;
return new AvatarInfoName(objectId, category, id, name, userType);
}
public static getFurniInfo(objectId: number, category: number): AvatarInfoFurni
{
const roomSession = GetRoomSession();
const furniInfo = new AvatarInfoFurni(AvatarInfoFurni.FURNI);
furniInfo.id = objectId;
furniInfo.category = category;
const roomObject = GetRoomEngine().getRoomObject(roomSession.roomId, objectId, category);
if(!roomObject) return;
const model = roomObject.model;
if(model.getValue<string>(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM))
{
furniInfo.extraParam = model.getValue<string>(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM);
}
const dataFormat = model.getValue<number>(RoomObjectVariable.FURNITURE_DATA_FORMAT);
const objectData = ObjectDataFactory.getData(dataFormat);
objectData.initializeFromRoomObjectModel(model);
furniInfo.stuffData = objectData;
const objectType = roomObject.type;
if(objectType.indexOf('poster') === 0)
{
const posterId = parseInt(objectType.replace('poster', ''));
furniInfo.name = LocalizeText(('${poster_' + posterId) + '_name}');
furniInfo.description = LocalizeText(('${poster_' + posterId) + '_desc}');
}
else
{
const typeId = model.getValue<number>(RoomObjectVariable.FURNITURE_TYPE_ID);
let furnitureData: IFurnitureData = null;
if(category === RoomObjectCategory.FLOOR)
{
furnitureData = GetSessionDataManager().getFloorItemData(typeId);
}
else if(category === RoomObjectCategory.WALL)
{
furnitureData = GetSessionDataManager().getWallItemData(typeId);
}
if(furnitureData)
{
furniInfo.name = furnitureData.name;
furniInfo.description = furnitureData.description;
furniInfo.purchaseOfferId = furnitureData.purchaseOfferId;
furniInfo.purchaseCouldBeUsedForBuyout = furnitureData.purchaseCouldBeUsedForBuyout;
furniInfo.rentOfferId = furnitureData.rentOfferId;
furniInfo.rentCouldBeUsedForBuyout = furnitureData.rentCouldBeUsedForBuyout;
furniInfo.availableForBuildersClub = furnitureData.availableForBuildersClub;
furniInfo.tileSizeX = furnitureData.tileSizeX;
furniInfo.tileSizeY = furnitureData.tileSizeY;
DispatchUiEvent(new WiredSelectObjectEvent(furniInfo.id, furniInfo.category));
}
}
if(objectType.indexOf('post_it') > -1) furniInfo.isStickie = true;
const expiryTime = model.getValue<number>(RoomObjectVariable.FURNITURE_EXPIRY_TIME);
const expiryTimestamp = model.getValue<number>(RoomObjectVariable.FURNITURE_EXPIRTY_TIMESTAMP);
furniInfo.expiration = ((expiryTime < 0) ? expiryTime : Math.max(0, (expiryTime - ((GetNitroInstance().time - expiryTimestamp) / 1000))));
let roomObjectImage = GetRoomEngine().getRoomObjectImage(roomSession.roomId, objectId, category, new Vector3d(180), 64, null);
if(!roomObjectImage.data || (roomObjectImage.data.width > 140) || (roomObjectImage.data.height > 200))
{
roomObjectImage = GetRoomEngine().getRoomObjectImage(roomSession.roomId, objectId, category, new Vector3d(180), 1, null);
}
furniInfo.image = roomObjectImage.getImage();
furniInfo.isWallItem = (category === RoomObjectCategory.WALL);
furniInfo.isRoomOwner = roomSession.isRoomOwner;
furniInfo.roomControllerLevel = roomSession.controllerLevel;
furniInfo.isAnyRoomController = GetSessionDataManager().isModerator;
furniInfo.ownerId = model.getValue<number>(RoomObjectVariable.FURNITURE_OWNER_ID);
furniInfo.ownerName = model.getValue<string>(RoomObjectVariable.FURNITURE_OWNER_NAME);
furniInfo.usagePolicy = model.getValue<number>(RoomObjectVariable.FURNITURE_USAGE_POLICY);
const guildId = model.getValue<number>(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_GUILD_ID);
if(guildId !== 0)
{
furniInfo.groupId = guildId;
//this.container.connection.send(new _Str_2863(guildId, false));
}
if(IsOwnerOfFurniture(roomObject)) furniInfo.isOwner = true;
return furniInfo;
}
public static getUserInfo(category: number, userData: RoomUserData): AvatarInfoUser
{
const roomSession = GetRoomSession();
let userInfoType = AvatarInfoUser.OWN_USER;
if(userData.webID !== GetSessionDataManager().userId) userInfoType = AvatarInfoUser.PEER;
const userInfo = new AvatarInfoUser(userInfoType);
userInfo.isSpectatorMode = roomSession.isSpectator;
userInfo.name = userData.name;
userInfo.motto = userData.custom;
userInfo.achievementScore = userData.activityPoints;
userInfo.webID = userData.webID;
userInfo.roomIndex = userData.roomIndex;
userInfo.userType = RoomObjectType.USER;
const roomObject = GetRoomEngine().getRoomObject(roomSession.roomId, userData.roomIndex, category);
if(roomObject) userInfo.carryItem = (roomObject.model.getValue<number>(RoomObjectVariable.FIGURE_CARRY_OBJECT) || 0);
if(userInfoType === AvatarInfoUser.OWN_USER) userInfo.allowNameChange = GetSessionDataManager().canChangeName;
userInfo.amIOwner = roomSession.isRoomOwner;
userInfo.isGuildRoom = roomSession.isGuildRoom;
userInfo.roomControllerLevel = roomSession.controllerLevel;
userInfo.amIAnyRoomController = GetSessionDataManager().isModerator;
userInfo.isAmbassador = GetSessionDataManager().isAmbassador;
if(userInfoType === AvatarInfoUser.PEER)
{
if(roomObject)
{
const flatControl = roomObject.model.getValue<number>(RoomObjectVariable.FIGURE_FLAT_CONTROL);
if(flatControl !== null) userInfo.targetRoomControllerLevel = flatControl;
userInfo.canBeMuted = this.canBeMuted(userInfo);
userInfo.canBeKicked = this.canBeKicked(userInfo);
userInfo.canBeBanned = this.canBeBanned(userInfo);
}
userInfo.isIgnored = GetSessionDataManager().isUserIgnored(userData.name);
userInfo.respectLeft = GetSessionDataManager().respectsLeft;
const isShuttingDown = GetSessionDataManager().isSystemShutdown;
const tradeMode = roomSession.tradeMode;
if(isShuttingDown)
{
userInfo.canTrade = false;
}
else
{
switch(tradeMode)
{
case RoomTradingLevelEnum.ROOM_CONTROLLER_REQUIRED: {
const roomController = ((userInfo.roomControllerLevel !== RoomControllerLevel.NONE) && (userInfo.roomControllerLevel !== RoomControllerLevel.GUILD_MEMBER));
const targetController = ((userInfo.targetRoomControllerLevel !== RoomControllerLevel.NONE) && (userInfo.targetRoomControllerLevel !== RoomControllerLevel.GUILD_MEMBER));
userInfo.canTrade = (roomController || targetController);
break;
}
case RoomTradingLevelEnum.NO_TRADING:
userInfo.canTrade = true;
break;
default:
userInfo.canTrade = false;
break;
}
}
userInfo.canTradeReason = AvatarInfoUser.TRADE_REASON_OK;
if(isShuttingDown) userInfo.canTradeReason = AvatarInfoUser.TRADE_REASON_SHUTDOWN;
if(tradeMode !== RoomTradingLevelEnum.FREE_TRADING) userInfo.canTradeReason = AvatarInfoUser.TRADE_REASON_NO_TRADING;
// const _local_12 = GetSessionDataManager().userId;
// _local_13 = GetSessionDataManager()._Str_18437(_local_12);
// this._Str_16287(_local_12, _local_13);
}
userInfo.groupId = userData.groupId;
userInfo.groupBadgeId = GetSessionDataManager().getGroupBadge(userInfo.groupId);
userInfo.groupName = userData.groupName;
userInfo.badges = roomSession.userDataManager.getUserBadges(userData.webID);
userInfo.figure = userData.figure;
//var _local_8:Array = GetSessionDataManager()._Str_18437(userData.webID);
//this._Str_16287(userData._Str_2394, _local_8);
//this._container._Str_8097._Str_14387(userData.webID);
//this._container.connection.send(new _Str_8049(userData._Str_2394));
return userInfo;
}
public static getBotInfo(category: number, userData: RoomUserData): AvatarInfoUser
{
const roomSession = GetRoomSession();
const userInfo = new AvatarInfoUser(AvatarInfoUser.BOT);
userInfo.name = userData.name;
userInfo.motto = userData.custom;
userInfo.webID = userData.webID;
userInfo.roomIndex = userData.roomIndex;
userInfo.userType = userData.type;
const roomObject = GetRoomEngine().getRoomObject(roomSession.roomId, userData.roomIndex, category);
if(roomObject) userInfo.carryItem = (roomObject.model.getValue<number>(RoomObjectVariable.FIGURE_CARRY_OBJECT) || 0);
userInfo.amIOwner = roomSession.isRoomOwner;
userInfo.isGuildRoom = roomSession.isGuildRoom;
userInfo.roomControllerLevel = roomSession.controllerLevel;
userInfo.amIAnyRoomController = GetSessionDataManager().isModerator;
userInfo.isAmbassador = GetSessionDataManager().isAmbassador;
userInfo.badges = [ AvatarInfoUser.DEFAULT_BOT_BADGE_ID ];
userInfo.figure = userData.figure;
return userInfo;
}
public static getRentableBotInfo(category: number, userData: RoomUserData): AvatarInfoRentableBot
{
const roomSession = GetRoomSession();
const botInfo = new AvatarInfoRentableBot(AvatarInfoRentableBot.RENTABLE_BOT);
botInfo.name = userData.name;
botInfo.motto = userData.custom;
botInfo.webID = userData.webID;
botInfo.roomIndex = userData.roomIndex;
botInfo.ownerId = userData.ownerId;
botInfo.ownerName = userData.ownerName;
botInfo.botSkills = userData.botSkills;
const roomObject = GetRoomEngine().getRoomObject(roomSession.roomId, userData.roomIndex, category);
if(roomObject) botInfo.carryItem = (roomObject.model.getValue<number>(RoomObjectVariable.FIGURE_CARRY_OBJECT) || 0);
botInfo.amIOwner = roomSession.isRoomOwner;
botInfo.roomControllerLevel = roomSession.controllerLevel;
botInfo.amIAnyRoomController = GetSessionDataManager().isModerator;
botInfo.badges = [ AvatarInfoUser.DEFAULT_BOT_BADGE_ID ];
botInfo.figure = userData.figure;
return botInfo;
}
public static getPetInfo(petData: RoomPetData): AvatarInfoPet
{
const roomSession = GetRoomSession();
const userData = roomSession.userDataManager.getPetData(petData.id);
if(!userData) return;
const figure = new PetFigureData(userData.figure);
let posture: string = null;
if(figure.typeId === PetType.MONSTERPLANT)
{
if(petData.level >= petData.adultLevel) posture = 'std';
else posture = ('grw' + petData.level);
}
const isOwner = (petData.ownerId === GetSessionDataManager().userId);
const petInfo = new AvatarInfoPet(AvatarInfoPet.PET_INFO);
petInfo.name = userData.name;
petInfo.id = petData.id;
petInfo.ownerId = petData.ownerId;
petInfo.ownerName = petData.ownerName;
petInfo.rarityLevel = petData.rarityLevel;
petInfo.petType = figure.typeId;
petInfo.petBreed = figure.paletteId;
petInfo.petFigure = userData.figure;
petInfo.posture = posture;
petInfo.isOwner = isOwner;
petInfo.roomIndex = userData.roomIndex;
petInfo.level = petData.level;
petInfo.maximumLevel = petData.maximumLevel;
petInfo.experience = petData.experience;
petInfo.levelExperienceGoal = petData.levelExperienceGoal;
petInfo.energy = petData.energy;
petInfo.maximumEnergy = petData.maximumEnergy;
petInfo.happyness = petData.happyness;
petInfo.maximumHappyness = petData.maximumHappyness;
petInfo.respect = petData.respect;
petInfo.respectsPetLeft = GetSessionDataManager().respectsPetLeft;
petInfo.age = petData.age;
petInfo.saddle = petData.saddle;
petInfo.rider = petData.rider;
petInfo.breedable = petData.breedable;
petInfo.fullyGrown = petData.fullyGrown;
petInfo.dead = petData.dead;
petInfo.rarityLevel = petData.rarityLevel;
petInfo.skillTresholds = petData.skillTresholds;
petInfo.canRemovePet = false;
petInfo.publiclyRideable = petData.publiclyRideable;
petInfo.maximumTimeToLive = petData.maximumTimeToLive;
petInfo.remainingTimeToLive = petData.remainingTimeToLive;
petInfo.remainingGrowTime = petData.remainingGrowTime;
petInfo.publiclyBreedable = petData.publiclyBreedable;
if(isOwner || roomSession.isRoomOwner || GetSessionDataManager().isModerator || (roomSession.controllerLevel >= RoomControllerLevel.GUEST)) petInfo.canRemovePet = true;
return petInfo;
}
private static checkGuildSetting(userInfo: AvatarInfoUser): boolean
{
if(userInfo.isGuildRoom) return (userInfo.roomControllerLevel >= RoomControllerLevel.GUILD_ADMIN);
return (userInfo.roomControllerLevel >= RoomControllerLevel.GUEST);
}
private static isValidSetting(userInfo: AvatarInfoUser, checkSetting: (userInfo: AvatarInfoUser, moderation: RoomModerationSettings) => boolean): boolean
{
const roomSession = GetRoomSession();
if(!roomSession.isPrivateRoom) return false;
const moderation = roomSession.moderationSettings;
let flag = false;
if(moderation) flag = checkSetting(userInfo, moderation);
return (flag && (userInfo.targetRoomControllerLevel < RoomControllerLevel.ROOM_OWNER));
}
private static canBeMuted(userInfo: AvatarInfoUser): boolean
{
const checkSetting = (userInfo: AvatarInfoUser, moderation: RoomModerationSettings) =>
{
switch(moderation.allowMute)
{
case RoomModerationSettings.MODERATION_LEVEL_USER_WITH_RIGHTS:
return this.checkGuildSetting(userInfo);
default:
return (userInfo.roomControllerLevel >= RoomControllerLevel.ROOM_OWNER);
}
}
return this.isValidSetting(userInfo, checkSetting);
}
private static canBeKicked(userInfo: AvatarInfoUser): boolean
{
const checkSetting = (userInfo: AvatarInfoUser, moderation: RoomModerationSettings) =>
{
switch(moderation.allowKick)
{
case RoomModerationSettings.MODERATION_LEVEL_ALL:
return true;
case RoomModerationSettings.MODERATION_LEVEL_USER_WITH_RIGHTS:
return this.checkGuildSetting(userInfo);
default:
return (userInfo.roomControllerLevel >= RoomControllerLevel.ROOM_OWNER);
}
}
return this.isValidSetting(userInfo, checkSetting);
}
private static canBeBanned(userInfo: AvatarInfoUser): boolean
{
const checkSetting = (userInfo: AvatarInfoUser, moderation: RoomModerationSettings) =>
{
switch(moderation.allowBan)
{
case RoomModerationSettings.MODERATION_LEVEL_USER_WITH_RIGHTS:
return this.checkGuildSetting(userInfo);
default:
return (userInfo.roomControllerLevel >= RoomControllerLevel.ROOM_OWNER);
}
}
return this.isValidSetting(userInfo, checkSetting);
}
}

View File

@ -0,0 +1,6 @@
export class ChatMessageTypeEnum
{
public static CHAT_DEFAULT: number = 0;
public static CHAT_WHISPER: number = 1;
public static CHAT_SHOUT: number = 2;
}

View File

@ -0,0 +1,29 @@
import { GetRoomEngine, GetRoomSession } from '../../nitro';
export class FurnitureDimmerUtilities
{
public static AVAILABLE_COLORS: number[] = [ 7665141, 21495, 15161822, 15353138, 15923281, 8581961, 0 ];
public static HTML_COLORS: string[] = [ '#74F5F5', '#0053F7', '#E759DE', '#EA4532', '#F2F851', '#82F349', '#000000' ];
public static MIN_BRIGHTNESS: number = 76;
public static MAX_BRIGHTNESS: number = 255;
public static savePreset(presetNumber: number, effectTypeId: number, color: number, brightness: number, apply: boolean): void
{
GetRoomSession().updateMoodlightData(presetNumber, effectTypeId, color, brightness, apply);
}
public static changeState(): void
{
GetRoomSession().toggleMoodlightState();
}
public static previewDimmer(color: number, brightness: number, bgOnly: boolean): void
{
GetRoomEngine().updateObjectRoomColor(GetRoomSession().roomId, color, brightness, bgOnly);
}
public static scaleBrightness(value: number): number
{
return ~~((((value - this.MIN_BRIGHTNESS) * (100 - 0)) / (this.MAX_BRIGHTNESS - this.MIN_BRIGHTNESS)) + 0);
}
}

Some files were not shown because too many files have changed in this diff Show More