little cleanup
This commit is contained in:
@@ -77,7 +77,6 @@ export class GameMap {
|
||||
this.flatLayers = flattenGroupLayersMap(map);
|
||||
this.tiledObjects = this.getObjectsFromLayers(this.flatLayers);
|
||||
this.zones = this.tiledObjects.filter((object) => object.width > 0);
|
||||
console.log(this.zones);
|
||||
|
||||
let depth = -2;
|
||||
for (const layer of this.flatLayers) {
|
||||
@@ -424,23 +423,8 @@ export class GameMap {
|
||||
* We use Tiled Objects with type "zone" as zones with defined x, y, width and height for easier event triggering.
|
||||
*/
|
||||
private triggerZonesChange(): void {
|
||||
const zonesByOldPosition = this.oldPosition
|
||||
? this.zones.filter((zone) => {
|
||||
if (!this.oldPosition) {
|
||||
return false;
|
||||
}
|
||||
return MathUtils.isOverlappingWithRectangle(this.oldPosition, zone);
|
||||
})
|
||||
: [];
|
||||
|
||||
const zonesByNewPosition = this.position
|
||||
? this.zones.filter((zone) => {
|
||||
if (!this.position) {
|
||||
return false;
|
||||
}
|
||||
return MathUtils.isOverlappingWithRectangle(this.position, zone);
|
||||
})
|
||||
: [];
|
||||
const zonesByOldPosition = this.getZonesOnPosition(this.oldPosition);
|
||||
const zonesByNewPosition = this.getZonesOnPosition(this.position);
|
||||
|
||||
const enterZones = new Set(zonesByNewPosition);
|
||||
const leaveZones = new Set(zonesByOldPosition);
|
||||
@@ -470,16 +454,7 @@ export class GameMap {
|
||||
private getProperties(key: number): Map<string, string | boolean | number> {
|
||||
const properties = new Map<string, string | boolean | number>();
|
||||
|
||||
const zonesByNewPosition = this.position
|
||||
? this.zones.filter((zone) => {
|
||||
if (!this.position) {
|
||||
return false;
|
||||
}
|
||||
return MathUtils.isOverlappingWithRectangle(this.position, zone);
|
||||
})
|
||||
: [];
|
||||
|
||||
for (const zone of zonesByNewPosition) {
|
||||
for (const zone of this.getZonesOnPosition(this.position)) {
|
||||
if (zone.properties !== undefined) {
|
||||
for (const property of zone.properties) {
|
||||
if (property.value === undefined) {
|
||||
@@ -528,6 +503,17 @@ export class GameMap {
|
||||
return properties;
|
||||
}
|
||||
|
||||
private getZonesOnPosition(position?: { x: number; y: number }): ITiledMapObject[] {
|
||||
return position
|
||||
? this.zones.filter((zone) => {
|
||||
if (!position) {
|
||||
return false;
|
||||
}
|
||||
return MathUtils.isOverlappingWithRectangle(position, zone);
|
||||
})
|
||||
: [];
|
||||
}
|
||||
|
||||
private getTileProperty(index: number): Array<ITiledMapProperty> {
|
||||
if (this.tileSetPropertyMap[index]) {
|
||||
return this.tileSetPropertyMap[index];
|
||||
|
||||
@@ -7,6 +7,7 @@ export enum GameMapProperties {
|
||||
EXIT_URL = "exitUrl",
|
||||
EXIT_SCENE_URL = "exitSceneUrl",
|
||||
FONT_FAMILY = "font-family",
|
||||
FOCUSABLE = "focusable",
|
||||
JITSI_ADMIN_ROOM_TAG = "jitsiRoomAdminTag",
|
||||
JITSI_CONFIG = "jitsiConfig",
|
||||
JITSI_INTERFACE_CONFIG = "jitsiInterfaceConfig",
|
||||
@@ -35,4 +36,5 @@ export enum GameMapProperties {
|
||||
URL = "url",
|
||||
WRITABLE_BY = "writableBy",
|
||||
ZONE = "zone",
|
||||
ZOOM_MARGIN = "zoom_margin",
|
||||
}
|
||||
|
||||
@@ -66,8 +66,6 @@ export class GameMapPropertiesListener {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.log("START JITSI");
|
||||
console.log(newValue, oldValue, allProps);
|
||||
const openJitsiRoomFunction = () => {
|
||||
const roomName = jitsiFactory.getRoomName(newValue.toString(), this.scene.instance);
|
||||
const jitsiUrl = allProps.get(GameMapProperties.JITSI_URL) as string | undefined;
|
||||
|
||||
@@ -893,11 +893,14 @@ export class GameScene extends DirtyScene {
|
||||
});
|
||||
|
||||
this.gameMap.onEnterZone((zones) => {
|
||||
console.log("ZONE ENTERED");
|
||||
for (const zone of zones) {
|
||||
const focusable = zone.properties?.find((property) => property.name === "focusable");
|
||||
const focusable = zone.properties?.find(
|
||||
(property) => property.name === GameMapProperties.FOCUSABLE
|
||||
);
|
||||
if (focusable && focusable.value === true) {
|
||||
const zoomMargin = zone.properties?.find((property) => property.name === "zoom_margin");
|
||||
const zoomMargin = zone.properties?.find(
|
||||
(property) => property.name === GameMapProperties.ZOOM_MARGIN
|
||||
);
|
||||
this.cameraManager.enterFocusMode(
|
||||
{
|
||||
x: zone.x + zone.width * 0.5,
|
||||
|
||||
Reference in New Issue
Block a user