Skip to content

Commit

Permalink
Update LCVR to v1.3.4
Browse files Browse the repository at this point in the history
Update LCVR to v1.3.4
  • Loading branch information
DaXcess authored Sep 29, 2024
2 parents 685600d + 406f909 commit 6e0499f
Show file tree
Hide file tree
Showing 20 changed files with 307 additions and 186 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 1.3.4

**Changes**:
- Stick-turning will now instantly apply rotation to the player body
- Improved tracking accuracy for remote VR players
- Removed car ownership patches, which potentially fixes the car exploding at random times

**Bug fixes**:
- Fixed player head rotation being applied in the wrong order
- Fixed CullFactory breaking item rendering when traversing an entrance
- Fixed a crash when leaving the game while on top of a car (?)
- Fixed snap points not working for remote VR players
- Fix item holding offset on the Zed Dog item

# 1.3.3

**Additions**:
Expand Down
3 changes: 2 additions & 1 deletion Docs/Thunderstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ Here is a list of LCVR versions and which version(s) of Lethal Company it suppor

| LCVR | Lethal Company |
|-------------------|-------------------|
| v1.3.3 *(LATEST)* | V64 and V64.1 |
| v1.3.4 *(LATEST)* | V64 and V64.1 |
| v1.3.3 | V64 and V64.1 |
| v1.3.2 | V64 |
| v1.3.1 | V62 |
| v1.3.0 | V56 |
Expand Down
2 changes: 1 addition & 1 deletion LCVR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.1</TargetFramework>
<AssemblyName>LCVR</AssemblyName>
<Description>Collecting Scrap in VR</Description>
<Version>1.3.3</Version>
<Version>1.3.4</Version>
<Authors>DaXcess</Authors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>12.0</LangVersion>
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ Here is a list of LCVR versions and which version(s) of Lethal Company it suppor

| LCVR | Lethal Company |
|-------------------|-------------------|
| v1.3.3 *(LATEST)* | V64 and V64.1 |
| v1.3.4 *(LATEST)* | V64 and V64.1 |
| v1.3.3 | V64 and V64.1 |
| v1.3.2 | V64 |
| v1.3.1 | V62 |
| v1.3.0 | V56 |
Expand Down
35 changes: 35 additions & 0 deletions Source/Compatibility/CullFactory/Patches.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection.Emit;
using CullFactory.Data;
using CullFactory.Extenders;
using GameNetcodeStuff;
using HarmonyLib;
using LCVR.Patches;
using LCVR.Player;
using UnityEngine;
using static HarmonyLib.AccessTools;

namespace LCVR.Compatibility.CullFactory;

Expand All @@ -26,4 +33,32 @@ private static void OnCollectAllPlayerLights()

DynamicObjects.allPlayerLights[clientId] = [..lights, ..cameraLights];
}

/// <summary>
/// Rather interesting patch that delays the player teleport code in CullFactory by a single frame
///
/// Fixes items turning invisible due to CullFactory thinking they're inside/outside the factory whilst we are not
/// </summary>
[HarmonyPatch(typeof(TeleportExtender), nameof(TeleportExtender.OnPlayerTeleported))]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> DelayPlayerTeleport(IEnumerable<CodeInstruction> instructions)
{
return new CodeMatcher(instructions)
.MatchForward(false, new CodeMatch(OpCodes.Call,
Method(typeof(DynamicObjects), nameof(DynamicObjects.OnPlayerTeleported))))
.SetOperandAndAdvance(((Action<PlayerControllerB>)OnPlayerTeleport).Method)
.InstructionEnumeration();

static void OnPlayerTeleport(PlayerControllerB player)
{
StartOfRound.Instance.StartCoroutine(OnPlayerTeleportedCoroutine(player));
}

static IEnumerator OnPlayerTeleportedCoroutine(PlayerControllerB player)
{
yield return null;

DynamicObjects.OnPlayerTeleported(player);
}
}
}
96 changes: 87 additions & 9 deletions Source/Experiments/Experiments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
using LCVR.Patches;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using LCVR.Assets;
using Unity.Netcode;
using UnityEngine;
using static HarmonyLib.AccessTools;

namespace LCVR.Experiments;

