@rpgjs/tiledmap 5.0.0-beta.2 → 5.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.js +35 -49
- package/dist/client/index2.js +3998 -12
- package/dist/client/index3.js +38 -5221
- package/dist/client/index4.js +11 -18
- package/dist/client/index5.js +20 -49
- package/dist/client.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/server/index.js +12 -14
- package/dist/server/index2.js +3997 -15
- package/dist/server/index3.js +53 -4943
- package/dist/server/index4.js +15 -72
- package/dist/server.d.ts +2 -2
- package/package.json +8 -8
package/dist/client/index4.js
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
13
|
-
let $this = h(Container, null, h(TiledMap, { map, basePath, createLayersPerTilesZ: true, objectLayer: () => h(EventLayerComponent) }));
|
|
14
|
-
return $this;
|
|
15
|
-
}
|
|
16
|
-
export {
|
|
17
|
-
component as default
|
|
18
|
-
};
|
|
1
|
+
import { prepareTiledPhysicsData } from "./index3.js";
|
|
2
|
+
import { defineModule } from "@rpgjs/common";
|
|
3
|
+
//#region src/client.ts
|
|
4
|
+
var client_default = defineModule({
|
|
5
|
+
componentAnimations: [],
|
|
6
|
+
sceneMap: { onPhysicsInit(map, context) {
|
|
7
|
+
prepareTiledPhysicsData(context?.mapData, map);
|
|
8
|
+
} }
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { client_default as default };
|
package/dist/client/index5.js
CHANGED
|
@@ -1,50 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { EventLayerComponent } from "@rpgjs/client";
|
|
2
|
+
import { Container, effect, h, signal, useDefineProps, useProps } from "canvasengine";
|
|
3
|
+
import { TiledMap } from "@canvasengine/presets";
|
|
4
|
+
//#region src/tiled.ce
|
|
5
|
+
function component($$props) {
|
|
6
|
+
useProps($$props);
|
|
7
|
+
const { data, params } = useDefineProps($$props)();
|
|
8
|
+
const map = signal(data());
|
|
9
|
+
const basePath = signal(params().basePath);
|
|
10
|
+
effect(() => {
|
|
11
|
+
map.set(data());
|
|
12
|
+
});
|
|
13
|
+
return h(Container, null, h(TiledMap, {
|
|
14
|
+
map,
|
|
15
|
+
basePath,
|
|
16
|
+
createLayersPerTilesZ: true,
|
|
17
|
+
objectLayer: () => h(EventLayerComponent)
|
|
18
|
+
}));
|
|
13
19
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const mapWidth = tiledMap.width;
|
|
17
|
-
const mapHeight = tiledMap.height;
|
|
18
|
-
const tileWidth = tiledMap.tilewidth;
|
|
19
|
-
const tileHeight = tiledMap.tileheight;
|
|
20
|
-
for (let y = 0; y < mapHeight; y++) {
|
|
21
|
-
for (let x = 0; x < mapWidth; x++) {
|
|
22
|
-
const tileInfo = tiledMap.getTileByPosition(x * tileWidth, y * tileHeight, [0, 0], {
|
|
23
|
-
populateTiles: true
|
|
24
|
-
});
|
|
25
|
-
if (tileInfo.hasCollision) {
|
|
26
|
-
hitboxes.push({
|
|
27
|
-
id: createTiledHitboxId(x, y),
|
|
28
|
-
x: x * tileWidth,
|
|
29
|
-
y: y * tileHeight,
|
|
30
|
-
width: tileWidth,
|
|
31
|
-
height: tileHeight
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return hitboxes;
|
|
37
|
-
}
|
|
38
|
-
function mergeTiledHitboxes(existingHitboxes, tiledHitboxes) {
|
|
39
|
-
const preservedHitboxes = Array.isArray(existingHitboxes) ? existingHitboxes.filter((hitbox) => !isGeneratedTiledHitbox(hitbox)) : [];
|
|
40
|
-
return [...preservedHitboxes, ...tiledHitboxes];
|
|
41
|
-
}
|
|
42
|
-
function isGeneratedTiledHitbox(hitbox) {
|
|
43
|
-
return typeof hitbox?.id === "string" && hitbox.id.startsWith(TILED_HITBOX_ID_PREFIX);
|
|
44
|
-
}
|
|
45
|
-
function createTiledHitboxId(x, y) {
|
|
46
|
-
return `${TILED_HITBOX_ID_PREFIX}${x},${y}`;
|
|
47
|
-
}
|
|
48
|
-
export {
|
|
49
|
-
prepareTiledPhysicsData
|
|
50
|
-
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { component as default };
|
package/dist/client.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createModule } from "@rpgjs/common";
|
|
1
|
+
import "./index2.js";
|
|
3
2
|
import "./index3.js";
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import server_default from "./index4.js";
|
|
4
|
+
import { createModule } from "@rpgjs/common";
|
|
5
|
+
//#region src/index.ts
|
|
6
|
+
var client = null;
|
|
7
|
+
var provideLoadMap = null;
|
|
6
8
|
function provideTiledMap(options) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
provideLoadMap?.()
|
|
13
|
-
]);
|
|
9
|
+
return createModule("TiledMap", [{
|
|
10
|
+
server: server_default,
|
|
11
|
+
client
|
|
12
|
+
}, provideLoadMap?.()]);
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { provideTiledMap };
|