From 5f9636e2d72916ea2da96efd6a8e258026fbd25d Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 20 Feb 2024 13:59:44 -0500 Subject: [PATCH] Fix crash with form changes --- src/pipelines/sprite.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pipelines/sprite.ts b/src/pipelines/sprite.ts index e9f2a51e7f2..28697d66db5 100644 --- a/src/pipelines/sprite.ts +++ b/src/pipelines/sprite.ts @@ -343,8 +343,10 @@ export default class SpritePipeline extends FieldSpritePipeline { const position = isEntityObj ? [ sprite.parentContainer.x, sprite.parentContainer.y ] : [ sprite.x, sprite.y ]; - position[0] += field.x / field.scale; - position[1] += field.y / field.scale; + if (field) { + position[0] += field.x / field.scale; + position[1] += field.y / field.scale; + } position[0] += -(sprite.width - (sprite.frame.width)) / 2 + sprite.frame.x; if (sprite.originY === 0.5) position[1] += (sprite.height / 2) * ((isEntityObj ? sprite.parentContainer : sprite).scale - 1); @@ -352,7 +354,7 @@ export default class SpritePipeline extends FieldSpritePipeline { this.set3fv('teraColor', teraColor.map(c => c / 255)); this.set1i('hasShadow', hasShadow ? 1 : 0); this.set1i('yCenter', sprite.originY === 0.5 ? 1 : 0); - this.set1f('fieldScale', field.scale); + this.set1f('fieldScale', field?.scale || 1); this.set2f('relPosition', position[0], position[1]); this.set2f('texFrameUv', sprite.frame.u0, sprite.frame.v0); this.set2f('size', sprite.frame.width, sprite.height);