Skip to content

Commit

Permalink
Merge pull request #238 from DaXcess/dev
Browse files Browse the repository at this point in the history
Merge hotfix 1.2.3
  • Loading branch information
DaXcess authored May 12, 2024
2 parents 8b14d6d + a3a4682 commit 1722f98
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 27 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# 1.2.3

**Bug Fixes**:
- Fixed issues with enemy collision that was causing error spam and potential other issues
- Changed the way `VerifyGameVersion` finds the game assembly, fixing some mod compatibility issues

**Additions**:
- Added configuration option to disable the settings button on the main menu

**Development Changes**:
- Added debug symbols in the assembly output if the mod is compiled in debug, which helps with tracking down errors

# 1.2.2

**Game Version**:
Expand Down
6 changes: 5 additions & 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.2.2</Version>
<Version>1.2.3</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>12.0</LangVersion>
<Title>LethalCompanyVR</Title>
Expand All @@ -19,6 +19,10 @@
<DebugType>none</DebugType>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugType>embedded</DebugType>
</PropertyGroup>

<ItemGroup>
<Compile Remove="ThirdParty\**" />
<EmbeddedResource Remove="ThirdParty\**" />
Expand Down
4 changes: 3 additions & 1 deletion Source/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public class Config(ConfigFile file)

public ConfigEntry<string> LastInternalControllerProfile { get; } = file.Bind("Internal", "LastInternalControllerProfile", "", "FOR INTERNAL USE ONLY, DO NOT EDIT");
public ConfigEntry<string> OpenXRRuntimeFile { get; } = file.Bind("Internal", "OpenXRRuntimeFile", "", "FOR INTERNAL USE ONLY, DO NOT EDIT");

public ConfigEntry<bool> DisableSettingsButton { get; } = file.Bind("Internal", "DisableSettingsButton", false,
"Disables the settings button on the main menu screen");

public enum TurnProviderOption
{
Snap,
Expand Down
44 changes: 27 additions & 17 deletions Source/Input/FingerCurler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public class Thumb(Transform root, Vector3 firstRotation, Vector3 secondRotation

public float curl;

private readonly Quaternion bone01Rotation = Quaternion.AngleAxis(-30f, Vector3.right) * Quaternion.Euler(firstRotation);
private readonly Quaternion bone01Rotation =
Quaternion.AngleAxis(-30f, Vector3.right) * Quaternion.Euler(firstRotation);

private readonly Quaternion bone02Rotation = Quaternion.Euler(secondRotation);

public void Update()
Expand All @@ -46,29 +48,37 @@ public void Update()
}
}

public Thumb thumbFinger;
public Finger indexFinger;
public Finger middleFinger;
public Finger ringFinger;
public Finger pinkyFinger;
public readonly Thumb thumbFinger;
public readonly Finger indexFinger;
public readonly Finger middleFinger;
public readonly Finger ringFinger;
public readonly Finger pinkyFinger;

public FingerCurler(Transform hand, bool isLeft)
{
if (isLeft)
{
thumbFinger = new Thumb(hand.Find($"finger1.L"), new Vector3(35f, -90f, 0f), new Vector3(-25f, 0f, 3f));
indexFinger = new Finger(hand.Find($"finger2.L"), isLeft, new Vector3(5f, -90f, 0f), new Vector3(3f, -3f, 33f));
middleFinger = new Finger(hand.Find($"finger3.L"), isLeft, new Vector3(-182f, 90f, -176f), new Vector3(1f, -5f, 22f));
ringFinger = new Finger(hand.Find($"finger4.L"), isLeft, new Vector3(186f, 90f, 177f), new Vector3(6f, -3f, 29f));
pinkyFinger = new Finger(hand.Find($"finger5.L"), isLeft, new Vector3(183f, 80f, 176f), new Vector3(-17f, 8f, 27f));
thumbFinger = new Thumb(hand.Find("finger1.L"), new Vector3(35f, -90f, 0f), new Vector3(-25f, 0f, 3f));
indexFinger = new Finger(hand.Find("finger2.L"), true, new Vector3(5f, -90f, 0f),
new Vector3(3f, -3f, 33f));
middleFinger = new Finger(hand.Find("finger3.L"), true, new Vector3(-182f, 90f, -176f),
new Vector3(1f, -5f, 22f));
ringFinger = new Finger(hand.Find("finger4.L"), true, new Vector3(186f, 90f, 177f),
new Vector3(6f, -3f, 29f));
pinkyFinger = new Finger(hand.Find("finger5.L"), true, new Vector3(183f, 80f, 176f),
new Vector3(-17f, 8f, 27f));
}
else
{
thumbFinger = new Thumb(hand.Find($"finger1.R"), new Vector3(143f, -90f, -180f), new Vector3(-26f, 0f, -5f));
indexFinger = new Finger(hand.Find($"finger2.R"), isLeft, new Vector3(-193f, -90f, 176f), new Vector3(-9f, 0f, -21f));
middleFinger = new Finger(hand.Find($"finger3.R"), isLeft, new Vector3(-186f, -90f, 180f), new Vector3(-6f, 0f, -24f));
ringFinger = new Finger(hand.Find($"finger4.R"), isLeft, new Vector3(180f, -90f, -177f), new Vector3(-9f, 0f, -25f));
pinkyFinger = new Finger(hand.Find($"finger5.R"), isLeft, new Vector3(182f, -90f, -168f), new Vector3(-13f, 3f, -33f));
thumbFinger = new Thumb(hand.Find("finger1.R"), new Vector3(143f, -90f, -180f), new Vector3(-26f, 0f, -5f));
indexFinger = new Finger(hand.Find("finger2.R"), false, new Vector3(-193f, -90f, 176f),
new Vector3(-9f, 0f, -21f));
middleFinger = new Finger(hand.Find("finger3.R"), false, new Vector3(-186f, -90f, 180f),
new Vector3(-6f, 0f, -24f));
ringFinger = new Finger(hand.Find("finger4.R"), false, new Vector3(180f, -90f, -177f),
new Vector3(-9f, 0f, -25f));
pinkyFinger = new Finger(hand.Find("finger5.R"), false, new Vector3(182f, -90f, -168f),
new Vector3(-13f, 3f, -33f));
}
}

