diff --git a/Assets/Prefabs/Puzzles/BasePuzzlePickup.prefab b/Assets/Prefabs/Puzzles/BasePuzzlePickup.prefab
index 22400ac2..c52311f4 100644
--- a/Assets/Prefabs/Puzzles/BasePuzzlePickup.prefab
+++ b/Assets/Prefabs/Puzzles/BasePuzzlePickup.prefab
@@ -50,7 +50,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7447346505753002421, guid: bf4b9d7045397f946b2125b1ad4a3fbd, type: 3}
propertyPath: m_Name
- value: BasePuzzlePickup
+ value: BurgerBuns
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
diff --git a/Assets/Scripts/Core/DebugUIMessage.cs b/Assets/Scripts/Core/DebugUIMessage.cs
index c39789ce..369df7d4 100644
--- a/Assets/Scripts/Core/DebugUIMessage.cs
+++ b/Assets/Scripts/Core/DebugUIMessage.cs
@@ -14,7 +14,8 @@ public class DebugUIMessage : MonoBehaviour
///
/// The message to display.
/// How long to display the message (seconds).
- public static void Show(string message, float duration = 2f)
+ ///
+ public static void Show(string message, Color displayColor, float duration = 2f)
{
if (instance == null)
{
@@ -23,7 +24,7 @@ public class DebugUIMessage : MonoBehaviour
instance.SetupUI();
DontDestroyOnLoad(go);
}
- instance.ShowMessage(message, duration);
+ instance.ShowMessage(message, duration, displayColor);
}
///
@@ -45,7 +46,7 @@ public class DebugUIMessage : MonoBehaviour
messageText.font = customFont;
else
messageText.font = Resources.GetBuiltinResource("LegacyRuntime.ttf");
- messageText.fontSize = 16;
+ messageText.fontSize = 32;
messageText.color = Color.yellow;
var outline = textGO.AddComponent();
outline.effectColor = Color.black;
@@ -55,16 +56,17 @@ public class DebugUIMessage : MonoBehaviour
rect.anchorMax = new Vector2(0.5f, 0.5f);
rect.pivot = new Vector2(0.5f, 0.5f);
rect.anchoredPosition = Vector2.zero;
- rect.sizeDelta = new Vector2(400, 40);
+ rect.sizeDelta = new Vector2(800, 40);
messageText.text = "";
}
///
/// Internal method to show a message and start the hide coroutine.
///
- private void ShowMessage(string message, float duration)
+ private void ShowMessage(string message, float duration, Color fontColor)
{
messageText.text = message;
+ messageText.color = fontColor;
messageText.enabled = true;
if (hideCoroutine != null)
StopCoroutine(hideCoroutine);
diff --git a/Assets/Scripts/Interactions/Interactable.cs b/Assets/Scripts/Interactions/Interactable.cs
index c6ed85c2..7578b894 100644
--- a/Assets/Scripts/Interactions/Interactable.cs
+++ b/Assets/Scripts/Interactions/Interactable.cs
@@ -130,7 +130,7 @@ namespace Interactions
var step = GetComponent();
if (step != null && !step.IsStepUnlocked())
{
- DebugUIMessage.Show("This step is locked!", 2f);
+ DebugUIMessage.Show("This step is locked!", Color.yellow);
BroadcastInteractionComplete(false);
// Reset variables for next time
_interactionInProgress = false;
diff --git a/Assets/Scripts/Interactions/ItemSlot.cs b/Assets/Scripts/Interactions/ItemSlot.cs
index 0d60aa31..20dc9ba3 100644
--- a/Assets/Scripts/Interactions/ItemSlot.cs
+++ b/Assets/Scripts/Interactions/ItemSlot.cs
@@ -18,7 +18,6 @@ namespace Interactions
private PickupItemData _currentlySlottedItemData;
public SpriteRenderer slottedItemRenderer;
private GameObject _currentlySlottedItemObject = null;
-
public GameObject GetSlottedObject()
{
@@ -38,107 +37,41 @@ namespace Interactions
{
var heldItemData = FollowerController.CurrentlyHeldItemData;
var heldItemObj = FollowerController.GetHeldPickupObject();
- var pickup = GetComponent();
- var slotItem = pickup != null ? pickup.itemData : null;
- var config = GameManager.Instance.GetSlotItemConfig(slotItem);
- var allowed = config?.allowedItems ?? new List();
+ var config = GameManager.Instance.GetSlotItemConfig(itemData);
var forbidden = config?.forbiddenItems ?? new List();
-
- if (heldItemData != null && _currentlySlottedItemObject != null)
- {
- // Remove the currently slotted item
- FollowerController.TryPickupItem(_currentlySlottedItemObject, _currentlySlottedItemData);
- _currentlySlottedItemObject = null;
- _currentlySlottedItemData = null;
- onItemSlotRemoved?.Invoke();
- UpdateSlottedSprite();
-
- // Now slot the held item and check correctness
- if (forbidden.Contains(heldItemData))
- {
- DebugUIMessage.Show("Can't place that here.");
- onForbiddenItemSlotted?.Invoke();
- Interactable.BroadcastInteractionComplete(false);
- return;
- }
-
- SlotItem(heldItemObj, heldItemData);
- if (allowed.Contains(heldItemData))
- {
- onCorrectItemSlotted?.Invoke();
- Interactable.BroadcastInteractionComplete(true);
- return;
- }
- else
- {
- DebugUIMessage.Show("I'm not sure this works.");
- onIncorrectItemSlotted?.Invoke();
- Interactable.BroadcastInteractionComplete(false);
- return;
- }
- }
- else if (heldItemData == null && _currentlySlottedItemObject != null)
- {
- FollowerController.TryPickupItem(_currentlySlottedItemObject, _currentlySlottedItemData);
- _currentlySlottedItemObject = null;
- _currentlySlottedItemData = null;
- onItemSlotRemoved?.Invoke();
- UpdateSlottedSprite();
- return;
- }
- // // CASE 1: No held item, slot has item -> pick up slotted item
- // if (heldItemData == null && _cachedSlottedObject != null)
- // {
- // InteractionOrchestrator.Instance.PickupItem(FollowerController, _cachedSlottedObject);
- // _cachedSlottedObject = null;
- // currentlySlottedItem = null;
- // UpdateSlottedSprite();
- // Interactable.BroadcastInteractionComplete(false);
- // return;
- // }
- // // CASE 2: Held item, slot has item -> swap
- // if
- // {
- // InteractionOrchestrator.Instance.SwapItems(FollowerController, this);
- // currentlySlottedItem = heldItemData;
- // UpdateSlottedSprite();
- // return;
- // }
- // CASE 3: Held item, slot empty -> slot the held item
+ // Held item, slot empty -> try to slot item
if (heldItemData != null && _currentlySlottedItemObject == null)
{
+ // First check for forbidden items at the very start so we don't continue unnecessarily
if (forbidden.Contains(heldItemData))
{
- DebugUIMessage.Show("Can't place that here.");
+ DebugUIMessage.Show("Can't place that here.", Color.red);
onForbiddenItemSlotted?.Invoke();
Interactable.BroadcastInteractionComplete(false);
return;
}
- SlotItem(heldItemObj, heldItemData);
- if (allowed.Contains(heldItemData))
- {
- onCorrectItemSlotted?.Invoke();
- Interactable.BroadcastInteractionComplete(true);
- return;
- }
- else
- {
- DebugUIMessage.Show("I'm not sure this works.");
- onIncorrectItemSlotted?.Invoke();
- Interactable.BroadcastInteractionComplete(false);
- return;
- }
- }
-
- // CASE 4: No held item, slot empty -> show warning
- if (heldItemData == null && _currentlySlottedItemObject == null)
- {
- DebugUIMessage.Show("This requires an item.");
+ SlotItem(heldItemObj, heldItemData, true);
+ return;
+ }
+
+ // Either pickup or swap items
+ if ((heldItemData == null && _currentlySlottedItemObject != null)
+ || (heldItemData != null && _currentlySlottedItemObject != null))
+ {
+ FollowerController.TryPickupItem(_currentlySlottedItemObject, _currentlySlottedItemData, false);
+ onItemSlotRemoved?.Invoke();
+ SlotItem(heldItemObj, heldItemData, _currentlySlottedItemObject == null);
+ return;
+ }
+
+ // No held item, slot empty -> show warning
+ if (heldItemData == null && _currentlySlottedItemObject == null)
+ {
+ DebugUIMessage.Show("This requires an item.", Color.red);
return;
}
- return;
}
///
@@ -170,18 +103,43 @@ namespace Interactions
}
}
- public void SlotItem(GameObject itemToSlot, PickupItemData itemToSlotData)
+ public void SlotItem(GameObject itemToSlot, PickupItemData itemToSlotData, bool clearFollowerHeldItem = true)
{
- if (itemToSlot == null)
- return;
+ if (itemToSlot == null)
+ {
+ _currentlySlottedItemData = null;
+ _currentlySlottedItemData = null;
+ }
+ else
+ {
+ itemToSlot.SetActive(false);
+ itemToSlot.transform.SetParent(null);
+ SetSlottedObject(itemToSlot);
- itemToSlot.SetActive(false);
- itemToSlot.transform.SetParent(null);
- SetSlottedObject(itemToSlot);
-
- _currentlySlottedItemData = itemToSlotData;
+ _currentlySlottedItemData = itemToSlotData;
+ if (clearFollowerHeldItem)
+ {
+ FollowerController.ClearHeldItem();
+ }
+ }
UpdateSlottedSprite();
- FollowerController.ClearHeldItem();
+
+ // Once an item is slotted, we know it is not forbidden, so we can skip that check, but now check if it was
+ // the correct item we're looking for
+ var config = GameManager.Instance.GetSlotItemConfig(itemData);
+ var allowed = config?.allowedItems ?? new List();
+ if (allowed.Contains(itemToSlotData))
+ {
+ DebugUIMessage.Show("You correctly slotted " + itemToSlotData.itemName + " into: " + itemData.itemName, Color.green);
+ onCorrectItemSlotted?.Invoke();
+ Interactable.BroadcastInteractionComplete(true);
+ }
+ else
+ {
+ DebugUIMessage.Show("I'm not sure this works.", Color.yellow);
+ onIncorrectItemSlotted?.Invoke();
+ Interactable.BroadcastInteractionComplete(false);
+ }
}
}
}
diff --git a/Assets/Scripts/Movement/FollowerController.cs b/Assets/Scripts/Movement/FollowerController.cs
index 36cf6419..0fbb18a4 100644
--- a/Assets/Scripts/Movement/FollowerController.cs
+++ b/Assets/Scripts/Movement/FollowerController.cs
@@ -311,9 +311,9 @@ public class FollowerController: MonoBehaviour
#endregion Movement
#region ItemInteractions
- public void TryPickupItem(GameObject itemObject, PickupItemData itemData)
+ public void TryPickupItem(GameObject itemObject, PickupItemData itemData, bool dropItem = true)
{
- if (_currentlyHeldItemData != null && _cachedPickupObject != null)
+ if (_currentlyHeldItemData != null && _cachedPickupObject != null && dropItem)
{
// Drop the currently held item at the current position
DropHeldItemAt(transform.position);