summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Tag/Area.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts/Tag/Area.cs')
-rw-r--r--Assets/Scripts/Tag/Area.cs39
1 files changed, 39 insertions, 0 deletions
diff --git a/Assets/Scripts/Tag/Area.cs b/Assets/Scripts/Tag/Area.cs
new file mode 100644
index 0000000..196bd36
--- /dev/null
+++ b/Assets/Scripts/Tag/Area.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Tag
+{
+ public class Area : MonoBehaviour
+ {
+ public ItemType itemAccepted;
+ public List<TagItem> items;
+
+ private void OnTriggerEnter(Collider other)
+ {
+ if (other.CompareTag("Part"))
+ {
+ var obj = other.GetComponent<TagItem>();
+ if (obj.info.itemType == itemAccepted)
+ {
+ if (! items.Contains(obj))
+ {
+ items.Add(obj);
+ }
+ }
+ }
+ }
+
+ private void OnTriggerExit(Collider other)
+ {
+ if (other.CompareTag("Part"))
+ {
+ var obj = other.GetComponent<TagItem>();
+ if (items.Contains(obj))
+ {
+ items.Remove(obj);
+ }
+ }
+ }
+ }
+}