From d55bdcbacf8c8b82ea5cf02b2f6d82edb022b7fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ku=C3=9F?= Date: Sat, 12 Dec 2020 18:13:34 +0100 Subject: [PATCH] Allow landscapes with no textures --- example/package-lock.json | 32 +++++++++++++++++- example/package.json | 1 + package.json | 2 +- src/objects/room/ILandscape.ts | 4 --- src/objects/room/Landscape.ts | 60 ++++++++++++++++------------------ src/objects/room/Room.ts | 18 +--------- 6 files changed, 62 insertions(+), 55 deletions(-) delete mode 100644 src/objects/room/ILandscape.ts diff --git a/example/package-lock.json b/example/package-lock.json index a49c2cba..fa17fbf4 100644 --- a/example/package-lock.json +++ b/example/package-lock.json @@ -1136,6 +1136,8 @@ }, "@jankuss/shroom": { "version": "0.1.0-alpha.13", + "resolved": "https://registry.npmjs.org/@jankuss/shroom/-/shroom-0.1.0-alpha.13.tgz", + "integrity": "sha512-F2ACdgw9/Apu7rVEjq6M3rPAC7WxX3CVSa9eMkHOA9EN5Xwpsx8Hig0RInhYZqdfQwfOYNpPmhHGMuiSUV1SZA==", "requires": { "bluebird": "^3.7.2", "chalk": "^4.1.0", @@ -7916,6 +7918,16 @@ "integrity": "sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ==", "dev": true }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "dev": true, + "optional": true, + "requires": { + "file-uri-to-path": "1.0.0" + } + }, "body-parser": { "version": "1.19.0", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", @@ -9396,6 +9408,13 @@ } } }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "dev": true, + "optional": true + }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -10874,6 +10893,13 @@ "integrity": "sha1-iZ8R2WhuXgXLkbNdXw5jt3PPyQE=", "dev": true }, + "nan": { + "version": "2.14.2", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz", + "integrity": "sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==", + "dev": true, + "optional": true + }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", @@ -13175,7 +13201,11 @@ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", "dev": true, - "optional": true + "optional": true, + "requires": { + "bindings": "^1.5.0", + "nan": "^2.12.1" + } }, "glob-parent": { "version": "3.1.0", diff --git a/example/package.json b/example/package.json index a3edab82..2dbff159 100644 --- a/example/package.json +++ b/example/package.json @@ -33,6 +33,7 @@ }, "scripts": { "dev": "webpack serve", + "build": "webpack", "dump": "shroom dump --url https://www.habbo.com/gamedata/external_variables/326b0a1abf9e2571d541ac05e6eb3173b83bddea --location ./public/resources" } } diff --git a/package.json b/package.json index adaae571..d1337e66 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "pixi.js": "^5.3.3" }, "scripts": { - "dev": "webpack serve", + "dev": "tsc --watch", "dump": "yarn ts-node src/downloading/cli.tsx", "test": "jest", "build": "rm -rf dist && tsc", diff --git a/src/objects/room/ILandscape.ts b/src/objects/room/ILandscape.ts deleted file mode 100644 index e74a66d5..00000000 --- a/src/objects/room/ILandscape.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { IRoomObject } from "../../interfaces/IRoomObject"; -import { RoomLandscapeMaskSprite } from "./RoomLandscapeMaskSprite"; - -export interface ILandscape extends IRoomObject {} diff --git a/src/objects/room/Landscape.ts b/src/objects/room/Landscape.ts index 7d6f9230..4bd44b9e 100644 --- a/src/objects/room/Landscape.ts +++ b/src/objects/room/Landscape.ts @@ -1,7 +1,6 @@ import * as PIXI from "pixi.js"; import { ParsedTileType } from "../../util/parseTileMap"; import { RoomObject } from "../RoomObject"; -import { ILandscape } from "./ILandscape"; import { getMaskId } from "./util/getMaskId"; interface WallCollectionMeta { @@ -11,7 +10,7 @@ interface WallCollectionMeta { level: number; } -export class Landscape extends RoomObject implements ILandscape { +export class Landscape extends RoomObject { private _container: PIXI.Container | undefined; private _leftTexture: PIXI.Texture | undefined; private _rightTexture: PIXI.Texture | undefined; @@ -112,13 +111,7 @@ export class Landscape extends RoomObject implements ILandscape { wall.addChild(colored); - if (meta.type === "rowWall" && this._leftTexture != null) { - const graphics = new PIXI.TilingSprite( - this._leftTexture, - width, - this._leftTexture.height - ); - + if (meta.type === "rowWall") { const maskLevel = this.landscapeContainer.getMaskLevel(meta.level, 0); const mask = this._getMask(2, maskLevel.roomX, 0); @@ -131,28 +124,27 @@ export class Landscape extends RoomObject implements ILandscape { "none" ); - graphics.texture = this._leftTexture; - wall.transform.setFromMatrix(new PIXI.Matrix(1, -0.5, 0, 1)); - graphics.tilePosition = new PIXI.Point(offsetRow, 0); - wall.x = position.x; wall.y = position.y + 16; - graphics.x = 0; - graphics.y = -this._leftTexture.height; + if (this._leftTexture != null) { + const graphics = new PIXI.TilingSprite( + this._leftTexture, + width, + this._leftTexture.height + ); - offsetRow += width; - - wall.addChild(graphics); - } else if (meta.type === "colWall" && this._rightTexture != null) { - const graphics = new PIXI.TilingSprite( - this._rightTexture, - width, - this._rightTexture.height - ); + graphics.tilePosition = new PIXI.Point(offsetRow, 0); + graphics.texture = this._leftTexture; + graphics.x = 0; + graphics.y = -this._leftTexture.height; + wall.addChild(graphics); + } + offsetRow += width; + } else if (meta.type === "colWall") { const maskLevel = this.landscapeContainer.getMaskLevel(0, meta.level); const mask = this._getMask(4, 0, maskLevel.roomY); wall.mask = mask; @@ -164,21 +156,25 @@ export class Landscape extends RoomObject implements ILandscape { "none" ); - graphics.texture = this._rightTexture; - wall.transform.setFromMatrix(new PIXI.Matrix(1, 0.5, 0, 1)); - graphics.tilePosition = new PIXI.Point(offsetCol, 0); - wall.x = position.x + 32; wall.y = position.y; - graphics.x = 0; - graphics.y = -this._rightTexture.height; + if (this._rightTexture != null) { + const graphics = new PIXI.TilingSprite( + this._rightTexture, + width, + this._rightTexture.height + ); + graphics.texture = this._rightTexture; + graphics.x = 0; + graphics.y = -this._rightTexture.height; + graphics.tilePosition = new PIXI.Point(offsetCol, 0); + wall.addChild(graphics); + } offsetCol += width; - - wall.addChild(graphics); } container.addChild(wall); diff --git a/src/objects/room/Room.ts b/src/objects/room/Room.ts index 4ca56bd2..ca9f2656 100644 --- a/src/objects/room/Room.ts +++ b/src/objects/room/Room.ts @@ -1,7 +1,5 @@ import * as PIXI from "pixi.js"; -import { AnimationTicker } from "../AnimationTicker"; -import { FurnitureData } from "../FurnitureData"; -import { HitDetection } from "../hitdetection/HitDetection"; + import { IAnimationTicker } from "../../interfaces/IAnimationTicker"; import { IAvatarLoader } from "../../interfaces/IAvatarLoader"; import { IConfiguration } from "../../interfaces/IConfiguration"; @@ -15,8 +13,6 @@ import { RoomPosition } from "../../types/RoomPosition"; import { TileType } from "../../types/TileType"; import { ParsedTileType, parseTileMap } from "../../util/parseTileMap"; import { parseTileMapString } from "../../util/parseTileMapString"; -import { AvatarLoader } from "../avatar/AvatarLoader"; -import { FurnitureLoader } from "../furniture/FurnitureLoader"; import { RoomVisualization } from "./RoomVisualization"; import { Stair } from "./Stair"; import { Tile } from "./Tile"; @@ -25,7 +21,6 @@ import { getTileMapBounds } from "./util/getTileMapBounds"; import { Wall } from "./Wall"; import { Shroom } from "../Shroom"; import { ITileMap } from "../../interfaces/ITileMap"; -import { ILandscape } from "./ILandscape"; import { ILandscapeContainer } from "./ILandscapeContainer"; export interface Dependencies { @@ -68,8 +63,6 @@ export class Room private _cursors: TileCursor[] = []; private _doorWall: Wall | undefined; - private _landscape: ILandscape | undefined; - private _roomBounds: { minX: number; minY: number; @@ -117,15 +110,6 @@ export class Room this.updateTiles(); } - public get landscape() { - return this._landscape; - } - - private _updateLandscape(newValue: ILandscape | undefined) { - this._landscape = newValue; - this.visualization.updateRoom(this); - } - public get hideFloor() { return this._hideFloor; }