From ebc1ab649e29b4c5d1050d9b0871d2bdc99ac2cf Mon Sep 17 00:00:00 2001 From: yhh <359807859@qq.com> Date: Sun, 27 Dec 2020 22:23:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0collider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- engine_support/egret | 2 +- extensions/behaviourTree-ai | 2 +- .../src/ECS/Components/Physics/Colliders/Collider.ts | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/engine_support/egret b/engine_support/egret index 1e658159..a2bcd99f 160000 --- a/engine_support/egret +++ b/engine_support/egret @@ -1 +1 @@ -Subproject commit 1e658159494f77b69319053096c7989c39c5d722 +Subproject commit a2bcd99ffefec38a42a148ca1ca282077992eb25 diff --git a/extensions/behaviourTree-ai b/extensions/behaviourTree-ai index 53bce65b..c21ddc04 160000 --- a/extensions/behaviourTree-ai +++ b/extensions/behaviourTree-ai @@ -1 +1 @@ -Subproject commit 53bce65be70d225dcc1e03d9ba71f120df29a8dd +Subproject commit c21ddc044ec3781f45bb655cb20d2fbebc9b4797 diff --git a/source/src/ECS/Components/Physics/Colliders/Collider.ts b/source/src/ECS/Components/Physics/Colliders/Collider.ts index 8d846d2c..da950836 100644 --- a/source/src/ECS/Components/Physics/Colliders/Collider.ts +++ b/source/src/ECS/Components/Physics/Colliders/Collider.ts @@ -27,6 +27,8 @@ module es { */ public registeredPhysicsBounds: Rectangle = new Rectangle(); + protected _colliderRequiresAutoSizing: boolean; + public _localOffsetLength: number; public _isPositionDirty: boolean = true; public _isRotationDirty: boolean = true; @@ -50,7 +52,7 @@ module es { * 封装变换。如果碰撞器没和实体一起旋转 则返回transform.rotation */ public get rotation(): number { - if (this.shouldColliderScaleAndRotateWithTransform && this.entity) + if (this.shouldColliderScaleAndRotateWithTransform && this.entity != null) return this.entity.transform.rotation; return 0; @@ -90,7 +92,7 @@ module es { * @param offset */ public setLocalOffset(offset: Vector2): Collider { - if (this._localOffset != offset) { + if (!this._localOffset.equals(offset)) { this.unregisterColliderWithPhysicsSystem(); this._localOffset = offset; this._localOffsetLength = this._localOffset.length(); @@ -112,6 +114,10 @@ module es { } public onAddedToEntity() { + if (this._colliderRequiresAutoSizing) { + Insist.isTrue(this instanceof BoxCollider || this instanceof CircleCollider, "只有框和圆的碰撞器可以自动创建"); + } + this._isParentEntityAddedToScene = true; this.registerColliderWithPhysicsSystem(); }