option to update tile
# Conflicts: # front/src/Api/Events/ApiUpdateTileEvent.ts # front/src/Api/IframeListener.ts # front/src/Phaser/Game/GameScene.ts
This commit is contained in:
parent
79e530f0e6
commit
ffe03d40f5
4 changed files with 227 additions and 163 deletions
16
front/src/Api/Events/ApiUpdateTileEvent.ts
Normal file
16
front/src/Api/Events/ApiUpdateTileEvent.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
import * as tg from "generic-type-guard";
|
||||
export const updateTile = "updateTile"
|
||||
|
||||
|
||||
export const isUpdateTileEvent =
|
||||
new tg.IsInterface().withProperties({
|
||||
x: tg.isNumber,
|
||||
y: tg.isNumber,
|
||||
tile: tg.isUnion(tg.isNumber, tg.isString),
|
||||
layer: tg.isUnion(tg.isNumber, tg.isString)
|
||||
}).get();
|
||||
/**
|
||||
* A message sent from the game to the iFrame when a user enters or leaves a zone marked with the "zone" property.
|
||||
*/
|
||||
export type UpdateTileEvent = tg.GuardedType<typeof isUpdateTileEvent>;
|
|
@ -57,6 +57,9 @@ class IframeListener {
|
|||
private readonly _removeBubbleStream: Subject<void> = new Subject();
|
||||
public readonly removeBubbleStream = this._removeBubbleStream.asObservable();
|
||||
|
||||
private readonly _updateTileEvent: Subject<UpdateTileEvent> = new Subject();
|
||||
public readonly updateTileEvent = this._updateTileEvent.asObservable();
|
||||
|
||||
private readonly iframes = new Set<HTMLIFrameElement>();
|
||||
private readonly scripts = new Map<string, HTMLIFrameElement>();
|
||||
|
||||
|
@ -110,6 +113,10 @@ class IframeListener {
|
|||
this._removeBubbleStream.next();
|
||||
}else if (payload.type === 'loadPage' && isLoadPageEvent(payload.data)){
|
||||
this._loadPageStream.next(payload.data.url);
|
||||
} else if (payload.type == "getState") {
|
||||
this._gameStateStream.next();
|
||||
} else if (payload.type == "updateTile" && isUpdateTileEvent(payload.data)) {
|
||||
this._updateTileEvent.next(payload.data)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue