we can now trigger events when stepping on tiled rectangular objects. WIP
This commit is contained in:
@@ -76,7 +76,8 @@ export class GameMap {
|
||||
) {
|
||||
this.flatLayers = flattenGroupLayersMap(map);
|
||||
this.tiledObjects = this.getObjectsFromLayers(this.flatLayers);
|
||||
this.zones = this.tiledObjects.filter((object) => object.type === "zone");
|
||||
this.zones = this.tiledObjects.filter((object) => object.width > 0);
|
||||
console.log(this.zones);
|
||||
|
||||
let depth = -2;
|
||||
for (const layer of this.flatLayers) {
|
||||
@@ -469,6 +470,26 @@ 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) {
|
||||
if (zone.properties !== undefined) {
|
||||
for (const property of zone.properties) {
|
||||
if (property.value === undefined) {
|
||||
continue;
|
||||
}
|
||||
properties.set(property.name, property.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const layer of this.flatLayers) {
|
||||
if (layer.type !== "tilelayer") {
|
||||
continue;
|
||||
|
||||
@@ -66,6 +66,8 @@ 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,6 +893,7 @@ 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");
|
||||
if (focusable && focusable.value === true) {
|
||||
|
||||
Reference in New Issue
Block a user