Skip to content

Commit

Permalink
Allow picking up non-tool items while holding bag
Browse files Browse the repository at this point in the history
  • Loading branch information
DaXcess committed Sep 9, 2024
1 parent edc4620 commit 7078f04
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions Source/Player/VRController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,8 @@ private void OnInteractPerformed(InputAction.CallbackContext context)
return;

// Handle belt bag item
if (PlayerController.currentlyHeldObjectServer is BeltBagItem bag)
{
BeginBagTool(bag);
if (PlayerController.currentlyHeldObjectServer is BeltBagItem bag && TryBagTool(bag))
return;
}

// Here we try and pickup the item if it's possible
if (!PlayerController.activatingItem && !VRSession.Instance.LocalPlayer.PlayerController.isPlayerDead)
Expand Down Expand Up @@ -373,17 +370,19 @@ private void BeginGrabObject()
GrabItem(hit.collider.transform.gameObject.GetComponent<GrabbableObject>());
}

private void BeginBagTool(BeltBagItem bag)
private bool TryBagTool(BeltBagItem bag)
{
var ray = new Ray(InteractOrigin.position, InteractOrigin.forward);
if (!ray.Raycast(out var hit, 4, 1073742144))
return;
return false;

var item = hit.collider.GetComponent<GrabbableObject>();
if (item == null || item == PlayerController.currentlyHeldObjectServer || !CanBeInsertedIntoBag(item))
return;
return false;

bag.TryAddObjectToBag(item);

return true;
}

public void GrabItem(GrabbableObject item)
Expand Down Expand Up @@ -439,6 +438,6 @@ public void GrabItem(GrabbableObject item)
private static bool CanBeInsertedIntoBag(GrabbableObject item)
{
return !item.itemProperties.isScrap && !item.isHeld && !item.isHeldByEnemy &&
item.itemProperties.itemId != 123984 && item.itemProperties.itemId != 819501;
item.itemProperties.itemId is not (123984 or 819501);
}
}

0 comments on commit 7078f04

Please sign in to comment.