workadventure/front/src/Phaser/Game/EmoteManager.ts

27 lines
763 B
TypeScript
Raw Normal View History

import {emoteEventStream} from "../../Connexion/EmoteEventStream";
2021-05-19 18:08:53 +02:00
import type {GameScene} from "./GameScene";
import type {Subscription} from "rxjs";
2021-06-29 08:37:01 +02:00
export const emotes: string[] = ['❤️', '👏', '✋', '🙏', '👍', '👎'];
export class EmoteManager {
private subscription: Subscription;
2021-06-29 08:37:01 +02:00
constructor(private scene: GameScene) {
this.subscription = emoteEventStream.stream.subscribe((event) => {
const actor = this.scene.MapPlayersByKey.get(event.userId);
2021-06-29 08:37:01 +02:00
if(actor) {
actor.playEmote(event.emote);
}
})
}
2021-06-29 08:37:01 +02:00
getEmotes(): string[] {
// TODO: localstorage + management
return emotes;
2021-05-10 17:10:41 +02:00
}
2021-06-29 08:37:01 +02:00
destroy() {
this.subscription.unsubscribe();
}
}