workadventure/front/src/Phaser/Game/EmoteManager.ts
David Négrier bf070c33b5 Migrating front protobuf encode/decode to ts-proto lib
The ts-proto lib has the huge advantage of producing code the "Typescript" way and not the "Java" way.
In particular, for "oneof" types in protobuf, it is generating "ADT" that can be used to check if we forgot or not to deal with a type.
2022-01-03 15:52:46 +01:00

21 lines
640 B
TypeScript

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