Collider::isColliding

This commit is contained in:
cha0s 2019-06-06 00:20:51 -05:00
parent 7b7b688d81
commit 6ea200f708

View File

@ -4,6 +4,7 @@ import {StateProperty, Trait} from '@avocado/entity';
const decorate = compose( const decorate = compose(
StateProperty('isCheckingCollisions'), StateProperty('isCheckingCollisions'),
StateProperty('isColliding'),
); );
export class Collider extends decorate(Trait) { export class Collider extends decorate(Trait) {
@ -23,6 +24,7 @@ export class Collider extends decorate(Trait) {
static defaultState() { static defaultState() {
return { return {
isCheckingCollisions: true, isCheckingCollisions: true,
isColliding: true,
} }
} }
@ -110,6 +112,9 @@ export class Collider extends decorate(Trait) {
return { return {
collidesWith: (entity) => { collidesWith: (entity) => {
if (!this.entity.isColliding || !entity.isColliding) {
return false;
}
if (-1 !== this._doesNotCollideWith.indexOf(entity)) { if (-1 !== this._doesNotCollideWith.indexOf(entity)) {
return false; return false;
} }