silphius/resources/misc/death-default.js
2024-10-21 02:36:11 -05:00

32 lines
660 B
JavaScript

import transition from '@/util/transition.js';
export default function*({ecs, entity}) {
const {Collider, Controlled, Sprite, Vulnerable} = entity;
if (Collider) {
Collider.isColliding = 0;
}
if (Controlled) {
Controlled.locked = 1;
}
if (Vulnerable) {
Vulnerable.isInvulnerable = 1;
}
if (Sprite) {
const {ticker} = transition(
entity.Sprite,
{
scaleX: {
duration: 0.25,
magnitude: -entity.Sprite.scaleX,
},
scaleY: {
duration: 0.25,
magnitude: entity.Sprite.scaleY * 2,
},
},
);
yield ticker;
ecs.destroy(entity.id);
}
}