Skip to content

Commit

Permalink
Apply turn provider rotations to player instantly
Browse files Browse the repository at this point in the history
  • Loading branch information
DaXcess committed Sep 23, 2024
1 parent 3416f9a commit 8d75508
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Here is a list of LCVR versions and which version(s) of Lethal Company it suppor

| LCVR | Lethal Company |
|-------------------|-------------------|
| v1.3.4 *(BETA)* | V64 and V64.1 |
| v1.3.3 *(LATEST)* | V64 and V64.1 |
| v1.3.2 | V64 |
| v1.3.1 | V62 |
Expand Down
6 changes: 4 additions & 2 deletions Source/Input/SmoothTurningProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ internal class SmoothTurningProvider : TurningProvider
{
private float offset;

public void Update()
public float Update()
{
var value = Actions.Instance["Turn"].ReadValue<float>();
var shouldExecute = MathF.Abs(value) > 0.75;

if (!shouldExecute)
return;
return 0;

var totalRotation = (value > 0 ? 180 : -180) * Time.deltaTime * Plugin.Config.SmoothTurnSpeedModifier.Value;

offset += totalRotation;

return totalRotation;
}

public void SetOffset(float offset)
Expand Down
17 changes: 10 additions & 7 deletions Source/Input/SnapTurningProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,26 @@ internal class SnapTurningProvider : TurningProvider
private bool turnedLastInput;
private float offset;

public void Update()
public float Update()
{
var value = Actions.Instance["Turn"].ReadValue<float>();
var shouldExecute = MathF.Abs(value) > 0.75;

if (shouldExecute)
{
var turnAmount = Plugin.Config.SnapTurnSize.Value;
if (turnedLastInput) return;
if (turnedLastInput) return 0;

turnAmount = value > 0 ? turnAmount : -turnAmount;
turnedLastInput = true;
offset += value > 0 ? turnAmount : -turnAmount;
}
else
{
turnedLastInput = false;
offset += turnAmount;

return turnAmount;
}

turnedLastInput = false;

return 0;
}

public void SetOffset(float offset)
Expand Down
5 changes: 3 additions & 2 deletions Source/Input/TurningProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public interface TurningProvider
{
void Update();
float Update();

void SetOffset(float offset);

Expand All @@ -20,7 +20,8 @@ public void SetOffset(float _)
{
}

public void Update()
public float Update()
{
return 0;
}
}
2 changes: 1 addition & 1 deletion Source/Player/VRPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ PlayerController.currentTriggerInAnimationWith is not null &&

// Update rotation offset after adding movement from frame (if not in build mode)
if (!ShipBuildModeManager.Instance.InBuildMode && !PlayerController.inSpecialInteractAnimation)
TurningProvider.Update();
transform.localEulerAngles += TurningProvider.Update() * Vector3.up;

// If we are in special animation allow 6 DOF but don't update player position
if (!PlayerController.inSpecialInteractAnimation)
Expand Down

0 comments on commit 8d75508

Please sign in to comment.