Merge branch 'develop' of github.com:thecodingmachine/workadventure
This commit is contained in:
@@ -35,4 +35,4 @@
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -137,18 +137,6 @@ class ConnectionManager {
|
||||
connexionType === GameConnexionTypes.empty
|
||||
) {
|
||||
this.authToken = localUserStore.getAuthToken();
|
||||
//todo: add here some kind of warning if authToken has expired.
|
||||
if (!this.authToken) {
|
||||
await this.anonymousLogin();
|
||||
} else {
|
||||
try {
|
||||
await this.checkAuthUserConnexion();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
await this.anonymousLogin();
|
||||
}
|
||||
}
|
||||
this.localUser = localUserStore.getLocalUser() as LocalUser; //if authToken exist in localStorage then localUser cannot be null
|
||||
|
||||
let roomPath: string;
|
||||
if (connexionType === GameConnexionTypes.empty) {
|
||||
@@ -173,14 +161,22 @@ class ConnectionManager {
|
||||
}
|
||||
|
||||
//get detail map for anonymous login and set texture in local storage
|
||||
try {
|
||||
this._currentRoom = await Room.createRoom(new URL(roomPath));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
localUserStore.setLastRoomUrl(null);
|
||||
this._currentRoom = null;
|
||||
//before set token of user we must load room and all information. For example the mandatory authentication could be require on current room
|
||||
this._currentRoom = await Room.createRoom(new URL(roomPath));
|
||||
|
||||
//todo: add here some kind of warning if authToken has expired.
|
||||
if (!this.authToken && !this._currentRoom.authenticationMandatory) {
|
||||
await this.anonymousLogin();
|
||||
} else {
|
||||
try {
|
||||
await this.checkAuthUserConnexion();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
if (this._currentRoom != undefined && this._currentRoom.textures != undefined && this._currentRoom.textures.length > 0) {
|
||||
this.localUser = localUserStore.getLocalUser() as LocalUser; //if authToken exist in localStorage then localUser cannot be null
|
||||
|
||||
if (this._currentRoom.textures != undefined && this._currentRoom.textures.length > 0) {
|
||||
//check if texture was changed
|
||||
if (this.localUser.textures.length === 0) {
|
||||
this.localUser.textures = this._currentRoom.textures;
|
||||
|
||||
@@ -51,19 +51,28 @@ export class StartPositionCalculator {
|
||||
if (!selectedOrDefaultLayer) {
|
||||
selectedOrDefaultLayer = defaultStartLayerName;
|
||||
}
|
||||
let foundLayer: ITiledMapLayer | null = null;
|
||||
for (const layer of this.gameMap.flatLayers) {
|
||||
if (layer.type !== "tilelayer") continue;
|
||||
//we want to prioritize the selectedLayer other the start layer
|
||||
if (
|
||||
(selectedOrDefaultLayer === layer.name || layer.name.endsWith("/" + selectedOrDefaultLayer)) &&
|
||||
(selectedOrDefaultLayer === layer.name ||
|
||||
selectedOrDefaultLayer === `#${layer.name}` ||
|
||||
layer.name.endsWith("/" + selectedOrDefaultLayer)) &&
|
||||
layer.type === "tilelayer" &&
|
||||
(selectedOrDefaultLayer === defaultStartLayerName || this.isStartLayer(layer))
|
||||
) {
|
||||
const startPosition = this.startUser(layer, selectedLayer);
|
||||
this.startPosition = {
|
||||
x: startPosition.x + this.mapFile.tilewidth / 2,
|
||||
y: startPosition.y + this.mapFile.tileheight / 2,
|
||||
};
|
||||
foundLayer = layer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user