|
|
@@ -7,37 +7,6 @@ define([ |
|
|
|
//Set by renderer |
|
|
|
atlasTextureDimensions: {}, |
|
|
|
|
|
|
|
tilesNoFlip: [ |
|
|
|
//Stairs |
|
|
|
171, 179 |
|
|
|
], |
|
|
|
wallsNoFlip: [ |
|
|
|
//Ledges |
|
|
|
156, 158, 162, 163, 167, 168, |
|
|
|
//Wall Sign |
|
|
|
189, |
|
|
|
//Stone Ledges |
|
|
|
195, 196, 197, 198, 199, 200, 201, 202, 203, |
|
|
|
//Ship Edges |
|
|
|
204, 205, 206, 207, 214, 215, 220, 221, 222, 223, |
|
|
|
//Gray wall sides and corners |
|
|
|
230, 231, 238, 239 |
|
|
|
], |
|
|
|
objectsNoFlip: [ |
|
|
|
//Clotheslines |
|
|
|
96, 101, |
|
|
|
//Table Sides |
|
|
|
103, 110, 118, 126, |
|
|
|
//Wall-mounted plants |
|
|
|
120, 122, 140, |
|
|
|
//Ship oars |
|
|
|
140, 143, |
|
|
|
//Ship Cannons |
|
|
|
141, 142, |
|
|
|
//Tent Pegs |
|
|
|
168, 169 |
|
|
|
], |
|
|
|
|
|
|
|
getSheetNum: function (tile) { |
|
|
|
if (tile < 224) |
|
|
|
return 0; |
|
|
@@ -46,8 +15,17 @@ define([ |
|
|
|
return 2; |
|
|
|
}, |
|
|
|
|
|
|
|
map: function (tile) { |
|
|
|
const { clientConfig: { atlasTextures, tileOpacities } } = globals; |
|
|
|
getSheetName: function (tile) { |
|
|
|
const { clientConfig: { atlasTextures } } = globals; |
|
|
|
|
|
|
|
const sheetNum = this.getSheetNum(tile); |
|
|
|
const sheetName = atlasTextures[sheetNum]; |
|
|
|
|
|
|
|
return sheetName; |
|
|
|
}, |
|
|
|
|
|
|
|
getOffsetAndSheet: function (tile) { |
|
|
|
const { clientConfig: { atlasTextures } } = globals; |
|
|
|
const { atlasTextureDimensions } = this; |
|
|
|
|
|
|
|
let offset = 0; |
|
|
@@ -66,11 +44,21 @@ define([ |
|
|
|
offset += spriteCount; |
|
|
|
} |
|
|
|
|
|
|
|
tile -= offset; |
|
|
|
return { |
|
|
|
offset, |
|
|
|
sheetName |
|
|
|
}; |
|
|
|
}, |
|
|
|
|
|
|
|
map: function (tile) { |
|
|
|
const { clientConfig: { tileOpacities } } = globals; |
|
|
|
|
|
|
|
const { offset, sheetName } = this.getOffsetAndSheet(tile); |
|
|
|
const mappedTile = tile - offset; |
|
|
|
|
|
|
|
const opacityConfig = tileOpacities[sheetName] || tileOpacities.default; |
|
|
|
|
|
|
|
let alpha = (opacityConfig[tile] || opacityConfig.default); |
|
|
|
let alpha = (opacityConfig[mappedTile] || opacityConfig.default); |
|
|
|
if (opacityConfig.max !== null) { |
|
|
|
alpha = alpha + (Math.random() * (alpha * 0.2)); |
|
|
|
alpha = Math.min(1, alpha); |
|
|
@@ -80,20 +68,16 @@ define([ |
|
|
|
}, |
|
|
|
|
|
|
|
canFlip: function (tile) { |
|
|
|
let sheetNum; |
|
|
|
const { clientConfig: { tilesNoFlip } } = globals; |
|
|
|
|
|
|
|
if (tile < 224) |
|
|
|
sheetNum = 0; |
|
|
|
else if (tile < 480) { |
|
|
|
tile -= 224; |
|
|
|
sheetNum = 1; |
|
|
|
} else { |
|
|
|
tile -= 480; |
|
|
|
sheetNum = 2; |
|
|
|
} |
|
|
|
const { offset, sheetName } = this.getOffsetAndSheet(tile); |
|
|
|
const mappedTile = tile - offset; |
|
|
|
|
|
|
|
const noFlipTiles = tilesNoFlip[sheetName]; |
|
|
|
if (!noFlipTiles) |
|
|
|
return true; |
|
|
|
|
|
|
|
let tilesheet = [this.tilesNoFlip, this.wallsNoFlip, this.objectsNoFlip][sheetNum]; |
|
|
|
return (tilesheet.indexOf(tile) === -1); |
|
|
|
return !noFlipTiles.includes(mappedTile); |
|
|
|
} |
|
|
|
}; |
|
|
|
}); |