workadventure/front/src/Phaser/Game/EmoteManager.ts
2021-07-21 09:41:22 +02:00

21 lines
587 B
TypeScript

import { emoteEventStream } from "../../Connexion/EmoteEventStream";
import type { GameScene } from "./GameScene";
import type { Subscription } from "rxjs";
export class EmoteManager {
private subscription: Subscription;
constructor(private scene: GameScene) {
this.subscription = emoteEventStream.stream.subscribe((event) => {
const actor = this.scene.MapPlayersByKey.get(event.userId);
if (actor) {
actor.playEmote(event.emote);
}
});
}
destroy() {
this.subscription.unsubscribe();
}
}