diff --git a/src/entities/base/mapObject.ts b/src/entities/base/mapObject.ts index 2663acb..d956be3 100644 --- a/src/entities/base/mapObject.ts +++ b/src/entities/base/mapObject.ts @@ -14,7 +14,7 @@ export class BaseMapObject extends BaseEntity { tags: string[] = [] @Property({ type: 'json' }) - pivotPoints: { x: number; y: number; }[] = [] + depthOffsets = [0] @Property({ type: 'decimal', precision: 10, scale: 2 }) originX = 0 @@ -64,13 +64,13 @@ export class BaseMapObject extends BaseEntity { return this.tags } - setPivotPoints(pivotPoints: { x: number; y: number; }[]) { - this.pivotPoints = pivotPoints + setDepthOffsets(offsets: any) { + this.depthOffsets = offsets return this } - getPivotPoints() { - return this.pivotPoints + getDepthOffsets() { + return this.depthOffsets; } setOriginX(originX: number) { diff --git a/src/events/gameMaster/assetManager/mapObject/update.ts b/src/events/gameMaster/assetManager/mapObject/update.ts index 0bc1495..6ad0276 100644 --- a/src/events/gameMaster/assetManager/mapObject/update.ts +++ b/src/events/gameMaster/assetManager/mapObject/update.ts @@ -7,7 +7,7 @@ type Payload = { id: UUID name: string tags: string[] - pivotPoints: { x: number; y: number; }[] + depthOffsets: number[] originX: number originY: number frameRate: number @@ -31,7 +31,7 @@ export default class MapObjectUpdateEvent extends BaseEvent { if (data.name !== undefined) mapObject.name = data.name if (data.tags !== undefined) mapObject.tags = data.tags - if (data.pivotPoints !== undefined) mapObject.pivotPoints = data.pivotPoints + if (data.depthOffsets !== undefined) mapObject.depthOffsets = data.depthOffsets if (data.originX !== undefined) mapObject.originX = data.originX if (data.originY !== undefined) mapObject.originY = data.originY if (data.frameRate !== undefined) mapObject.frameRate = data.frameRate diff --git a/src/migrations/.snapshot-game.json b/src/migrations/.snapshot-game.json index 3a6735c..c610141 100644 --- a/src/migrations/.snapshot-game.json +++ b/src/migrations/.snapshot-game.json @@ -479,8 +479,8 @@ "length": null, "mappedType": "json" }, - "pivot_points": { - "name": "pivot_points", + "depth_offsets": { + "name": "depth_offsets", "type": "json", "unsigned": false, "autoincrement": false, diff --git a/src/migrations/Migration20250312011946.ts b/src/migrations/Migration20250312011946.ts new file mode 100644 index 0000000..5d166a3 --- /dev/null +++ b/src/migrations/Migration20250312011946.ts @@ -0,0 +1,13 @@ +import { Migration } from '@mikro-orm/migrations'; + +export class Migration20250312011946 extends Migration { + + override async up(): Promise { + this.addSql(`alter table \`map_object\` change \`pivot_points\` \`depth_offsets\` json not null;`); + } + + override async down(): Promise { + this.addSql(`alter table \`map_object\` change \`depth_offsets\` \`pivot_points\` json not null;`); + } + +}