Skip to content

Commit

Permalink
Allow landscapes with no textures
Browse files Browse the repository at this point in the history
  • Loading branch information
jankuss committed Dec 12, 2020
1 parent 10b7fe0 commit d55bdcb
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 55 deletions.
32 changes: 31 additions & 1 deletion example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 0 additions & 4 deletions src/objects/room/ILandscape.ts

This file was deleted.

60 changes: 28 additions & 32 deletions src/objects/room/Landscape.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -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;
Expand All @@ -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);
Expand Down
18 changes: 1 addition & 17 deletions src/objects/room/Room.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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";
Expand All @@ -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 {
Expand Down Expand Up @@ -68,8 +63,6 @@ export class Room
private _cursors: TileCursor[] = [];
private _doorWall: Wall | undefined;

private _landscape: ILandscape | undefined;

private _roomBounds: {
minX: number;
minY: number;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit d55bdcb

Please sign in to comment.