Skip to content

Commit bdce5ca

Browse files
committed
Fixing object interaction rotations on custom maps
1 parent 4e81ce7 commit bdce5ca

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

src/game-engine/world/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class World {
9292
return { object: templateMapObject, cacheOriginal: true };
9393
}
9494

95-
return null;
95+
return { object: null, cacheOriginal: false };
9696
}
9797

9898
let cacheOriginal = true;
@@ -161,10 +161,7 @@ export class World {
161161
const chunkIndexX = objectChunk.position.x - (mapChunk.position.x - 2);
162162
const chunkIndexY = objectChunk.position.y - (mapChunk.position.y - 2);
163163

164-
const centerOffsetX = map.centerOffsetX || 0;
165-
const centerOffsetY = map.centerOffsetY || 0;
166-
167-
const objectTile = map.tileData[actor.position.level][chunkIndexX + centerOffsetX][chunkIndexY + centerOffsetY];
164+
const objectTile = map.tileData[actor.position.level][chunkIndexX][chunkIndexY];
168165

169166
const tileX = objectTile >> 14 & 0x3ff;
170167
const tileY = objectTile >> 3 & 0x7ff;

src/game-engine/world/map/region.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,27 @@ export interface ConstructedMap {
3333

3434

3535
export const getRotatedObjectX = (orientation: number, localX: number, localY: number): number => {
36-
orientation &= 0x3;
3736
if(orientation === 0) {
3837
return localX;
3938
}
4039
if(orientation === 1) {
41-
return localY;
40+
return 7 + -localY;
4241
}
4342
if(orientation === 2) {
4443
return -localX + 7;
4544
}
46-
return 7 + -localY;
45+
return localY;
4746
};
4847

4948
export const getRotatedObjectY = (orientation: number, localX: number, localY: number): number => {
50-
orientation &= 0x3;
5149
if(orientation === 0) {
5250
return localY;
5351
}
5452
if(orientation === 1) {
55-
return 7 + -localX;
53+
return localX;
5654
}
5755
if(orientation === 2) {
5856
return -localY + 7;
5957
}
60-
return localX;
58+
return 7 + -localX;
6159
};

src/plugins/skills/construction/construction.plugin.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,23 @@ const openHouse = (player: Player): void => {
1313

1414
const gardenPortal = new Room('garden_1');
1515
const firstParlor = new Room('parlor');
16+
const secondParlor = new Room('parlor', 1);
17+
const thirdParlor = new Room('parlor', 2);
18+
const fourthParlor = new Room('parlor', 3);
1619
const emptySpace = new Room('empty_grass');
1720

1821
for(let x = 0; x < MAP_SIZE; x++) {
1922
for(let y = 0; y < MAP_SIZE; y++) {
2023
if(x === 6 && y === 6) {
2124
house.rooms[0][x][y] = gardenPortal;
22-
} else if((x === 7 && y === 6) || (x === 6 && y === 7) || (x === 5 && y === 6)) {
25+
} else if(x === 5 && y === 6) {
2326
house.rooms[0][x][y] = firstParlor;
27+
} else if(x === 7 && y === 6) {
28+
house.rooms[0][x][y] = secondParlor;
29+
} else if(x === 6 && y === 5) {
30+
house.rooms[0][x][y] = thirdParlor;
31+
} else if(x === 6 && y === 7) {
32+
house.rooms[0][x][y] = fourthParlor;
2433
}
2534
}
2635
}

0 commit comments

Comments
 (0)