From 4a9b7987dc7a7b9f0e1df89a6f0577256c643c85 Mon Sep 17 00:00:00 2001 From: Dennis Postma <dennis@directonline.io> Date: Mon, 23 Sep 2024 14:02:25 +0200 Subject: [PATCH] Added option to set rotation on teleport tiles, new base database migration (db reset needed) --- .../migration.sql | 1 + prisma/schema/zone.prisma | 1 + src/services/zoneEventTileService.ts | 5 ++++- src/socketEvents/gameMaster/zoneEditor/update.ts | 4 +++- 4 files changed, 9 insertions(+), 2 deletions(-) rename prisma/migrations/{20240907234541_init => 20240923114327_init}/migration.sql (99%) diff --git a/prisma/migrations/20240907234541_init/migration.sql b/prisma/migrations/20240923114327_init/migration.sql similarity index 99% rename from prisma/migrations/20240907234541_init/migration.sql rename to prisma/migrations/20240923114327_init/migration.sql index 6e857f1..04cfd65 100644 --- a/prisma/migrations/20240907234541_init/migration.sql +++ b/prisma/migrations/20240923114327_init/migration.sql @@ -174,6 +174,7 @@ CREATE TABLE `ZoneEventTileTeleport` ( `id` VARCHAR(191) NOT NULL, `zoneEventTileId` VARCHAR(191) NOT NULL, `toZoneId` INTEGER NOT NULL, + `toRotation` INTEGER NOT NULL, `toPositionX` INTEGER NOT NULL, `toPositionY` INTEGER NOT NULL, diff --git a/prisma/schema/zone.prisma b/prisma/schema/zone.prisma index e0b1bd7..063dd44 100644 --- a/prisma/schema/zone.prisma +++ b/prisma/schema/zone.prisma @@ -81,6 +81,7 @@ model ZoneEventTileTeleport { zoneEventTile ZoneEventTile @relation(fields: [zoneEventTileId], references: [id], onDelete: Cascade) toZoneId Int toZone Zone @relation(fields: [toZoneId], references: [id], onDelete: Cascade) + toRotation Int toPositionX Int toPositionY Int } diff --git a/src/services/zoneEventTileService.ts b/src/services/zoneEventTileService.ts index fa22dcb..3ff0b07 100644 --- a/src/services/zoneEventTileService.ts +++ b/src/services/zoneEventTileService.ts @@ -23,14 +23,17 @@ export class ZoneEventTileService { data: { zoneId: newZoneId, positionX: teleport.toPositionX, - positionY: teleport.toPositionY + positionY: teleport.toPositionY, + rotation: teleport.toRotation } }) // Update local character object character.zoneId = newZoneId + character.rotation = teleport.toRotation character.positionX = teleport.toPositionX character.positionY = teleport.toPositionY + character.isMoving = false // Emit events io.to(oldZoneId.toString()).emit('zone:character:leave', character.id) diff --git a/src/socketEvents/gameMaster/zoneEditor/update.ts b/src/socketEvents/gameMaster/zoneEditor/update.ts index 423f6ca..603b4db 100644 --- a/src/socketEvents/gameMaster/zoneEditor/update.ts +++ b/src/socketEvents/gameMaster/zoneEditor/update.ts @@ -22,6 +22,7 @@ interface IPayload { toZoneId: number toPositionX: number toPositionY: number + toRotation: number } }[] zoneObjects: ZoneObject[] @@ -88,7 +89,8 @@ export default class ZoneUpdateEvent { create: { toZoneId: zoneEventTile.teleport.toZoneId, toPositionX: zoneEventTile.teleport.toPositionX, - toPositionY: zoneEventTile.teleport.toPositionY + toPositionY: zoneEventTile.teleport.toPositionY, + toRotation: zoneEventTile.teleport.toRotation } } }