diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 53f035ce..db66a32c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,10 +3,10 @@ name: RPG CI on: push: branches: - - v4 + - '*' pull_request: branches: - - v4 + - '*' jobs: tests: @@ -22,4 +22,24 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'npm' - run: npm i - - run: npm test \ No newline at end of file + - run: npm test + + build_and_publish: + needs: tests + if: github.ref == 'refs/heads/v4' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Use Node.js 18.x + uses: actions/setup-node@v3 + with: + node-version: 18.x + cache: 'npm' + - run: npm i + - run: npm run build + - name: Bump version using conventional commits + run: npx lerna version --conventional-commits --no-push --yes + - name: Publish to NPM + run: npm run lerna:actions:publish + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index c68c0ad6..5324d203 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "postinstall": "lerna bootstrap --ci && npm run build:types && npm run build:tiled && npm run build:common && npm run build:client && npm run build:database && npm run build:server && npm run build:testing && npm run build:compiler && cd packages/client && cd ../../packages/plugins/agones/matchmaker && npm i", "test": "vitest --config ./packages/compiler/src/test/vitest.config.ts && cd ./packages/compiler && npm test", "lerna:publish": "lerna publish --ignore-prepublish --force-publish --no-private --no-push --no-git-tag-version", + "lerna:actions:publish": "lerna publish from-git --ignore-prepublish --force-publish --no-private --no-push --no-git-tag-version --yes", "lerna:ls": "lerna ls", "build": "concurrently -n build \"npm:build:*\" && npm run fix-esm", "build:common": "cd packages/common && npm run build", diff --git a/packages/sample2/main/events/npc.ts b/packages/sample2/main/events/npc.ts index 9de25521..5b94f1e3 100644 --- a/packages/sample2/main/events/npc.ts +++ b/packages/sample2/main/events/npc.ts @@ -8,6 +8,8 @@ export default class CharaEvent extends RpgEvent { onInit() { this.setGraphic('male') this.setHitbox(32, 32) + this.throughOtherPlayer = true + this.through = true } async onAction(player: RpgPlayer) { await player.showText('Hello ', { diff --git a/packages/sample2/main/player.ts b/packages/sample2/main/player.ts index 7e7ce62d..4c7f5d9d 100644 --- a/packages/sample2/main/player.ts +++ b/packages/sample2/main/player.ts @@ -2,12 +2,26 @@ import { RpgMap } from '@rpgjs/server'; import { Speed } from '@rpgjs/server'; import { RpgPlayer, RpgPlayerHooks, Control, Components, RpgEvent, EventData } from '@rpgjs/server' import Potion from './database/items/Potion'; +import CharaEvent from './events/npc'; const player: RpgPlayerHooks = { onConnected(player: RpgPlayer) { player.name = 'YourName' player.setComponentsTop(Components.text('{name}')) }, + onInput(player: RpgPlayer, { input }) { + if (input == 'action') { + const map = player.getCurrentMap() + const event = map?.createDynamicEvent({ + x: player.position.x + 5, + y: player.position.y + 5, + event: CharaEvent, + }); + } + if (input == 'back') { + player.callMainMenu() + } + }, async onJoinMap(player: RpgPlayer, map: RpgMap) { player.save(); } diff --git a/packages/sample2/main/sprite.ts b/packages/sample2/main/sprite.ts index 56004c9f..1f615d0a 100644 --- a/packages/sample2/main/sprite.ts +++ b/packages/sample2/main/sprite.ts @@ -1 +1,7 @@ -export default {} \ No newline at end of file +import { RpgSprite, RpgSpriteHooks } from '@rpgjs/client' + +const sprite: RpgSpriteHooks = { + +} + +export default sprite \ No newline at end of file diff --git a/packages/server/src/Game/Map.ts b/packages/server/src/Game/Map.ts index fd63a3e3..720cc464 100644 --- a/packages/server/src/Game/Map.ts +++ b/packages/server/src/Game/Map.ts @@ -428,7 +428,7 @@ export class RpgMap extends RpgCommonMap { } else { event = obj.event - position = { x: obj.x, y: obj.y, z: 0 } + position = { x: obj.x, y: obj.y, z: obj.z ?? 0 } } // The event is ignored if the mode is different. diff --git a/packages/tiled/src/classes/Map.ts b/packages/tiled/src/classes/Map.ts index 0778dbe8..c2578f33 100644 --- a/packages/tiled/src/classes/Map.ts +++ b/packages/tiled/src/classes/Map.ts @@ -325,7 +325,9 @@ export class MapClass extends TiledProperties { private mapTilesets() { this.tilesets = this.tilesets.map(tileset => { if (bufferTilesets[tileset.name]) { - return bufferTilesets[tileset.name] + const instance = bufferTilesets[tileset.name] + instance.firstgid = tileset.firstgid + return instance } const _tileset = new Tileset(tileset) bufferTilesets[_tileset.name] = _tileset