feat: select paired emote lines from own character
This commit is contained in:
@@ -14,7 +14,7 @@ interface FriendConfig {
|
||||
matchId: string; slot: 0 | 1; engine: MatchEngine; peer: GamePeer; clock: GameClock;
|
||||
setOffset(offset: number): void; changed(): void; finished(): void;
|
||||
saved?: { confirmed?: MatchCheckpoint; epoch: number };
|
||||
onEmote?(id: unknown): void;
|
||||
onEmote?(id: unknown, variant: unknown): void;
|
||||
}
|
||||
export function createFriendMatch(config: FriendConfig) {
|
||||
const { peer, engine, clock } = config;
|
||||
@@ -162,7 +162,7 @@ export function createFriendMatch(config: FriendConfig) {
|
||||
if (message.type === 'clock:pong') { if (Number.isFinite(message.remoteAt)) clockReplies.get(message.sentAt)?.resolve(message.remoteAt); clockReplies.delete(message.sentAt); return; }
|
||||
if (message.type === 'pong') return;
|
||||
if (message.type === 'emote') {
|
||||
if (!recovering && engine.view().phase !== 'finished') config.onEmote?.(message.id);
|
||||
if (!recovering && engine.view().phase !== 'finished') config.onEmote?.(message.id, message.variant);
|
||||
return;
|
||||
}
|
||||
if (message.type === 'ready') { if (message.slot === config.slot) throw new Error('INVALID_SLOT'); peerReady = true; maybeStart(); return; }
|
||||
@@ -210,9 +210,9 @@ export function createFriendMatch(config: FriendConfig) {
|
||||
catch { abort('connection_failed'); }
|
||||
},
|
||||
get recovering() { return recovering; },
|
||||
sendEmote(id: import('../../constants/emotes.js').EmoteId) {
|
||||
sendEmote(id: import('../../constants/emotes.js').EmoteId, variant: 0 | 1) {
|
||||
if (stopped || recovering || !peer.connected || engine.view().phase === 'finished') return false;
|
||||
try { send('emote', { id }); return true; } catch { return false; }
|
||||
try { send('emote', { id, variant }); return true; } catch { return false; }
|
||||
},
|
||||
submitAction() { if (!recovering && !stopped) run(() => exchange!.commit(engine.view().ownAction)); },
|
||||
requestRematch() { engine.requestRematch(config.slot); if (peer.connected) send('match:rematch'); config.changed(); },
|
||||
|
||||
Reference in New Issue
Block a user