Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: block camera input #2999

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Explorer/Assets/DCL/Chat/ChatController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,13 @@ private void ToggleEmojiPanel()
private void DisableUnwantedInputs()
{
world.AddOrGet(cameraEntity, new CameraBlockerComponent());
inputBlock.Disable(InputMapComponent.Kind.CAMERA , InputMapComponent.Kind.SHORTCUTS , InputMapComponent.Kind.PLAYER);
inputBlock.Disable(InputMapComponent.BLOCK_USER_INPUT);
}

private void EnableUnwantedInputs()
{
world.TryRemove<CameraBlockerComponent>(cameraEntity);
inputBlock.Enable(InputMapComponent.Kind.CAMERA , InputMapComponent.Kind.SHORTCUTS , InputMapComponent.Kind.PLAYER);
inputBlock.Enable(InputMapComponent.BLOCK_USER_INPUT);
}

private void OnSubmitAction(InputAction.CallbackContext obj)
Expand Down
9 changes: 9 additions & 0 deletions Explorer/Assets/DCL/Input/Component/InputMapComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ public struct InputMapComponent
{
public static readonly IReadOnlyList<Kind> VALUES = EnumUtils.Values<Kind>();

public static readonly Kind[] BLOCK_USER_INPUT =
{
Kind.IN_WORLD_CAMERA,
Kind.CAMERA,
Kind.SHORTCUTS,
Kind.PLAYER
};


[Flags]
public enum Kind
{
Expand Down
3 changes: 3 additions & 0 deletions Explorer/Assets/DCL/Input/Systems/ApplyInputMapsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ protected override void Update(float t)
case InputMapComponent.Kind.SHORTCUTS:
SetActionMapEnabled(isActive, dclInput.Shortcuts);
break;
case InputMapComponent.Kind.IN_WORLD_CAMERA:
SetActionMapEnabled(isActive, dclInput.InWorldCamera);
break;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@ private async UniTaskVoid RotateTipsOverTimeAsync(TimeSpan frequency, Cancellati

private void BlockUnwantedInputs()
{
inputBlock.Disable(InputMapComponent.Kind.CAMERA, InputMapComponent.Kind.SHORTCUTS, InputMapComponent.Kind.PLAYER);
inputBlock.Disable(InputMapComponent.BLOCK_USER_INPUT);
}

private void UnblockUnwantedInputs()
{
inputBlock.Enable(InputMapComponent.Kind.CAMERA, InputMapComponent.Kind.SHORTCUTS, InputMapComponent.Kind.PLAYER);
inputBlock.Enable(InputMapComponent.BLOCK_USER_INPUT);
}
}
}
3 changes: 2 additions & 1 deletion Explorer/Assets/Scripts/Global/Dynamic/MainSceneLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ private void RestoreInputs()
{
// We enable Inputs through the inputBlock so the block counters can be properly updated and the component Active flags are up-to-date as well
// We restore all inputs except EmoteWheel and FreeCamera as they should be disabled by default
staticContainer!.InputBlock.Enable(InputMapComponent.Kind.SHORTCUTS, InputMapComponent.Kind.PLAYER, InputMapComponent.Kind.EMOTES, InputMapComponent.Kind.CAMERA);
staticContainer!.InputBlock.Enable(InputMapComponent.Kind.IN_WORLD_CAMERA, InputMapComponent.Kind.SHORTCUTS,
InputMapComponent.Kind.PLAYER, InputMapComponent.Kind.EMOTES, InputMapComponent.Kind.CAMERA);
}

[ContextMenu(nameof(ValidateSettingsAsync))]
Expand Down
Loading