Move to Renderer V2

This commit is contained in:
duckietm
2024-04-03 09:27:56 +02:00
parent 110c3ad393
commit b3134ce50b
4080 changed files with 115593 additions and 66375 deletions
@@ -0,0 +1,121 @@
import { IFurnitureStackingHeightMap } from '@nitrots/api';
export class FurnitureStackingHeightMap implements IFurnitureStackingHeightMap
{
private _width: number;
private _height: number;
private _heights: number[];
private _isNotStackable: boolean[];
private _isRoomTile: boolean[];
constructor(width: number, height: number)
{
this._width = width;
this._height = height;
this._heights = [];
this._isNotStackable = [];
this._isRoomTile = [];
let total = (width * height);
while(total > 0)
{
this._heights.push(0);
this._isNotStackable.push(false);
this._isRoomTile.push(false);
total--;
}
}
public dispose(): void
{
this._width = 0;
this._height = 0;
this._height = null;
this._isNotStackable = null;
this._isRoomTile = null;
}
private validPosition(x: number, y: number): boolean
{
return (((x >= 0) && (x < this._width)) && (y >= 0)) && (y < this._height);
}
public getTileHeight(x: number, y: number): number
{
return ((this.validPosition(x, y)) ? this._heights[((y * this._width) + x)] : 0);
}
public setTileHeight(x: number, y: number, height: number): void
{
if(this.validPosition(x, y)) this._heights[((y * this._width) + x)] = height;
}
public setStackingBlocked(x: number, y: number, isNotStackable: boolean): void
{
if(this.validPosition(x, y)) this._isNotStackable[((y * this._width) + x)] = isNotStackable;
}
public setIsRoomTile(x: number, y: number, isRoomTile: boolean): void
{
if(this.validPosition(x, y)) this._isRoomTile[((y * this._width) + x)] = isRoomTile;
}
public validateLocation(k: number, _arg_2: number, _arg_3: number, _arg_4: number, _arg_5: number, _arg_6: number, _arg_7: number, _arg_8: number, _arg_9: boolean, _arg_10: number = -1): boolean
{
let _local_12 = 0;
let _local_13 = 0;
if(!this.validPosition(k, _arg_2) || !this.validPosition(((k + _arg_3) - 1), ((_arg_2 + _arg_4) - 1))) return false;
if(((_arg_5 < 0) || (_arg_5 >= this._width))) _arg_5 = 0;
if(((_arg_6 < 0) || (_arg_6 >= this._height))) _arg_6 = 0;
_arg_7 = Math.min(_arg_7, (this._width - _arg_5));
_arg_8 = Math.min(_arg_8, (this._height - _arg_6));
if(_arg_10 === -1) _arg_10 = this.getTileHeight(k, _arg_2);
let _local_11 = _arg_2;
while(_local_11 < (_arg_2 + _arg_4))
{
_local_12 = k;
while(_local_12 < (k + _arg_3))
{
if(((((_local_12 < _arg_5) || (_local_12 >= (_arg_5 + _arg_7))) || (_local_11 < _arg_6)) || (_local_11 >= (_arg_6 + _arg_8))))
{
_local_13 = ((_local_11 * this._width) + _local_12);
if(_arg_9)
{
if(!this._isRoomTile[_local_13]) return false;
}
else
{
if(((this._isNotStackable[_local_13]) || (!(this._isRoomTile[_local_13]))) || (Math.abs((this._heights[_local_13] - _arg_10)) > 0.01)) return false;
}
}
_local_12++;
}
_local_11++;
}
return true;
}
public get width(): number
{
return this._width;
}
public get height(): number
{
return this._height;
}
}
@@ -0,0 +1,322 @@
import { ILegacyWallGeometry, IVector3D } from '@nitrots/api';
import { Vector3d } from '@nitrots/utils';
export class LegacyWallGeometry implements ILegacyWallGeometry
{
public static DEFAULT_SCALE: number = 32;
private static L: string = 'l';
private static R: string = 'r';
private _isDisposed: boolean;
private _scale: number;
private _heightMap: number[][];
private _width: number;
private _height: number;
private _floorHeight: number;
constructor()
{
this._isDisposed = false;
this._scale = 64;
this._heightMap = [];
this._width = 0;
this._height = 0;
this._floorHeight = 0;
}
public get disposed(): boolean
{
return this._isDisposed;
}
public get scale(): number
{
return this._scale;
}
public set scale(k: number)
{
this._scale = k;
}
public dispose(): void
{
this.reset();
this._isDisposed = true;
}
public initialize(width: number, height: number, floorHeight: number): void
{
if((width <= this._width) && (height <= this._height))
{
this._width = width;
this._height = height;
this._floorHeight = floorHeight;
return;
}
this.reset();
let y = 0;
while(y < height)
{
const heights: number[] = [];
this._heightMap.push(heights);
let x = 0;
while(x < width)
{
heights.push(0);
x++;
}
y++;
}
this._width = width;
this._height = height;
this._floorHeight = floorHeight;
}
private reset(): void
{
this._heightMap = [];
}
public setHeight(x: number, y: number, height: number): boolean
{
if((((x < 0) || (x >= this._width)) || (y < 0)) || (y >= this._height)) return false;
const heightMap = this._heightMap[y];
if(!heightMap) return false;
heightMap[x] = height;
return true;
}
public getHeight(x: number, y: number): number
{
if((((x < 0) || (x >= this._width)) || (y < 0)) || (y >= this._height)) return 0;
const heightMap = this._heightMap[y];
if(!heightMap) return 0;
return heightMap[x];
}
public getLocation(width: number, height: number, localX: number, localY: number, direction: string): IVector3D
{
let _local_7: number;
if(((width == 0) && (height == 0)))
{
width = this._width;
height = this._height;
const _local_12 = Math.round((this.scale / 10));
if(direction == LegacyWallGeometry.R)
{
let _local_7 = (this._width - 1);
while(_local_7 >= 0)
{
let _local_6 = 1;
while(_local_6 < this._height)
{
if(this.getHeight(_local_7, _local_6) <= this._floorHeight)
{
if((_local_6 - 1) < height)
{
width = _local_7;
height = (_local_6 - 1);
}
break;
}
_local_6++;
}
_local_7--;
}
localY = (localY + ((this.scale / 4) - (_local_12 / 2)));
localX = (localX + (this.scale / 2));
}
else
{
let _local_6 = (this._height - 1);
while(_local_6 >= 0)
{
let _local_7 = 1;
while(_local_7 < this._width)
{
if(this.getHeight(_local_7, _local_6) <= this._floorHeight)
{
if((_local_7 - 1) < width)
{
width = (_local_7 - 1);
height = _local_6;
}
break;
}
_local_7++;
}
_local_6--;
}
localY = (localY + ((this.scale / 4) - (_local_12 / 2)));
localX = (localX - _local_12);
}
}
let _local_8: number = width;
let _local_9: number = height;
let _local_10: number = this.getHeight(width, height);
if(direction == LegacyWallGeometry.R)
{
_local_8 = (_local_8 + ((localX / (this._scale / 2)) - 0.5));
_local_9 = (_local_9 + 0.5);
_local_10 = (_local_10 - ((localY - (localX / 2)) / (this._scale / 2)));
}
else
{
_local_9 = (_local_9 + ((((this._scale / 2) - localX) / (this._scale / 2)) - 0.5));
_local_8 = (_local_8 + 0.5);
_local_10 = (_local_10 - ((localY - (((this._scale / 2) - localX) / 2)) / (this._scale / 2)));
}
const _local_11: IVector3D = new Vector3d(_local_8, _local_9, _local_10);
return _local_11;
}
public getLocationOldFormat(k: number, _arg_2: number, _arg_3: string): IVector3D
{
let _local_4: number;
let _local_5: number;
let _local_6 = 0;
let _local_7 = 0;
_local_5 = Math.ceil(k);
_local_6 = (_local_5 - k);
let _local_8: number;
let _local_9: number;
let _local_11: number;
let _local_12 = 0;
_local_4 = 0;
while(_local_4 < this._width)
{
if(((_local_5 >= 0) && (_local_5 < this._height)))
{
if(this.getHeight(_local_4, _local_5) <= this._floorHeight)
{
_local_8 = (_local_4 - 1);
_local_9 = _local_5;
_local_7 = _local_4;
_arg_3 = LegacyWallGeometry.L;
break;
}
if(this.getHeight(_local_4, (_local_5 + 1)) <= this._floorHeight)
{
_local_8 = _local_4;
_local_9 = _local_5;
_local_7 = (_local_9 - k);
_arg_3 = LegacyWallGeometry.R;
break;
}
}
_local_5++;
_local_4++;
}
const _local_10 = ((this.scale / 2) * _local_6);
let _local_13: number = ((-(_local_7) * this.scale) / 2);
_local_13 = (_local_13 + ((((-(_arg_2) * 18) / 32) * this.scale) / 2));
_local_12 = this.getHeight(_local_8, _local_9);
_local_11 = (((_local_12 * this.scale) / 2) + _local_13);
if(_arg_3 == LegacyWallGeometry.R)
{
_local_11 = (_local_11 + ((_local_6 * this.scale) / 4));
}
else
{
_local_11 = (_local_11 + (((1 - _local_6) * this.scale) / 4));
}
return this.getLocation(_local_8, _local_9, _local_10, _local_11, _arg_3);
}
public getOldLocation(k: IVector3D, _arg_2: number): [number, number, number, number, string]
{
if(k == null)
{
return null;
}
let _local_3 = 0;
let _local_4 = 0;
let _local_5 = 0;
let _local_6 = 0;
let _local_7 = '';
let _local_8 = 0;
if(_arg_2 == 90)
{
_local_3 = Math.floor((k.x - 0.5));
_local_4 = Math.floor((k.y + 0.5));
_local_8 = this.getHeight(_local_3, _local_4);
_local_5 = ((this._scale / 2) - (((k.y - _local_4) + 0.5) * (this._scale / 2)));
_local_6 = (((_local_8 - k.z) * (this._scale / 2)) + (((this._scale / 2) - _local_5) / 2));
_local_7 = LegacyWallGeometry.L;
}
else
{
if(_arg_2 == 180)
{
_local_3 = Math.floor((k.x + 0.5));
_local_4 = Math.floor((k.y - 0.5));
_local_8 = this.getHeight(_local_3, _local_4);
_local_5 = (((k.x + 0.5) - _local_3) * (this._scale / 2));
_local_6 = (((_local_8 - k.z) * (this._scale / 2)) + (_local_5 / 2));
_local_7 = LegacyWallGeometry.R;
}
else
{
return null;
}
}
return [_local_3, _local_4, _local_5, _local_6, _local_7];
}
public getOldLocationString(k: IVector3D, _arg_2: number): string
{
const _local_3 = this.getOldLocation(k, _arg_2);
if(_local_3 == null)
{
return null;
}
const _local_4: number = Math.trunc(_local_3[0]);
const _local_5: number = Math.trunc(_local_3[1]);
const _local_6: number = Math.trunc(_local_3[2]);
const _local_7: number = Math.trunc(_local_3[3]);
const _local_8: string = _local_3[4];
const _local_9: string = (((((((((':w=' + _local_4) + ',') + _local_5) + ' l=') + _local_6) + ',') + _local_7) + ' ') + _local_8);
return _local_9;
}
public getDirection(k: string): number
{
if(k == LegacyWallGeometry.R)
{
return 180;
}
return 90;
}
public getFloorAltitude(k: number, _arg_2: number): number
{
const _local_3 = this.getHeight(k, _arg_2);
const _local_4 = (_local_3 + 1);
return _local_3 + (((((((((Math.trunc(this.getHeight((k - 1), (_arg_2 - 1))) == _local_4) || (Math.trunc(this.getHeight(k, (_arg_2 - 1))) == _local_4)) || (Math.trunc(this.getHeight((k + 1), (_arg_2 - 1))) == _local_4)) || (Math.trunc(this.getHeight((k - 1), _arg_2)) == _local_4)) || (Math.trunc(this.getHeight((k + 1), _arg_2)) == _local_4)) || (Math.trunc(this.getHeight((k - 1), (_arg_2 + 1))) == _local_4)) || (Math.trunc(this.getHeight(k, (_arg_2 + 1))) == _local_4)) || (Math.trunc(this.getHeight((k + 1), (_arg_2 + 1))) == _local_4)) ? 0.5 : 0);
}
public isRoomTile(k: number, _arg_2: number): boolean
{
return ((((k >= 0) && (k < this._width)) && (_arg_2 >= 0)) && (_arg_2 < this._height)) && (this._heightMap[_arg_2][k] >= 0);
}
}
+288
View File
@@ -0,0 +1,288 @@
import { IVector3D } from '@nitrots/api';
import { Vector3d } from '@nitrots/utils';
export class RoomCamera
{
private static MOVE_SPEED_DENOMINATOR: number = 12;
private _targetId: number = -1;
private _targetCategory: number = -2;
private _targetLoc: IVector3D = null;
private _moveDistance: number = 0;
private _previousMoveSpeed: number = 0;
private _maintainPreviousMoveSpeed: boolean = false;
private _currentLoc: IVector3D = null;
private _targetObjectLoc: IVector3D;
private _limitedLocX: boolean = false;
private _limitedLocY: boolean = false;
private _centeredLocX: boolean = false;
private _centeredLocY: boolean = false;
private _screenWd: number = 0;
private _screenHt: number = 0;
private _scale: number = 0;
private _roomWd: number = 0;
private _roomHt: number = 0;
private _geometryUpdateId: number = -1;
private _scaleChanged: boolean = false;
private _followDuration: number;
constructor()
{
this._targetObjectLoc = new Vector3d();
}
public get location(): IVector3D
{
return this._currentLoc;
}
public get targetId(): number
{
return this._targetId;
}
public set targetId(k: number)
{
this._targetId = k;
}
public get targetCategory(): number
{
return this._targetCategory;
}
public set targetCategory(k: number)
{
this._targetCategory = k;
}
public get targetObjectLoc(): IVector3D
{
return this._targetObjectLoc;
}
public set targetObjectLoc(k: IVector3D)
{
this._targetObjectLoc.assign(k);
}
public get limitedLocationX(): boolean
{
return this._limitedLocX;
}
public set limitedLocationX(k: boolean)
{
this._limitedLocX = k;
}
public get limitedLocationY(): boolean
{
return this._limitedLocY;
}
public set limitedLocationY(k: boolean)
{
this._limitedLocY = k;
}
public get centeredLocX(): boolean
{
return this._centeredLocX;
}
public set centeredLocX(k: boolean)
{
this._centeredLocX = k;
}
public get centeredLocY(): boolean
{
return this._centeredLocY;
}
public set centeredLocY(k: boolean)
{
this._centeredLocY = k;
}
public get screenWd(): number
{
return this._screenWd;
}
public set screenWd(k: number)
{
this._screenWd = k;
}
public get screenHt(): number
{
return this._screenHt;
}
public set screenHt(k: number)
{
this._screenHt = k;
}
public get scale(): number
{
return this._scale;
}
public set scale(k: number)
{
if(this._scale != k)
{
this._scale = k;
this._scaleChanged = true;
}
}
public get roomWd(): number
{
return this._roomWd;
}
public set roomWd(k: number)
{
this._roomWd = k;
}
public get roomHt(): number
{
return this._roomHt;
}
public set roomHt(k: number)
{
this._roomHt = k;
}
public get geometryUpdateId(): number
{
return this._geometryUpdateId;
}
public set geometryUpdateId(k: number)
{
this._geometryUpdateId = k;
}
public get isMoving(): boolean
{
if(((!(this._targetLoc == null)) && (!(this._currentLoc == null))))
{
return true;
}
return false;
}
public set target(k: IVector3D)
{
let _local_2: IVector3D;
if(this._targetLoc == null)
{
this._targetLoc = new Vector3d();
}
if((((!(this._targetLoc.x == k.x)) || (!(this._targetLoc.y == k.y))) || (!(this._targetLoc.z == k.z))))
{
this._targetLoc.assign(k);
_local_2 = Vector3d.dif(this._targetLoc, this._currentLoc);
this._moveDistance = _local_2.length;
this._maintainPreviousMoveSpeed = true;
}
}
public dispose(): void
{
this._targetLoc = null;
this._currentLoc = null;
}
public initializeLocation(k: IVector3D): void
{
if(this._currentLoc != null)
{
return;
}
this._currentLoc = new Vector3d();
this._currentLoc.assign(k);
}
public resetLocation(k: IVector3D): void
{
if(this._currentLoc == null)
{
this._currentLoc = new Vector3d();
}
this._currentLoc.assign(k);
}
public update(k: number, _arg_2: number): void
{
let _local_3: IVector3D;
let _local_4: number;
let _local_5: number;
let _local_6: number;
let _local_7: number;
if((((this._followDuration > 0) && (!(this._targetLoc == null))) && (!(this._currentLoc == null))))
{
if(this._scaleChanged)
{
this._scaleChanged = false;
this._currentLoc = this._targetLoc;
this._targetLoc = null;
return;
}
_local_3 = Vector3d.dif(this._targetLoc, this._currentLoc);
if(_local_3.length > this._moveDistance)
{
this._moveDistance = _local_3.length;
}
if(_local_3.length <= _arg_2)
{
this._currentLoc = this._targetLoc;
this._targetLoc = null;
this._previousMoveSpeed = 0;
}
else
{
_local_4 = Math.sin(((Math.PI * _local_3.length) / this._moveDistance));
_local_5 = (_arg_2 * 0.5);
_local_6 = (this._moveDistance / RoomCamera.MOVE_SPEED_DENOMINATOR);
_local_7 = (_local_5 + ((_local_6 - _local_5) * _local_4));
if(this._maintainPreviousMoveSpeed)
{
if(_local_7 < this._previousMoveSpeed)
{
_local_7 = this._previousMoveSpeed;
if(_local_7 > _local_3.length)
{
_local_7 = _local_3.length;
}
}
else
{
this._maintainPreviousMoveSpeed = false;
}
}
this._previousMoveSpeed = _local_7;
_local_3.divide(_local_3.length);
_local_3.multiply(_local_7);
this._currentLoc = Vector3d.sum(this._currentLoc, _local_3);
}
}
}
public reset(): void
{
this._geometryUpdateId = -1;
}
public activateFollowing(k: number): void
{
this._followDuration = k;
}
}
+59
View File
@@ -0,0 +1,59 @@
import { RoomMapData } from '../object';
export class RoomData
{
private _roomId: number;
private _data: RoomMapData;
private _floorType: string;
private _wallType: string;
private _landscapeType: string;
constructor(roomId: number, data: RoomMapData)
{
this._roomId = roomId;
this._data = data;
this._floorType = null;
this._wallType = null;
this._landscapeType = null;
}
public get roomId(): number
{
return this._roomId;
}
public get data(): RoomMapData
{
return this._data;
}
public get floorType(): string
{
return this._floorType;
}
public set floorType(k: string)
{
this._floorType = k;
}
public get wallType(): string
{
return this._wallType;
}
public set wallType(k: string)
{
this._wallType = k;
}
public get landscapeType(): string
{
return this._landscapeType;
}
public set landscapeType(k: string)
{
this._landscapeType = k;
}
}
@@ -0,0 +1,78 @@
import { GetTickerTime } from '@nitrots/utils';
export class RoomEnterEffect
{
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 _state: number = RoomEnterEffect.STATE_NOT_INITIALIZED;
private static _visualizationOn: boolean = false;
private static _currentDelta: number = 0;
private static _initializationTimeMs: number = 0;
private static _startDelayMs: number = (20 * 1000);
private static _effectDurationMs: number = 2000;
public static init(delay: number, duration: number): void
{
RoomEnterEffect._currentDelta = 0;
RoomEnterEffect._startDelayMs = delay;
RoomEnterEffect._effectDurationMs = duration;
RoomEnterEffect._initializationTimeMs = GetTickerTime();
RoomEnterEffect._state = RoomEnterEffect.STATE_START_DELAY;
}
public static turnVisualizationOn(): void
{
if((RoomEnterEffect._state === RoomEnterEffect.STATE_NOT_INITIALIZED) || (RoomEnterEffect._state === RoomEnterEffect.STATE_OVER)) return;
const k = (GetTickerTime() - RoomEnterEffect._initializationTimeMs);
if(k > (RoomEnterEffect._startDelayMs + RoomEnterEffect._effectDurationMs))
{
RoomEnterEffect._state = RoomEnterEffect.STATE_OVER;
return;
}
RoomEnterEffect._visualizationOn = true;
if(k < RoomEnterEffect._startDelayMs)
{
RoomEnterEffect._state = RoomEnterEffect.STATE_START_DELAY;
return;
}
RoomEnterEffect._state = RoomEnterEffect.STATE_RUNNING;
RoomEnterEffect._currentDelta = ((k - RoomEnterEffect._startDelayMs) / RoomEnterEffect._effectDurationMs);
}
public static turnVisualizationOff(): void
{
RoomEnterEffect._visualizationOn = false;
}
public static isVisualizationOn(): boolean
{
return (RoomEnterEffect._visualizationOn) && (RoomEnterEffect.isRunning());
}
public static isRunning(): boolean
{
if((RoomEnterEffect._state === RoomEnterEffect.STATE_START_DELAY) || (RoomEnterEffect._state === RoomEnterEffect.STATE_RUNNING)) return true;
return false;
}
public static getDelta(k: number = 0, _arg_2: number = 1): number
{
return Math.min(Math.max(RoomEnterEffect._currentDelta, k), _arg_2);
}
public static get totalRunningTime(): number
{
return RoomEnterEffect._startDelayMs + RoomEnterEffect._effectDurationMs;
}
}
@@ -0,0 +1,119 @@
import { IObjectData, IVector3D } from '@nitrots/api';
import { Vector3d } from '@nitrots/utils';
export class RoomFurnitureData
{
private _id: number;
private _typeId: number;
private _type: string;
private _location: IVector3D;
private _direction: IVector3D;
private _state: number;
private _data: IObjectData;
private _extra: number;
private _expiryTime: number;
private _usagePolicy: number;
private _ownerId: number;
private _ownerName: string;
private _synchronized: boolean;
private _realRoomObject: boolean;
private _sizeZ: number;
constructor(id: number, typeId: number, type: string, location: IVector3D, direction: IVector3D, state: number, objectData: IObjectData, extra: number = NaN, expires: number = -1, usagePolicy: number = 0, ownerId: number = 0, ownerName: string = '', synchronized: boolean = true, realRoomObject: boolean = true, sizeZ: number = -1)
{
this._id = id;
this._typeId = typeId;
this._type = type;
this._state = state;
this._data = objectData;
this._extra = extra;
this._expiryTime = expires;
this._usagePolicy = usagePolicy;
this._ownerId = ownerId;
this._ownerName = ownerName;
this._synchronized = synchronized;
this._realRoomObject = realRoomObject;
this._sizeZ = sizeZ;
this._location = new Vector3d();
this._direction = new Vector3d();
this._location.assign(location);
this._direction.assign(direction);
}
public get id(): number
{
return this._id;
}
public get typeId(): number
{
return this._typeId;
}
public get type(): string
{
return this._type;
}
public get location(): IVector3D
{
return this._location;
}
public get direction(): IVector3D
{
return this._direction;
}
public get state(): number
{
return this._state;
}
public get data(): IObjectData
{
return this._data;
}
public get extra(): number
{
return this._extra;
}
public get expiryTime(): number
{
return this._expiryTime;
}
public get usagePolicy(): number
{
return this._usagePolicy;
}
public get ownerId(): number
{
return this._ownerId;
}
public get ownerName(): string
{
return this._ownerName;
}
public get synchronized(): boolean
{
return this._synchronized;
}
public get realRoomObject(): boolean
{
return this._realRoomObject;
}
public get sizeZ(): number
{
return this._sizeZ;
}
}
+432
View File
@@ -0,0 +1,432 @@
import { IRoomGeometry, IVector3D } from '@nitrots/api';
import { Vector3d } from '@nitrots/utils';
import { Point } from 'pixi.js';
export class RoomGeometry implements IRoomGeometry
{
public static SCALE_ZOOMED_IN: number = 64;
public static SCALE_ZOOMED_OUT: number = 32;
private _updateId: number = 0;
private _x: IVector3D;
private _y: IVector3D;
private _z: IVector3D;
private _directionAxis: IVector3D;
private _location: IVector3D;
private _direction: IVector3D;
private _depth: IVector3D;
private _scale: number = 1;
private _x_scale: number = 1;
private _y_scale: number = 1;
private _z_scale: number = 1;
private _x_scale_internal: number = 1;
private _y_scale_internal: number = 1;
private _z_scale_internal: number = 1;
private _loc: IVector3D;
private _dir: IVector3D;
private _clipNear: number = -500;
private _clipFar: number = 500;
private _displacements: Map<string, IVector3D> = null;
constructor(scale: number, direction: IVector3D, location: IVector3D, _arg_4: IVector3D = null)
{
this.scale = scale;
this._x = new Vector3d();
this._y = new Vector3d();
this._z = new Vector3d();
this._directionAxis = new Vector3d();
this._location = new Vector3d();
this._direction = new Vector3d();
this._depth = new Vector3d();
this._x_scale_internal = 1;
this._y_scale_internal = 1;
this.x_scale = 1;
this.y_scale = 1;
this._z_scale_internal = (Math.sqrt((1 / 2)) / Math.sqrt((3 / 4)));
this.z_scale = 1;
this.location = new Vector3d(location.x, location.y, location.z);
this.direction = new Vector3d(direction.x, direction.y, direction.z);
if(_arg_4 != null)
{
this.setDepthVector(_arg_4);
}
else
{
this.setDepthVector(direction);
}
this._displacements = new Map();
}
public static getIntersectionVector(k: IVector3D, _arg_2: IVector3D, _arg_3: IVector3D, _arg_4: IVector3D): IVector3D
{
const _local_5: number = Vector3d.dotProduct(_arg_2, _arg_4);
if(Math.abs(_local_5) < 1E-5)
{
return null;
}
const _local_6: IVector3D = Vector3d.dif(k, _arg_3);
const _local_7: number = (-(Vector3d.dotProduct(_arg_4, _local_6)) / _local_5);
const _local_8: IVector3D = Vector3d.sum(k, Vector3d.product(_arg_2, _local_7));
return _local_8;
}
public get updateId(): number
{
return this._updateId;
}
public get scale(): number
{
return this._scale / Math.sqrt(0.5);
}
public set scale(scale: number)
{
if(scale <= 1)
{
scale = 1;
}
scale = (scale * Math.sqrt(0.5));
if(scale != this._scale)
{
this._scale = scale;
this._updateId++;
}
}
public get directionAxis(): IVector3D
{
return this._directionAxis;
}
public get location(): IVector3D
{
this._location.assign(this._loc);
this._location.x = (this._location.x * this._x_scale);
this._location.y = (this._location.y * this._y_scale);
this._location.z = (this._location.z * this._z_scale);
return this._location;
}
public set location(location: IVector3D)
{
if(location == null)
{
return;
}
if(this._loc == null)
{
this._loc = new Vector3d();
}
const _local_2: number = this._loc.x;
const _local_3: number = this._loc.y;
const _local_4: number = this._loc.z;
this._loc.assign(location);
this._loc.x = (this._loc.x / this._x_scale);
this._loc.y = (this._loc.y / this._y_scale);
this._loc.z = (this._loc.z / this._z_scale);
if((((!(this._loc.x == _local_2)) || (!(this._loc.y == _local_3))) || (!(this._loc.z == _local_4))))
{
this._updateId++;
}
}
public get direction(): IVector3D
{
return this._direction;
}
public set direction(direction: IVector3D)
{
let _local_21: number;
let _local_22: number;
let _local_23: IVector3D;
let _local_24: IVector3D;
let _local_25: IVector3D;
if(direction == null)
{
return;
}
if(this._dir == null)
{
this._dir = new Vector3d();
}
const _local_2: number = this._dir.x;
const _local_3: number = this._dir.y;
const _local_4: number = this._dir.z;
this._dir.assign(direction);
this._direction.assign(direction);
if((((!(this._dir.x == _local_2)) || (!(this._dir.y == _local_3))) || (!(this._dir.z == _local_4))))
{
this._updateId++;
}
const _local_5: IVector3D = new Vector3d(0, 1, 0);
const _local_6: IVector3D = new Vector3d(0, 0, 1);
const _local_7: IVector3D = new Vector3d(1, 0, 0);
const _local_8: number = ((direction.x / 180) * Math.PI);
const _local_9: number = ((direction.y / 180) * Math.PI);
const _local_10: number = ((direction.z / 180) * Math.PI);
const _local_11: number = Math.cos(_local_8);
const _local_12: number = Math.sin(_local_8);
const _local_13: IVector3D = Vector3d.sum(Vector3d.product(_local_5, _local_11), Vector3d.product(_local_7, -(_local_12)));
const _local_14: IVector3D = new Vector3d(_local_6.x, _local_6.y, _local_6.z);
const _local_15: IVector3D = Vector3d.sum(Vector3d.product(_local_5, _local_12), Vector3d.product(_local_7, _local_11));
const _local_16: number = Math.cos(_local_9);
const _local_17: number = Math.sin(_local_9);
const _local_18: IVector3D = new Vector3d(_local_13.x, _local_13.y, _local_13.z);
const _local_19: IVector3D = Vector3d.sum(Vector3d.product(_local_14, _local_16), Vector3d.product(_local_15, _local_17));
const _local_20: IVector3D = Vector3d.sum(Vector3d.product(_local_14, -(_local_17)), Vector3d.product(_local_15, _local_16));
if(_local_10 != 0)
{
_local_21 = Math.cos(_local_10);
_local_22 = Math.sin(_local_10);
_local_23 = Vector3d.sum(Vector3d.product(_local_18, _local_21), Vector3d.product(_local_19, _local_22));
_local_24 = Vector3d.sum(Vector3d.product(_local_18, -(_local_22)), Vector3d.product(_local_19, _local_21));
_local_25 = new Vector3d(_local_20.x, _local_20.y, _local_20.z);
this._x.assign(_local_23);
this._y.assign(_local_24);
this._z.assign(_local_25);
this._directionAxis.assign(this._z);
}
else
{
this._x.assign(_local_18);
this._y.assign(_local_19);
this._z.assign(_local_20);
this._directionAxis.assign(this._z);
}
}
public set x_scale(xScale: number)
{
if(this._x_scale != (xScale * this._x_scale_internal))
{
this._x_scale = (xScale * this._x_scale_internal);
this._updateId++;
}
}
public set y_scale(yScale: number)
{
if(this._y_scale != (yScale * this._y_scale_internal))
{
this._y_scale = (yScale * this._y_scale_internal);
this._updateId++;
}
}
public set z_scale(zScale: number)
{
if(this._z_scale != (zScale * this._z_scale_internal))
{
this._z_scale = (zScale * this._z_scale_internal);
this._updateId++;
}
}
public dispose(): void
{
this._x = null;
this._y = null;
this._z = null;
this._loc = null;
this._dir = null;
this._directionAxis = null;
this._location = null;
if(this._displacements != null)
{
this._displacements.clear();
this._displacements = null;
}
}
public setDisplacement(k: IVector3D, _arg_2: IVector3D): void
{
let _local_3: string;
let _local_4: IVector3D;
if(((k == null) || (_arg_2 == null)))
{
return;
}
if(this._displacements != null)
{
_local_3 = Math.trunc(Math.round(k.x)) + '_' + Math.trunc(Math.round(k.y)) + '_' + Math.trunc(Math.round(k.z));
this._displacements.delete(_local_3);
_local_4 = new Vector3d();
_local_4.assign(_arg_2);
this._displacements.set(_local_3, _local_4);
this._updateId++;
}
}
private getDisplacenent(k: IVector3D): IVector3D
{
let _local_2: string;
if(this._displacements != null)
{
_local_2 = Math.trunc(Math.round(k.x)) + '_' + Math.trunc(Math.round(k.y)) + '_' + Math.trunc(Math.round(k.z));
return this._displacements.get(_local_2);
}
return null;
}
public setDepthVector(k: IVector3D): void
{
let _local_18: number;
let _local_19: number;
let _local_20: IVector3D;
let _local_21: IVector3D;
let _local_22: IVector3D;
const _local_2: IVector3D = new Vector3d(0, 1, 0);
const _local_3: IVector3D = new Vector3d(0, 0, 1);
const _local_4: IVector3D = new Vector3d(1, 0, 0);
const _local_5: number = ((k.x / 180) * Math.PI);
const _local_6: number = ((k.y / 180) * Math.PI);
const _local_7: number = ((k.z / 180) * Math.PI);
const _local_8: number = Math.cos(_local_5);
const _local_9: number = Math.sin(_local_5);
const _local_10: IVector3D = Vector3d.sum(Vector3d.product(_local_2, _local_8), Vector3d.product(_local_4, -(_local_9)));
const _local_11: IVector3D = new Vector3d(_local_3.x, _local_3.y, _local_3.z);
const _local_12: IVector3D = Vector3d.sum(Vector3d.product(_local_2, _local_9), Vector3d.product(_local_4, _local_8));
const _local_13: number = Math.cos(_local_6);
const _local_14: number = Math.sin(_local_6);
const _local_15: IVector3D = new Vector3d(_local_10.x, _local_10.y, _local_10.z);
const _local_16: IVector3D = Vector3d.sum(Vector3d.product(_local_11, _local_13), Vector3d.product(_local_12, _local_14));
const _local_17: IVector3D = Vector3d.sum(Vector3d.product(_local_11, -(_local_14)), Vector3d.product(_local_12, _local_13));
if(_local_7 != 0)
{
_local_18 = Math.cos(_local_7);
_local_19 = Math.sin(_local_7);
_local_20 = Vector3d.sum(Vector3d.product(_local_15, _local_18), Vector3d.product(_local_16, _local_19));
_local_21 = Vector3d.sum(Vector3d.product(_local_15, -(_local_19)), Vector3d.product(_local_16, _local_18));
_local_22 = new Vector3d(_local_17.x, _local_17.y, _local_17.z);
this._depth.assign(_local_22);
}
else
{
this._depth.assign(_local_17);
}
this._updateId++;
}
public adjustLocation(k: IVector3D, _arg_2: number): void
{
if(((k == null) || (this._z == null)))
{
return;
}
const _local_3: IVector3D = Vector3d.product(this._z, -(_arg_2));
const _local_4: IVector3D = new Vector3d((k.x + _local_3.x), (k.y + _local_3.y), (k.z + _local_3.z));
this.location = _local_4;
}
public getCoordinatePosition(k: IVector3D): IVector3D
{
if(k == null)
{
return null;
}
const _local_2: number = Vector3d.scalarProjection(k, this._x);
const _local_3: number = Vector3d.scalarProjection(k, this._y);
const _local_4: number = Vector3d.scalarProjection(k, this._z);
const _local_5: IVector3D = new Vector3d(_local_2, _local_3, _local_4);
return _local_5;
}
public getScreenPosition(k: IVector3D): IVector3D
{
let _local_2: IVector3D = Vector3d.dif(k, this._loc);
_local_2.x = (_local_2.x * this._x_scale);
_local_2.y = (_local_2.y * this._y_scale);
_local_2.z = (_local_2.z * this._z_scale);
let _local_3: number = Vector3d.scalarProjection(_local_2, this._depth);
if(((_local_3 < this._clipNear) || (_local_3 > this._clipFar)))
{
return null;
}
let _local_4: number = Vector3d.scalarProjection(_local_2, this._x);
let _local_5: number = -(Vector3d.scalarProjection(_local_2, this._y));
_local_4 = (_local_4 * this._scale);
_local_5 = (_local_5 * this._scale);
const _local_6: IVector3D = this.getDisplacenent(k);
if(_local_6 != null)
{
_local_2 = Vector3d.dif(k, this._loc);
_local_2.add(_local_6);
_local_2.x = (_local_2.x * this._x_scale);
_local_2.y = (_local_2.y * this._y_scale);
_local_2.z = (_local_2.z * this._z_scale);
_local_3 = Vector3d.scalarProjection(_local_2, this._depth);
}
_local_2.x = _local_4;
_local_2.y = _local_5;
_local_2.z = _local_3;
return _local_2;
}
public getScreenPoint(k: IVector3D): Point
{
const _local_2: IVector3D = this.getScreenPosition(k);
if(_local_2 == null)
{
return null;
}
const _local_3: Point = new Point(_local_2.x, _local_2.y);
return _local_3;
}
public getPlanePosition(k: Point, _arg_2: IVector3D, _arg_3: IVector3D, _arg_4: IVector3D): Point
{
let _local_15: number;
let _local_16: number;
const _local_5: number = (k.x / this._scale);
const _local_6: number = (-(k.y) / this._scale);
const _local_7: IVector3D = Vector3d.product(this._x, _local_5);
_local_7.add(Vector3d.product(this._y, _local_6));
const _local_8: IVector3D = new Vector3d((this._loc.x * this._x_scale), (this._loc.y * this._y_scale), (this._loc.z * this._z_scale));
_local_8.add(_local_7);
const _local_9: IVector3D = this._z;
const _local_10: IVector3D = new Vector3d((_arg_2.x * this._x_scale), (_arg_2.y * this._y_scale), (_arg_2.z * this._z_scale));
const _local_11: IVector3D = new Vector3d((_arg_3.x * this._x_scale), (_arg_3.y * this._y_scale), (_arg_3.z * this._z_scale));
const _local_12: IVector3D = new Vector3d((_arg_4.x * this._x_scale), (_arg_4.y * this._y_scale), (_arg_4.z * this._z_scale));
const _local_13: IVector3D = Vector3d.crossProduct(_local_11, _local_12);
const _local_14: IVector3D = new Vector3d();
_local_14.assign(RoomGeometry.getIntersectionVector(_local_8, _local_9, _local_10, _local_13));
if(_local_14 != null)
{
_local_14.subtract(_local_10);
_local_15 = ((Vector3d.scalarProjection(_local_14, _arg_3) / _local_11.length) * _arg_3.length);
_local_16 = ((Vector3d.scalarProjection(_local_14, _arg_4) / _local_12.length) * _arg_4.length);
return new Point(_local_15, _local_16);
}
return null;
}
public performZoom(): void
{
if(this.isZoomedIn())
{
this.scale = RoomGeometry.SCALE_ZOOMED_OUT;
}
else
{
this.scale = RoomGeometry.SCALE_ZOOMED_IN;
}
}
public isZoomedIn(): boolean
{
return this.scale == RoomGeometry.SCALE_ZOOMED_IN;
}
public performZoomOut(): void
{
this.scale = RoomGeometry.SCALE_ZOOMED_OUT;
}
public performZoomIn(): void
{
this.scale = RoomGeometry.SCALE_ZOOMED_IN;
}
}
+234
View File
@@ -0,0 +1,234 @@
import { IFurnitureStackingHeightMap, ILegacyWallGeometry, ISelectedRoomObjectData, ITileObjectMap } from '@nitrots/api';
import { LegacyWallGeometry } from './LegacyWallGeometry';
import { RoomCamera } from './RoomCamera';
import { RoomFurnitureData } from './RoomFurnitureData';
import { TileObjectMap } from './TileObjectMap';
export class RoomInstanceData
{
private _roomId: number;
private _modelName: string;
private _legacyGeometry: ILegacyWallGeometry;
private _tileObjectMap: ITileObjectMap;
private _roomCamera: RoomCamera;
private _selectedObject: ISelectedRoomObjectData;
private _placedObject: ISelectedRoomObjectData;
private _furnitureStackingHeightMap: IFurnitureStackingHeightMap;
private _floorStack: Map<number, RoomFurnitureData>;
private _wallStack: Map<number, RoomFurnitureData>;
private _mouseButtonCursorOwners: string[];
constructor(roomId: number)
{
this._roomId = roomId;
this._modelName = null;
this._legacyGeometry = new LegacyWallGeometry();
this._tileObjectMap = null;
this._roomCamera = new RoomCamera();
this._selectedObject = null;
this._placedObject = null;
this._furnitureStackingHeightMap = null;
this._floorStack = new Map();
this._wallStack = new Map();
this._mouseButtonCursorOwners = [];
}
public dispose(): void
{
return;
}
public setModelName(name: string): void
{
this._modelName = name;
}
public setSelectedObject(data: ISelectedRoomObjectData): void
{
if(this._selectedObject)
{
this._selectedObject.dispose();
}
this._selectedObject = data;
}
public setPlacedObject(data: ISelectedRoomObjectData): void
{
if(this._placedObject)
{
this._placedObject.dispose();
}
this._placedObject = data;
}
public setFurnitureStackingHeightMap(heightMap: IFurnitureStackingHeightMap): void
{
if(this._furnitureStackingHeightMap) this._furnitureStackingHeightMap.dispose();
this._furnitureStackingHeightMap = heightMap;
if(this._tileObjectMap) this._tileObjectMap.dispose();
if(this._furnitureStackingHeightMap)
{
this._tileObjectMap = new TileObjectMap(this._furnitureStackingHeightMap.width, this._furnitureStackingHeightMap.height);
}
}
public addPendingFurnitureFloor(data: RoomFurnitureData): void
{
if(!data) return;
this._floorStack.delete(data.id);
this._floorStack.set(data.id, data);
}
public removePendingFunitureFloor(id: number): RoomFurnitureData
{
const existing = this._floorStack.get(id);
if(!existing) return null;
this._floorStack.delete(id);
return existing;
}
public getPendingFurnitureFloor(id: number): RoomFurnitureData
{
const existing = this._floorStack.get(id);
if(!existing) return null;
this._floorStack.delete(id);
return existing;
}
public getNextPendingFurnitureFloor(): RoomFurnitureData
{
if(!this._floorStack.size) return null;
const keys = this._floorStack.keys();
return this.getPendingFurnitureFloor(keys.next().value as number);
}
public addPendingFurnitureWall(data: RoomFurnitureData): void
{
if(!data) return;
this._wallStack.delete(data.id);
this._wallStack.set(data.id, data);
}
public removePendingFurnitureWall(id: number): RoomFurnitureData
{
const existing = this._wallStack.get(id);
if(!existing) return null;
this._wallStack.delete(id);
return existing;
}
public getPendingFurnitureWall(id: number): RoomFurnitureData
{
const existing = this._wallStack.get(id);
if(!existing) return null;
this._wallStack.delete(id);
return existing;
}
public getNextPendingFurnitureWall(): RoomFurnitureData
{
if(!this._wallStack.size) return null;
const keys = this._wallStack.keys();
return this.getPendingFurnitureWall(keys.next().value as number);
}
public addButtonMouseCursorOwner(k: string): boolean
{
const _local_2 = this._mouseButtonCursorOwners.indexOf(k);
if(_local_2 === -1)
{
this._mouseButtonCursorOwners.push(k);
return true;
}
return false;
}
public removeButtonMouseCursorOwner(k: string): boolean
{
const _local_2 = this._mouseButtonCursorOwners.indexOf(k);
if(_local_2 > -1)
{
this._mouseButtonCursorOwners.splice(_local_2, 1);
return true;
}
return false;
}
public hasButtonMouseCursorOwners(): boolean
{
return this._mouseButtonCursorOwners.length > 0;
}
public get roomId(): number
{
return this._roomId;
}
public get modelName(): string
{
return this._modelName;
}
public get legacyGeometry(): ILegacyWallGeometry
{
return this._legacyGeometry;
}
public get tileObjectMap(): ITileObjectMap
{
return this._tileObjectMap;
}
public get roomCamera(): RoomCamera
{
return this._roomCamera;
}
public get selectedObject(): ISelectedRoomObjectData
{
return this._selectedObject;
}
public get placedObject(): ISelectedRoomObjectData
{
return this._placedObject;
}
public get furnitureStackingHeightMap(): IFurnitureStackingHeightMap
{
return this._furnitureStackingHeightMap;
}
}
@@ -0,0 +1,23 @@
import { IRoomObjectController } from '@nitrots/api';
export class RoomObjectBadgeImageAssetListener
{
private _object: IRoomObjectController;
private _groupBadge: boolean;
constructor(object: IRoomObjectController, groupBadge: boolean)
{
this._object = object;
this._groupBadge = groupBadge;
}
public get object(): IRoomObjectController
{
return this._object;
}
public get groupBadge(): boolean
{
return this._groupBadge;
}
}
@@ -0,0 +1,75 @@
import { GetTickerTime } from '@nitrots/utils';
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 = GetTickerTime();
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 = (GetTickerTime() - 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;
}
}
@@ -0,0 +1,75 @@
import { GetTickerTime } from '@nitrots/utils';
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 = GetTickerTime();
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 = (GetTickerTime() - 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;
}
}
@@ -0,0 +1,95 @@
import { IObjectData, ISelectedRoomObjectData, IVector3D } from '@nitrots/api';
import { Vector3d } from '@nitrots/utils';
export class SelectedRoomObjectData implements ISelectedRoomObjectData
{
private _id: number = 0;
private _category: number = 0;
private _operation: string = '';
private _loc: IVector3D = null;
private _dir: IVector3D = null;
private _typeId: number = 0;
private _instanceData: string = null;
private _stuffData: IObjectData = null;
private _state: number = -1;
private _animFrame: number = -1;
private _posture: string = null;
constructor(id: number, category: number, operation: string, location: IVector3D, direction: IVector3D, typeId: number = 0, instanceData: string = null, stuffData: IObjectData = null, state: number = -1, frameNumber: number = -1, posture: string = null)
{
this._id = id;
this._category = category;
this._operation = operation;
this._loc = new Vector3d();
this._loc.assign(location);
this._dir = new Vector3d();
this._dir.assign(direction);
this._typeId = typeId;
this._instanceData = instanceData;
this._stuffData = stuffData;
this._state = state;
this._animFrame = frameNumber;
this._posture = posture;
}
public get id(): number
{
return this._id;
}
public get category(): number
{
return this._category;
}
public get operation(): string
{
return this._operation;
}
public get loc(): IVector3D
{
return this._loc;
}
public get dir(): IVector3D
{
return this._dir;
}
public get typeId(): number
{
return this._typeId;
}
public get instanceData(): string
{
return this._instanceData;
}
public get stuffData(): IObjectData
{
return this._stuffData;
}
public get state(): number
{
return this._state;
}
public get animFrame(): number
{
return this._animFrame;
}
public get posture(): string
{
return this._posture;
}
public dispose(): void
{
this._loc = null;
this._dir = null;
}
}
@@ -0,0 +1,453 @@
import { IPlaneDrawingData, IPlaneVisualization, IRoomObjectSpriteVisualization, IRoomPlane, IRoomRenderingCanvas, RoomObjectCategory, RoomObjectSpriteData } from '@nitrots/api';
import { GetStage, Vector3d } from '@nitrots/utils';
import { Point, Rectangle } from 'pixi.js';
import { RoomEngine } from '../RoomEngine';
import { PlaneDrawingData } from '../object';
export class SpriteDataCollector
{
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 maxZ: number;
private spriteCount: number = 0;
private externalImageCount: number = 0;
private static addMannequinSprites(k: RoomObjectSpriteData[], _arg_2: RoomEngine): RoomObjectSpriteData[]
{
const datas: RoomObjectSpriteData[] = [];
for(const data of k)
{
if(!data) continue;
if((data.type === 'boutique_mannequin1') && (data.name.indexOf('mannequin_') === 0))
{
const roomObject = _arg_2.getRoomObject(_arg_2.activeRoomId, data.objectId, RoomObjectCategory.FLOOR);
if(roomObject)
{
const spriteList = (roomObject.visualization as IRoomObjectSpriteVisualization).getSpriteList();
if(spriteList)
{
for(const sprite of spriteList)
{
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);
}
}
}
}
else
{
datas.push(data);
}
}
return datas;
}
private static sortSpriteDataObjects(k: RoomObjectSpriteData, _arg_2: RoomObjectSpriteData): number
{
if(k.z < _arg_2.z) return 1;
if(k.z > _arg_2.z) return -1;
return -1;
}
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);
// // intersects
// return _local_4.contains(_arg_2.x, _arg_2.y);
}
private static sortQuadPoints(k: Point, _arg_2: Point, _arg_3: Point, _arg_4: Point): Point[]
{
const points: Point[] = [];
if(k.x == _arg_2.x)
{
points.push(k, _arg_3, _arg_2, _arg_4);
}
else
{
if(k.x == _arg_3.x)
{
points.push(k, _arg_2, _arg_3, _arg_4);
}
else
{
if((((_arg_2.x < k.x) && (_arg_2.y > k.y)) || ((_arg_2.x > k.x) && (_arg_2.y < k.y))))
{
points.push(k, _arg_3, _arg_2, _arg_4);
}
else
{
points.push(k, _arg_2, _arg_3, _arg_4);
}
}
}
if(points[0].x < points[1].x)
{
let _local_6 = points[0];
points[0] = points[1];
points[1] = _local_6;
_local_6 = points[2];
points[2] = points[3];
points[3] = _local_6;
}
if(points[0].y < points[2].y)
{
let _local_6 = points[0];
points[0] = points[2];
points[2] = _local_6;
_local_6 = points[1];
points[1] = points[3];
points[3] = _local_6;
}
return points;
}
public getFurniData(k: Rectangle, _arg_2: IRoomRenderingCanvas, _arg_3: RoomEngine, _arg_4: number): string
{
const _local_5: Object[] = [];
let _local_6 = _arg_2.getSortableSpriteList();
const _local_7 = _arg_3.getRoomObjects(_arg_3.activeRoomId, RoomObjectCategory.UNIT);
for(const _local_8 of _local_7)
{
if(_local_8.id !== _arg_4)
{
const _local_11 = (_local_8.visualization as IRoomObjectSpriteVisualization).getSpriteList();
if(_local_11)
{
let _local_12 = 0;
let _local_13 = 0;
for(const _local_14 of _local_6)
{
if(_local_14.name === ('avatar_' + _local_8.id))
{
_local_12 = _local_14.z;
_local_13 = ((_local_14.y + _local_14.height) - (_arg_2.geometry.scale / 4));
break;
}
}
const _local_15 = _arg_3.getRoomObjectScreenLocation(_arg_3.activeRoomId, _local_8.id, RoomObjectCategory.UNIT, _arg_2.id);
if(_local_15)
{
if(_local_13 === 0) _local_13 = _local_15.y;
for(const _local_16 of _local_11)
{
_local_16.x = (_local_16.x + (_local_15.x - _arg_2.screenOffsetX));
_local_16.y = (_local_16.y + _local_13);
_local_16.z = (_local_16.z + _local_12);
if(((_local_16.name.indexOf('h_std_fx29_') === 0) || (_local_16.name.indexOf('h_std_fx185_') === 0)))
{
_local_16.y = (_local_16.y + SpriteDataCollector.AVATAR_WATER_EFFECT_MAGIC_Y_OFFSET);
}
_local_6.push(_local_16);
}
}
}
}
}
_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.isSpriteInViewPort(_local_9, k, _arg_2))) && ((_arg_4 < 0) || (!(_local_9.objectId == _arg_4)))))
{
_local_5.push(this.getSpriteDataObject(_local_9, k, _arg_2, _arg_3));
if(!this.maxZ) this.maxZ = _local_9.z;
this.spriteCount++;
}
}
return JSON.stringify(_local_5);
}
public getRoomRenderingModifiers(k: RoomEngine): string
{
return JSON.stringify(new Object());
}
private getSpriteDataObject(k: RoomObjectSpriteData, _arg_2: Rectangle, _arg_3: IRoomRenderingCanvas, _arg_4: RoomEngine): Object
{
let _local_7: string = null;
let _local_9: string[] = [];
const _local_5: {
name?: string,
x?: number,
y?: number,
z?: number,
alpha?: number,
flipH?: boolean,
skew?: number,
frame?: boolean,
color?: number,
blendMode?: string,
width?: number,
height?: number,
posture?: string
} = {};
let _local_6 = k.name;
if(k.name.indexOf('@') !== -1)
{
_local_9 = k.name.split('@');
_local_6 = _local_9[0];
_local_7 = _local_9[1];
}
// if(((_local_7) && (k.type)))
// {
// const _local_10 = _arg_4.roomContentLoader.getCollection(k.type);
// if(_local_10)
// {
// const _local_11 = _local_10.getPalette(_local_7);
// if (((!(_local_11 == null)) && (!(_local_11.@source == null))))
// {
// _local_5.paletteSourceName = (_local_11.@source + '');
// }
// }
// }
// var _local_8: string = _arg_4.configuration.getProperty('image.library.url');
// _local_6 = _local_6.replace('%image.library.url%', _local_8);
// if (_local_6.indexOf('%group.badge.url%') != -1)
// {
// _local_12 = _arg_4.configuration.getProperty('group.badge.url');
// _local_6 = _local_6.replace('%group.badge.url%', '');
// _local_13 = _local_12.replace('%imagerdata%', _local_6);
// _local_6 = _local_13;
// }
_local_5.name = _local_6;
_local_5.x = (k.x - _arg_2.x);
_local_5.y = (k.y - _arg_2.y);
_local_5.x = (_local_5.x + _arg_3.screenOffsetX);
_local_5.y = (_local_5.y + _arg_3.screenOffsetY);
_local_5.z = k.z;
if(k.alpha && (k.alpha.toString() !== '255')) _local_5.alpha = k.alpha;
if(k.flipH) _local_5.flipH = k.flipH;
if(k.skew) _local_5.skew = k.skew;
if(k.frame) _local_5.frame = k.frame;
if(k.color && (k.color.length > 0)) _local_5.color = parseInt(k.color);
if(k.blendMode && (k.blendMode !== 'normal')) _local_5.blendMode = k.blendMode;
if(_local_6.indexOf('http') === 0)
{
_local_5.width = k.width;
_local_5.height = k.height;
this.externalImageCount++;
if(this.externalImageCount > SpriteDataCollector.MAX_EXTERNAL_IMAGE_COUNT) _local_5.name = 'box';
}
if(k.posture) _local_5.posture = k.posture;
return _local_5;
}
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.sortQuadPoints(_local_4, _local_5, _local_6, _local_7);
let _local_9 = 0;
if(_arg_3.length > 0)
{
_local_9 = _arg_3[0].z;
if(this.maxZ) _local_9 = Math.max(this.maxZ, _local_9);
}
else
{
_local_9 = ((this.maxZ) ? this.maxZ : 0);
}
_local_9 = (_local_9 + ((this.spriteCount * 1.776104) + (_arg_3.length * 2.31743)));
const _local_10 = new PlaneDrawingData(null, _arg_2);
_local_10.cornerPoints = _local_8;
_local_10.z = _local_9;
return _local_10;
}
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.maxZ)
{
_local_5 = (_local_5 + this.maxZ);
}
for(const _local_6 of k)
{
const _local_10 = {
plane: _local_6,
z: _local_5
};
_local_4.set(_local_6.uniqueId, _local_10);
}
const sprites = _arg_2.getPlaneSortableSprites();
sprites.sort((a, b) =>
{
return (b.z - a.z);
});
sprites.reverse();
let _local_8: { plane: IRoomPlane, z: number }[] = [];
for(const sprite of sprites)
{
const objectSprite = sprite.sprite;
if(objectSprite)
{
const _local_10 = _local_4.get(objectSprite.id);
if(_local_10)
{
_local_4.delete(objectSprite.id);
_local_10.z = sprite.z;
_local_8.push(_local_10);
}
}
}
_local_8 = _local_8.concat(Array.from(_local_4.values()));
return _local_8;
}
public getRoomPlanes(k: Rectangle, _arg_2: IRoomRenderingCanvas, _arg_3: RoomEngine, _arg_4: number): IPlaneDrawingData[]
{
const _local_5: IPlaneDrawingData[] = [];
const roomObject = _arg_3.getRoomObject(_arg_3.activeRoomId, RoomEngine.ROOM_OBJECT_ID, RoomObjectCategory.ROOM);
const visualization = (roomObject.visualization as unknown as IPlaneVisualization);
if(visualization)
{
const _local_8 = _arg_2.geometry;
const _local_9 = this.sortRoomPlanes(visualization.planes, _arg_2, _arg_3);
const _local_10 = GetStage();
for(const _local_11 of _local_9)
{
const _local_12 = _local_11.plane;
const _local_13: Point[] = [];
const _local_14 = Vector3d.sum(_local_12.location, _local_12.leftSide);
const _local_15 = _local_8.getScreenPoint(_local_12.location);
const _local_16 = _local_8.getScreenPoint(_local_14);
const _local_17 = _local_8.getScreenPoint(Vector3d.sum(_local_12.location, _local_12.rightSide));
const _local_18 = _local_8.getScreenPoint(Vector3d.sum(_local_14, _local_12.rightSide));
_local_13.push(_local_15, _local_16, _local_17, _local_18);
let _local_19 = 0;
let _local_20 = 0;
for(const _local_21 of _local_13)
{
_local_21.x += (_local_10.width / 2);
_local_21.y += (_local_10.height / 2);
_local_21.x += _arg_2.screenOffsetX;
_local_21.y += _arg_2.screenOffsetY;
_local_21.x += -(k.x);
_local_21.y += -(k.y);
if(_local_21.x < 0) _local_19--;
else if(_local_21.x >= k.width) _local_19++;
if(_local_21.y < 0) _local_20--;
else if(_local_21.y >= k.height) _local_20++;
}
if(((Math.abs(_local_19) === 4) || (Math.abs(_local_20) === 4)))
{
//
}
else
{
const _local_22 = SpriteDataCollector.sortQuadPoints(_local_15, _local_16, _local_17, _local_18);
/* for(const _local_23 of _local_12.getDrawingDatas(_local_8))
{
_local_23.cornerPoints = _local_22;
_local_23.z = _local_11.z;
_local_5.push(_local_23);
} */
}
}
_local_5.unshift(this.makeBackgroundPlane(k, _arg_4, _local_5));
}
return _local_5;
}
}
+122
View File
@@ -0,0 +1,122 @@
import { IRoomObject, ITileObjectMap, RoomObjectVariable } from '@nitrots/api';
import { NitroLogger } from '@nitrots/utils';
export class TileObjectMap implements ITileObjectMap
{
private _tileObjectMap: Map<number, Map<number, IRoomObject>>;
private _width: number;
private _height: number;
constructor(k: number, _arg_2: number)
{
this._tileObjectMap = new Map();
let index = 0;
while(index < _arg_2)
{
this._tileObjectMap.set(index, new Map());
index++;
}
this._width = k;
this._height = _arg_2;
}
public clear(): void
{
for(const k of this._tileObjectMap.values())
{
if(!k) continue;
k.clear();
}
this._tileObjectMap.clear();
}
public populate(k: IRoomObject[]): void
{
this.clear();
for(const _local_2 of k) this.addRoomObject(_local_2);
}
public dispose(): void
{
this._tileObjectMap = null;
this._width = 0;
this._height = 0;
}
public getObjectIntTile(k: number, _arg_2: number): IRoomObject
{
if((((k >= 0) && (k < this._width)) && (_arg_2 >= 0)) && (_arg_2 < this._height))
{
const existing = this._tileObjectMap.get(_arg_2);
if(existing) return existing.get(k);
}
return null;
}
public setObjectInTile(k: number, _arg_2: number, _arg_3: IRoomObject): void
{
if(!_arg_3.isReady)
{
NitroLogger.log('Assigning non initialized object to tile object map!');
return;
}
if((((k >= 0) && (k < this._width)) && (_arg_2 >= 0)) && (_arg_2 < this._height))
{
const existing = this._tileObjectMap.get(_arg_2);
if(existing) existing.set(k, _arg_3);
}
}
public addRoomObject(k: IRoomObject): void
{
if(!k || !k.model || !k.isReady) return;
const location = k.getLocation();
const direction = k.getDirection();
if(!location || !direction) return;
let sizeX = k.model.getValue<number>(RoomObjectVariable.FURNITURE_SIZE_X);
let sizeY = k.model.getValue<number>(RoomObjectVariable.FURNITURE_SIZE_Y);
if(sizeX < 1) sizeX = 1;
if(sizeY < 1) sizeY = 1;
const directionNumber = ((Math.trunc((direction.x + 45)) % 360) / 90);
if((directionNumber === 1) || (directionNumber === 3)) [sizeX, sizeY] = [sizeY, sizeX];
let y = location.y;
while(y < (location.y + sizeY))
{
let x = location.x;
while(x < (location.x + sizeX))
{
const roomObject = this.getObjectIntTile(x, y);
if((!(roomObject)) || ((!(roomObject === k)) && (roomObject.getLocation().z <= location.z)))
{
this.setObjectInTile(x, y, k);
}
x++;
}
y++;
}
}
}
+14
View File
@@ -0,0 +1,14 @@
export * from './FurnitureStackingHeightMap';
export * from './LegacyWallGeometry';
export * from './RoomCamera';
export * from './RoomData';
export * from './RoomEnterEffect';
export * from './RoomFurnitureData';
export * from './RoomGeometry';
export * from './RoomInstanceData';
export * from './RoomObjectBadgeImageAssetListener';
export * from './RoomRotatingEffect';
export * from './RoomShakingEffect';
export * from './SelectedRoomObjectData';
export * from './SpriteDataCollector';
export * from './TileObjectMap';