You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-20 07:26:18 +00:00
Move to Renderer V2
This commit is contained in:
@@ -0,0 +1,222 @@
|
||||
import { IFurnitureData } from '@nitrots/api';
|
||||
|
||||
export class FurnitureData implements IFurnitureData
|
||||
{
|
||||
private _type: string;
|
||||
private _id: number;
|
||||
private _className: string;
|
||||
private _fullName: string;
|
||||
private _category: string;
|
||||
private _hasIndexedColor: boolean;
|
||||
private _colourIndex: number;
|
||||
private _revision: number;
|
||||
private _tileSizeX: number;
|
||||
private _tileSizeY: number;
|
||||
private _tileSizeZ: number;
|
||||
private _colors: number[];
|
||||
private _localizedName: string;
|
||||
private _description: string;
|
||||
private _adUrl: string;
|
||||
private _purchaseOfferId: number;
|
||||
private _rentOfferId: number;
|
||||
private _customParams: string;
|
||||
private _specialType: number;
|
||||
private _purchaseCouldBeUsedForBuyout: boolean;
|
||||
private _rentCouldBeUsedForBuyout: boolean;
|
||||
private _availableForBuildersClub: boolean;
|
||||
private _canStandOn: boolean;
|
||||
private _canSitOn: boolean;
|
||||
private _canLayOn: boolean;
|
||||
private _excludedFromDynamic: boolean;
|
||||
private _furniLine: string;
|
||||
private _environment: string;
|
||||
private _rare: boolean;
|
||||
|
||||
constructor(type: string, id: number, fullName: string, className: string, category: string, localizedName: string, description: string, revision: number, tileSizeX: number, tileSizeY: number, tileSizeZ: number, colors: number[], hadIndexedColor: boolean, colorIndex: number, adUrl: string, purchaseOfferId: number, purchaseCouldBeUsedForBuyout: boolean, rentOfferId: number, rentCouldBeUsedForBuyout: boolean, availableForBuildersClub: boolean, customParams: string, specialType: number, canStandOn: boolean, canSitOn: boolean, canLayOn: boolean, excludedfromDynamic: boolean, furniLine: string, environment: string, rare: boolean)
|
||||
{
|
||||
this._type = type;
|
||||
this._id = id;
|
||||
this._fullName = fullName;
|
||||
this._className = className;
|
||||
this._category = category;
|
||||
this._revision = revision;
|
||||
this._tileSizeX = tileSizeX;
|
||||
this._tileSizeY = tileSizeY;
|
||||
this._tileSizeZ = tileSizeZ;
|
||||
this._colors = colors;
|
||||
this._hasIndexedColor = hadIndexedColor;
|
||||
this._colourIndex = colorIndex;
|
||||
this._localizedName = localizedName;
|
||||
this._description = description;
|
||||
this._adUrl = adUrl;
|
||||
this._purchaseOfferId = purchaseOfferId;
|
||||
this._purchaseCouldBeUsedForBuyout = purchaseCouldBeUsedForBuyout;
|
||||
this._rentOfferId = rentOfferId;
|
||||
this._rentCouldBeUsedForBuyout = rentCouldBeUsedForBuyout;
|
||||
this._customParams = customParams;
|
||||
this._specialType = specialType;
|
||||
this._availableForBuildersClub = availableForBuildersClub;
|
||||
this._canStandOn = canStandOn;
|
||||
this._canSitOn = canSitOn;
|
||||
this._canLayOn = canLayOn;
|
||||
this._excludedFromDynamic = excludedfromDynamic;
|
||||
this._furniLine = furniLine;
|
||||
this._environment = environment;
|
||||
this._rare = rare;
|
||||
}
|
||||
|
||||
public get type(): string
|
||||
{
|
||||
return this._type;
|
||||
}
|
||||
|
||||
public get id(): number
|
||||
{
|
||||
return this._id;
|
||||
}
|
||||
|
||||
public get className(): string
|
||||
{
|
||||
return this._className;
|
||||
}
|
||||
|
||||
public set className(k: string)
|
||||
{
|
||||
this._className = k;
|
||||
}
|
||||
|
||||
public get fullName(): string
|
||||
{
|
||||
return this._fullName;
|
||||
}
|
||||
|
||||
public get category(): string
|
||||
{
|
||||
return this._category;
|
||||
}
|
||||
|
||||
public get hasIndexedColor(): boolean
|
||||
{
|
||||
return this._hasIndexedColor;
|
||||
}
|
||||
|
||||
public get colorIndex(): number
|
||||
{
|
||||
return this._colourIndex;
|
||||
}
|
||||
|
||||
public get revision(): number
|
||||
{
|
||||
return this._revision;
|
||||
}
|
||||
|
||||
public get tileSizeX(): number
|
||||
{
|
||||
return this._tileSizeX;
|
||||
}
|
||||
|
||||
public get tileSizeY(): number
|
||||
{
|
||||
return this._tileSizeY;
|
||||
}
|
||||
|
||||
public get tileSizeZ(): number
|
||||
{
|
||||
return this._tileSizeZ;
|
||||
}
|
||||
|
||||
public get colors(): number[]
|
||||
{
|
||||
return this._colors;
|
||||
}
|
||||
|
||||
public get name(): string
|
||||
{
|
||||
return this._localizedName;
|
||||
}
|
||||
|
||||
public get description(): string
|
||||
{
|
||||
return this._description;
|
||||
}
|
||||
|
||||
public get adUrl(): string
|
||||
{
|
||||
return this._adUrl;
|
||||
}
|
||||
|
||||
public get purchaseOfferId(): number
|
||||
{
|
||||
return this._purchaseOfferId;
|
||||
}
|
||||
|
||||
public get customParams(): string
|
||||
{
|
||||
return this._customParams;
|
||||
}
|
||||
|
||||
public get specialType(): number
|
||||
{
|
||||
return this._specialType;
|
||||
}
|
||||
|
||||
public get rentOfferId(): number
|
||||
{
|
||||
return this._rentOfferId;
|
||||
}
|
||||
|
||||
public get purchaseCouldBeUsedForBuyout(): boolean
|
||||
{
|
||||
return this._purchaseCouldBeUsedForBuyout;
|
||||
}
|
||||
|
||||
public get rentCouldBeUsedForBuyout(): boolean
|
||||
{
|
||||
return this._rentCouldBeUsedForBuyout;
|
||||
}
|
||||
|
||||
public get availableForBuildersClub(): boolean
|
||||
{
|
||||
return this._availableForBuildersClub;
|
||||
}
|
||||
|
||||
public get canStandOn(): boolean
|
||||
{
|
||||
return this._canStandOn;
|
||||
}
|
||||
|
||||
public get canSitOn(): boolean
|
||||
{
|
||||
return this._canSitOn;
|
||||
}
|
||||
|
||||
public get canLayOn(): boolean
|
||||
{
|
||||
return this._canLayOn;
|
||||
}
|
||||
|
||||
public get isExternalImage(): boolean
|
||||
{
|
||||
return !(this._className.indexOf('external_image') === -1);
|
||||
}
|
||||
|
||||
public get excludeDynamic(): boolean
|
||||
{
|
||||
return this._excludedFromDynamic;
|
||||
}
|
||||
|
||||
public get furniLine(): string
|
||||
{
|
||||
return this._furniLine;
|
||||
}
|
||||
|
||||
public get environment(): string
|
||||
{
|
||||
return this._environment;
|
||||
}
|
||||
|
||||
public get rare(): boolean
|
||||
{
|
||||
return this._rare;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import { FurnitureType, IFurnitureData } from '@nitrots/api';
|
||||
import { GetConfiguration } from '@nitrots/configuration';
|
||||
import { GetLocalizationManager } from '@nitrots/localization';
|
||||
import { FurnitureData } from './FurnitureData';
|
||||
|
||||
export class FurnitureDataLoader
|
||||
{
|
||||
private _floorItems: Map<number, IFurnitureData>;
|
||||
private _wallItems: Map<number, IFurnitureData>;
|
||||
|
||||
constructor(floorItems: Map<number, IFurnitureData>, wallItems: Map<number, IFurnitureData>)
|
||||
{
|
||||
this._floorItems = floorItems;
|
||||
this._wallItems = wallItems;
|
||||
}
|
||||
|
||||
public async init(): Promise<void>
|
||||
{
|
||||
const url = GetConfiguration().getValue<string>('furnidata.url');
|
||||
|
||||
if(!url || !url.length) throw new Error('invalid furni data url');
|
||||
|
||||
const response = await fetch(url);
|
||||
|
||||
if(response.status !== 200) throw new Error('Invalid furni data file');
|
||||
|
||||
const responseData = await response.json();
|
||||
|
||||
if(responseData.roomitemtypes) this.parseFloorItems(responseData.roomitemtypes);
|
||||
|
||||
if(responseData.wallitemtypes) this.parseWallItems(responseData.wallitemtypes);
|
||||
}
|
||||
|
||||
private parseFloorItems(data: any): void
|
||||
{
|
||||
if(!data || !data.furnitype) return;
|
||||
|
||||
for(const furniture of data.furnitype)
|
||||
{
|
||||
if(!furniture) continue;
|
||||
|
||||
const colors: number[] = [];
|
||||
|
||||
if(furniture.partcolors)
|
||||
{
|
||||
for(const color of furniture.partcolors.color)
|
||||
{
|
||||
let colorCode = (color as string);
|
||||
|
||||
if(colorCode.charAt(0) === '#')
|
||||
{
|
||||
colorCode = colorCode.replace('#', '');
|
||||
|
||||
colors.push(parseInt(colorCode, 16));
|
||||
}
|
||||
else
|
||||
{
|
||||
colors.push((parseInt(colorCode, 16)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const classSplit = (furniture.classname as string).split('*');
|
||||
const className = classSplit[0];
|
||||
const colorIndex = ((classSplit.length > 1) ? parseInt(classSplit[1]) : 0);
|
||||
const hasColorIndex = (classSplit.length > 1);
|
||||
|
||||
const furnitureData = new FurnitureData(FurnitureType.FLOOR, furniture.id, furniture.classname, className, furniture.category, furniture.name, furniture.description, furniture.revision, furniture.xdim, furniture.ydim, 0, colors, hasColorIndex, colorIndex, furniture.adurl, furniture.offerid, furniture.buyout, furniture.rentofferid, furniture.rentbuyout, furniture.bc, furniture.customparams, furniture.specialtype, furniture.canstandon, furniture.cansiton, furniture.canlayon, furniture.excludeddynamic, furniture.furniline, furniture.environment, furniture.rare);
|
||||
|
||||
this._floorItems.set(furnitureData.id, furnitureData);
|
||||
|
||||
this.updateLocalizations(furnitureData);
|
||||
}
|
||||
}
|
||||
|
||||
private parseWallItems(data: any): void
|
||||
{
|
||||
if(!data || !data.furnitype) return;
|
||||
|
||||
for(const furniture of data.furnitype)
|
||||
{
|
||||
if(!furniture) continue;
|
||||
|
||||
const furnitureData = new FurnitureData(FurnitureType.WALL, furniture.id, furniture.classname, furniture.classname, furniture.category, furniture.name, furniture.description, furniture.revision, 0, 0, 0, null, false, 0, furniture.adurl, furniture.offerid, furniture.buyout, furniture.rentofferid, furniture.rentbuyout, furniture.bc, null, furniture.specialtype, false, false, false, furniture.excludeddynamic, furniture.furniline, furniture.environment, furniture.rare);
|
||||
|
||||
this._wallItems.set(furnitureData.id, furnitureData);
|
||||
|
||||
this.updateLocalizations(furnitureData);
|
||||
}
|
||||
}
|
||||
|
||||
private updateLocalizations(furniture: FurnitureData): void
|
||||
{
|
||||
switch(furniture.type)
|
||||
{
|
||||
case FurnitureType.FLOOR:
|
||||
GetLocalizationManager().setValue(('roomItem.name.' + furniture.id), furniture.name);
|
||||
GetLocalizationManager().setValue(('roomItem.desc.' + furniture.id), furniture.description);
|
||||
return;
|
||||
case FurnitureType.WALL:
|
||||
GetLocalizationManager().setValue(('wallItem.name.' + furniture.id), furniture.name);
|
||||
GetLocalizationManager().setValue(('wallItem.desc.' + furniture.id), furniture.description);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './FurnitureData';
|
||||
export * from './FurnitureDataLoader';
|
||||
Reference in New Issue
Block a user