🆙 Init V3

This commit is contained in:
DuckieTM
2026-01-31 09:10:52 +01:00
commit 7feb10ab15
1733 changed files with 53405 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
import { IObjectData } from '@nitrots/nitro-renderer';
import { IAvatarInfo } from './IAvatarInfo';
export class AvatarInfoFurni implements IAvatarInfo
{
public static FURNI: string = 'IFI_FURNI';
public id: number = 0;
public category: number = 0;
public name: string = '';
public description: string = '';
public isWallItem: boolean = false;
public isStickie: boolean = false;
public isRoomOwner: boolean = false;
public roomControllerLevel: number = 0;
public isAnyRoomController: boolean = false;
public expiration: number = -1;
public purchaseCatalogPageId: number = -1;
public purchaseOfferId: number = -1;
public extraParam: string = '';
public isOwner: boolean = false;
public stuffData: IObjectData = null;
public groupId: number = 0;
public ownerId: number = 0;
public ownerName: string = '';
public usagePolicy: number = 0;
public rentCatalogPageId: number = -1;
public rentOfferId: number = -1;
public purchaseCouldBeUsedForBuyout: boolean = false;
public rentCouldBeUsedForBuyout: boolean = false;
public availableForBuildersClub: boolean = false;
public tileSizeX: number = 1;
public tileSizeY: number = 1;
constructor(public readonly type: string)
{}
}
+11
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)
{}
}
+46
View File
@@ -0,0 +1,46 @@
import { IAvatarInfo } from './IAvatarInfo';
export class AvatarInfoPet implements IAvatarInfo
{
public static PET_INFO: string = 'IPI_PET_INFO';
public level: number = 0;
public maximumLevel: number = 0;
public experience: number = 0;
public levelExperienceGoal: number = 0;
public energy: number = 0;
public maximumEnergy: number = 0;
public happyness: number = 0;
public maximumHappyness: number = 0;
public respectsPetLeft: number = 0;
public respect: number = 0;
public age: number = 0;
public name: string = '';
public id: number = -1;
public image: HTMLImageElement = null;
public petType: number = 0;
public petBreed: number = 0;
public petFigure: string = '';
public posture: string = 'std';
public isOwner: boolean = false;
public ownerId: number = -1;
public ownerName: string = '';
public canRemovePet: boolean = false;
public roomIndex: number = 0;
public unknownRarityLevel: number = 0;
public saddle: boolean = false;
public rider: boolean = false;
public breedable: boolean = false;
public skillTresholds: number[] = [];
public publiclyRideable: number = 0;
public fullyGrown: boolean = false;
public dead: boolean = false;
public rarityLevel: number = 0;
public maximumTimeToLive: number = 0;
public remainingTimeToLive: number = 0;
public remainingGrowTime: number = 0;
public publiclyBreedable: boolean = false;
constructor(public readonly type: string)
{}
}
@@ -0,0 +1,23 @@
import { IAvatarInfo } from './IAvatarInfo';
export class AvatarInfoRentableBot implements IAvatarInfo
{
public static RENTABLE_BOT: string = 'IRBI_RENTABLE_BOT';
public name: string = '';
public motto: string = '';
public webID: number = 0;
public figure: string = '';
public badges: string[] = [];
public carryItem: number = 0;
public roomIndex: number = 0;
public amIOwner: boolean = false;
public amIAnyRoomController: boolean = false;
public roomControllerLevel: number = 0;
public ownerId: number = -1;
public ownerName: string = '';
public botSkills: number[] = [];
constructor(public readonly type: string)
{}
}
+52
View File
@@ -0,0 +1,52 @@
import { IAvatarInfo } from './IAvatarInfo';
export class AvatarInfoUser implements IAvatarInfo
{
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;
public static DEFAULT_BOT_BADGE_ID: string = 'BOT';
public name: string = '';
public motto: string = '';
public achievementScore: number = 0;
public backgroundId: number = 0;
public standId: number = 0;
public overlayId: number = 0;
public webID: number = 0;
public xp: number = 0;
public userType: number = -1;
public figure: string = '';
public badges: string[] = [];
public groupId: number = 0;
public groupName: string = '';
public groupBadgeId: string = '';
public carryItem: number = 0;
public roomIndex: number = 0;
public isSpectatorMode: boolean = false;
public allowNameChange: boolean = false;
public amIOwner: boolean = false;
public amIAnyRoomController: boolean = false;
public roomControllerLevel: number = 0;
public canBeKicked: boolean = false;
public canBeBanned: boolean = false;
public canBeMuted: boolean = false;
public respectLeft: number = 0;
public isIgnored: boolean = false;
public isGuildRoom: boolean = false;
public canTrade: boolean = false;
public canTradeReason: number = 0;
public targetRoomControllerLevel: number = 0;
public isAmbassador: boolean = false;
constructor(public readonly type: string)
{}
public get isOwnUser(): boolean
{
return (this.type === AvatarInfoUser.OWN_USER);
}
}
+442
View File
@@ -0,0 +1,442 @@
import { GetRoomEngine, GetSessionDataManager, GetTickerTime, IFurnitureData, IRoomModerationSettings, IRoomPetData, IRoomUserData, ObjectDataFactory, PetFigureData, PetType, RoomControllerLevel, RoomModerationSettings, RoomObjectCategory, RoomObjectType, RoomObjectVariable, RoomTradingLevelEnum, RoomWidgetEnumItemExtradataParameter } from '@nitrots/nitro-renderer';
import { GetRoomSession, 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 roomObject = GetRoomEngine().getRoomObject(roomSession.roomId, objectId, category);
if(!roomObject) return null;
const furniInfo = new AvatarInfoFurni(AvatarInfoFurni.FURNI);
furniInfo.id = objectId;
furniInfo.category = category;
const model = roomObject.model;
if(model.getValue<string>(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM)) furniInfo.extraParam = model.getValue<string>(RoomWidgetEnumItemExtradataParameter.INFOSTAND_EXTRA_PARAM);
const objectData = ObjectDataFactory.getData(model.getValue<number>(RoomObjectVariable.FURNITURE_DATA_FORMAT));
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;
}
}
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 - ((GetTickerTime() - 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;
if(IsOwnerOfFurniture(roomObject)) furniInfo.isOwner = true;
return furniInfo;
}
public static getUserInfo(category: number, userData: IRoomUserData): AvatarInfoUser
{
const roomSession = GetRoomSession();
const userInfo = new AvatarInfoUser((userData.webID === GetSessionDataManager().userId) ? AvatarInfoUser.OWN_USER : AvatarInfoUser.PEER);
userInfo.isSpectatorMode = roomSession.isSpectator;
userInfo.name = userData.name;
userInfo.motto = userData.custom;
userInfo.backgroundId = userData.background;
userInfo.standId = userData.stand;
userInfo.overlayId = userData.overlay;
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(userInfo.type === 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(userInfo.type === AvatarInfoUser.PEER)
{
if(roomObject)
{
userInfo.targetRoomControllerLevel = roomObject.model.getValue<number>(RoomObjectVariable.FIGURE_FLAT_CONTROL);
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.FREE_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().getUserTags(_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().getUserTags(userData.webID);
//this._Str_16287(userData.webId, _local_8);
//this._container.habboGroupsManager.updateVisibleExtendedProfile(userData.webID);
//this._container.connection.send(new GetRelationshipStatusInfoMessageComposer(userData.webId));
return userInfo;
}
public static getBotInfo(category: number, userData: IRoomUserData): 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: IRoomUserData): 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: IRoomPetData): 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: IRoomModerationSettings) => 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: IRoomModerationSettings) =>
{
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: IRoomModerationSettings) =>
{
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: IRoomModerationSettings) =>
{
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);
}
}
+18
View File
@@ -0,0 +1,18 @@
export class BotSkillsEnum
{
public static GENERIC_SKILL: number = 0;
public static DRESS_UP: number = 1;
public static SETUP_CHAT: number = 2;
public static RANDOM_WALK: number = 3;
public static DANCE: number = 4;
public static CHANGE_BOT_NAME: number = 5;
public static SERVE_BEVERAGE: number = 6;
public static INCLIENT_LINK: number = 7;
public static NUX_PROCEED: number = 8;
public static CHANGE_BOT_MOTTO: number = 9;
public static NUX_TAKE_TOUR: number = 10;
public static NO_PICK_UP: number = 12;
public static NAVIGATOR_SEARCH: number = 14;
public static DONATE_TO_USER: number = 24;
public static DONATE_TO_ALL: number = 25;
}
+54
View File
@@ -0,0 +1,54 @@
export class ChatBubbleMessage
{
public static BUBBLE_COUNTER: number = 0;
public id: number = -1;
public width: number = 0;
public height: number = 0;
public elementRef: HTMLDivElement = null;
public skipMovement: boolean = false;
private _top: number = 0;
private _left: number = 0;
constructor(
public senderId: number = -1,
public senderCategory: number = -1,
public roomId: number = -1,
public text: string = '',
public formattedText: string = '',
public username: string = '',
public location: { x: number, y: number } = null,
public type: number = 0,
public styleId: number = 0,
public imageUrl: string = null,
public color: string = null
)
{
this.id = ++ChatBubbleMessage.BUBBLE_COUNTER;
}
public get top(): number
{
return this._top;
}
public set top(value: number)
{
this._top = value;
if(this.elementRef) this.elementRef.style.top = (this._top + 'px');
}
public get left(): number
{
return this._left;
}
public set left(value: number)
{
this._left = value;
if(this.elementRef) this.elementRef.style.left = (this._left + 'px');
}
}
@@ -0,0 +1,69 @@
import { AvatarFigurePartType, AvatarScaleType, AvatarSetType, GetAvatarRenderManager, GetRoomEngine, PetFigureData, TextureUtils, Vector3d } from '@nitrots/nitro-renderer';
export class ChatBubbleUtilities
{
public static AVATAR_COLOR_CACHE: Map<string, number> = new Map();
public static AVATAR_IMAGE_CACHE: Map<string, string> = new Map();
public static PET_IMAGE_CACHE: Map<string, string> = new Map();
private static placeHolderImageUrl: string = '';
public static async setFigureImage(figure: string): Promise<string>
{
const avatarImage = GetAvatarRenderManager().createAvatarImage(figure, AvatarScaleType.LARGE, null, {
resetFigure: figure => this.setFigureImage(figure),
dispose: () =>
{},
disposed: false
});
if(!avatarImage) return null;
const isPlaceholder = avatarImage.isPlaceholder();
if(isPlaceholder && this.placeHolderImageUrl?.length) return this.placeHolderImageUrl;
figure = avatarImage.getFigure().getFigureString();
const imageUrl = avatarImage.processAsImageUrl(AvatarSetType.HEAD);
const color = avatarImage.getPartColor(AvatarFigurePartType.CHEST);
if(isPlaceholder) this.placeHolderImageUrl = imageUrl;
this.AVATAR_COLOR_CACHE.set(figure, ((color && color.rgb) || 16777215));
this.AVATAR_IMAGE_CACHE.set(figure, imageUrl);
avatarImage.dispose();
return imageUrl;
}
public static async getUserImage(figure: string): Promise<string>
{
let existing = this.AVATAR_IMAGE_CACHE.get(figure);
if(!existing) existing = await this.setFigureImage(figure);
return existing;
}
public static async getPetImage(figure: string, direction: number, _arg_3: boolean, scale: number = 64, posture: string = null)
{
let existing = this.PET_IMAGE_CACHE.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 = await TextureUtils.generateImageUrl(image.data);
this.PET_IMAGE_CACHE.set((figure + posture), existing);
}
return existing;
}
}
@@ -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;
}
@@ -0,0 +1,9 @@
export class DimmerFurnitureWidgetPresetItem
{
constructor(
public id: number = 0,
public type: number = 0,
public color: number = 0,
public light: number = 0)
{}
}
+6
View File
@@ -0,0 +1,6 @@
import { ChatBubbleMessage } from './ChatBubbleMessage';
export const DoChatsOverlap = (a: ChatBubbleMessage, b: ChatBubbleMessage, additionalBTop: number, padding: number = 0) =>
{
return !((((a.left + padding) + a.width) < (b.left + padding)) || ((a.left + padding) > ((b.left + padding) + b.width)) || ((a.top + a.height) < (b.top + additionalBTop)) || (a.top > ((b.top + additionalBTop) + b.height)));
};
@@ -0,0 +1,30 @@
import { GetRoomEngine } from '@nitrots/nitro-renderer';
import { 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);
}
}
+37
View File
@@ -0,0 +1,37 @@
const DISK_COLOR_RED_MIN: number = 130;
const DISK_COLOR_RED_RANGE: number = 100;
const DISK_COLOR_GREEN_MIN: number = 130;
const DISK_COLOR_GREEN_RANGE: number = 100;
const DISK_COLOR_BLUE_MIN: number = 130;
const DISK_COLOR_BLUE_RANGE: number = 100;
export const GetDiskColor = (name: string) =>
{
let r: number = 0;
let g: number = 0;
let b: number = 0;
let index: number = 0;
while(index < name.length)
{
switch((index % 3))
{
case 0:
r = (r + ( name.charCodeAt(index) * 37) );
break;
case 1:
g = (g + ( name.charCodeAt(index) * 37) );
break;
case 2:
b = (b + ( name.charCodeAt(index) * 37) );
break;
}
index++;
}
r = ((r % DISK_COLOR_RED_RANGE) + DISK_COLOR_RED_MIN);
g = ((g % DISK_COLOR_GREEN_RANGE) + DISK_COLOR_GREEN_MIN);
b = ((b % DISK_COLOR_BLUE_RANGE) + DISK_COLOR_BLUE_MIN);
return `rgb(${ r },${ g },${ b })`;
};
+4
View File
@@ -0,0 +1,4 @@
export interface IAvatarInfo
{
type: string;
}
@@ -0,0 +1,6 @@
export interface ICraftingIngredient
{
name: string;
iconUrl: string;
count: number;
}
+6
View File
@@ -0,0 +1,6 @@
export interface ICraftingRecipe
{
name: string;
localizedName: string;
iconUrl: string;
}
+42
View File
@@ -0,0 +1,42 @@
export interface IPhotoData
{
/**
* creator username
*/
n?: string;
/**
* creator user id
*/
s?: number;
/**
* photo unique id
*/
u?: number;
/**
* creation timestamp
*/
t?: number;
/**
* photo caption
*/
m?: string;
/**
* photo image url
*/
w?: string;
/**
* owner id
*/
oi?: number;
/**
* owner name
*/
o?: string;
}
@@ -0,0 +1,38 @@
import { AvatarFigurePartType, GetAvatarRenderManager, IAvatarFigureContainer } from '@nitrots/nitro-renderer';
export class MannequinUtilities
{
public static MANNEQUIN_FIGURE = [ 'hd', 99999, [ 99998 ] ];
public static MANNEQUIN_CLOTHING_PART_TYPES = [
AvatarFigurePartType.CHEST_ACCESSORY,
AvatarFigurePartType.COAT_CHEST,
AvatarFigurePartType.CHEST,
AvatarFigurePartType.LEGS,
AvatarFigurePartType.SHOES,
AvatarFigurePartType.WAIST_ACCESSORY
];
public static getMergedMannequinFigureContainer(figure: string, targetFigure: string): IAvatarFigureContainer
{
const figureContainer = GetAvatarRenderManager().createFigureContainer(figure);
const targetFigureContainer = GetAvatarRenderManager().createFigureContainer(targetFigure);
for(const part of this.MANNEQUIN_CLOTHING_PART_TYPES) figureContainer.removePart(part);
for(const part of targetFigureContainer.getPartTypeIds()) figureContainer.updatePart(part, targetFigureContainer.getPartSetId(part), targetFigureContainer.getPartColorIds(part));
return figureContainer;
}
public static transformAsMannequinFigure(figureContainer: IAvatarFigureContainer): void
{
for(const part of figureContainer.getPartTypeIds())
{
if(this.MANNEQUIN_CLOTHING_PART_TYPES.indexOf(part) >= 0) continue;
figureContainer.removePart(part);
}
figureContainer.updatePart((this.MANNEQUIN_FIGURE[0] as string), (this.MANNEQUIN_FIGURE[1] as number), (this.MANNEQUIN_FIGURE[2] as number[]));
};
}
@@ -0,0 +1,5 @@
export class PetSupplementEnum
{
public static WATER: number = 0;
public static LIGHT: number = 1;
}
+5
View File
@@ -0,0 +1,5 @@
export class PostureTypeEnum
{
public static POSTURE_STAND: number = 0;
public static POSTURE_SIT: number = 1;
}
+35
View File
@@ -0,0 +1,35 @@
export class RoomDimmerPreset
{
private _id: number;
private _type: number;
private _color: number;
private _brightness: number;
constructor(id: number, type: number, color: number, brightness: number)
{
this._id = id;
this._type = type;
this._color = color;
this._brightness = brightness;
}
public get id(): number
{
return this._id;
}
public get type(): number
{
return this._type;
}
public get color(): number
{
return this._color;
}
public get brightness(): number
{
return this._brightness;
}
}
+28
View File
@@ -0,0 +1,28 @@
export class RoomObjectItem
{
private _id: number;
private _category: number;
private _name: string;
constructor(id: number, category: number, name: string)
{
this._id = id;
this._category = category;
this._name = name;
}
public get id(): number
{
return this._id;
}
public get category(): number
{
return this._category;
}
public get name(): string
{
return this._name;
}
}
+12
View File
@@ -0,0 +1,12 @@
export class UseProductItem
{
constructor(
public readonly id: number,
public readonly category: number,
public readonly name: string,
public readonly requestRoomObjectId: number,
public readonly targetRoomObjectId: number,
public readonly requestInventoryStripId: number,
public readonly replace: boolean)
{}
}
+8
View File
@@ -0,0 +1,8 @@
export const VALUE_KEY_DISLIKE = '0';
export const VALUE_KEY_LIKE = '1';
export interface VoteValue
{
value: string;
secondsLeft: number;
}
@@ -0,0 +1,9 @@
export class YoutubeVideoPlaybackStateEnum
{
public static readonly UNSTARTED = -1;
public static readonly ENDED = 0;
public static readonly PLAYING = 1;
public static readonly PAUSED = 2;
public static readonly BUFFERING = 3;
public static readonly CUED = 5;
}
+26
View File
@@ -0,0 +1,26 @@
export * from './AvatarInfoFurni';
export * from './AvatarInfoName';
export * from './AvatarInfoPet';
export * from './AvatarInfoRentableBot';
export * from './AvatarInfoUser';
export * from './AvatarInfoUtilities';
export * from './BotSkillsEnum';
export * from './ChatBubbleMessage';
export * from './ChatBubbleUtilities';
export * from './ChatMessageTypeEnum';
export * from './DimmerFurnitureWidgetPresetItem';
export * from './DoChatsOverlap';
export * from './FurnitureDimmerUtilities';
export * from './GetDiskColor';
export * from './IAvatarInfo';
export * from './ICraftingIngredient';
export * from './ICraftingRecipe';
export * from './IPhotoData';
export * from './MannequinUtilities';
export * from './PetSupplementEnum';
export * from './PostureTypeEnum';
export * from './RoomDimmerPreset';
export * from './RoomObjectItem';
export * from './UseProductItem';
export * from './VoteValue';
export * from './YoutubeVideoPlaybackStateEnum';