Skip to content

Commit

Permalink
Merge pull request #273 from DaXcess/dev
Browse files Browse the repository at this point in the history
Update LCVR to 1.3.5
  • Loading branch information
DaXcess authored Oct 26, 2024
2 parents 6e0499f + a3fa0c9 commit 10295be
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 81 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 1.3.5

**Additions**:
- Added support for V66

**Compatibility**:
- Fixed compatibility with MoreCompany 1.10.2
- Removed Spin Drag functionality for MoreCompany in LCVR, as it was already broken for a long time

# 1.3.4

**Changes**:
Expand Down
6 changes: 3 additions & 3 deletions 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.4</Version>
<Version>1.3.5</Version>
<Authors>DaXcess</Authors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>12.0</LangVersion>
Expand Down Expand Up @@ -37,9 +37,9 @@
<PackageReference Include="CullFactory" Version="1.0.4" />
<PackageReference Include="DissonanceVoip" Version="1.50.0-lc.1" />
<PackageReference Include="Diversity" Version="2.0.3" />
<PackageReference Include="LethalCompany" Version="1.64.0-beta.1" />
<PackageReference Include="LethalCompany" Version="1.66.0" />
<PackageReference Include="Mimics" Version="2.4.1" />
<PackageReference Include="MoreCompany" Version="1.8.1" />
<PackageReference Include="MoreCompany" Version="1.10.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Unity.Animation.Rigging" Version="1.2.1" />
<PackageReference Include="Unity.InputSystem" Version="1.7.0" />
Expand Down
14 changes: 11 additions & 3 deletions Source/Compatibility/MoreCompany/MoreCompanyCompatibility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace LCVR.Compatibility.MoreCompany;

internal static class MoreCompanyCompatibility
{
public static void SetupMoreCompanyUI()
public static void SetupMoreCompanyUIMainMenu()
{
var overlay = GameObject.Find("TestOverlay(Clone)");
var menuContainer = GameObject.Find("MenuContainer");
Expand All @@ -19,8 +19,16 @@ public static void SetupMoreCompanyUI()
canvasUi.transform.localScale = Vector3.one;

var activateButton = canvasUi.Find("ActivateButton");
activateButton.transform.localPosition = new Vector3(activateButton.transform.localPosition.x, activateButton.transform.localPosition.y, 90);
activateButton.transform.localPosition = new Vector3(activateButton.transform.localPosition.x,
activateButton.transform.localPosition.y, 90);

overlay.Find("CanvasCam").SetActive(false);
}
}

public static void SetupMoreCompanyUIInGame()
{
var canvasUi = GameObject.Find("Systems/UI/Canvas/GlobalScale");

canvasUi.transform.localPosition = new Vector3(0, 0, -90);
}
}
77 changes: 4 additions & 73 deletions Source/Compatibility/MoreCompany/Patches.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using HarmonyLib;
using LCVR.Patches;
using MoreCompany.Behaviors;
using MoreCompany.Cosmetics;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.XR.Interaction.Toolkit;

namespace LCVR.Compatibility.MoreCompany;

