Skip to content

Commit

Permalink
1.2.2 patch
Browse files Browse the repository at this point in the history
- Updated CHANGELOG.md
- Fixed VR players not sinking (visual)
- Fixed spectator underwater filter issues
  • Loading branch information
DaXcess committed Apr 17, 2024
1 parent fade407 commit c7f3127
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 13 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# 1.2.2

**Game Version**:
- Added compatibility with V50 Patch 1

**Bug Fixes**:
- Fixed visual glitch where VR players would not appear to be sinking in mud

**Mod Compatibility**:
- Fixed lighting culling issues when CullFactory is installed

# 1.2.1

### V50 IS HERE
Expand Down
27 changes: 14 additions & 13 deletions Source/Networking/VRNetPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ public class VRNetPlayer : MonoBehaviour
{
private ChainIKConstraintData originalLeftArmConstraintData;
private ChainIKConstraintData originalRightArmConstraintData;

private GameObject playerGhost;
private Transform usernameBillboard;
private CanvasGroup usernameAlpha;
private TextMeshProUGUI usernameText;

private bool spectatorWasParentedToShip;

private Transform xrOrigin;
private Transform leftController;
private Transform rightController;
Expand All @@ -46,7 +46,7 @@ public class VRNetPlayer : MonoBehaviour

public PlayerControllerB PlayerController { get; private set; }
public Bones Bones { get; private set; }

public Transform LeftItemHolder { get; private set; }
public Transform RightItemHolder { get; private set; }

Expand Down Expand Up @@ -111,20 +111,20 @@ private void Awake()
usernameAlpha = playerGhost.GetComponentInChildren<CanvasGroup>();

playerGhost.GetComponentInChildren<SpectatorGhost>().player = this;

// Disable rendering ghost until player dies
foreach (var renderer in playerGhost.GetComponentsInChildren<MeshRenderer>())
{
renderer.enabled = false;
}

// Set username text
if (PlayerController.playerSteamId is 76561198438308784 or 76561199575858981)
{
usernameText.color = new Color(0, 1, 1, 1);
usernameText.fontStyle = FontStyles.Bold;
}

usernameText.text = $"<noparse>{PlayerController.playerUsername}</noparse>";
}

Expand Down Expand Up @@ -195,7 +195,8 @@ private void Update()
transform.position.z + (modelOffset.z * 1.5f) - (cameraPosAccounted.z * 1.5f)
);

Bones.Model.localPosition = transform.InverseTransformPoint(transform.position + modelOffset);
Bones.Model.localPosition = transform.InverseTransformPoint(transform.position + modelOffset) +
Vector3.down * (2.5f * PlayerController.sinkingValue);
}
else
{
Expand Down Expand Up @@ -236,7 +237,7 @@ private void LateUpdate()
{
rightFingerCurler?.Update();
}

// Rotate spectator username billboard
if (StartOfRound.Instance.localPlayerController.localVisorTargetPoint is not null)
{
Expand Down Expand Up @@ -265,7 +266,7 @@ public void HideSpectatorGhost()
{
renderer.enabled = false;
}

usernameAlpha.alpha = 0f;
}

Expand All @@ -279,7 +280,7 @@ public void ShowSpectatorNameBillboard()

usernameAlpha.alpha = 1f;
}

internal void UpdateTargetTransforms(DNet.Rig rig)
{
leftController.localPosition = rig.leftHandPosition;
Expand Down Expand Up @@ -321,7 +322,7 @@ internal void UpdateSpectatorTransforms(DNet.SpectatorRig rig)
}

spectatorWasParentedToShip = rig.parentedToShip;

head.localPosition = rig.headPosition;
head.eulerAngles = rig.headRotation;

Expand All @@ -343,7 +344,7 @@ internal void UpdateSpectatorTransforms(DNet.SpectatorRig rig)
void OnDestroy()
{
Destroy(playerGhost);

Bones.ResetToPrefabPositions();

Destroy(Bones.LeftArmRig.GetComponent<TwoBoneIKConstraint>());
Expand All @@ -357,4 +358,4 @@ void OnDestroy()

GetComponentInChildren<RigBuilder>().Build();
}
}
}
39 changes: 39 additions & 0 deletions Source/Patches/Spectating/EnvironmentPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,43 @@ private static bool PreventTeleportDeadPlayer(ShipTeleporter __instance, ref IEn
__result = Utils.NopRoutine();
return false;
}

/// <summary>
/// Prevent the spectator camera (which is not used) from triggering the underwater filter
/// </summary>
[HarmonyPatch(typeof(HUDManager), nameof(HUDManager.UnderwaterScreenFilters))]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> SpectatorCamDontTriggerWater(IEnumerable<CodeInstruction> instructions)
{
return new CodeMatcher(instructions)
.MatchForward(false, [new CodeMatch(OpCodes.Ldc_I4_1)])
.SetOpcodeAndAdvance(OpCodes.Ldc_I4_0)
.InstructionEnumeration();
}

/// <summary>
/// Allow dead players to still experience the underwater filter
/// </summary>
[HarmonyPatch(typeof(PlayerControllerB), nameof(PlayerControllerB.SetFaceUnderwaterFilters))]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> EnableDeadPlayerUnderwater(IEnumerable<CodeInstruction> instructions)
{
return new CodeMatcher(instructions)
.Advance(1)
.RemoveInstructions(4)
.InstructionEnumeration();
}

/// <summary>
/// Prevent dead players from dying again if they are underwater as a spectator
/// </summary>
[HarmonyPatch(typeof(PlayerControllerB), nameof(PlayerControllerB.SetFaceUnderwaterFilters))]
[HarmonyPostfix]
private static void UnderwaterPreventDeath(PlayerControllerB __instance)
{
if (!__instance.isPlayerDead)
return;

StartOfRound.Instance.drowningTimer = 1;
}
}

0 comments on commit c7f3127

Please sign in to comment.