From 0c8e5d3bb2d6ee1f007f4afcfe1bdf4b5b9da9cf Mon Sep 17 00:00:00 2001 From: Sean Bohan Date: Thu, 22 Jul 2021 23:25:46 +0800 Subject: [PATCH] Fix RayCast2D support --- src/engine/scene/2d/ray_cast_2d.ts | 4 ++-- tool/converter/res/RayCast2D.js | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 tool/converter/res/RayCast2D.js diff --git a/src/engine/scene/2d/ray_cast_2d.ts b/src/engine/scene/2d/ray_cast_2d.ts index 1db815f2..ba9d3456 100644 --- a/src/engine/scene/2d/ray_cast_2d.ts +++ b/src/engine/scene/2d/ray_cast_2d.ts @@ -41,8 +41,8 @@ export class RayCast2D extends Node2D { if (data.cast_to !== undefined) { this.cast_to.copy(data.cast_to); } - if (data.collide_with_ares !== undefined) { - this.collide_with_areas = data.collide_with_ares; + if (data.collide_with_areas !== undefined) { + this.collide_with_areas = data.collide_with_areas; } if (data.collide_with_bodies !== undefined) { this.collide_with_bodies = data.collide_with_bodies; diff --git a/tool/converter/res/RayCast2D.js b/tool/converter/res/RayCast2D.js new file mode 100644 index 00000000..f41814a7 --- /dev/null +++ b/tool/converter/res/RayCast2D.js @@ -0,0 +1,22 @@ +const { + int, + boolean, +} = require('../../parser/type_converters'); + +const Node2D = require('./Node2D'); + +module.exports = (data) => { + const res = Object.assign({}, Node2D(data), { + type: 'RayCast2D', + cast_to: data.prop.cast_to, + collide_with_areas: boolean(data.prop.collide_with_areas), + collide_with_bodies: boolean(data.prop.collide_with_bodies), + collision_mask: int(data.prop.collision_mask), + enabled: boolean(data.prop.enabled), + exclude_parent: boolean(data.prop.exclude_parent), + }); + + return res; +}; + +module.exports.is_tres = true;