mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2025-01-18 22:36:27 +01:00
Merge branch 'main' into dev
This commit is contained in:
commit
1b9b69969a
@ -24,6 +24,9 @@
|
||||
"SwitchCase": 1
|
||||
}
|
||||
],
|
||||
"no-multi-spaces": [
|
||||
"error"
|
||||
],
|
||||
"no-trailing-spaces": [
|
||||
"error",
|
||||
{
|
||||
|
2404
package-lock.json
generated
2404
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
17
package.json
17
package.json
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@nitrots/nitro-renderer",
|
||||
"description": "Javascript library for rendering Nitro in the browser using PixiJS",
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.5",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
@ -21,18 +21,19 @@
|
||||
"postinstall": "node ./post-install.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pixi/canvas-renderer": "^6.2.0",
|
||||
"@pixi/extract": "^6.2.0",
|
||||
"@pixi/canvas-renderer": "^6.2.2",
|
||||
"@pixi/extract": "^6.2.2",
|
||||
"@pixi/filter-adjustment": "^4.1.3",
|
||||
"@pixi/tilemap": "^3.2.2",
|
||||
"pako": "^2.0.4",
|
||||
"pixi.js": "^6.2.0"
|
||||
"pixi.js": "^6.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/pako": "^1.0.2",
|
||||
"@typescript-eslint/eslint-plugin": "^5.6.0",
|
||||
"@typescript-eslint/parser": "^5.6.0",
|
||||
"eslint": "^7.32.0",
|
||||
"@types/pako": "^1.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "^5.13.0",
|
||||
"@typescript-eslint/parser": "^5.13.0",
|
||||
"eslint": "^8.10.0",
|
||||
"tslib": "^2.3.1",
|
||||
"typescript": "~4.4.4"
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import { ICommunicationManager } from './communication/ICommunicationManager';
|
||||
import { ConfigurationManager } from './configuration/ConfigurationManager';
|
||||
import { IConfigurationManager } from './configuration/IConfigurationManager';
|
||||
import { INitroCore } from './INitroCore';
|
||||
import { NitroVersion } from './NitroVersion';
|
||||
import { SayHello } from './utils/SayHello';
|
||||
|
||||
export class NitroCore extends Disposable implements INitroCore
|
||||
{
|
||||
@ -18,9 +18,7 @@ export class NitroCore extends Disposable implements INitroCore
|
||||
{
|
||||
super();
|
||||
|
||||
window.console.log.apply(console, [
|
||||
`\n%c _ ___ __ \n / | / (_) /__________ \n / |/ / / __/ ___/ __ \\ \n / /| / / /_/ / / /_/ / \n /_/ |_/_/\\__/_/ \\____/ \n \n Thanks for using Nitro \n To report bugs or issues \n join us on Discord \n https://nitrots.co/discord \n \n Renderer: v${ NitroVersion.RENDERER_VERSION } \n UI: v${ NitroVersion.UI_VERSION } \n \n`,
|
||||
'color: #FFFFFF; background: #000000; padding:0px 0;' ]);
|
||||
SayHello();
|
||||
|
||||
this._configuration = new ConfigurationManager();
|
||||
this._communication = new CommunicationManager();
|
||||
|
@ -1,5 +1,5 @@
|
||||
export class NitroVersion
|
||||
{
|
||||
public static RENDERER_VERSION: string = '1.1.0';
|
||||
public static RENDERER_VERSION: string = '1.1.5';
|
||||
public static UI_VERSION: string = '';
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ export class NitroLogger implements INitroLogger
|
||||
|
||||
public static log(message: string, name: string = 'Nitro', modus: string = null): void
|
||||
{
|
||||
const logString = `[Nitro] ${ new Date().toDateString() } [${ name }] ${ message } ${ this.getTimestamp() }`;
|
||||
const logString = `[Nitro] [${ name }] ${ message } ${ this.getTimestamp() }`;
|
||||
|
||||
switch(modus)
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ import { ICommunicationManager } from './ICommunicationManager';
|
||||
|
||||
export class CommunicationManager extends Disposable implements ICommunicationManager, IUpdateReceiver
|
||||
{
|
||||
private _connections: IConnection[]
|
||||
private _connections: IConnection[];
|
||||
|
||||
constructor()
|
||||
{
|
||||
|
@ -301,9 +301,12 @@ export class SocketConnection extends EventDispatcher implements IConnection
|
||||
|
||||
try
|
||||
{
|
||||
const parser = events[0].parser;
|
||||
//@ts-ignore
|
||||
const parser = new events[0].parserClass();
|
||||
|
||||
if(!parser || !parser.flush() || !parser.parse(wrapper)) return null;
|
||||
|
||||
for(const event of events) (event.parser = parser);
|
||||
}
|
||||
|
||||
catch (e)
|
||||
|
@ -67,13 +67,6 @@ export class MessageClassManager
|
||||
existing = [];
|
||||
|
||||
this._messageInstancesById.set(header, existing);
|
||||
|
||||
//@ts-ignore
|
||||
event.parser = new event.parserClass();
|
||||
}
|
||||
else
|
||||
{
|
||||
event.parser = existing[0].parser;
|
||||
}
|
||||
|
||||
existing.push(event);
|
||||
|
26
src/core/utils/SayHello.ts
Normal file
26
src/core/utils/SayHello.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { NitroVersion } from '..';
|
||||
|
||||
export const SayHello = () =>
|
||||
{
|
||||
if(navigator.userAgent.toLowerCase().indexOf('chrome') > -1)
|
||||
{
|
||||
const args = [
|
||||
`\n %c %c %c Nitro ${ NitroVersion.UI_VERSION } - Renderer ${ NitroVersion.RENDERER_VERSION } %c %c %c https://nitrots.co/discord %c %c \n\n`,
|
||||
'background: #ffffff; padding:5px 0;',
|
||||
'background: #ffffff; padding:5px 0;',
|
||||
'color: #ffffff; background: #000000; padding:5px 0;',
|
||||
'background: #ffffff; padding:5px 0;',
|
||||
'background: #ffffff; padding:5px 0;',
|
||||
'background: #000000; padding:5px 0;',
|
||||
'background: #ffffff; padding:5px 0;',
|
||||
'background: #ffffff; padding:5px 0;'
|
||||
];
|
||||
|
||||
self.console.log(...args);
|
||||
}
|
||||
|
||||
else if(self.console)
|
||||
{
|
||||
self.console.log(`Nitro ${ NitroVersion.UI_VERSION } - Renderer ${ NitroVersion.RENDERER_VERSION } `);
|
||||
}
|
||||
};
|
@ -49,6 +49,7 @@ import { GroupInformationEvent } from './messages/incoming/group/GroupInformatio
|
||||
import { GroupMembersEvent } from './messages/incoming/group/GroupMembersEvent';
|
||||
import { GroupPurchasedEvent } from './messages/incoming/group/GroupPurchasedEvent';
|
||||
import { GroupSettingsEvent } from './messages/incoming/group/GroupSettingsEvent';
|
||||
import { HabboGroupDeactivatedMessageEvent } from './messages/incoming/group/HabboGroupDeactivatedMessageEvent';
|
||||
import { CallForHelpDisabledNotifyMessageEvent } from './messages/incoming/help/CallForHelpDisabledNotifyMessageEvent';
|
||||
import { CallForHelpResultMessageEvent } from './messages/incoming/help/CallForHelpResultMessageEvent';
|
||||
import { GuideReportingStatusMessageEvent } from './messages/incoming/help/GuideReportingStatusMessageEvent';
|
||||
@ -604,6 +605,7 @@ export class NitroMessages implements IMessageConfiguration
|
||||
this._events.set(IncomingHeader.GROUP_SETTINGS, GroupSettingsEvent);
|
||||
this._events.set(IncomingHeader.GROUP_PURCHASED, GroupPurchasedEvent);
|
||||
this._events.set(IncomingHeader.GROUP_BADGES, GroupBadgesEvent);
|
||||
this._events.set(IncomingHeader.GROUP_DEACTIVATE, HabboGroupDeactivatedMessageEvent);
|
||||
|
||||
// HELP
|
||||
this._events.set(IncomingHeader.CFH_DISABLED_NOTIFY, CallForHelpDisabledNotifyMessageEvent);
|
||||
@ -961,8 +963,8 @@ export class NitroMessages implements IMessageConfiguration
|
||||
// CRAFTING
|
||||
this._composers.set(OutgoingHeader.CRAFT, CraftComposer);
|
||||
this._composers.set(OutgoingHeader.CRAFT_SECRET, CraftSecretComposer);
|
||||
this._composers.set(OutgoingHeader.GET_CRAFTABLE_PRODUCTS, GetCraftableProductsComposer);
|
||||
this._composers.set(OutgoingHeader.GET_CRAFTING_RECIPE, GetCraftingRecipeComposer);
|
||||
this._composers.set(OutgoingHeader.GET_CRAFTABLE_PRODUCTS, GetCraftingRecipeComposer);
|
||||
this._composers.set(OutgoingHeader.GET_CRAFTING_RECIPE, GetCraftableProductsComposer);
|
||||
this._composers.set(OutgoingHeader.GET_CRAFTING_RECIPES_AVAILABLE, GetCraftingRecipesAvailableComposer);
|
||||
|
||||
// FRIENDFURNI
|
||||
|
@ -364,4 +364,5 @@ export class IncomingHeader
|
||||
public static CHAT_REVIEW_SESSION_VOTING_STATUS = 1829;
|
||||
public static SCR_SEND_KICKBACK_INFO = 3277;
|
||||
public static PET_STATUS = 1907;
|
||||
public static GROUP_DEACTIVATE = 3129;
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
export * from './CraftableProductsEvent';
|
||||
export * from './CraftingRecipeEvent';
|
||||
export * from './CraftingRecipesAvailableEvent';
|
||||
export * from './CraftingResultEvent';
|
@ -0,0 +1,16 @@
|
||||
import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent';
|
||||
import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent';
|
||||
import { HabboGroupDeactivatedMessageParser } from '../../parser/group/HabboGroupDeactivatedMessageParser';
|
||||
|
||||
export class HabboGroupDeactivatedMessageEvent extends MessageEvent implements IMessageEvent
|
||||
{
|
||||
constructor(callBack: Function)
|
||||
{
|
||||
super(callBack, HabboGroupDeactivatedMessageParser);
|
||||
}
|
||||
|
||||
public getParser(): HabboGroupDeactivatedMessageParser
|
||||
{
|
||||
return this.parser as HabboGroupDeactivatedMessageParser;
|
||||
}
|
||||
}
|
@ -6,3 +6,4 @@ export * from './GroupInformationEvent';
|
||||
export * from './GroupMembersEvent';
|
||||
export * from './GroupPurchasedEvent';
|
||||
export * from './GroupSettingsEvent';
|
||||
export * from './HabboGroupDeactivatedMessageEvent';
|
||||
|
@ -7,6 +7,7 @@ export * from './camera';
|
||||
export * from './campaign';
|
||||
export * from './catalog';
|
||||
export * from './client';
|
||||
export * from './crafting';
|
||||
export * from './desktop';
|
||||
export * from './friendlist';
|
||||
export * from './game';
|
||||
|
@ -7,7 +7,7 @@ export class CfhChatlogData
|
||||
private _callerUserId: number;
|
||||
private _reportedUserId: number;
|
||||
private _chatRecordId: number;
|
||||
private _chatRecord: ChatRecordData
|
||||
private _chatRecord: ChatRecordData;
|
||||
|
||||
constructor(k:IMessageDataWrapper)
|
||||
{
|
||||
|
@ -367,7 +367,7 @@ export class OutgoingHeader
|
||||
public static GUIDE_SESSION_GUIDE_DECIDES = 1424;
|
||||
public static GUIDE_SESSION_INVITE_REQUESTER = 234;
|
||||
public static GUIDE_SESSION_IS_TYPING = 519;
|
||||
public static GUIDE_SESSION_MESSAGE = 3899
|
||||
public static GUIDE_SESSION_MESSAGE = 3899;
|
||||
public static GUIDE_SESSION_ON_DUTY_UPDATE = 1922;
|
||||
public static GUIDE_SESSION_REPORT = 3969;
|
||||
public static GUIDE_SESSION_REQUESTER_CANCELS = 291;
|
||||
|
@ -4,7 +4,7 @@ export class GetCraftableProductsComposer implements IMessageComposer<Constructo
|
||||
{
|
||||
private _data: ConstructorParameters<typeof GetCraftableProductsComposer>;
|
||||
|
||||
constructor(k: string)
|
||||
constructor(k: number)
|
||||
{
|
||||
this._data = [k];
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ export class GetCraftingRecipeComposer implements IMessageComposer<ConstructorPa
|
||||
{
|
||||
private _data: ConstructorParameters<typeof GetCraftingRecipeComposer>;
|
||||
|
||||
constructor(k: number)
|
||||
constructor(k: string)
|
||||
{
|
||||
this._data = [k];
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
export * from './CraftComposer';
|
||||
export * from './CraftSecretComposer';
|
||||
export * from './GetCraftableProductsComposer';
|
||||
export * from './GetCraftingRecipeComposer';
|
||||
export * from './GetCraftingRecipesAvailableComposer';
|
@ -4,6 +4,7 @@ export * from './camera';
|
||||
export * from './campaign';
|
||||
export * from './catalog';
|
||||
export * from './competition';
|
||||
export * from './crafting';
|
||||
export * from './desktop';
|
||||
export * from './friendfurni';
|
||||
export * from './friendlist';
|
||||
|
@ -0,0 +1,6 @@
|
||||
export * from './CraftableProductsMessageParser';
|
||||
export * from './CraftingRecipeIngredientParser';
|
||||
export * from './CraftingRecipeMessageParser';
|
||||
export * from './CraftingRecipesAvailableMessageParser';
|
||||
export * from './CraftingResultMessageParser';
|
||||
export * from './CraftingResultObjectParser';
|
@ -0,0 +1,24 @@
|
||||
import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper';
|
||||
import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser';
|
||||
|
||||
export class HabboGroupDeactivatedMessageParser implements IMessageParser
|
||||
{
|
||||
private _groupId: number;
|
||||
|
||||
public flush():boolean
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public parse(wrapper: IMessageDataWrapper):boolean
|
||||
{
|
||||
this._groupId = wrapper.readInt();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public get groupId(): number
|
||||
{
|
||||
return this._groupId;
|
||||
}
|
||||
}
|
@ -6,4 +6,5 @@ export * from './GroupInformationParser';
|
||||
export * from './GroupMembersParser';
|
||||
export * from './GroupPurchasedParser';
|
||||
export * from './GroupSettingsParser';
|
||||
export * from './HabboGroupDeactivatedMessageParser';
|
||||
export * from './utils';
|
||||
|
@ -3,11 +3,12 @@ import { IMessageDataWrapper, IMessageParser } from '../../../../../core';
|
||||
export class IssueCloseNotificationMessageParser implements IMessageParser
|
||||
{
|
||||
private _closeReason: number;
|
||||
private _messageText: string;
|
||||
|
||||
public flush(): boolean
|
||||
{
|
||||
this._closeReason = 0;
|
||||
|
||||
this._messageText = '';
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -16,6 +17,7 @@ export class IssueCloseNotificationMessageParser implements IMessageParser
|
||||
if(!wrapper) return false;
|
||||
|
||||
this._closeReason = wrapper.readInt();
|
||||
this._messageText = wrapper.readString();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -24,4 +26,9 @@ export class IssueCloseNotificationMessageParser implements IMessageParser
|
||||
{
|
||||
return this._closeReason;
|
||||
}
|
||||
|
||||
public get messageText(): string
|
||||
{
|
||||
return this._messageText;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ export * from './campaign';
|
||||
export * from './catalog';
|
||||
export * from './client';
|
||||
export * from './competition';
|
||||
export * from './crafting';
|
||||
export * from './desktop';
|
||||
export * from './friendlist';
|
||||
export * from './game';
|
||||
|
@ -3,7 +3,7 @@
|
||||
export class FigureSetIdsMessageParser implements IMessageParser
|
||||
{
|
||||
private _figureSetIds: number[];
|
||||
private _boundFurnitureNames: string[]
|
||||
private _boundFurnitureNames: string[];
|
||||
|
||||
public flush(): boolean
|
||||
{
|
||||
|
@ -2,7 +2,7 @@ import { IMessageDataWrapper, IMessageParser } from '../../../../../core';
|
||||
|
||||
export class MOTDNotificationParser implements IMessageParser
|
||||
{
|
||||
private _messages: string[]
|
||||
private _messages: string[];
|
||||
|
||||
public flush(): boolean
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ export class PollContentsParser implements IMessageParser
|
||||
private _endMessage = '';
|
||||
private _numQuestions = 0;
|
||||
private _questionArray:PollQuestion[] = [];
|
||||
private _npsPoll = false
|
||||
private _npsPoll = false;
|
||||
|
||||
flush(): boolean
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ export class TalentTrackLevel
|
||||
{
|
||||
private _level: number;
|
||||
private _state: number;
|
||||
private _tasks: TalentTrackTask[]
|
||||
private _tasks: TalentTrackTask[];
|
||||
private _rewardPerks: string[];
|
||||
private _rewardProducts: TalentTrackRewardProduct[];
|
||||
|
||||
|
@ -34,7 +34,7 @@ export class RoomEngineTriggerWidgetEvent extends RoomEngineObjectEvent
|
||||
public static REQUEST_INTERNAL_LINK: string = 'RETWE_REQUEST_INTERNAL_LINK';
|
||||
public static REQUEST_ROOM_LINK: string = 'RETWE_REQUEST_ROOM_LINK';
|
||||
|
||||
private _widget: string
|
||||
private _widget: string;
|
||||
|
||||
constructor(type: string, roomId: number, objectId: number, category: number, widget: string = null)
|
||||
{
|
||||
|
@ -506,7 +506,7 @@ export class FurnitureVisualization extends RoomObjectSpriteVisualization
|
||||
|
||||
protected getLayerYOffset(scale: number, direction: number, layerId: number): number
|
||||
{
|
||||
if(layerId === this._shadowLayerIndex) return Math.ceil((this._furnitureLift * (64 / 2)));
|
||||
if(layerId === this._shadowLayerIndex) return Math.ceil((this._furnitureLift * (scale / 2)));
|
||||
|
||||
const existing = this._spriteYOffsets[layerId];
|
||||
|
||||
|
@ -258,8 +258,6 @@ export class RoomPreviewer
|
||||
|
||||
if(this.isRoomEngineReady)
|
||||
{
|
||||
if((this._currentPreviewObjectCategory === RoomObjectCategory.FLOOR) && (this._currentPreviewObjectType === classId)) return RoomPreviewer.PREVIEW_OBJECT_ID;
|
||||
|
||||
this.reset(false);
|
||||
|
||||
this._currentPreviewObjectType = classId;
|
||||
@ -512,7 +510,7 @@ export class RoomPreviewer
|
||||
return this._addViewOffset;
|
||||
}
|
||||
|
||||
private updatePreviewObjectBoundingRectangle(point: Point): void
|
||||
public updatePreviewObjectBoundingRectangle(point: Point): void
|
||||
{
|
||||
const objectBounds = this._roomEngine.getRoomObjectBoundingRectangle(this._previewRoomId, RoomPreviewer.PREVIEW_OBJECT_ID, this._currentPreviewObjectCategory, RoomPreviewer.PREVIEW_CANVAS_ID);
|
||||
|
||||
|
@ -2,7 +2,7 @@ export class FurnitureStackingHeightMap
|
||||
{
|
||||
private _width: number;
|
||||
private _height: number;
|
||||
private _heights: number[]
|
||||
private _heights: number[];
|
||||
private _isNotStackable: boolean[];
|
||||
private _isRoomTile: boolean[];
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Resource, Texture } from '@pixi/core';
|
||||
import { NitroContainer, NitroTexture } from '../../..';
|
||||
import { IAssetManager } from '../../../core/asset/IAssetManager';
|
||||
import { IMessageEvent } from '../../../core/communication/messages/IMessageEvent';
|
||||
import { NitroSprite } from '../../../core/utils/proxy/NitroSprite';
|
||||
@ -100,18 +101,18 @@ export class BadgeImageManager implements IDisposable
|
||||
{
|
||||
const url = this.getBadgeUrl(badgeName, type);
|
||||
|
||||
if(!url || !url.length) return null;
|
||||
|
||||
const existing = this._assets.getTexture(url);
|
||||
|
||||
if(existing) return existing.clone();
|
||||
|
||||
if(this._requestedBadges.get(badgeName)) return null;
|
||||
|
||||
if(url)
|
||||
{
|
||||
this._requestedBadges.set(badgeName, true);
|
||||
|
||||
if(type === BadgeImageManager.NORMAL_BADGE)
|
||||
{
|
||||
if(this._requestedBadges.get(badgeName)) return null;
|
||||
|
||||
this._requestedBadges.set(badgeName, true);
|
||||
|
||||
this._assets.downloadAsset(url, (flag: boolean) =>
|
||||
{
|
||||
if(flag)
|
||||
@ -124,17 +125,14 @@ export class BadgeImageManager implements IDisposable
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
|
||||
else if(type === BadgeImageManager.GROUP_BADGE)
|
||||
{
|
||||
if(!this._readyToGenerateGroupBadges)
|
||||
{
|
||||
if(!this._groupBadgesQueue.get(badgeName)) this._groupBadgesQueue.set(badgeName, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.loadGroupBadge(badgeName);
|
||||
}
|
||||
}
|
||||
if(this._groupBadgesQueue.get(badgeName)) return;
|
||||
|
||||
this._groupBadgesQueue.set(badgeName, true);
|
||||
|
||||
if(this._readyToGenerateGroupBadges) this.loadGroupBadge(badgeName);
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -170,80 +168,65 @@ export class BadgeImageManager implements IDisposable
|
||||
private loadGroupBadge(badgeCode: string): void
|
||||
{
|
||||
const groupBadge = new GroupBadge(badgeCode);
|
||||
const imagePath = Nitro.instance.getConfiguration<string>('badge.asset.grouparts.url');
|
||||
|
||||
const urlsToLoad: string[] = [];
|
||||
|
||||
const partMatches = [...badgeCode.matchAll(/[b|s][0-9]{5,6}/g)];
|
||||
|
||||
for(const partMatch of partMatches)
|
||||
{
|
||||
const partCode = partMatch[0];
|
||||
const shortMethod = (partCode.length === 6);
|
||||
|
||||
const partType = partCode[0];
|
||||
const partId = parseInt(partCode.slice(1, shortMethod ? 3 : 4));
|
||||
const partColor = parseInt(partCode.slice(shortMethod ? 3 : 4, shortMethod ? 5 : 6));
|
||||
const partPosition = parseInt(partCode.slice(shortMethod ? 5 : 6, shortMethod ? 6 : 7));
|
||||
|
||||
const part = new GroupBadgePart(partType, partId, partColor, partPosition);
|
||||
|
||||
groupBadge.parts.push(part);
|
||||
|
||||
const isBase = (partType === 'b');
|
||||
|
||||
const requiredAssets = isBase ? this._groupBases.get(partId) : this._groupSymbols.get(partId);
|
||||
|
||||
if(!requiredAssets) continue;
|
||||
|
||||
for(const requiredAsset of requiredAssets)
|
||||
{
|
||||
if(requiredAsset.length > 0)
|
||||
{
|
||||
const url = imagePath.replace('%part%', requiredAsset);
|
||||
part.urls.push(url);
|
||||
|
||||
if(!this._assets.getAsset(requiredAsset)) urlsToLoad.push(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(urlsToLoad.length === 0) return this.renderGroupBadge(groupBadge);
|
||||
|
||||
this._assets.downloadAssets(urlsToLoad, (flag: boolean) =>
|
||||
{
|
||||
this.renderGroupBadge(groupBadge);
|
||||
});
|
||||
}
|
||||
|
||||
private renderGroupBadge(groupBadge: GroupBadge): void
|
||||
{
|
||||
const container = new NitroContainer();
|
||||
const tempSprite = new NitroSprite(NitroTexture.EMPTY);
|
||||
|
||||
tempSprite.width = GroupBadgePart.IMAGE_WIDTH;
|
||||
tempSprite.height = GroupBadgePart.IMAGE_HEIGHT;
|
||||
|
||||
container.addChild(tempSprite);
|
||||
|
||||
for(const part of groupBadge.parts)
|
||||
{
|
||||
let isFirst = true;
|
||||
for(const partUrl of part.urls)
|
||||
|
||||
const partNames = ((part.type === 'b') ? this._groupBases.get(part.key) : this._groupSymbols.get(part.key));
|
||||
|
||||
for(const partName of partNames)
|
||||
{
|
||||
const texture = this._assets.getTexture(partUrl);
|
||||
if(!partName || !partName.length) continue;
|
||||
|
||||
if(!texture) continue; //Generate with what we got
|
||||
const texture = this._assets.getTexture(`badgepart_${ partName }`);
|
||||
|
||||
const pos = part.calculatePosition(texture);
|
||||
if(!texture) continue;
|
||||
|
||||
const { x, y } = part.calculatePosition(texture);
|
||||
const sprite = new NitroSprite(texture);
|
||||
sprite.x = pos.x;
|
||||
sprite.y = pos.y;
|
||||
|
||||
sprite.position.set(x, y);
|
||||
|
||||
if(isFirst) sprite.tint = parseInt(this._groupPartColors.get(part.color), 16);
|
||||
|
||||
isFirst = false;
|
||||
|
||||
groupBadge.container.addChild(sprite);
|
||||
container.addChild(sprite);
|
||||
}
|
||||
}
|
||||
|
||||
this._requestedBadges.delete(groupBadge.code);
|
||||
this._groupBadgesQueue.delete(groupBadge.code);
|
||||
|
||||
const texture = TextureUtils.generateTexture(groupBadge.container);
|
||||
const texture = TextureUtils.generateTexture(container);
|
||||
this._assets.setTexture(groupBadge.code, texture);
|
||||
|
||||
if(this._sessionDataManager) this._sessionDataManager.events.dispatchEvent(new BadgeImageReadyEvent(groupBadge.code, texture));
|
||||
@ -257,23 +240,14 @@ export class BadgeImageManager implements IDisposable
|
||||
|
||||
if(!data) return;
|
||||
|
||||
data.bases.forEach( (names, id) =>
|
||||
{
|
||||
this._groupBases.set(id, names.map( val => val.replace('.png', '').replace('.gif', '')));
|
||||
});
|
||||
data.bases.forEach((names, id) => this._groupBases.set(id, names.map( val => val.replace('.png', '').replace('.gif', ''))));
|
||||
|
||||
data.symbols.forEach( (names, id) =>
|
||||
{
|
||||
this._groupSymbols.set(id, names.map( val => val.replace('.png', '').replace('.gif', '')));
|
||||
});
|
||||
data.symbols.forEach( (names, id) => this._groupSymbols.set(id, names.map( val => val.replace('.png', '').replace('.gif', ''))));
|
||||
|
||||
this._groupPartColors = data.partColors;
|
||||
this._readyToGenerateGroupBadges = true;
|
||||
|
||||
this._groupBadgesQueue.forEach((_, badgeCode) =>
|
||||
{
|
||||
this.loadGroupBadge(badgeCode);
|
||||
});
|
||||
for(const badgeCode of this._groupBadgesQueue.keys()) this.loadGroupBadge(badgeCode);
|
||||
}
|
||||
|
||||
public get disposed(): boolean
|
||||
|
@ -1,17 +1,14 @@
|
||||
import { NitroContainer } from '../../..';
|
||||
import { GroupBadgePart } from './GroupBadgePart';
|
||||
|
||||
export class GroupBadge
|
||||
{
|
||||
private _code: string;
|
||||
private _parts: GroupBadgePart[];
|
||||
private _container: NitroContainer;
|
||||
|
||||
constructor(code: string)
|
||||
{
|
||||
this._code = code;
|
||||
this._parts = [];
|
||||
this._container = new NitroContainer();
|
||||
}
|
||||
|
||||
public get code(): string
|
||||
@ -23,9 +20,4 @@ export class GroupBadge
|
||||
{
|
||||
return this._parts;
|
||||
}
|
||||
|
||||
public get container(): NitroContainer
|
||||
{
|
||||
return this._container;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ export class GroupBadgePart
|
||||
public static BASE: string = 'b';
|
||||
public static SYMBOL: string = 's';
|
||||
public static SYMBOL_ALT: string = 't';
|
||||
|
||||
public static BASE_PART: number = 0;
|
||||
public static LAYER_PART: number = 1;
|
||||
public static IMAGE_WIDTH: number = 39;
|
||||
@ -17,15 +16,13 @@ export class GroupBadgePart
|
||||
public key: number;
|
||||
public color: number;
|
||||
public position: number;
|
||||
public urls: string[];
|
||||
|
||||
constructor(type: string, key?: number, color?: number, position?: number)
|
||||
constructor(type: string, key: number = 0, color: number = 0, position: number = 0)
|
||||
{
|
||||
this.type = type;
|
||||
this.key = key ? key : 0;
|
||||
this.color = color ? color : 0;
|
||||
this.position = position ? position : 4;
|
||||
this.urls = [];
|
||||
this.key = key;
|
||||
this.color = color;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public get code(): string
|
||||
|
@ -21,6 +21,10 @@ export interface IRoomRenderingCanvas
|
||||
handleMouseEvent(x: number, y: number, type: string, altKey: boolean, ctrlKey: boolean, shiftKey: boolean, buttonDown: boolean): boolean;
|
||||
getSortableSpriteList(): RoomObjectSpriteData[];
|
||||
getDisplayAsTexture(): RenderTexture;
|
||||
moveLeft(): void;
|
||||
moveRight(): void;
|
||||
moveUp(): void;
|
||||
moveDown(): void;
|
||||
id: number;
|
||||
geometry: IRoomGeometry;
|
||||
master: DisplayObject;
|
||||
|
@ -12,6 +12,7 @@ import { RoomObjectSpriteType } from '../object/enum/RoomObjectSpriteType';
|
||||
import { IRoomObject } from '../object/IRoomObject';
|
||||
import { IRoomObjectSprite } from '../object/visualization/IRoomObjectSprite';
|
||||
import { IRoomObjectSpriteVisualization } from '../object/visualization/IRoomObjectSpriteVisualization';
|
||||
import { RoomRotatingEffect, RoomShakingEffect } from '../utils';
|
||||
import { IRoomGeometry } from '../utils/IRoomGeometry';
|
||||
import { RoomEnterEffect } from '../utils/RoomEnterEffect';
|
||||
import { RoomGeometry } from '../utils/RoomGeometry';
|
||||
@ -63,6 +64,14 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
|
||||
private _eventId: number;
|
||||
private _scale: number;
|
||||
|
||||
private _SafeStr_4507: boolean = false;
|
||||
private _rotation: number = 0;
|
||||
private _rotationOrigin: Vector3d = null;
|
||||
private _rotationRodLength: number = 0;
|
||||
private _effectDirection: Vector3d;
|
||||
private _effectLocation: Vector3d;
|
||||
private _SafeStr_795: number = 0;
|
||||
|
||||
private _restrictsScaling: boolean;
|
||||
private _noSpriteVisibilityChecking: boolean;
|
||||
private _usesExclusionRectangles: boolean;
|
||||
@ -353,6 +362,8 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
|
||||
update = true;
|
||||
}
|
||||
|
||||
this.doMagic();
|
||||
|
||||
const frame = Math.round(this._totalTimeRunning / (60 / this._animationFPS));
|
||||
|
||||
let updateVisuals = false;
|
||||
@ -1033,6 +1044,177 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas
|
||||
return renderTexture;
|
||||
}
|
||||
|
||||
private doMagic(): void
|
||||
{
|
||||
const geometry = (this.geometry as RoomGeometry);
|
||||
|
||||
if(this._rotation !== 0)
|
||||
{
|
||||
let direction = this._effectDirection;
|
||||
|
||||
geometry.direction = new Vector3d((direction.x + this._rotation), direction.y, direction.z);
|
||||
|
||||
direction = (geometry.direction as Vector3d);
|
||||
|
||||
geometry.setDepthVector(new Vector3d(direction.x, direction.y, 5));
|
||||
|
||||
const location = new Vector3d();
|
||||
|
||||
location.assign(this._rotationOrigin);
|
||||
|
||||
location.x = (location.x + ((this._rotationRodLength * Math.cos((((direction.x + 180) / 180) * 3.14159265358979))) * Math.cos(((direction.y / 180) * 3.14159265358979))));
|
||||
location.y = (location.y + ((this._rotationRodLength * Math.sin((((direction.x + 180) / 180) * 3.14159265358979))) * Math.cos(((direction.y / 180) * 3.14159265358979))));
|
||||
location.z = (location.z + (this._rotationRodLength * Math.sin(((direction.y / 180) * 3.14159265358979))));
|
||||
|
||||
geometry.location = location;
|
||||
|
||||
this._effectLocation = new Vector3d();
|
||||
this._effectLocation.assign(location);
|
||||
this._effectDirection = new Vector3d();
|
||||
this._effectDirection.assign(geometry.direction);
|
||||
}
|
||||
|
||||
if(RoomShakingEffect.isVisualizationOn() && !this._SafeStr_4507)
|
||||
{
|
||||
this.changeShaking();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!RoomShakingEffect.isVisualizationOn() && this._SafeStr_4507) this.changeShaking();
|
||||
}
|
||||
|
||||
if(RoomRotatingEffect.isVisualizationOn()) this.changeRotation();
|
||||
|
||||
if(this._SafeStr_4507)
|
||||
{
|
||||
this._SafeStr_795++;
|
||||
|
||||
const _local_4 = this._effectDirection;
|
||||
const _local_1 = Vector3d.sum(_local_4, new Vector3d((Math.sin((((this._SafeStr_795 * 5) / 180) * 3.14159265358979)) * 2), (Math.sin(((this._SafeStr_795 / 180) * 3.14159265358979)) * 5), (Math.sin((((this._SafeStr_795 * 10) / 180) * 3.14159265358979)) * 2)));
|
||||
|
||||
geometry.direction = _local_1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._SafeStr_795 = 0;
|
||||
|
||||
geometry.direction = this._effectDirection;
|
||||
}
|
||||
}
|
||||
|
||||
private changeShaking(): void
|
||||
{
|
||||
this._SafeStr_4507 = !this._SafeStr_4507;
|
||||
|
||||
if(this._SafeStr_4507)
|
||||
{
|
||||
const direction = this.geometry.direction;
|
||||
|
||||
this._effectDirection = new Vector3d(direction.x, direction.y, direction.z);
|
||||
}
|
||||
}
|
||||
|
||||
private changeRotation(): void
|
||||
{
|
||||
if(this._SafeStr_4507) return;
|
||||
|
||||
const geometry = (this.geometry as RoomGeometry);
|
||||
|
||||
if(!geometry) return;
|
||||
|
||||
if(this._rotation === 0)
|
||||
{
|
||||
const location = geometry.location;
|
||||
const directionAxis = geometry.directionAxis;
|
||||
|
||||
this._effectLocation = new Vector3d();
|
||||
this._effectLocation.assign(location);
|
||||
this._effectDirection = new Vector3d();
|
||||
this._effectDirection.assign(geometry.direction);
|
||||
|
||||
const intersection = RoomGeometry.getIntersectionVector(location, directionAxis, new Vector3d(0, 0, 0), new Vector3d(0, 0, 1));
|
||||
|
||||
if(intersection !== null)
|
||||
{
|
||||
this._rotationOrigin = new Vector3d(intersection.x, intersection.y, intersection.z);
|
||||
this._rotationRodLength = Vector3d.dif(intersection, location).length;
|
||||
this._rotation = 1;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this._rotation = 0;
|
||||
|
||||
geometry.location = this._effectLocation;
|
||||
geometry.direction = this._effectDirection;
|
||||
geometry.setDepthVector(new Vector3d(this._effectDirection.x, this._effectDirection.y, 5));
|
||||
}
|
||||
|
||||
public moveLeft(): void
|
||||
{
|
||||
if(this._rotation !== 0)
|
||||
{
|
||||
if(this._rotation === 1)
|
||||
{
|
||||
this._rotation = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._rotation = (this._rotation - 1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const geometry = (this.geometry as RoomGeometry);
|
||||
const direction = (((geometry.direction.x - 90) / 180) * 3.14159265358979);
|
||||
|
||||
geometry.location = Vector3d.sum(geometry.location, new Vector3d((Math.cos(direction) * Math.sqrt(2)), (Math.sin(direction) * Math.sqrt(2))));
|
||||
}
|
||||
|
||||
public moveRight(): void
|
||||
{
|
||||
if(this._rotation !== 0)
|
||||
{
|
||||
if(this._rotation === -1)
|
||||
{
|
||||
this._rotation = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._rotation = (this._rotation + 1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const geometry = (this.geometry as RoomGeometry);
|
||||
const direction = (((geometry.direction.x + 90) / 180) * 3.14159265358979);
|
||||
|
||||
geometry.location = Vector3d.sum(geometry.location, new Vector3d((Math.cos(direction) * Math.sqrt(2)), (Math.sin(direction) * Math.sqrt(2))));
|
||||
}
|
||||
|
||||
public moveUp(): void
|
||||
{
|
||||
if(this._rotation !== 0) return;
|
||||
|
||||
const geometry = (this.geometry as RoomGeometry);
|
||||
const direction = ((geometry.direction.x / 180) * 3.14159265358979);
|
||||
|
||||
geometry.location = Vector3d.sum(geometry.location, new Vector3d((Math.cos(direction) * Math.sqrt(2)), (Math.sin(direction) * Math.sqrt(2))));
|
||||
}
|
||||
|
||||
public moveDown(): void
|
||||
{
|
||||
if(this._rotation !== 0) return;
|
||||
|
||||
const geometry = (this.geometry as RoomGeometry);
|
||||
const direction = (((geometry.direction.x + 180) / 180) * 3.14159265358979);
|
||||
|
||||
geometry.location = Vector3d.sum(geometry.location, new Vector3d((Math.cos(direction) * Math.sqrt(2)), (Math.sin(direction) * Math.sqrt(2))));
|
||||
}
|
||||
|
||||
public get id(): number
|
||||
{
|
||||
return this._id;
|
||||
|
75
src/room/utils/RoomRotatingEffect.ts
Normal file
75
src/room/utils/RoomRotatingEffect.ts
Normal file
@ -0,0 +1,75 @@
|
||||
import { Nitro } from '../../nitro/Nitro';
|
||||
|
||||
export class RoomRotatingEffect
|
||||
{
|
||||
public static STATE_NOT_INITIALIZED: number = 0;
|
||||
public static STATE_START_DELAY: number = 1;
|
||||
public static STATE_RUNNING: number = 2;
|
||||
public static STATE_OVER: number = 3;
|
||||
|
||||
private static _SafeStr_448: number = 0;
|
||||
private static _SafeStr_4512: boolean = false;
|
||||
private static _SafeStr_4513: number = 0;
|
||||
private static _SafeStr_4514: number = 0;
|
||||
private static _SafeStr_4515: number = 20000;
|
||||
private static _SafeStr_4516: number = 5000;
|
||||
private static _SafeStr_4524: ReturnType<typeof setTimeout>;
|
||||
|
||||
public static init(_arg_1: number, _arg_2: number): void
|
||||
{
|
||||
this._SafeStr_4513 = 0;
|
||||
this._SafeStr_4515 = _arg_1;
|
||||
this._SafeStr_4516 = _arg_2;
|
||||
this._SafeStr_4514 = Nitro.instance.time;
|
||||
this._SafeStr_448 = 1;
|
||||
}
|
||||
|
||||
public static turnVisualizationOn(): void
|
||||
{
|
||||
if((this._SafeStr_448 === 0) || (this._SafeStr_448 === 3)) return;
|
||||
|
||||
if(!this._SafeStr_4524) this._SafeStr_4524 = setTimeout(() => this.turnVisualizationOff(), this._SafeStr_4516);
|
||||
|
||||
const _local_1 = (Nitro.instance.time - this._SafeStr_4514);
|
||||
|
||||
if(_local_1 > (this._SafeStr_4515 + this._SafeStr_4516))
|
||||
{
|
||||
this._SafeStr_448 = 3;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this._SafeStr_4512 = true;
|
||||
|
||||
if(_local_1 < this._SafeStr_4515)
|
||||
{
|
||||
this._SafeStr_448 = 1;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this._SafeStr_448 = 2;
|
||||
this._SafeStr_4513 = ((_local_1 - this._SafeStr_4515) / this._SafeStr_4516);
|
||||
}
|
||||
|
||||
public static turnVisualizationOff():void
|
||||
{
|
||||
this._SafeStr_4512 = false;
|
||||
|
||||
clearTimeout(this._SafeStr_4524);
|
||||
|
||||
this._SafeStr_4524 = null;
|
||||
}
|
||||
|
||||
public static isVisualizationOn(): boolean
|
||||
{
|
||||
return (this._SafeStr_4512 && this.isRunning());
|
||||
}
|
||||
|
||||
private static isRunning(): boolean
|
||||
{
|
||||
if((this._SafeStr_448 === 1) || (this._SafeStr_448 === 2)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
75
src/room/utils/RoomShakingEffect.ts
Normal file
75
src/room/utils/RoomShakingEffect.ts
Normal file
@ -0,0 +1,75 @@
|
||||
import { Nitro } from '../../nitro/Nitro';
|
||||
|
||||
export class RoomShakingEffect
|
||||
{
|
||||
public static STATE_NOT_INITIALIZED: number = 0;
|
||||
public static STATE_START_DELAY: number = 1;
|
||||
public static STATE_RUNNING: number = 2;
|
||||
public static STATE_OVER: number = 3;
|
||||
|
||||
private static _SafeStr_448: number = 0;
|
||||
private static _SafeStr_4512: boolean = false;
|
||||
private static _SafeStr_4513: number;
|
||||
private static _SafeStr_4514: number = 0;
|
||||
private static _SafeStr_4515: number = 20000;
|
||||
private static _SafeStr_4516: number = 5000;
|
||||
private static _SafeStr_4524: ReturnType<typeof setTimeout>;
|
||||
|
||||
public static init(_arg_1: number, _arg_2: number): void
|
||||
{
|
||||
this._SafeStr_4513 = 0;
|
||||
this._SafeStr_4515 = _arg_1;
|
||||
this._SafeStr_4516 = _arg_2;
|
||||
this._SafeStr_4514 = Nitro.instance.time;
|
||||
this._SafeStr_448 = 1;
|
||||
}
|
||||
|
||||
public static turnVisualizationOn(): void
|
||||
{
|
||||
if((this._SafeStr_448 === 0) || (this._SafeStr_448 === 3)) return;
|
||||
|
||||
if(!this._SafeStr_4524) this._SafeStr_4524 = setTimeout(() => this.turnVisualizationOff(), this._SafeStr_4516);
|
||||
|
||||
const _local_1 = (Nitro.instance.time - this._SafeStr_4514);
|
||||
|
||||
if(_local_1 > (this._SafeStr_4515 + this._SafeStr_4516))
|
||||
{
|
||||
this._SafeStr_448 = 3;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this._SafeStr_4512 = true;
|
||||
|
||||
if(_local_1 < this._SafeStr_4515)
|
||||
{
|
||||
this._SafeStr_448 = 1;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this._SafeStr_448 = 2;
|
||||
this._SafeStr_4513 = ((_local_1 - this._SafeStr_4515) / this._SafeStr_4516);
|
||||
}
|
||||
|
||||
public static turnVisualizationOff():void
|
||||
{
|
||||
this._SafeStr_4512 = false;
|
||||
|
||||
clearTimeout(this._SafeStr_4524);
|
||||
|
||||
this._SafeStr_4524 = null;
|
||||
}
|
||||
|
||||
public static isVisualizationOn(): boolean
|
||||
{
|
||||
return (this._SafeStr_4512 && this.isRunning());
|
||||
}
|
||||
|
||||
private static isRunning(): boolean
|
||||
{
|
||||
if((this._SafeStr_448 === 1) || (this._SafeStr_448 === 2)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -11,6 +11,10 @@ export class SpriteUtilities
|
||||
{
|
||||
if(ink == 'ADD' || ink == 33) return BLEND_MODES.ADD;
|
||||
|
||||
if(ink == 'SUBTRACT') return BLEND_MODES.SUBTRACT;
|
||||
|
||||
if(ink == 'DARKEN') return BLEND_MODES.DARKEN;
|
||||
|
||||
return BLEND_MODES.NORMAL;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ export * from './Rasterizer';
|
||||
export * from './RoomEnterEffect';
|
||||
export * from './RoomGeometry';
|
||||
export * from './RoomId';
|
||||
export * from './RoomRotatingEffect';
|
||||
export * from './RoomShakingEffect';
|
||||
export * from './SpriteUtilities';
|
||||
export * from './TextureUtils';
|
||||
export * from './Vector3d';
|
||||
|
Loading…
Reference in New Issue
Block a user