|
|
@ -87,8 +87,16 @@ public partial class PickupController : Node3D |
|
|
|
if (!_player.IsLocal) return; |
|
|
|
if (!_player.IsLocal) return; |
|
|
|
EnsureCurrentItemValid(); |
|
|
|
EnsureCurrentItemValid(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool CanPlaceAgainst(Grid grid, Vector3 normal) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
normal = grid.GlobalBasis.Inverse() * normal; |
|
|
|
|
|
|
|
return normal.IsEqualApprox(Vector3.Up); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (HasItemsHeld) { |
|
|
|
if (HasItemsHeld) { |
|
|
|
if ((RayToMouseCursor() is RayResult ray) && (ray.Collider is Grid grid) |
|
|
|
if ((RayToMouseCursor() is RayResult ray) && (ray.Collider is Grid grid) |
|
|
|
|
|
|
|
// Make sure this is placed against the top of the grid. |
|
|
|
|
|
|
|
&& CanPlaceAgainst(grid, ray.Normal) |
|
|
|
// Ensure item is not being added to itself or nested items. |
|
|
|
// Ensure item is not being added to itself or nested items. |
|
|
|
&& !((grid.GetParent() == CurrentItem) || grid.ContainsItem(CurrentItem))) { |
|
|
|
&& !((grid.GetParent() == CurrentItem) || grid.ContainsItem(CurrentItem))) { |
|
|
|
var transform = CurrentItem.GlobalTransform with { Origin = ray.Position }; |
|
|
|
var transform = CurrentItem.GlobalTransform with { Origin = ray.Position }; |
|
|
|