com.wallstop-studios.unity-helpers 2.0.0-rc66 → 2.0.0-rc68

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.
@@ -20,7 +20,7 @@
20
20
  {
21
21
  private static readonly WaitForEndOfFrame WaitForEndOfFrame = new();
22
22
  private static readonly Dictionary<Type, MethodInfo> AwakeMethodsByType = new();
23
- private static readonly Object LogObject = new() { name = "Wallstop Log Helper" };
23
+ private static readonly Object LogObject = new();
24
24
  private static readonly Dictionary<string, Object> ObjectsByTag = new(
25
25
  StringComparer.Ordinal
26
26
  );
@@ -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
- bool hasTag = _tagCount.ContainsKey(effectTag);
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
- bool hasTag = _tagCount.ContainsKey(effectTag);
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "2.0.0-rc66",
3
+ "version": "2.0.0-rc68",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {},