aa78bf44ef
update GetGameState to add nickname to the returned data update GameMap to separate phaserLayer and mapLayer
21 lines
652 B
TypeScript
21 lines
652 B
TypeScript
import type {ITiledMap, ITiledMapLayer} from "./ITiledMap";
|
|
|
|
/**
|
|
* Flatten the grouped layers
|
|
*/
|
|
export function flattenGroupLayersMap(map: ITiledMap) {
|
|
const flatLayers: ITiledMapLayer[] = [];
|
|
flattenGroupLayers(map.layers, '', flatLayers);
|
|
return flatLayers;
|
|
}
|
|
|
|
function flattenGroupLayers(layers : ITiledMapLayer[], prefix : string, flatLayers: ITiledMapLayer[]) {
|
|
for (const layer of layers) {
|
|
if (layer.type === 'group') {
|
|
flattenGroupLayers(layer.layers, prefix + layer.name + '/', flatLayers);
|
|
} else {
|
|
layer.name = prefix+layer.name
|
|
flatLayers.push(layer);
|
|
}
|
|
}
|
|
} |