浏览代码

Added clientConfig.getTileIndexInAtlasSync for use by mods when we know that the sprite atlas has already fully loaded

tags/v0.14.0^2
Shaun 4 个月前
父节点
当前提交
36248f84ea
共有 1 个文件被更改,包括 20 次插入0 次删除
  1. +20
    -0
      src/server/config/clientConfig.js

+ 20
- 0
src/server/config/clientConfig.js 查看文件

@@ -283,6 +283,26 @@ module.exports = {
return result;
},

getTileIndexInAtlasSync: function (spriteSheet, tileIndexInSource) {
const { atlasTextures, atlasTextureDimensions } = config;

const indexOfSheet = atlasTextures.indexOf(spriteSheet);

let tileCountBeforeSheet = 0;

for (let i = 0; i < indexOfSheet; i++) {
const sheet = atlasTextures[i];
const { width, height } = atlasTextureDimensions[sheet];

tileCountBeforeSheet += ((width / 8) * (height / 8));
}

//Tile index 0 is 'no tile' in map files so we need to increment by 1
const result = tileCountBeforeSheet + tileIndexInSource + 1;

return result;
},

//Used to send to clients
getClientConfig: function (msg) {
msg.callback(config);


正在加载...
取消
保存