Expand Down Expand Up @@ -131,18 +133,94 @@ private static LineRenderer CreateRenderer()
#if DEBUG
[LCVRPatch(LCVRPatchTarget.Universal)]
[HarmonyPatch]
internal static class ExperimentalPatches
internal static class ExperimentalPatches;

/// <summary>
/// All the patches in this class will enable the debug menu in Lethal Company
/// </summary>
[LCVRPatch(LCVRPatchTarget.Universal)]
[HarmonyPatch]
internal static class DebugMenuPatches
{
/// <summary>
/// Enables the game's built in debug mode
/// </summary>
[HarmonyPatch(typeof(Application), nameof(Application.isEditor), MethodType.Getter)]
[HarmonyPrefix]
private static bool DeveloperMode(ref bool __result)
private static IEnumerable<CodeInstruction> PatchIsEditor(IEnumerable<CodeInstruction> instructions)
{
__result = true;
return new CodeMatcher(instructions)
.MatchForward(false,
new CodeMatch(OpCodes.Call, PropertyGetter(typeof(Application), nameof(Application.isEditor))))
.SetOpcodeAndAdvance(OpCodes.Ldc_I4_1)
.InstructionEnumeration();
}

return false;
[HarmonyPatch(typeof(QuickMenuManager), nameof(QuickMenuManager.CanEnableDebugMenu))]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> CanEnableDebugMenu(IEnumerable<CodeInstruction> instructions)
{
return PatchIsEditor(instructions);
}

[HarmonyPatch(typeof(QuickMenuManager), nameof(QuickMenuManager.Debug_KillLocalPlayer))]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Debug_KillLocalPlayer(IEnumerable<CodeInstruction> instructions)
{
return PatchIsEditor(instructions);
}

[HarmonyPatch(typeof(QuickMenuManager), nameof(QuickMenuManager.Debug_SpawnEnemy))]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Debug_SpawnEnemy(IEnumerable<CodeInstruction> instructions)
{
return PatchIsEditor(instructions);
}

[HarmonyPatch(typeof(QuickMenuManager), nameof(QuickMenuManager.Debug_SpawnItem))]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Debug_SpawnItem(IEnumerable<CodeInstruction> instructions)
{
return PatchIsEditor(instructions);
}

[HarmonyPatch(typeof(QuickMenuManager), nameof(QuickMenuManager.Debug_SpawnTruck))]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Debug_SpawnTruck(IEnumerable<CodeInstruction> instructions)
{
return PatchIsEditor(instructions);
}

[HarmonyPatch(typeof(QuickMenuManager), nameof(QuickMenuManager.Debug_ToggleAllowDeath))]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Debug_ToggleAllowDeath(IEnumerable<CodeInstruction> instructions)
{
return PatchIsEditor(instructions);
}

[HarmonyPatch(typeof(QuickMenuManager), nameof(QuickMenuManager.Debug_ToggleTestRoom))]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Debug_ToggleTestRoom(IEnumerable<CodeInstruction> instructions)
{
return PatchIsEditor(instructions);
}

[HarmonyPatch(typeof(StartOfRound), nameof(StartOfRound.Debug_EnableTestRoomServerRpc))]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Debug_EnableTestRoomServerRpc(IEnumerable<CodeInstruction> instructions)
{
return PatchIsEditor(instructions);
}

[HarmonyPatch(typeof(StartOfRound), nameof(StartOfRound.Debug_ReviveAllPlayersServerRpc))]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Debug_ReviveAllPlayersServerRpc(
IEnumerable<CodeInstruction> instructions)
{
return PatchIsEditor(instructions);
}

[HarmonyPatch(typeof(StartOfRound), nameof(StartOfRound.Debug_ToggleAllowDeathServerRpc))]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Debug_ToggleAllowDeathServerRpc(
IEnumerable<CodeInstruction> instructions)
{
return PatchIsEditor(instructions);
}
}
#endif
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/Networking/NetworkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace LCVR.Networking;
public class NetworkSystem : MonoBehaviour
{
/// Protocol Version, increase this every time a change is made that is not compatible with older versions
private const ushort PROTOCOL_VERSION = 7;
private const ushort PROTOCOL_VERSION = 8;

/// Packet size limit to prevent denial-of-service attacks
private const uint PACKET_MAX_SIZE = 4 * 1024;
Expand Down
Loading

0 comments on commit 6e0499f

Please sign in to comment.