Expand Down Expand Up @@ -158,4 +168,4 @@ public void ForceFist(bool enabled)
{
forceFist = enabled;
}
}
}
14 changes: 9 additions & 5 deletions Source/Patches/Spectating/AIPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,23 @@ private static IEnumerable<CodeInstruction> LineOfSightClosestPlayerIgnoreDeadPl
/// <summary>
/// Prevent collision detection on dead players
/// </summary>
[HarmonyPatch(typeof(EnemyAICollisionDetect), "OnTriggerStay")]
[HarmonyPatch(typeof(EnemyAICollisionDetect), nameof(EnemyAICollisionDetect.OnTriggerStay))]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> OnCollidePlayerTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
return new CodeMatcher(instructions, generator)
.MatchForward(false, new CodeMatch(OpCodes.Brfalse))
.Advance(1)
.InsertAndAdvance(new CodeInstruction(OpCodes.Ldarg_1))
.InsertAndAdvance(new CodeInstruction(OpCodes.Callvirt, PropertyGetter(typeof(Component), nameof(Component.gameObject))))
.InsertAndAdvance(new CodeInstruction(OpCodes.Callvirt, Method(typeof(GameObject), nameof(GameObject.GetComponent)).MakeGenericMethod([typeof(PlayerControllerB)])))
.InsertAndAdvance(new CodeInstruction(OpCodes.Ldfld, Field(typeof(PlayerControllerB), nameof(PlayerControllerB.isPlayerDead))))
.InsertBranchAndAdvance(OpCodes.Brfalse_S, 8)
.InsertAndAdvance(new CodeInstruction(OpCodes.Call, Method(typeof(SpectatorAIPatches), nameof(IsPlayerDead))))
.InsertBranchAndAdvance(OpCodes.Brfalse_S, 6)
.InsertAndAdvance(new CodeInstruction(OpCodes.Ret))
.InstructionEnumeration();
}

private static bool IsPlayerDead(Component other)
{
var player = other.GetComponent<PlayerControllerB>();
return player && player.isPlayerDead;
}
}
3 changes: 3 additions & 0 deletions Source/Patches/UIPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ private static void OnMainMenuShown(MenuManager __instance)

private static void InjectSettingsScreen()
{
if (Plugin.Config.DisableSettingsButton.Value)
return;

// Add button to main menu
var container = GameObject.Find("Canvas/MenuContainer");
var mainButtons = container.Find("MainButtons");
Expand Down
3 changes: 2 additions & 1 deletion Source/Player/VRPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ private void Update()

var rotationOffset = playerController.jetpackControls switch
{
true => Quaternion.Euler(playerController.jetpackTurnCompass.eulerAngles.x, TurningProvider.GetRotationOffset(), playerController.jetpackTurnCompass.eulerAngles.z),
true => Quaternion.Euler(playerController.jetpackTurnCompass.eulerAngles.x,
TurningProvider.GetRotationOffset(), playerController.jetpackTurnCompass.eulerAngles.z),
false => Quaternion.Euler(0, TurningProvider.GetRotationOffset(), 0)
};

Expand Down
4 changes: 2 additions & 2 deletions Source/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,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.2.2";
public const string PLUGIN_VERSION = "1.2.3";

private readonly string[] GAME_ASSEMBLY_HASHES = [
"7CFABBA203022CC46EF309B0E651276CB59217AF6D38C34E2085E67957DBBCBD", // V50
Expand Down Expand Up @@ -139,7 +139,7 @@ private void Awake()

private bool VerifyGameVersion()
{
var location = typeof(PlayerControllerB).Assembly.Location;
var location = Path.Combine(Paths.ManagedPath, "Assembly-CSharp.dll");
var shasum = BitConverter.ToString(Utils.ComputeHash(File.ReadAllBytes(location))).Replace("-", "");

return GAME_ASSEMBLY_HASHES.Contains(shasum);
Expand Down

0 comments on commit 1722f98

Please sign in to comment.