Merge pull request #1484 from thecodingmachine/fixExitUrl

FIX: initPositionFromLayerName will now prioritize its target layer rather than the start layer
This commit is contained in:
Kharhamel 2021-09-24 12:00:23 +02:00 committed by GitHub
commit 8d1943d6e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,19 +51,25 @@ export class StartPositionCalculator {
if (!selectedOrDefaultLayer) { if (!selectedOrDefaultLayer) {
selectedOrDefaultLayer = defaultStartLayerName; selectedOrDefaultLayer = defaultStartLayerName;
} }
let foundLayer: ITiledMapLayer | null = null;
for (const layer of this.gameMap.flatLayers) { for (const layer of this.gameMap.flatLayers) {
if ( if (layer.type !== "tilelayer") continue;
(selectedOrDefaultLayer === layer.name || layer.name.endsWith("/" + selectedOrDefaultLayer)) && //we want to prioritize the selectedLayer other the start layer
layer.type === "tilelayer" && if (selectedOrDefaultLayer === layer.name || layer.name.endsWith("/" + selectedOrDefaultLayer)) {
(selectedOrDefaultLayer === defaultStartLayerName || this.isStartLayer(layer)) foundLayer = layer;
) { break;
const startPosition = this.startUser(layer, selectedLayer); } else if (selectedOrDefaultLayer === defaultStartLayerName || this.isStartLayer(layer)) {
this.startPosition = { foundLayer = layer;
x: startPosition.x + this.mapFile.tilewidth / 2, break;
y: startPosition.y + this.mapFile.tileheight / 2,
};
} }
} }
if (foundLayer) {
const startPosition = this.startUser(foundLayer, selectedLayer);
this.startPosition = {
x: startPosition.x + this.mapFile.tilewidth / 2,
y: startPosition.y + this.mapFile.tileheight / 2,
};
}
} }
private isStartLayer(layer: ITiledMapLayer): boolean { private isStartLayer(layer: ITiledMapLayer): boolean {