Allows to read and write "Player properties" from LocalStorage
This commit is contained in:
parent
ecb72d0fd1
commit
89cd292527
5 changed files with 60 additions and 3 deletions
|
@ -1,8 +1,9 @@
|
|||
import { IframeApiContribution, sendToWorkadventure } from "./IframeApiContribution";
|
||||
import { IframeApiContribution, queryWorkadventure, sendToWorkadventure } from "./IframeApiContribution";
|
||||
import type { HasPlayerMovedEvent, HasPlayerMovedEventCallback } from "../Events/HasPlayerMovedEvent";
|
||||
import { Subject } from "rxjs";
|
||||
import { apiCallback } from "./registeredCallbacks";
|
||||
import { isHasPlayerMovedEvent } from "../Events/HasPlayerMovedEvent";
|
||||
import type { PlayerPropertyEvent } from "../Events/PlayerPropertyEvent";
|
||||
|
||||
const moveStream = new Subject<HasPlayerMovedEvent>();
|
||||
|
||||
|
@ -67,6 +68,20 @@ export class WorkadventurePlayerCommands extends IframeApiContribution<Workadven
|
|||
}
|
||||
return uuid;
|
||||
}
|
||||
|
||||
getPlayerProperty(name: string): Promise<PlayerPropertyEvent> {
|
||||
return queryWorkadventure({
|
||||
type: "getPlayerProperty",
|
||||
data: name,
|
||||
});
|
||||
}
|
||||
|
||||
setPlayerProperty(property: PlayerPropertyEvent) {
|
||||
queryWorkadventure({
|
||||
type: "setPlayerProperty",
|
||||
data: property,
|
||||
}).catch((e) => console.error(e));
|
||||
}
|
||||
}
|
||||
|
||||
export default new WorkadventurePlayerCommands();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue