Skip to content

Commit

Permalink
Few bug fixes and new additions
Browse files Browse the repository at this point in the history
- Fix channel system causing game hang
- Fix error spam in some VR items
- Added new option to set UI button press sensitivity
  • Loading branch information
DaXcess committed Aug 28, 2024
1 parent 95c4231 commit c8dd877
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 26 deletions.
3 changes: 2 additions & 1 deletion LCVR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
<DebugType>embedded</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand Down
Binary file modified Resources/lethalcompanyvr
Binary file not shown.
4 changes: 2 additions & 2 deletions Source/Assets/AssetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal static class AssetManager
public static Shader TMPAlwaysOnTop;

public static InputActionAsset VRActions;
public static InputActionAsset TrackingActions;
public static InputActionAsset DefaultXRActions;
public static InputActionAsset NullActions;

public static RemappableControls RemappableControls;
Expand Down Expand Up @@ -58,7 +58,7 @@ public static bool LoadAssets()
SteeringWheelPoints = assetBundle.LoadAsset<GameObject>("SnapPointContainer");

VRActions = assetBundle.LoadAsset<InputActionAsset>("VRActions");
TrackingActions = assetBundle.LoadAsset<InputActionAsset>("TrackingActions");
DefaultXRActions = assetBundle.LoadAsset<InputActionAsset>("DefaultXRActions");
NullActions = assetBundle.LoadAsset<InputActionAsset>("NullPlayerActions");

TMPAlwaysOnTop = assetBundle.LoadAsset<Shader>("TextMeshPro Always On Top");
Expand Down
3 changes: 2 additions & 1 deletion Source/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public class Config(ConfigFile file)
public ConfigEntry<float> SnapTurnSize { get; } = file.Bind("Input", "SnapTurnSize", 45f, new ConfigDescription("The amount of rotation that is applied when performing a snap turn. Requires turn provider to be set to snap.", new AcceptableValueRange<float>(10, 180)));
public ConfigEntry<bool> ToggleSprint { get; } = file.Bind("Input", "ToggleSprint", false, "Whether the sprint button should toggle sprint instead of having to hold it down.");
public ConfigEntry<float> MovementSprintToggleCooldown { get; } = file.Bind("Input", "MovementSprintToggleCooldown", 1f, new ConfigDescription("The amount of seconds that you need to stand still for sprint to be toggled off automatically. Requires sprint toggle to be enabled.", new AcceptableValueRange<float>(0, 60)));

public ConfigEntry<float> ButtonPressPoint { get; } = file.Bind("Input", "ButtonPressPoint", 0.25f, new ConfigDescription("The amount of force required to register a UI button press. The lower the value, the more sensitive UI presses become.", new AcceptableValueRange<float>(0, 1)));

// UI configuration

public ConfigEntry<bool> EnablePitchLockedCanvas { get; } = file.Bind("UI", "EnablePitchLockedCanvas", true, "Whether most of the camera-locked UI elements should only (smoothly) rotate on the Y axis, instead of being stuck on your face.");
Expand Down
18 changes: 9 additions & 9 deletions Source/Input/Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ public class Actions

private Actions()
{
HeadPosition = AssetManager.TrackingActions.FindAction("Head/Position");
HeadRotation = AssetManager.TrackingActions.FindAction("Head/Rotation");
HeadTrackingState = AssetManager.TrackingActions.FindAction("Head/Tracking State");
HeadPosition = AssetManager.DefaultXRActions.FindAction("Head/Position");
HeadRotation = AssetManager.DefaultXRActions.FindAction("Head/Rotation");
HeadTrackingState = AssetManager.DefaultXRActions.FindAction("Head/Tracking State");

LeftHandPosition = AssetManager.TrackingActions.FindAction("Left/Position");
LeftHandRotation = AssetManager.TrackingActions.FindAction("Left/Rotation");
LeftHandTrackingState = AssetManager.TrackingActions.FindAction("Left/Tracking State");
LeftHandPosition = AssetManager.DefaultXRActions.FindAction("Left/Position");
LeftHandRotation = AssetManager.DefaultXRActions.FindAction("Left/Rotation");
LeftHandTrackingState = AssetManager.DefaultXRActions.FindAction("Left/Tracking State");

RightHandPosition = AssetManager.TrackingActions.FindAction("Right/Position");
RightHandRotation = AssetManager.TrackingActions.FindAction("Right/Rotation");
RightHandTrackingState = AssetManager.TrackingActions.FindAction("Right/Tracking State");
RightHandPosition = AssetManager.DefaultXRActions.FindAction("Right/Position");
RightHandRotation = AssetManager.DefaultXRActions.FindAction("Right/Rotation");
RightHandTrackingState = AssetManager.DefaultXRActions.FindAction("Right/Tracking State");
}

public InputAction this[string name] => IngamePlayerSettings.Instance.playerInput.actions[name];
Expand Down
3 changes: 3 additions & 0 deletions Source/Items/VRManeaterBaby.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ private IEnumerator KeepRockingHard()

