cleaned SpriteDataCollector

This commit is contained in:
Dank074 2021-06-12 16:21:38 -05:00
parent 9f2c1fa2f0
commit 5a842a2864
4 changed files with 42 additions and 42 deletions

View File

@ -73,7 +73,7 @@ export interface IRoomEngine extends INitroManager
getRoomObjectImage(roomId: number, objectId: number, category: number, direction: IVector3D, scale: number, listener: IGetImageListener, bgColor?: number): ImageResult;
getRoomObjectPetImage(typeId: number, paletteId: number, color: number, direction: IVector3D, scale: number, listener: IGetImageListener, headOnly?: boolean, bgColor?: number, customParts?: PetCustomPart[], posture?: string): ImageResult;
selectRoomObject(roomId: number, objectId: number, objectCategory: number): void;
_Str_8675(): void;
cancelRoomObjectInsert(): void;
getPetColorResult(petIndex: number, paletteIndex: number): PetColorResult;
cancelRoomObjectPlacement(): void;
getFurnitureFloorName(typeId: number): string;

View File

@ -2717,11 +2717,11 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
this._roomObjectEventHandler._Str_17481(roomId, objectId, objectCategory);
}
public _Str_8675(): void
public cancelRoomObjectInsert(): void
{
if(!this._roomObjectEventHandler) return;
this._roomObjectEventHandler._Str_8675(this._activeRoomId);
this._roomObjectEventHandler.cancelRoomObjectInsert(this._activeRoomId);
}
private addOverlayIconSprite(k: Sprite, _arg_2: string, _arg_3: Texture, scale: number = 1): Sprite
@ -3391,7 +3391,7 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
if(tileObjectMap) tileObjectMap.populate(this._Str_21072(k, RoomObjectCategory.FLOOR));
}
public _Str_9972(k: Rectangle, _arg_2: number, _arg_3: boolean = false, _arg_4: boolean = true, _arg_5: boolean = false, canvasId: number = -1): IMessageComposer<unknown[]>
public getRenderRoomMessage(k: Rectangle, _arg_2: number, _arg_3: boolean = false, _arg_4: boolean = true, _arg_5: boolean = false, canvasId: number = -1): IMessageComposer<unknown[]>
{
let canvas: IRoomRenderingCanvas = null;
@ -3419,9 +3419,9 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
}
const _local_9 = new SpriteDataCollector();
const _local_10 = _local_9._Str_4536(k, canvas, this, _local_8);
const _local_11 = _local_9._Str_24177(this);
const _local_12 = _local_9._Str_22985(k, canvas, this, _arg_2);
const _local_10 = _local_9.getFurniData(k, canvas, this, _local_8);
const _local_11 = _local_9.getRoomRenderingModifiers(this);
const _local_12 = _local_9.getRoomPlanes(k, canvas, this, _arg_2);
if(_arg_5) canvas.resumeSpriteVisibilityChecking();

View File

