Interactables fully working now
This commit is contained in:
@@ -151,4 +151,68 @@ public class InteractionOrchestrator : MonoBehaviour
|
||||
interactable.CompleteInteraction(false);
|
||||
}
|
||||
}
|
||||
|
||||
// --- ITEM MANAGEMENT API ---
|
||||
public void PickupItem(FollowerController follower, GameObject item)
|
||||
{
|
||||
if (item == null || follower == null) return;
|
||||
item.SetActive(false);
|
||||
item.transform.SetParent(null);
|
||||
follower.SetHeldItemFromObject(item);
|
||||
// Optionally: fire event, update UI, etc.
|
||||
}
|
||||
|
||||
public void DropItem(FollowerController follower, Vector3 position)
|
||||
{
|
||||
var item = follower.GetHeldPickupObject();
|
||||
if (item == null) return;
|
||||
item.transform.position = position;
|
||||
item.transform.SetParent(null);
|
||||
item.SetActive(true);
|
||||
follower.ClearHeldItem();
|
||||
// Optionally: fire event, update UI, etc.
|
||||
}
|
||||
|
||||
public void SlotItem(SlotItemBehavior slot, GameObject item)
|
||||
{
|
||||
if (slot == null || item == null) return;
|
||||
item.SetActive(false);
|
||||
item.transform.SetParent(null);
|
||||
slot.SetSlottedObject(item);
|
||||
// Optionally: update visuals, fire event, etc.
|
||||
}
|
||||
|
||||
public void SwapItems(FollowerController follower, SlotItemBehavior slot)
|
||||
{
|
||||
var heldObj = follower.GetHeldPickupObject();
|
||||
var slotObj = slot.GetSlottedObject();
|
||||
// 1. Slot the follower's held object
|
||||
SlotItem(slot, heldObj);
|
||||
// 2. Give the slot's object to the follower
|
||||
PickupItem(follower, slotObj);
|
||||
}
|
||||
|
||||
public GameObject CombineItems(GameObject itemA, GameObject itemB)
|
||||
{
|
||||
if (itemA == null || itemB == null) return null;
|
||||
var pickupA = itemA.GetComponent<Pickup>();
|
||||
var pickupB = itemB.GetComponent<Pickup>();
|
||||
if (pickupA == null || pickupB == null) {
|
||||
if (itemA != null) Destroy(itemA);
|
||||
if (itemB != null) Destroy(itemB);
|
||||
return null;
|
||||
}
|
||||
var rule = GameManager.Instance.GetCombinationRule(pickupA.itemData, pickupB.itemData);
|
||||
Vector3 spawnPos = itemA.transform.position;
|
||||
if (rule != null && rule.resultPrefab != null) {
|
||||
var newItem = Instantiate(rule.resultPrefab, spawnPos, Quaternion.identity);
|
||||
Destroy(itemA);
|
||||
Destroy(itemB);
|
||||
return newItem;
|
||||
}
|
||||
// If no combination found, just destroy both
|
||||
Destroy(itemA);
|
||||
Destroy(itemB);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user