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

21 lines
640 B
TypeScript
Raw Normal View History

2021-07-21 09:41:22 +02:00
import type { GameScene } from "./GameScene";
import type { Subscription } from "rxjs";
import type { RoomConnection } from "../../Connexion/RoomConnection";
export class EmoteManager {
private subscription: Subscription;
2021-06-29 08:37:01 +02:00
constructor(private scene: GameScene, private connection: RoomConnection) {
this.subscription = connection.emoteEventMessageStream.subscribe((event) => {
const actor = this.scene.MapPlayersByKey.get(event.actorUserId);
2021-07-21 09:41:22 +02:00
if (actor) {
2021-06-29 08:37:01 +02:00
actor.playEmote(event.emote);
}
2021-07-21 09:41:22 +02:00
});
2021-05-10 17:10:41 +02:00
}
2021-06-29 08:37:01 +02:00
destroy() {
this.subscription.unsubscribe();
}
2021-07-21 09:41:22 +02:00
}