Interactables fully working now

This commit is contained in:
Michal Pikulski
2025-09-10 17:38:03 +02:00
parent 0ef25f265c
commit 3a40d1a151
8 changed files with 101 additions and 109 deletions

View File

@@ -325,7 +325,7 @@ public class FollowerController : Character
if (pickup != null)
{
SetHeldItem(pickup.itemData, pickup.iconRenderer);
CacheHeldPickupObject(obj);
_cachedPickupObject = obj;
}
else
{
@@ -335,11 +335,7 @@ public class FollowerController : Character
public void ClearHeldItem()
{
if (_cachedPickupObject != null)
{
// Destroy(_cachedPickupObject);
_cachedPickupObject = null;
}
_cachedPickupObject = null;
_currentlyHeldItem = null;
if (heldObjectRenderer != null)
{
@@ -348,6 +344,11 @@ public class FollowerController : Character
}
}
public void DropHeldItemAt(Vector3 position)
{
InteractionOrchestrator.Instance.DropItem(this, position);
}
private System.Collections.IEnumerator PickupSequence(Vector2 itemPosition, Transform playerTransform)
{
_isManualFollowing = false;
@@ -376,26 +377,21 @@ public class FollowerController : Character
var slotBehavior = pickup.GetComponent<SlotItemBehavior>();
if (slotBehavior != null)
{
// Slot item: do not destroy or swap, just return to player
// Slot item: orchestrator handles slotting
break;
}
if (justCombined)
{
GameObject.Destroy(pickup.gameObject);
InteractionOrchestrator.Instance.CombineItems(pickup.gameObject, _cachedPickupObject);
justCombined = false;
break;
}
// Swap logic: if holding an item, drop it here
if (_currentlyHeldItem != null && _cachedPickupObject != null)
{
// Drop the cached object at the pickup's position
_cachedPickupObject.transform.position = pickup.transform.position;
_cachedPickupObject.transform.SetParent(null);
_cachedPickupObject.SetActive(true);
_cachedPickupObject = null;
InteractionOrchestrator.Instance.DropItem(this, pickup.transform.position);
}
SetHeldItem(pickup.itemData, pickup.iconRenderer);
CacheHeldPickupObject(pickup.gameObject);
InteractionOrchestrator.Instance.PickupItem(this, pickup.gameObject);
break;
}
}
@@ -425,27 +421,6 @@ public class FollowerController : Character
_pickupCoroutine = null;
}
/// <summary>
/// Drop the held item at the specified position, unparenting and activating it.
/// </summary>
/// <param name="position">The world position to drop the item at.</param>
public void DropHeldItemAt(Vector3 position)
{
if (_cachedPickupObject != null)
{
_cachedPickupObject.transform.position = position;
_cachedPickupObject.transform.SetParent(null);
_cachedPickupObject.SetActive(true);
_cachedPickupObject = null;
_currentlyHeldItem = null;
if (heldObjectRenderer != null)
{
heldObjectRenderer.sprite = null;
heldObjectRenderer.enabled = false;
}
}
}
void OnDrawGizmos()
{
if (debugDrawTarget && Application.isPlaying)