feat: isCollidinig

This commit is contained in:
cha0s 2024-10-21 02:36:11 -05:00
parent 26b3f5049c
commit 34247e00db
2 changed files with 8 additions and 1 deletions

View File

@ -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'},
}; };
} }

View File

@ -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;
} }