fix: context entities

This commit is contained in:
cha0s 2024-08-05 03:21:11 -05:00
parent 917465a35f
commit d6af0199c9

View File

@ -106,6 +106,7 @@ export default class Collider extends Component {
if (!hasMatchingIntersection) { if (!hasMatchingIntersection) {
if (this.$$collisionStart) { if (this.$$collisionStart) {
const script = this.$$collisionStart.clone(); const script = this.$$collisionStart.clone();
script.context.entity = thisEntity;
script.context.other = otherEntity; script.context.other = otherEntity;
script.context.pair = [body, otherBody]; script.context.pair = [body, otherBody];
const ticker = script.ticker(); const ticker = script.ticker();
@ -115,6 +116,7 @@ export default class Collider extends Component {
} }
if (other.$$collisionStart) { if (other.$$collisionStart) {
const script = other.$$collisionStart.clone(); const script = other.$$collisionStart.clone();
script.context.entity = otherEntity;
script.context.other = thisEntity; script.context.other = thisEntity;
script.context.pair = [otherBody, body]; script.context.pair = [otherBody, body];
const ticker = script.ticker(); const ticker = script.ticker();
@ -271,14 +273,12 @@ export default class Collider extends Component {
instance.collisionEndScript, instance.collisionEndScript,
{ {
ecs: this.ecs, ecs: this.ecs,
entity: this.ecs.get(instance.entity),
}, },
); );
instance.$$collisionStart = await this.ecs.readScript( instance.$$collisionStart = await this.ecs.readScript(
instance.collisionStartScript, instance.collisionStartScript,
{ {
ecs: this.ecs, ecs: this.ecs,
entity: this.ecs.get(instance.entity),
}, },
); );
} }