Merge pull request #1680 from workadventure-xce/fix/follow-via-keyboard
Fix follow requests via keyboard
This commit is contained in:
commit
4eb2ebd034
@ -14,14 +14,11 @@ vim: ft=typescript
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sendFollowRequest() {
|
function sendFollowRequest() {
|
||||||
gameScene.connection?.emitFollowRequest();
|
gameScene.CurrentPlayer.sendFollowRequest();
|
||||||
followRoleStore.set("leader");
|
|
||||||
followStateStore.set("active");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function acceptFollowRequest() {
|
function acceptFollowRequest() {
|
||||||
gameScene.CurrentPlayer.enableFollowing();
|
gameScene.CurrentPlayer.startFollowing();
|
||||||
gameScene.connection?.emitFollowConfirmation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function abortEnding() {
|
function abortEnding() {
|
||||||
@ -42,23 +39,15 @@ vim: ft=typescript
|
|||||||
|
|
||||||
<svelte:window on:keydown={onKeyDown} />
|
<svelte:window on:keydown={onKeyDown} />
|
||||||
|
|
||||||
{#if $followStateStore === "requesting"}
|
{#if $followStateStore === "requesting" && $followRoleStore === "follower"}
|
||||||
<div class="interact-menu nes-container is-rounded">
|
<div class="interact-menu nes-container is-rounded">
|
||||||
{#if $followRoleStore === "follower"}
|
|
||||||
<section class="interact-menu-title">
|
<section class="interact-menu-title">
|
||||||
<h2>Do you want to follow {name($followUsersStore[0])}?</h2>
|
<h2>Do you want to follow {name($followUsersStore[0])}?</h2>
|
||||||
</section>
|
</section>
|
||||||
<section class="interact-menu-action">
|
<section class="interact-menu-action">
|
||||||
<button type="button" class="nes-btn is-success" on:click|preventDefault={acceptFollowRequest}
|
<button type="button" class="nes-btn is-success" on:click|preventDefault={acceptFollowRequest}>Yes</button>
|
||||||
>Yes</button
|
|
||||||
>
|
|
||||||
<button type="button" class="nes-btn is-error" on:click|preventDefault={reset}>No</button>
|
<button type="button" class="nes-btn is-error" on:click|preventDefault={reset}>No</button>
|
||||||
</section>
|
</section>
|
||||||
{:else if $followRoleStore === "leader"}
|
|
||||||
<section class="interact-menu-question">
|
|
||||||
<p>Should never be displayed</p>
|
|
||||||
</section>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
@ -100,10 +100,6 @@ export class Player extends Character {
|
|||||||
return [xMovement, yMovement];
|
return [xMovement, yMovement];
|
||||||
}
|
}
|
||||||
|
|
||||||
public enableFollowing() {
|
|
||||||
followStateStore.set("active");
|
|
||||||
}
|
|
||||||
|
|
||||||
public moveUser(delta: number): void {
|
public moveUser(delta: number): void {
|
||||||
const activeEvents = this.userInputManager.getEventListForGameTick();
|
const activeEvents = this.userInputManager.getEventListForGameTick();
|
||||||
const state = get(followStateStore);
|
const state = get(followStateStore);
|
||||||
@ -111,8 +107,7 @@ export class Player extends Character {
|
|||||||
|
|
||||||
if (activeEvents.get(UserInputEvent.Follow)) {
|
if (activeEvents.get(UserInputEvent.Follow)) {
|
||||||
if (state === "off" && this.scene.groups.size > 0) {
|
if (state === "off" && this.scene.groups.size > 0) {
|
||||||
followStateStore.set("requesting");
|
this.sendFollowRequest();
|
||||||
followRoleStore.set("leader");
|
|
||||||
} else if (state === "active") {
|
} else if (state === "active") {
|
||||||
followStateStore.set("ending");
|
followStateStore.set("ending");
|
||||||
}
|
}
|
||||||
@ -125,4 +120,15 @@ export class Player extends Character {
|
|||||||
}
|
}
|
||||||
this.inputStep(activeEvents, x, y);
|
this.inputStep(activeEvents, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sendFollowRequest() {
|
||||||
|
this.scene.connection?.emitFollowRequest();
|
||||||
|
followRoleStore.set("leader");
|
||||||
|
followStateStore.set("active");
|
||||||
|
}
|
||||||
|
|
||||||
|
public startFollowing() {
|
||||||
|
followStateStore.set("active");
|
||||||
|
this.scene.connection?.emitFollowConfirmation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,6 @@ export const followUsersStore = createFollowUsersStore();
|
|||||||
export const followUsersColorStore = derived(
|
export const followUsersColorStore = derived(
|
||||||
[followStateStore, followRoleStore, followUsersStore],
|
[followStateStore, followRoleStore, followUsersStore],
|
||||||
([$followStateStore, $followRoleStore, $followUsersStore]) => {
|
([$followStateStore, $followRoleStore, $followUsersStore]) => {
|
||||||
console.log($followStateStore);
|
|
||||||
if ($followStateStore !== "active") {
|
if ($followStateStore !== "active") {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user