summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Tag/Area.cs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-01-31 20:14:48 +0800
committer魏曹先生 <1992414357@qq.com>2026-01-31 20:14:48 +0800
commit74a4f421b436b5950e52660ba7d6ebc53a818fa5 (patch)
tree9841fb6655fee855ba581768872de2deacf57f38 /Assets/Scripts/Tag/Area.cs
parent38e3e1fa64334f9cfd2f35e21439b93f525bf1b4 (diff)
完成好多HEADmain
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);
+ }
+ }
+ }
+ }
+}