Implement disable/restore proximity meeting in api (#2166)
Co-authored-by: Alexis Faizeau <a.faizeau@workadventu.re>
This commit is contained in:
parent
b6e006d7bb
commit
f7caacc598
@ -14,7 +14,7 @@ When controls are disabled, the user cannot move anymore using keyboard input. T
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```javascript
|
```ts
|
||||||
WA.room.onEnterLayer('myZone').subscribe(() => {
|
WA.room.onEnterLayer('myZone').subscribe(() => {
|
||||||
WA.controls.disablePlayerControls();
|
WA.controls.disablePlayerControls();
|
||||||
WA.ui.openPopup("popupRectangle", 'This is an imporant message!', [{
|
WA.ui.openPopup("popupRectangle", 'This is an imporant message!', [{
|
||||||
@ -25,5 +25,28 @@ WA.room.onEnterLayer('myZone').subscribe(() => {
|
|||||||
popup.close();
|
popup.close();
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
})
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Disabling / restoring proximity meeting
|
||||||
|
|
||||||
|
```
|
||||||
|
WA.controls.disablePlayerProximityMeeting(): void
|
||||||
|
WA.controls.restorePlayerProximityMeeting(): void
|
||||||
|
```
|
||||||
|
|
||||||
|
These 2 methods can be used to completely disable player proximity meeting and to enable them again.
|
||||||
|
|
||||||
|
When proximity meeting are disabled, the user cannot speak with anyone.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
WA.room.onEnterLayer('myZone').subscribe(() => {
|
||||||
|
WA.controls.disablePlayerProximityMeeting();
|
||||||
|
});
|
||||||
|
|
||||||
|
WA.room.onLeaveLayer('myZone').subscribe(() => {
|
||||||
|
WA.controls.restorePlayerProximityMeeting();
|
||||||
|
});
|
||||||
```
|
```
|
||||||
|
@ -97,6 +97,14 @@ export const isIframeEventWrapper = z.union([
|
|||||||
type: z.literal("restorePlayerControls"),
|
type: z.literal("restorePlayerControls"),
|
||||||
data: z.undefined(),
|
data: z.undefined(),
|
||||||
}),
|
}),
|
||||||
|
z.object({
|
||||||
|
type: z.literal("disablePlayerProximityMeeting"),
|
||||||
|
data: z.undefined(),
|
||||||
|
}),
|
||||||
|
z.object({
|
||||||
|
type: z.literal("restorePlayerProximityMeeting"),
|
||||||
|
data: z.undefined(),
|
||||||
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
type: z.literal("displayBubble"),
|
type: z.literal("displayBubble"),
|
||||||
data: z.undefined(),
|
data: z.undefined(),
|
||||||
|
@ -59,6 +59,15 @@ class IframeListener {
|
|||||||
private readonly _disablePlayerControlStream: Subject<void> = new Subject();
|
private readonly _disablePlayerControlStream: Subject<void> = new Subject();
|
||||||
public readonly disablePlayerControlStream = this._disablePlayerControlStream.asObservable();
|
public readonly disablePlayerControlStream = this._disablePlayerControlStream.asObservable();
|
||||||
|
|
||||||
|
private readonly _enablePlayerControlStream: Subject<void> = new Subject();
|
||||||
|
public readonly enablePlayerControlStream = this._enablePlayerControlStream.asObservable();
|
||||||
|
|
||||||
|
private readonly _disablePlayerProximityMeetingStream: Subject<void> = new Subject();
|
||||||
|
public readonly disablePlayerProximityMeetingStream = this._disablePlayerProximityMeetingStream.asObservable();
|
||||||
|
|
||||||
|
private readonly _enablePlayerProximityMeetingStream: Subject<void> = new Subject();
|
||||||
|
public readonly enablePlayerProximityMeetingStream = this._enablePlayerProximityMeetingStream.asObservable();
|
||||||
|
|
||||||
private readonly _cameraSetStream: Subject<CameraSetEvent> = new Subject();
|
private readonly _cameraSetStream: Subject<CameraSetEvent> = new Subject();
|
||||||
public readonly cameraSetStream = this._cameraSetStream.asObservable();
|
public readonly cameraSetStream = this._cameraSetStream.asObservable();
|
||||||
|
|
||||||
@ -74,9 +83,6 @@ class IframeListener {
|
|||||||
public readonly removeActionsMenuKeyFromRemotePlayerEvent =
|
public readonly removeActionsMenuKeyFromRemotePlayerEvent =
|
||||||
this._removeActionsMenuKeyFromRemotePlayerEvent.asObservable();
|
this._removeActionsMenuKeyFromRemotePlayerEvent.asObservable();
|
||||||
|
|
||||||
private readonly _enablePlayerControlStream: Subject<void> = new Subject();
|
|
||||||
public readonly enablePlayerControlStream = this._enablePlayerControlStream.asObservable();
|
|
||||||
|
|
||||||
private readonly _closePopupStream: Subject<ClosePopupEvent> = new Subject();
|
private readonly _closePopupStream: Subject<ClosePopupEvent> = new Subject();
|
||||||
public readonly closePopupStream = this._closePopupStream.asObservable();
|
public readonly closePopupStream = this._closePopupStream.asObservable();
|
||||||
|
|
||||||
@ -264,6 +270,10 @@ class IframeListener {
|
|||||||
this._disablePlayerControlStream.next();
|
this._disablePlayerControlStream.next();
|
||||||
} else if (iframeEvent.type === "restorePlayerControls") {
|
} else if (iframeEvent.type === "restorePlayerControls") {
|
||||||
this._enablePlayerControlStream.next();
|
this._enablePlayerControlStream.next();
|
||||||
|
} else if (iframeEvent.type === "disablePlayerProximityMeeting") {
|
||||||
|
this._disablePlayerProximityMeetingStream.next();
|
||||||
|
} else if (iframeEvent.type === "restorePlayerProximityMeeting") {
|
||||||
|
this._enablePlayerProximityMeetingStream.next();
|
||||||
} else if (iframeEvent.type === "displayBubble") {
|
} else if (iframeEvent.type === "displayBubble") {
|
||||||
this._displayBubbleStream.next();
|
this._displayBubbleStream.next();
|
||||||
} else if (iframeEvent.type === "removeBubble") {
|
} else if (iframeEvent.type === "removeBubble") {
|
||||||
|
@ -10,6 +10,14 @@ export class WorkadventureControlsCommands extends IframeApiContribution<Workadv
|
|||||||
restorePlayerControls(): void {
|
restorePlayerControls(): void {
|
||||||
sendToWorkadventure({ type: "restorePlayerControls", data: undefined });
|
sendToWorkadventure({ type: "restorePlayerControls", data: undefined });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disablePlayerProximityMeeting(): void {
|
||||||
|
sendToWorkadventure({ type: "disablePlayerProximityMeeting", data: undefined });
|
||||||
|
}
|
||||||
|
|
||||||
|
restorePlayerProximityMeeting(): void {
|
||||||
|
sendToWorkadventure({ type: "restorePlayerProximityMeeting", data: undefined });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new WorkadventureControlsCommands();
|
export default new WorkadventureControlsCommands();
|
||||||
|
@ -1103,6 +1103,24 @@ ${escapedMessage}
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.iframeSubscriptionList.push(
|
||||||
|
iframeListener.enablePlayerControlStream.subscribe(() => {
|
||||||
|
this.userInputManager.restoreControls();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
this.iframeSubscriptionList.push(
|
||||||
|
iframeListener.disablePlayerProximityMeetingStream.subscribe(() => {
|
||||||
|
this.disableMediaBehaviors();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
this.iframeSubscriptionList.push(
|
||||||
|
iframeListener.enablePlayerProximityMeetingStream.subscribe(() => {
|
||||||
|
this.enableMediaBehaviors();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
this.iframeSubscriptionList.push(
|
this.iframeSubscriptionList.push(
|
||||||
iframeListener.cameraSetStream.subscribe((cameraSetEvent) => {
|
iframeListener.cameraSetStream.subscribe((cameraSetEvent) => {
|
||||||
const duration = cameraSetEvent.smooth ? 1000 : 0;
|
const duration = cameraSetEvent.smooth ? 1000 : 0;
|
||||||
@ -1190,11 +1208,6 @@ ${escapedMessage}
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
this.iframeSubscriptionList.push(
|
|
||||||
iframeListener.enablePlayerControlStream.subscribe(() => {
|
|
||||||
this.userInputManager.restoreControls();
|
|
||||||
})
|
|
||||||
);
|
|
||||||
this.iframeSubscriptionList.push(
|
this.iframeSubscriptionList.push(
|
||||||
iframeListener.loadPageStream.subscribe((url: string) => {
|
iframeListener.loadPageStream.subscribe((url: string) => {
|
||||||
this.loadNextGameFromExitUrl(url)
|
this.loadNextGameFromExitUrl(url)
|
||||||
|
Loading…
Reference in New Issue
Block a user