Skip to content

Commit

Permalink
Fix race condition on item interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
DaXcess committed Jan 22, 2024
1 parent b56335d commit d3bc3c7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
9 changes: 5 additions & 4 deletions Experiments/Experiments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ public static void RunExperiments()
ShowMeTheMoney(10000);
// SpawnBuyableItem<JetpackItem>("Jetpack");
// SpawnBuyableItem<SprayPaintItem>("Spray paint");
SpawnBuyableItem<FlashlightItem>("Flashlight");
SpawnBuyableItem<FlashlightItem>("Pro-flashlight");
// SpawnBuyableItem<FlashlightItem>("Flashlight");
// SpawnBuyableItem<FlashlightItem>("Pro-flashlight");
// SpawnBuyableItem<StunGrenadeItem>("Stun grenade");
SpawnBuyableItem<PatcherTool>("Zap gun");
// SpawnBuyableItem<PatcherTool>("Zap gun");
SpawnBuyableItem<WalkieTalkie>("Walkie-talkie");

SpawnNonBuyableItem(["Laser pointer"]);
// SpawnNonBuyableItem(["Laser pointer"]);
}

private static void SpawnShotgun()
Expand Down
2 changes: 1 addition & 1 deletion Items/VRShovelItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private void ReelUpShovel()
if (!CanUseItem())
return;

if (Time.realtimeSinceStartup - lastActionTime < 0.5f)
if (Time.realtimeSinceStartup - lastActionTime < 1f)
return;

lastActionTime = Time.realtimeSinceStartup;
Expand Down
10 changes: 5 additions & 5 deletions Networking/DNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,11 @@ public static Fingers Deserialize(byte[] raw)

var fingers = new Fingers
{
thumb = ((float)br.ReadByte()) / 255f,
index = ((float)br.ReadByte()) / 255f,
middle = ((float)br.ReadByte()) / 255f,
pinky = ((float)br.ReadByte()) / 255f,
ring = ((float)br.ReadByte()) / 255f,
thumb = br.ReadByte() / 255f,
index = br.ReadByte() / 255f,
middle = br.ReadByte() / 255f,
pinky = br.ReadByte() / 255f,
ring = br.ReadByte() / 255f,
};

return fingers;
Expand Down
4 changes: 4 additions & 0 deletions Player/Items.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public static void UpdateVRControlsItemsOffsets()
{
foreach (var item in StartOfRound.Instance.allItemsList.itemsList)
{
#if DEBUG
item.canBeGrabbedBeforeGameStart = true;
#endif

if (item.itemName == "Chemical Jug")
{
item.positionOffset = new Vector3(-0.1f, 0.18f, -0.24f);
Expand Down
6 changes: 1 addition & 5 deletions Player/VRController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private void OnDestroy()
public void Initialize(VRPlayer player)
{
this.player = player;
this.playerController = player.gameObject.GetComponent<PlayerControllerB>();
playerController = player.gameObject.GetComponent<PlayerControllerB>();

var interactOriginObject = new GameObject("Raycast Origin");

Expand Down Expand Up @@ -117,14 +117,10 @@ private void OnInteractPerformed(InputAction.CallbackContext context)
if (playerController.isPlayerDead)
{
if (StartOfRound.Instance.overrideSpectateCamera)
{
return;
}

if (playerController.spectatedPlayerScript != null && !playerController.spectatedPlayerScript.isPlayerDead)
{
InvokeAction("SpectateNextPlayer");
}

return;
}
Expand Down
Binary file modified Resources/lethalcompanyvr
Binary file not shown.

0 comments on commit d3bc3c7

Please sign in to comment.