2021-03-31 11:21:06 +02:00
|
|
|
import {emoteEventStream} from "../../Connexion/EmoteEventStream";
|
2021-05-19 18:08:53 +02:00
|
|
|
import type {GameScene} from "./GameScene";
|
2021-05-21 16:25:12 +02:00
|
|
|
import type {Subscription} from "rxjs";
|
2021-03-31 11:21:06 +02:00
|
|
|
|
2021-06-29 08:37:01 +02:00
|
|
|
export const emotes: string[] = ['❤️', '👏', '✋', '🙏', '👍', '👎'];
|
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-06-29 08:37:01 +02:00
|
|
|
if(actor) {
|
|
|
|
actor.playEmote(event.emote);
|
2021-03-31 11:21:06 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
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
|
|
|
|
2021-05-21 16:25:12 +02:00
|
|
|
destroy() {
|
|
|
|
this.subscription.unsubscribe();
|
|
|
|
}
|
2021-03-31 11:21:06 +02:00
|
|
|
}
|