Skip to content

Commit

Permalink
block camera input and some refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
dalkia committed Dec 12, 2024
1 parent eb04fb6 commit 4c34ed6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
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

0 comments on commit 4c34ed6

Please sign in to comment.