feat: isCollidinig
This commit is contained in:
parent
26b3f5049c
commit
34247e00db
|
@ -35,6 +35,9 @@ export default class Collider extends Component {
|
||||||
return aabbs;
|
return aabbs;
|
||||||
}
|
}
|
||||||
checkCollision(other) {
|
checkCollision(other) {
|
||||||
|
if (!this.isColliding || !other.isColliding) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const otherEntity = ecs.get(other.entity);
|
const otherEntity = ecs.get(other.entity);
|
||||||
const thisEntity = ecs.get(this.entity);
|
const thisEntity = ecs.get(this.entity);
|
||||||
const intersections = this.intersectionsWith(other);
|
const intersections = this.intersectionsWith(other);
|
||||||
|
@ -306,5 +309,6 @@ export default class Collider extends Component {
|
||||||
},
|
},
|
||||||
collisionEndScript: {type: 'string'},
|
collisionEndScript: {type: 'string'},
|
||||||
collisionStartScript: {type: 'string'},
|
collisionStartScript: {type: 'string'},
|
||||||
|
isColliding: {defaultValue: 1, type: 'uint8'},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
import transition from '@/util/transition.js';
|
import transition from '@/util/transition.js';
|
||||||
|
|
||||||
export default function*({ecs, entity}) {
|
export default function*({ecs, entity}) {
|
||||||
const {Controlled, Sprite, Vulnerable} = entity;
|
const {Collider, Controlled, Sprite, Vulnerable} = entity;
|
||||||
|
if (Collider) {
|
||||||
|
Collider.isColliding = 0;
|
||||||
|
}
|
||||||
if (Controlled) {
|
if (Controlled) {
|
||||||
Controlled.locked = 1;
|
Controlled.locked = 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user