added callback on playermove - gets quite delayed after walking for a few seconds

This commit is contained in:
jonny 2021-05-10 21:27:17 +02:00
parent ce0c7ea3eb
commit 8e136cebe8
8 changed files with 104 additions and 44 deletions

View file

@ -0,0 +1,19 @@
import * as tg from "generic-type-guard";
export const isHasMovedEvent =
new tg.IsInterface().withProperties({
direction: tg.isString,
moving: tg.isBoolean,
x: tg.isNumber,
y: tg.isNumber
}).get();
/**
* A message sent from the iFrame to the game to add a message in the chat.
*/
export type HasMovedEvent = tg.GuardedType<typeof isHasMovedEvent>;
export type HasMovedEventCallback = (event: HasMovedEvent) => void

View file

@ -1,11 +1,11 @@
import { GameStateEvent } from './ApiGameStateEvent';
import { ButtonClickedEvent } from './ButtonClickedEvent';
import { ChatEvent } from './ChatEvent';
import { ClosePopupEvent } from './ClosePopupEvent';
import { EnterLeaveEvent } from './EnterLeaveEvent';
import { GoToPageEvent } from './GoToPageEvent';
import { HasMovedEvent } from './HasMovedEvent';
import { OpenCoWebSiteEvent } from './OpenCoWebSiteEvent';
import { OpenPopupEvent } from './OpenPopupEvent';
import { OpenTabEvent } from './OpenTabEvent';
@ -30,6 +30,7 @@ export type IframeEventMap = {
restorePlayerControl: null
displayBubble: null
removeBubble: null
enableMoveEvents: undefined
}
export interface IframeEvent<T extends keyof IframeEventMap> {
type: T;
@ -46,6 +47,7 @@ export interface IframeResponseEventMap {
leaveEvent: EnterLeaveEvent
buttonClickedEvent: ButtonClickedEvent
gameState: GameStateEvent
hasMovedEvent: HasMovedEvent
}
export interface IframeResponseEvent<T extends keyof IframeResponseEventMap> {
type: T;