Fix co website closing on exit zone

This commit is contained in:
Alexis Faizeau 2021-10-07 14:40:02 +02:00
parent 1efcbb4529
commit 1ee0b28f66

View File

@ -37,10 +37,13 @@ export class GameMapPropertiesListener {
}
});
this.gameMap.onPropertyChange("openWebsite", (newValue, oldValue, allProps) => {
if (newValue === undefined) {
const handler = async () => {
if (newValue === undefined || newValue !== oldValue) {
layoutManagerActionStore.removeAction("openWebsite");
coWebsiteManager.closeCoWebsite();
} else {
await coWebsiteManager.closeCoWebsites();
}
if (newValue !== undefined) {
const openWebsiteFunction = () => {
coWebsiteManager.loadCoWebsite(
newValue as string,
@ -49,6 +52,7 @@ export class GameMapPropertiesListener {
allProps.get("openWebsitePolicy") as string | undefined,
allProps.get("openWebsiteWidth") as number | undefined
);
layoutManagerActionStore.removeAction("openWebsite");
};
const openWebsiteTriggerValue = allProps.get(TRIGGER_WEBSITE_PROPERTIES);
@ -68,6 +72,9 @@ export class GameMapPropertiesListener {
openWebsiteFunction();
}
}
};
handler();
});
}
}