2021-07-21 09:41:22 +02:00
|
|
|
import { emoteEventStream } from "../../Connexion/EmoteEventStream";
|
|
|
|
import type { GameScene } from "./GameScene";
|
|
|
|
import type { Subscription } from "rxjs";
|
2021-03-31 11:21:06 +02:00
|
|
|
|
|
|
|
export class EmoteManager {
|
2021-05-21 16:25:12 +02:00
|
|
|
private subscription: Subscription;
|
2021-06-29 08:37:01 +02:00
|
|
|
|
2021-03-31 11:21:06 +02:00
|
|
|
constructor(private scene: GameScene) {
|
2021-05-21 16:25:12 +02:00
|
|
|
this.subscription = emoteEventStream.stream.subscribe((event) => {
|
2021-03-31 11:21:06 +02:00
|
|
|
const actor = this.scene.MapPlayersByKey.get(event.userId);
|
2021-07-21 09:41:22 +02:00
|
|
|
if (actor) {
|
2021-06-29 08:37:01 +02:00
|
|
|
actor.playEmote(event.emote);
|
2021-03-31 11:21:06 +02:00
|
|
|
}
|
2021-07-21 09:41:22 +02:00
|
|
|
});
|
2021-05-10 17:10:41 +02:00
|
|
|
}
|
2021-06-29 08:37:01 +02:00
|
|
|
|
2021-05-21 16:25:12 +02:00
|
|
|
destroy() {
|
|
|
|
this.subscription.unsubscribe();
|
|
|
|
}
|
2021-07-21 09:41:22 +02:00
|
|
|
}
|