@ -194,7 +194,7 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou
return true;
}
public _Str_8675(k: number): boolean
public cancelRoomObjectInsert(k: number): boolean
{
this.resetSelectedObjectData(k);

View File

@ -13,16 +13,16 @@ import { RoomEngine } from '../RoomEngine';
export class SpriteDataCollector
{
private static _Str_16967: number = 1;
private static _Str_18197: number = -16;
private static _Str_18565: number = -52;
private static _Str_17558: number = 30;
private static MANNEQUIN_MAGIC_X_OFFSET: number = 1;
private static MANNEQUIN_MAGIC_Y_OFFSET: number = -16;
private static AVATAR_WATER_EFFECT_MAGIC_Y_OFFSET: number = -52;
private static MAX_EXTERNAL_IMAGE_COUNT: number = 30;
private _Str_6409: number;
private maxZ: number;
private spriteCount: number = 0;
private _Str_18433: number = 0;
private externalImageCount: number = 0;
private static _Str_22230(k: RoomObjectSpriteData[], _arg_2: RoomEngine): RoomObjectSpriteData[]
private static addMannequinSprites(k: RoomObjectSpriteData[], _arg_2: RoomEngine): RoomObjectSpriteData[]
{
const datas: RoomObjectSpriteData[] = [];
@ -42,8 +42,8 @@ export class SpriteDataCollector
{
for(const sprite of spriteList)
{
sprite.x = (sprite.x + ((data.x + (data.width / 2)) + SpriteDataCollector._Str_16967));
sprite.y = (sprite.y + ((data.y + data.height) + SpriteDataCollector._Str_18197));
sprite.x = (sprite.x + ((data.x + (data.width / 2)) + SpriteDataCollector.MANNEQUIN_MAGIC_X_OFFSET));
sprite.y = (sprite.y + ((data.y + data.height) + SpriteDataCollector.MANNEQUIN_MAGIC_Y_OFFSET));
sprite.z = (sprite.z + data.z);
datas.push(sprite);
}
@ -59,7 +59,7 @@ export class SpriteDataCollector
return datas;
}
private static _Str_22564(k: RoomObjectSpriteData, _arg_2: RoomObjectSpriteData): number
private static sortSpriteDataObjects(k: RoomObjectSpriteData, _arg_2: RoomObjectSpriteData): number
{
if(k.z < _arg_2.z) return 1;
@ -68,7 +68,7 @@ export class SpriteDataCollector
return -1;
}
private static _Str_20789(k:RoomObjectSpriteData, _arg_2: Rectangle, _arg_3: IRoomRenderingCanvas): boolean
private static isSpriteInViewPort(k:RoomObjectSpriteData, _arg_2: Rectangle, _arg_3: IRoomRenderingCanvas): boolean
{
return true;
// var _local_4 = new Rectangle((k.x + _arg_3.screenOffsetX), (k.y + _arg_3.screenOffsetY), k.width, k.height);
@ -76,7 +76,7 @@ export class SpriteDataCollector
// return _local_4.contains(_arg_2.x, _arg_2.y);
}
private static _Str_14110(k: Point, _arg_2: Point, _arg_3: Point, _arg_4: Point): Point[]
private static sortQuadPoints(k: Point, _arg_2: Point, _arg_3: Point, _arg_4: Point): Point[]
{
const points: Point[] = [];
@ -133,7 +133,7 @@ export class SpriteDataCollector
}
public _Str_4536(k: Rectangle, _arg_2:IRoomRenderingCanvas, _arg_3:RoomEngine, _arg_4: number): string
public getFurniData(k: Rectangle, _arg_2:IRoomRenderingCanvas, _arg_3:RoomEngine, _arg_4: number): string
{
const _local_5: Object[] = [];
let _local_6 = _arg_2.getSortableSpriteList();
@ -176,7 +176,7 @@ export class SpriteDataCollector
if(((_local_16.name.indexOf('h_std_fx29_') === 0) || (_local_16.name.indexOf('h_std_fx185_') === 0)))
{
_local_16.y = (_local_16.y + SpriteDataCollector._Str_18565);
_local_16.y = (_local_16.y + SpriteDataCollector.AVATAR_WATER_EFFECT_MAGIC_Y_OFFSET);
}
_local_6.push(_local_16);
@ -186,16 +186,16 @@ export class SpriteDataCollector
}
}
_local_6 = SpriteDataCollector._Str_22230(_local_6, _arg_3);
_local_6.sort(SpriteDataCollector._Str_22564);
_local_6 = SpriteDataCollector.addMannequinSprites(_local_6, _arg_3);
_local_6.sort(SpriteDataCollector.sortSpriteDataObjects);
for(const _local_9 of _local_6)
{
if((((((!(_local_9.name === null)) && (_local_9.name.length > 0)) && (!(_local_9.name.indexOf('tile_cursor_') === 0))) && (SpriteDataCollector._Str_20789(_local_9, k, _arg_2))) && ((_arg_4 < 0) || (!(_local_9.objectId == _arg_4)))))
if((((((!(_local_9.name === null)) && (_local_9.name.length > 0)) && (!(_local_9.name.indexOf('tile_cursor_') === 0))) && (SpriteDataCollector.isSpriteInViewPort(_local_9, k, _arg_2))) && ((_arg_4 < 0) || (!(_local_9.objectId == _arg_4)))))
{
_local_5.push(this._Str_25132(_local_9, k, _arg_2, _arg_3));
_local_5.push(this.getSpriteDataObject(_local_9, k, _arg_2, _arg_3));
if(!this._Str_6409) this._Str_6409 = _local_9.z;
if(!this.maxZ) this.maxZ = _local_9.z;
this.spriteCount++;
}
@ -204,12 +204,12 @@ export class SpriteDataCollector
return JSON.stringify(_local_5);
}
public _Str_24177(k: RoomEngine): string
public getRoomRenderingModifiers(k: RoomEngine): string
{
return JSON.stringify(new Object());
}
private _Str_25132(k: RoomObjectSpriteData, _arg_2: Rectangle, _arg_3: IRoomRenderingCanvas, _arg_4: RoomEngine): Object
private getSpriteDataObject(k: RoomObjectSpriteData, _arg_2: Rectangle, _arg_3: IRoomRenderingCanvas, _arg_4: RoomEngine): Object
{
let _local_7: string = null;
let _local_9: string[] = [];
@ -288,9 +288,9 @@ export class SpriteDataCollector
_local_5.width = k.width;
_local_5.height = k.height;
this._Str_18433++;
this.externalImageCount++;
if(this._Str_18433 > SpriteDataCollector._Str_17558) _local_5.name = 'box';
if(this.externalImageCount > SpriteDataCollector.MAX_EXTERNAL_IMAGE_COUNT) _local_5.name = 'box';
}
if(k.posture) _local_5.posture = k.posture;
@ -298,13 +298,13 @@ export class SpriteDataCollector
return _local_5;
}
private _Str_25196(k: Rectangle, _arg_2: number, _arg_3: IPlaneDrawingData[]): PlaneDrawingData
private makeBackgroundPlane(k: Rectangle, _arg_2: number, _arg_3: IPlaneDrawingData[]): PlaneDrawingData
{
const _local_4 = new Point(0, 0);
const _local_5 = new Point(k.width, 0);
const _local_6 = new Point(0, k.height);
const _local_7 = new Point(k.width, k.height);
const _local_8 = SpriteDataCollector._Str_14110(_local_4, _local_5, _local_6, _local_7);
const _local_8 = SpriteDataCollector.sortQuadPoints(_local_4, _local_5, _local_6, _local_7);
let _local_9 = 0;
@ -312,11 +312,11 @@ export class SpriteDataCollector
{
_local_9 = _arg_3[0].z;
if(this._Str_6409) _local_9 = Math.max(this._Str_6409, _local_9);
if(this.maxZ) _local_9 = Math.max(this.maxZ, _local_9);
}
else
{
_local_9 = ((this._Str_6409) ? this._Str_6409 : 0);
_local_9 = ((this.maxZ) ? this.maxZ : 0);
}
_local_9 = (_local_9 + ((this.spriteCount * 1.776104) + (_arg_3.length * 2.31743)));
@ -329,15 +329,15 @@ export class SpriteDataCollector
return _local_10;
}
private _Str_25623(k: IRoomPlane[], _arg_2: IRoomRenderingCanvas, _arg_3: RoomEngine): { plane: IRoomPlane, z: number }[]
private sortRoomPlanes(k: IRoomPlane[], _arg_2: IRoomRenderingCanvas, _arg_3: RoomEngine): { plane: IRoomPlane, z: number }[]
{
const _local_4: Map<number, { plane: IRoomPlane, z: number }> = new Map();
let _local_5 = 1;
if(this._Str_6409)
if(this.maxZ)
{
_local_5 = (_local_5 + this._Str_6409);
_local_5 = (_local_5 + this.maxZ);
}
for(const _local_6 of k)
@ -385,7 +385,7 @@ export class SpriteDataCollector
return _local_8;
}
public _Str_22985(k: Rectangle, _arg_2: IRoomRenderingCanvas, _arg_3: RoomEngine, _arg_4: number): PlaneDrawingData[]
public getRoomPlanes(k: Rectangle, _arg_2: IRoomRenderingCanvas, _arg_3: RoomEngine, _arg_4: number): PlaneDrawingData[]
{
const _local_5: PlaneDrawingData[] = [];
@ -395,7 +395,7 @@ export class SpriteDataCollector
if(visualization)
{
const _local_8 = _arg_2.geometry;
const _local_9 = this._Str_25623(visualization.planes, _arg_2, _arg_3);
const _local_9 = this.sortRoomPlanes(visualization.planes, _arg_2, _arg_3);
const _local_10 = Nitro.instance.stage;
for(const _local_11 of _local_9)
@ -440,7 +440,7 @@ export class SpriteDataCollector
}
else
{
const _local_22 = SpriteDataCollector._Str_14110(_local_15, _local_16, _local_17, _local_18);
const _local_22 = SpriteDataCollector.sortQuadPoints(_local_15, _local_16, _local_17, _local_18);
for(const _local_23 of _local_12.getDrawingDatas(_local_8))
{
@ -452,7 +452,7 @@ export class SpriteDataCollector
}
}
_local_5.unshift(this._Str_25196(k, _arg_4, _local_5));
_local_5.unshift(this.makeBackgroundPlane(k, _arg_4, _local_5));
}
return _local_5;