This commit is contained in:
Bill 2021-05-22 12:16:52 -04:00
parent 40be434792
commit 33da59c3c2
5 changed files with 76 additions and 14 deletions

View File

@ -15,6 +15,7 @@ import { IGetImageListener } from './IGetImageListener';
import { ImageResult } from './ImageResult';
import { IObjectData } from './object/data/IObjectData';
import { RoomMapData } from './object/RoomMapData';
import { PetColorResult } from './PetColorResult';
import { RoomContentLoader } from './RoomContentLoader';
import { RoomObjectEventHandler } from './RoomObjectEventHandler';
@ -73,6 +74,7 @@ export interface IRoomEngine extends INitroManager
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;
getPetColorResult(petIndex: number, paletteIndex: number): PetColorResult;
cancelRoomObjectPlacement(): void;
getFurnitureFloorName(typeId: number): string;
useRoomObject(objectId: number, category: number): boolean;

View File

@ -10,16 +10,16 @@ export class PetColorResult
private _isMaster: boolean;
private _layerTags: string[];
constructor(k: number, _arg_2: number, _arg_3: number, _arg_4: number, _arg_5: string, _arg_6: boolean, _arg_7: string[])
constructor(primaryColor: number, secondaryColor: number, breed: number, tag: number, id: string, isMaster: boolean, layerTags: string[])
{
this._layerTags = [];
this._primaryColor = (k & 0xFFFFFF);
this._secondaryColor = (_arg_2 & 0xFFFFFF);
this._breed = _arg_3;
this._tag = (((_arg_4 > -1) && (_arg_4 < PetColorResult._Str_12950.length)) ? PetColorResult._Str_12950[_arg_4] : '');
this._id = _arg_5;
this._isMaster = _arg_6;
this._layerTags = _arg_7;
this._primaryColor = (primaryColor & 0xFFFFFF);
this._secondaryColor = (secondaryColor & 0xFFFFFF);
this._breed = breed;
this._tag = (((tag > -1) && (tag < PetColorResult._Str_12950.length)) ? PetColorResult._Str_12950[tag] : '');
this._id = id;
this._isMaster = isMaster;
this._layerTags = layerTags;
}
public get _Str_5845(): number

View File

@ -19,6 +19,7 @@ import { RoomObjectCategory } from './object/RoomObjectCategory';
import { RoomObjectUserType } from './object/RoomObjectUserType';
import { RoomObjectVariable } from './object/RoomObjectVariable';
import { RoomObjectVisualizationType } from './object/RoomObjectVisualizationType';
import { PetColorResult } from './PetColorResult';
export class RoomContentLoader implements IFurnitureDataListener
{
@ -51,6 +52,7 @@ export class RoomContentLoader implements IFurnitureDataListener
private _wallItemTypeIds: Map<string, number>;
private _furniRevisions: Map<string, number>;
private _pets: { [index: string]: number };
private _petColors: Map<number, Map<number, PetColorResult>>;
private _objectAliases: Map<string, string>;
private _objectOriginalNames: Map<string, string>;
@ -77,6 +79,7 @@ export class RoomContentLoader implements IFurnitureDataListener
this._wallItemTypeIds = new Map();
this._furniRevisions = new Map();
this._pets = {};
this._petColors = new Map();
this._objectAliases = new Map();
this._objectOriginalNames = new Map();
@ -250,6 +253,15 @@ export class RoomContentLoader implements IFurnitureDataListener
return name.substr(0, index);
}
public getPetColorResult(petIndex: number, paletteIndex: number): PetColorResult
{
const colorResults = this._petColors.get(petIndex);
if(!colorResults) return null;
return colorResults.get(paletteIndex);
}
public getCollection(name: string): IGraphicAssetCollection
{
if(!name) return null;
@ -304,6 +316,27 @@ export class RoomContentLoader implements IFurnitureDataListener
const collection = new GraphicAssetCollection(data, spritesheet);
this._collections.set(collection.name, collection);
const petIndex = this._pets[collection.name];
if(petIndex !== undefined)
{
const keys = collection.getPaletteNames();
const palettes: Map<number, PetColorResult> = new Map();
for(const key of keys)
{
const palette = collection.getPalette(key);
const breed = 0;
const primaryColor = palette.primaryColor;
const secondaryColor = palette.secondaryColor;
palettes.set(parseInt(key), new PetColorResult(primaryColor, secondaryColor, breed, -1, key, false, []));
}
this._petColors.set(petIndex, palettes);
}
}
public getPlaceholderName(type: string): string

View File

@ -94,6 +94,7 @@ import { RoomObjectCategory } from './object/RoomObjectCategory';
import { RoomObjectUserType } from './object/RoomObjectUserType';
import { RoomObjectVariable } from './object/RoomObjectVariable';
import { RoomObjectVisualizationFactory } from './object/RoomObjectVisualizationFactory';
import { PetColorResult } from './PetColorResult';
import { RoomContentLoader } from './RoomContentLoader';
import { RoomMessageHandler } from './RoomMessageHandler';
import { RoomObjectEventHandler } from './RoomObjectEventHandler';
@ -3527,6 +3528,13 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato
return (this._roomContentLoader.getCollection(name) !== null);
}
public getPetColorResult(petIndex: number, paletteIndex: number): PetColorResult
{
if(!this._roomContentLoader) return null;
return this._roomContentLoader.getPetColorResult(petIndex, paletteIndex);
}
public modifyRoomObjectData(objectId: number, objectCategory: number, colorHex: string, text: string): boolean
{
if(!this._roomObjectEventHandler || (objectCategory !== RoomObjectCategory.WALL)) return false;

View File

@ -52,6 +52,7 @@ export class RoomPreviewer
private _previousAutomaticStateChangeTime: number;
private _addViewOffset: Point;
private _backgroundColor: number = 305148561;
private _backgroundSprite: Sprite = null;
private _disableUpdate: boolean = false;
constructor(roomEngine: IRoomEngine, roomId: number = 1)
@ -85,6 +86,13 @@ export class RoomPreviewer
this._roomEngine.events.removeEventListener(RoomEngineEvent.INITIALIZED, this.onRoomInitializedonRoomInitialized);
}
if(this._backgroundSprite)
{
this._backgroundSprite.destroy();
this._backgroundSprite = null;
}
if(this._planeParser)
{
this._planeParser.dispose();
@ -438,13 +446,18 @@ export class RoomPreviewer
if(displayObject && (this._backgroundColor !== null))
{
const background = new Sprite(Texture.WHITE);
let backgroundSprite = this._backgroundSprite;
background.width = width;
background.height = height;
background.tint = this._backgroundColor;
if(!backgroundSprite)
{
backgroundSprite = new Sprite(Texture.WHITE);
displayObject.addChildAt(background, 0);
displayObject.addChildAt(backgroundSprite, 0);
}
backgroundSprite.width = width;
backgroundSprite.height = height;
backgroundSprite.tint = this._backgroundColor;
}
this._roomEngine.setRoomInstanceRenderingCanvasMask(this._previewRoomId, RoomPreviewer.PREVIEW_CANVAS_ID, true);
@ -469,6 +482,12 @@ export class RoomPreviewer
this._currentPreviewCanvasWidth = width;
this._currentPreviewCanvasHeight = height;
if(this._backgroundSprite)
{
this._backgroundSprite.width = width;
this._backgroundSprite.height = height;
}
this._roomEngine.initializeRoomInstanceRenderingCanvas(this._previewRoomId, RoomPreviewer.PREVIEW_CANVAS_ID, width, height);
}
}