little cleanup
This commit is contained in:
parent
6a394945f3
commit
67f4972292
@ -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,
|
||||
|
@ -26,24 +26,6 @@
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 454, 454, 454, 454, 454, 454, 454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 454, 454, 454, 454, 454, 454, 454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 454, 454, 454, 454, 454, 454, 454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 454, 454, 454, 454, 454, 454, 454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 454, 454, 454, 454, 454, 454, 454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 454, 454, 454, 454, 454, 454, 454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 454, 454, 454, 454, 454, 454, 454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 454, 454, 454, 454, 454, 454, 454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 454, 454, 454, 454, 454, 454, 454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 454, 454, 454, 454, 454, 454, 454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 454, 454, 454, 454, 454, 454, 454, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
"height":17,
|
||||
"id":29,
|
||||
"name":"jitsiMeetingRoom",
|
||||
"opacity":1,
|
||||
"properties":[
|
||||
{
|
||||
"name":"jitsiRoom",
|
||||
"type":"string",
|
||||
"value":"MeetingRoom"
|
||||
}],
|
||||
"type":"tilelayer",
|
||||
"visible":true,
|
||||
"width":31,
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"data":[0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
"height":17,
|
||||
@ -147,6 +129,66 @@
|
||||
"width":76.5390990955655,
|
||||
"x":59.0274706237854,
|
||||
"y":91.8390566468795
|
||||
},
|
||||
{
|
||||
"height":179.413785031117,
|
||||
"id":10,
|
||||
"name":"focusableChillZone",
|
||||
"properties":[
|
||||
{
|
||||
"name":"focusOn",
|
||||
"type":"bool",
|
||||
"value":true
|
||||
},
|
||||
{
|
||||
"name":"focusable",
|
||||
"type":"bool",
|
||||
"value":true
|
||||
},
|
||||
{
|
||||
"name":"jitsiRoom",
|
||||
"type":"string",
|
||||
"value":"MeetingRoom"
|
||||
},
|
||||
{
|
||||
"name":"jitsiTrigger",
|
||||
"type":"string",
|
||||
"value":"onaction"
|
||||
}],
|
||||
"rotation":0.513254,
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":283.802849832786,
|
||||
"x":316.73045,
|
||||
"y":255.367599999999
|
||||
},
|
||||
{
|
||||
"height":119,
|
||||
"id":11,
|
||||
"name":"",
|
||||
"properties":[
|
||||
{
|
||||
"name":"silent",
|
||||
"type":"bool",
|
||||
"value":true
|
||||
}],
|
||||
"rotation":0,
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":214,
|
||||
"x":745,
|
||||
"y":329
|
||||
},
|
||||
{
|
||||
"height":0,
|
||||
"id":13,
|
||||
"name":"",
|
||||
"rotation":0,
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":0,
|
||||
"x":358,
|
||||
"y":629
|
||||
}],
|
||||
"opacity":1,
|
||||
"type":"objectgroup",
|
||||
@ -191,7 +233,7 @@
|
||||
"y":0
|
||||
}],
|
||||
"nextlayerid":39,
|
||||
"nextobjectid":10,
|
||||
"nextobjectid":14,
|
||||
"orientation":"orthogonal",
|
||||
"properties":[
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user