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