2022-12-22 12:08:00 +01:00
|
|
|
import { IProjectileLauncherSignaler } from "../Projectile/IProjectileLauncherSignaler";
|
2022-11-30 08:21:22 +01:00
|
|
|
import { ProjectileCollision } from "../Projectile/ProjectileCollision";
|
|
|
|
import { Enemy } from "../Unit/Enemy/Enemy";
|
|
|
|
|
|
|
|
export class PlayerProjectileCollisionSystem {
|
2022-12-22 12:08:00 +01:00
|
|
|
public constructor(collisionSignalers: IProjectileLauncherSignaler[]) {
|
2022-11-30 11:44:20 +01:00
|
|
|
for (const collisionSignaler of collisionSignalers) {
|
|
|
|
collisionSignaler.ProjectileCollisionEvent.on(this.onProjectileCollision, this);
|
|
|
|
}
|
2022-11-30 08:21:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private onProjectileCollision(projectileCollision: ProjectileCollision): void {
|
2022-12-13 11:58:40 +01:00
|
|
|
projectileCollision.otherCollider.getComponent(Enemy).dealDamage(projectileCollision.projectile.Damage);
|
|
|
|
projectileCollision.projectile.pierce();
|
2022-11-30 08:21:22 +01:00
|
|
|
}
|
|
|
|
}
|