protected override void OnUpdate()
{
if (!IsLocal)
return;

shake.Update();
shakeBig.Update();
}
Expand Down
3 changes: 3 additions & 0 deletions Source/Items/VRSprayPaintItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ private void OnShakeMotion()

protected override void OnUpdate()
{
if (!IsLocal)
return;

shake.Update();
}
}
1 change: 1 addition & 0 deletions Source/Networking/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public void SendPacket(byte[] packet)
else
bw.Write(false);

bw.Write((uint)packet.Length);
bw.Write(packet);

network.BroadcastPacket(NetworkSystem.MessageType.Channel, mem.ToArray());
Expand Down
4 changes: 2 additions & 2 deletions Source/Networking/NetworkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ private void HandleChannelMessage(ushort sender, BinaryReader reader)
if (!channels.TryGetValue(type, out var channelList))
return;

var data = reader.ReadBytes(int.MaxValue);

var data = reader.ReadBytes((int)reader.ReadUInt32());
if (instanceId.HasValue)
channelList.Where(channel => channel.InstanceId == instanceId.Value)
.Do(channel =>
Expand Down
3 changes: 3 additions & 0 deletions Source/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ private bool InitializeVR()
ScalableSettingSchemaId.With3Levels);

asset.currentPlatformRenderPipelineSettings = settings;

// Input settings
InputSystem.settings.defaultButtonPressPoint = Config.ButtonPressPoint.Value;

return true;
}
Expand Down
3 changes: 3 additions & 0 deletions Source/UI/Settings/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using LCVR.Player;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.UI;
Expand Down Expand Up @@ -288,6 +289,8 @@ public void ConfirmSettings()

asset.currentPlatformRenderPipelineSettings = settings;

InputSystem.settings.defaultButtonPressPoint = Plugin.Config.ButtonPressPoint.Value;

#endregion
}
}
22 changes: 11 additions & 11 deletions Source/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,26 +145,26 @@ private static void AddActionBasedControllerBinds(this ActionBasedController con
controller.trackingStateAction = new InputActionProperty(hand.TrackingState());

controller.enableInputActions = actionsEnabled;
controller.selectAction = new InputActionProperty(AssetManager.TrackingActions.FindAction($"{hand}/Select"));
controller.selectAction = new InputActionProperty(AssetManager.DefaultXRActions.FindAction($"{hand}/Select"));
controller.selectActionValue =
new InputActionProperty(AssetManager.TrackingActions.FindAction($"{hand}/Select Value"));
new InputActionProperty(AssetManager.DefaultXRActions.FindAction($"{hand}/Select Value"));
controller.activateAction =
new InputActionProperty(AssetManager.TrackingActions.FindAction($"{hand}/Activate"));
new InputActionProperty(AssetManager.DefaultXRActions.FindAction($"{hand}/Activate"));
controller.activateActionValue =
new InputActionProperty(AssetManager.TrackingActions.FindAction($"{hand}/Activate Value"));
controller.uiPressAction = new InputActionProperty(AssetManager.TrackingActions.FindAction($"{hand}/UI Press"));
new InputActionProperty(AssetManager.DefaultXRActions.FindAction($"{hand}/Activate Value"));
controller.uiPressAction = new InputActionProperty(AssetManager.DefaultXRActions.FindAction($"{hand}/UI Press"));
controller.uiPressActionValue =
new InputActionProperty(AssetManager.TrackingActions.FindAction($"{hand}/UI Press Value"));
new InputActionProperty(AssetManager.DefaultXRActions.FindAction($"{hand}/UI Press Value"));
controller.uiScrollAction =
new InputActionProperty(AssetManager.TrackingActions.FindAction($"{hand}/UI Scroll"));
new InputActionProperty(AssetManager.DefaultXRActions.FindAction($"{hand}/UI Scroll"));
controller.rotateAnchorAction =
new InputActionProperty(AssetManager.TrackingActions.FindAction($"{hand}/Rotate Anchor"));
new InputActionProperty(AssetManager.DefaultXRActions.FindAction($"{hand}/Rotate Anchor"));
controller.translateAnchorAction =
new InputActionProperty(AssetManager.TrackingActions.FindAction($"{hand}/Translate Anchor"));
new InputActionProperty(AssetManager.DefaultXRActions.FindAction($"{hand}/Translate Anchor"));
controller.scaleToggleAction =
new InputActionProperty(AssetManager.TrackingActions.FindAction($"{hand}/Scale Toggle"));
new InputActionProperty(AssetManager.DefaultXRActions.FindAction($"{hand}/Scale Toggle"));
controller.scaleDeltaAction =
new InputActionProperty(AssetManager.TrackingActions.FindAction($"{hand}/Scale Delta"));
new InputActionProperty(AssetManager.DefaultXRActions.FindAction($"{hand}/Scale Delta"));
}

public static bool Raycast(this Ray ray, out RaycastHit hit, float maxDistance = Mathf.Infinity,
Expand Down

0 comments on commit c8dd877

Please sign in to comment.