Expand All @@ -13,78 +9,13 @@ namespace LCVR.Compatibility.MoreCompany;
internal static class MoreCompanyUIPatches
{
/// <summary>
/// Not too sure why this was needed, probably had to do with me moving the UI around in the GameObject hierarchy
/// Yeah... I'm completely lost on this one
/// </summary>
[HarmonyPatch(typeof(CosmeticRegistry), nameof(CosmeticRegistry.UpdateCosmeticsOnDisplayGuy))]
[HarmonyPostfix]
private static void AfterUpdateCosmetics()
{
CosmeticRegistry.cosmeticApplication.spawnedCosmetics.Do(cosmetic => cosmetic.transform.localScale *= 0.5f);
CosmeticRegistry.displayGuyCosmeticApplication.spawnedCosmetics.Do(cosmetic =>
cosmetic.transform.localScale *= CosmeticRegistry.menuIsInGame ? 2.15f : 0.5f);
}

// Spin dragger patches
private static int pointer = -1;
private static XRRayInteractor leftInteractor;
private static XRRayInteractor rightInteractor;
private static Vector2 lastRayPosition = Vector2.zero;
private static Vector3 rotationalVelocity = Vector3.zero;

[HarmonyPatch(typeof(SpinDragger), nameof(SpinDragger.Update))]
[HarmonyPrefix]
private static bool UpdateSpinDragger(SpinDragger __instance)
{
if (pointer != -1)
{
var position = Vector2.zero;

var interactor = (pointer == 1 ? rightInteractor : leftInteractor);
if (interactor.TryGetCurrentUIRaycastResult(out var res))
position = res.screenPosition;

var delta = position - lastRayPosition;
rotationalVelocity = new Vector3(0, -delta.x, 0) * __instance.dragSpeed;
lastRayPosition = position;
}

rotationalVelocity *= __instance.airDrag;

__instance.target.transform.Rotate(rotationalVelocity * Time.deltaTime * __instance.speed, Space.World);

return false;
}

[HarmonyPatch(typeof(SpinDragger), nameof(SpinDragger.OnPointerDown))]
[HarmonyPrefix]
private static bool OnPointerDown(SpinDragger __instance, PointerEventData eventData)
{
__instance.dragSpeed = 10;

leftInteractor = GameObject.Find("Left Controller").GetComponent<XRRayInteractor>();
rightInteractor = GameObject.Find("Right Controller").GetComponent<XRRayInteractor>();

pointer = eventData.pointerId;

if (pointer != 1 && pointer != 2)
{
pointer = -1;
return false;
}

var interactor = (pointer == 1 ? rightInteractor : leftInteractor);
if (interactor.TryGetCurrentUIRaycastResult(out var res))
lastRayPosition = res.screenPosition;
else
lastRayPosition = Vector2.zero;

return false;
}

[HarmonyPatch(typeof(SpinDragger), nameof(SpinDragger.OnPointerUp))]
[HarmonyPrefix]
private static bool OnPointerUp()
{
pointer = -1;

return false;
}
}
}
2 changes: 1 addition & 1 deletion Source/Patches/UIPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private static void OnMainMenuShown(MenuManager __instance)
InitMenuScene(canvas);

if (Compat.IsLoaded(Compat.MoreCompany))
Compatibility.MoreCompany.MoreCompanyCompatibility.SetupMoreCompanyUI();
Compatibility.MoreCompany.MoreCompanyCompatibility.SetupMoreCompanyUIMainMenu();

if (__instance.isInitScene)
return;
Expand Down
3 changes: 2 additions & 1 deletion Source/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Plugin : BaseUnityPlugin
{
public const string PLUGIN_GUID = "io.daxcess.lcvr";
public const string PLUGIN_NAME = "LCVR";
public const string PLUGIN_VERSION = "1.3.4";
public const string PLUGIN_VERSION = "1.3.5";

#if DEBUG
private const string SKIP_CHECKSUM_VAR = $"--lcvr-skip-checksum={PLUGIN_VERSION}-dev";
Expand All @@ -37,6 +37,7 @@ public class Plugin : BaseUnityPlugin
[
"BFF45683C267F402429049EF7D8095C078D5CD534E5300E56317ACB6056D70FB", // V64
"A6BDE2EB39028B36CB1667DCFB4ED10F688FB3FF72E71491AC25C5CB47A7EF6C", // V64.1
"B0BC7D3392FDAD3BB6515C0769363A51FF3599E67325FAE153948E0B82EB7596", // V66
];

public new static Config Config { get; private set; }
Expand Down
4 changes: 4 additions & 0 deletions Source/UI/VRHUD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ private void Awake()

// Set up belt bag UI
FindObjectOfType<BeltBagInventoryUI>(true).gameObject.AddComponent<BeltBagUI>();

// MoreCompany compatibility
if (Compat.IsLoaded(Compat.MoreCompany))
Compatibility.MoreCompany.MoreCompanyCompatibility.SetupMoreCompanyUIInGame();
}

private static void MoveToFront(Component component)
Expand Down

0 comments on commit 10295be

Please sign in to comment.