diff --git a/Assets/Scenes/Levels/Quarry.unity b/Assets/Scenes/Levels/Quarry.unity index 65f47483..092cb35b 100644 --- a/Assets/Scenes/Levels/Quarry.unity +++ b/Assets/Scenes/Levels/Quarry.unity @@ -434448,6 +434448,18 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: stepData: {fileID: 11400000, guid: 8ac614a698631554ab8ac39aed04a189, type: 2} +--- !u!114 &1182494941 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1182494929} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 833a4ccef651449e973e623d9107bef5, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1001 &1192177492 PrefabInstance: m_ObjectHideFlags: 0 @@ -441481,6 +441493,9 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 7379304988657006554, guid: c36b48a324dcaef4cb5ee0f8ca57f0d6, type: 3} insertIndex: -1 addedObject: {fileID: 1182494937} + - targetCorrespondingSourceObject: {fileID: 7379304988657006554, guid: c36b48a324dcaef4cb5ee0f8ca57f0d6, type: 3} + insertIndex: -1 + addedObject: {fileID: 1182494941} m_SourcePrefab: {fileID: 100100000, guid: c36b48a324dcaef4cb5ee0f8ca57f0d6, type: 3} --- !u!1001 &7535757761066548300 PrefabInstance: diff --git a/Assets/Scripts/Interactions/Interactable.cs b/Assets/Scripts/Interactions/Interactable.cs index 5966e58d..bab8a866 100644 --- a/Assets/Scripts/Interactions/Interactable.cs +++ b/Assets/Scripts/Interactions/Interactable.cs @@ -68,4 +68,9 @@ public class Interactable : MonoBehaviour, ITouchInputConsumer } return anySuccess; } + + public void CompleteInteraction(bool success) + { + InteractionComplete?.Invoke(success); + } } diff --git a/Assets/Scripts/Interactions/OneClickInteraction.cs b/Assets/Scripts/Interactions/OneClickInteraction.cs new file mode 100644 index 00000000..c53fa477 --- /dev/null +++ b/Assets/Scripts/Interactions/OneClickInteraction.cs @@ -0,0 +1,35 @@ +using UnityEngine; +using System; + +/// +/// MonoBehaviour that immediately completes an interaction when started. +/// +public class OneClickInteraction : MonoBehaviour +{ + private Interactable interactable; + + void Awake() + { + interactable = GetComponent(); + if (interactable != null) + { + interactable.StartedInteraction += OnStartedInteraction; + } + } + + void OnDestroy() + { + if (interactable != null) + { + interactable.StartedInteraction -= OnStartedInteraction; + } + } + + private void OnStartedInteraction() + { + if (interactable != null) + { + interactable.CompleteInteraction(true); + } + } +} diff --git a/Assets/Scripts/Interactions/OneClickInteraction.cs.meta b/Assets/Scripts/Interactions/OneClickInteraction.cs.meta new file mode 100644 index 00000000..f19903d4 --- /dev/null +++ b/Assets/Scripts/Interactions/OneClickInteraction.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 833a4ccef651449e973e623d9107bef5 +timeCreated: 1757417586 \ No newline at end of file