bf070c33b5
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.
21 lines
640 B
TypeScript
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();
|
|
}
|
|
}
|