Semi-working Interactables rework

This commit is contained in:
Michal Pikulski
2025-09-10 16:42:43 +02:00
parent 5d81a2acfc
commit 4c8ffbfaf8
15 changed files with 271 additions and 124 deletions

View File

@@ -47,14 +47,13 @@ public class SlotItemBehavior : InteractionRequirementBase
SetSlottedObject(obj);
}
private void RestoreSlottedObject(Vector3 position)
private void RestoreSlottedObject()
{
if (_cachedSlottedObject != null)
{
_cachedSlottedObject.transform.position = position;
_cachedSlottedObject.transform.SetParent(null);
_cachedSlottedObject.SetActive(true);
_cachedSlottedObject = null;
// Do NOT activate or move the object here; it stays hidden until dropped
// Activation is handled by the drop logic elsewhere
}
}
@@ -76,8 +75,10 @@ public class SlotItemBehavior : InteractionRequirementBase
// CASE 1: No held item, slot has item -> pick up slotted item
if (heldItem == null && _cachedSlottedObject != null)
{
// Give the hidden slotted object to the follower (do NOT activate or move it)
RestoreSlottedObject();
follower.SetHeldItemFromObject(_cachedSlottedObject);
RemoveSlottedObject();
_cachedSlottedObject = null;
currentlySlottedItem = null;
UpdateSlottedSprite();
return true;
@@ -95,7 +96,8 @@ public class SlotItemBehavior : InteractionRequirementBase
currentlySlottedItem = followerHeldItem;
UpdateSlottedSprite();
// 2. Give the slot's object to the follower
// 2. Give the slot's object to the follower (do NOT activate or move it)
RestoreSlottedObject();
follower.SetHeldItemFromObject(slotObj);
return true;