com.wallstop-studios.unity-helpers 2.0.0-rc66 → 2.0.0-rc67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Runtime/Utils/TagHandler.cs +22 -5
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
namespace WallstopStudios.UnityHelpers.Utils
|
|
2
2
|
{
|
|
3
|
+
using System;
|
|
3
4
|
using System.Collections.Generic;
|
|
4
5
|
using Core.Extension;
|
|
5
6
|
using UnityEngine;
|
|
@@ -7,10 +8,12 @@
|
|
|
7
8
|
[DisallowMultipleComponent]
|
|
8
9
|
public class TagHandler : MonoBehaviour
|
|
9
10
|
{
|
|
11
|
+
public IReadOnlyCollection<string> Tags => _tagCount.Keys;
|
|
12
|
+
|
|
10
13
|
[SerializeField]
|
|
11
14
|
protected List<string> _initialEffectTags = new();
|
|
12
15
|
|
|
13
|
-
protected readonly Dictionary<string, uint> _tagCount = new();
|
|
16
|
+
protected readonly Dictionary<string, uint> _tagCount = new(StringComparer.Ordinal);
|
|
14
17
|
|
|
15
18
|
protected virtual void Awake()
|
|
16
19
|
{
|
|
@@ -32,8 +35,7 @@
|
|
|
32
35
|
{
|
|
33
36
|
foreach (string effectTag in effectTags)
|
|
34
37
|
{
|
|
35
|
-
|
|
36
|
-
if (hasTag)
|
|
38
|
+
if (_tagCount.ContainsKey(effectTag))
|
|
37
39
|
{
|
|
38
40
|
return true;
|
|
39
41
|
}
|
|
@@ -47,8 +49,7 @@
|
|
|
47
49
|
for (int i = 0; i < effectTags.Count; ++i)
|
|
48
50
|
{
|
|
49
51
|
string effectTag = effectTags[i];
|
|
50
|
-
|
|
51
|
-
if (hasTag)
|
|
52
|
+
if (_tagCount.ContainsKey(effectTag))
|
|
52
53
|
{
|
|
53
54
|
return true;
|
|
54
55
|
}
|
|
@@ -57,6 +58,22 @@
|
|
|
57
58
|
return false;
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
public void ApplyTag(string effectTag)
|
|
62
|
+
{
|
|
63
|
+
InternalApplyTag(effectTag);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public void RemoveTag(string effectTag, bool allInstances)
|
|
67
|
+
{
|
|
68
|
+
if (allInstances)
|
|
69
|
+
{
|
|
70
|
+
_tagCount.Remove(effectTag);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
InternalRemoveTag(effectTag);
|
|
75
|
+
}
|
|
76
|
+
|
|
60
77
|
private void InternalApplyTag(string effectTag)
|
|
61
78
|
{
|
|
62
79
|
_ = _tagCount.AddOrUpdate(effectTag, _ => 1U, (_, existing) => existing + 1);
|