com.wallstop-studios.dxmessaging 2.0.0-rc26.8 → 2.0.0-rc27

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/README.md CHANGED
@@ -40,16 +40,16 @@ For UntargetedMessages, DxMessaging is significantly faster (roughly 2x) than Un
40
40
  ## Windows
41
41
 
42
42
  | Message Tech | Operations / Second | Allocations? |
43
- | ------------ | ------------------- | ------------ |
44
- | Unity | 2,649,000 | Yes |
45
- | DxMessaging (GameObject) - Normal | 2,672,800 | No |
46
- | DxMessaging (Component) - Normal | 2,665,600 | No |
47
- | DxMessaging (GameObject) - No-Copy | 2,778,800 | No |
48
- | DxMessaging (Component) - No-Copy | 2,783,800 | No |
49
- | DxMessaging (Untargeted) - No-Copy | 4,205,600 | No |
50
- | Reflexive (One Argument) | 2,394,800 | No |
51
- | Reflexive (Two Arguments) | 1,000,400 | No |
52
- | Reflexive (Three Arguments) | 993,800 | No |
43
+ | ------------ | ------------------- | ------------ |
44
+ | Unity | 2,496,800 | Yes |
45
+ | DxMessaging (GameObject) - Normal | 2,574,400 | No |
46
+ | DxMessaging (Component) - Normal | 2,539,800 | No |
47
+ | DxMessaging (GameObject) - No-Copy | 2,745,000 | No |
48
+ | DxMessaging (Component) - No-Copy | 2,747,000 | No |
49
+ | DxMessaging (Untargeted) - No-Copy | 4,138,600 | No |
50
+ | Reflexive (One Argument) | 1,954,600 | No |
51
+ | Reflexive (Two Arguments) | 928,800 | No |
52
+ | Reflexive (Three Arguments) | 916,400 | No |
53
53
 
54
54
  ## Linux
55
55
 
@@ -0,0 +1,7 @@
1
+ using System.Runtime.CompilerServices;
2
+
3
+ [assembly: InternalsVisibleTo(
4
+ assemblyName: "WallstopStudios.DxMessaging.Tests.Runtime",
5
+ AllInternalsVisible = true
6
+ )]
7
+ [assembly: InternalsVisibleTo("WallstopStudios.DxMessaging.Editor")]
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 83aab80bf265483fb08c5f884e4b24fc
3
+ timeCreated: 1759525804
@@ -51,6 +51,7 @@ namespace DxMessaging.Core.DataStructure
51
51
  public int Count { get; private set; }
52
52
 
53
53
  private readonly List<T> _buffer;
54
+ private readonly List<T> _cache;
54
55
  private int _position;
55
56
 
56
57
  public T this[int index]
@@ -78,6 +79,7 @@ namespace DxMessaging.Core.DataStructure
78
79
  _position = 0;
79
80
  Count = 0;
80
81
  _buffer = new List<T>();
82
+ _cache = new List<T>();
81
83
  if (initialContents != null)
82
84
  {
83
85
  foreach (T item in initialContents)
@@ -132,21 +134,24 @@ namespace DxMessaging.Core.DataStructure
132
134
  return false;
133
135
  }
134
136
 
135
- int write = 0;
136
- bool removed = false;
137
137
  comparer ??= EqualityComparer<T>.Default;
138
+
139
+ _cache.Clear();
138
140
  for (int i = 0; i < Count; ++i)
139
141
  {
140
- int readIdx = AdjustedIndexFor(i);
141
- T item = _buffer[readIdx];
142
+ _cache.Add(_buffer[AdjustedIndexFor(i)]);
143
+ }
142
144
 
143
- if (!removed && comparer.Equals(item, element))
145
+ // Find and remove the element
146
+ bool removed = false;
147
+ for (int i = 0; i < _cache.Count; ++i)
148
+ {
149
+ if (comparer.Equals(_cache[i], element))
144
150
  {
151
+ _cache.RemoveAt(i);
145
152
  removed = true;
146
- continue;
153
+ break;
147
154
  }
148
-
149
- _buffer[write++] = item;
150
155
  }
151
156
 
152
157
  if (!removed)
@@ -154,48 +159,41 @@ namespace DxMessaging.Core.DataStructure
154
159
  return false;
155
160
  }
156
161
 
157
- _buffer.RemoveRange(write, _buffer.Count - write);
158
-
159
- Count--;
160
- _position = Count < Capacity ? Count : 0;
162
+ RebuildFromCache();
161
163
  return true;
162
164
  }
163
165
 
164
- public int RemoveAll(Func<T, bool> predicate)
166
+ public int RemoveAll(Predicate<T> predicate)
165
167
  {
166
168
  if (Count == 0)
167
169
  {
168
170
  return 0;
169
171
  }
170
172
 
171
- int write = 0;
172
- int removedCount = 0;
173
-
173
+ _cache.Clear();
174
174
  for (int i = 0; i < Count; ++i)
175
175
  {
176
- int readIdx = AdjustedIndexFor(i);
177
- T item = _buffer[readIdx];
178
- if (predicate(item))
179
- {
180
- removedCount++;
181
- }
182
- else
183
- {
184
- _buffer[write++] = item;
185
- }
176
+ _cache.Add(_buffer[AdjustedIndexFor(i)]);
186
177
  }
187
178
 
179
+ int removedCount = _cache.RemoveAll(predicate);
188
180
  if (removedCount == 0)
189
181
  {
190
182
  return 0;
191
183
  }
192
184
 
193
- _buffer.RemoveRange(write, _buffer.Count - write);
194
- Count -= removedCount;
195
- _position = Count < Capacity ? Count : 0;
185
+ RebuildFromCache();
196
186
  return removedCount;
197
187
  }
198
188
 
189
+ private void RebuildFromCache()
190
+ {
191
+ _buffer.Clear();
192
+ _buffer.AddRange(_cache);
193
+ Count = _cache.Count;
194
+ _position = Count < Capacity ? Count : 0;
195
+ }
196
+
199
197
  public void Clear()
200
198
  {
201
199
  Count = 0;
@@ -736,8 +736,6 @@ namespace DxMessaging.Core.MessageBus
736
736
  }
737
737
 
738
738
  bool foundAnyHandlers = false;
739
- Dictionary<InstanceId, HandlerCache<int, HandlerCache>> targetedHandlers;
740
- HandlerCache<int, HandlerCache> sortedHandlers;
741
739
 
742
740
  if (typeof(TMessage) == typeof(ReflexiveMessage))
743
741
  {
@@ -931,8 +929,13 @@ namespace DxMessaging.Core.MessageBus
931
929
  }
932
930
 
933
931
  if (
934
- _targetedSinks.TryGetValue<TMessage>(out targetedHandlers)
935
- && targetedHandlers.TryGetValue(target, out sortedHandlers)
932
+ _targetedSinks.TryGetValue<TMessage>(
933
+ out Dictionary<InstanceId, HandlerCache<int, HandlerCache>> targetedHandlers
934
+ )
935
+ && targetedHandlers.TryGetValue(
936
+ target,
937
+ out HandlerCache<int, HandlerCache> sortedHandlers
938
+ )
936
939
  && 0 < sortedHandlers.handlers.Count
937
940
  )
938
941
  {
@@ -2415,14 +2418,17 @@ namespace DxMessaging.Core.MessageBus
2415
2418
  foreach (KeyValuePair<int, List<object>> entry in interceptorStack)
2416
2419
  {
2417
2420
  interceptorObjects.Clear();
2418
- foreach (object interceptor in entry.Value)
2421
+ List<object> interceptors = entry.Value;
2422
+ int count = interceptors.Count;
2423
+
2424
+ for (int i = 0; i < count; ++i)
2419
2425
  {
2420
- interceptorObjects.Add(interceptor);
2426
+ interceptorObjects.Add(interceptors[i]);
2421
2427
  }
2422
2428
 
2423
- foreach (object transformer in interceptorObjects)
2429
+ for (int i = 0; i < interceptorObjects.Count; ++i)
2424
2430
  {
2425
- if (transformer is not UntargetedInterceptor<T> typedTransformer)
2431
+ if (interceptorObjects[i] is not UntargetedInterceptor<T> typedTransformer)
2426
2432
  {
2427
2433
  continue;
2428
2434
  }
@@ -2460,14 +2466,16 @@ namespace DxMessaging.Core.MessageBus
2460
2466
  foreach (KeyValuePair<int, List<object>> entry in interceptorStack)
2461
2467
  {
2462
2468
  interceptorObjects.Clear();
2463
- foreach (object interceptor in entry.Value)
2469
+ List<object> interceptors = entry.Value;
2470
+ int count = interceptors.Count;
2471
+ for (int i = 0; i < count; ++i)
2464
2472
  {
2465
- interceptorObjects.Add(interceptor);
2473
+ interceptorObjects.Add(interceptors[i]);
2466
2474
  }
2467
2475
 
2468
- foreach (object transformer in interceptorObjects)
2476
+ for (int i = 0; i < interceptorObjects.Count; ++i)
2469
2477
  {
2470
- if (transformer is not TargetedInterceptor<T> typedTransformer)
2478
+ if (interceptorObjects[i] is not TargetedInterceptor<T> typedTransformer)
2471
2479
  {
2472
2480
  continue;
2473
2481
  }
@@ -2505,14 +2513,17 @@ namespace DxMessaging.Core.MessageBus
2505
2513
  foreach (KeyValuePair<int, List<object>> entry in interceptorStack)
2506
2514
  {
2507
2515
  interceptorObjects.Clear();
2508
- foreach (object interceptor in entry.Value)
2516
+ List<object> interceptors = entry.Value;
2517
+ int count = interceptors.Count;
2518
+
2519
+ for (int i = 0; i < count; ++i)
2509
2520
  {
2510
- interceptorObjects.Add(interceptor);
2521
+ interceptorObjects.Add(interceptors[i]);
2511
2522
  }
2512
2523
 
2513
- foreach (object transformer in interceptorObjects)
2524
+ for (int i = 0; i < interceptorObjects.Count; ++i)
2514
2525
  {
2515
- if (transformer is not BroadcastInterceptor<T> typedTransformer)
2526
+ if (interceptorObjects[i] is not BroadcastInterceptor<T> typedTransformer)
2516
2527
  {
2517
2528
  continue;
2518
2529
  }
@@ -1317,8 +1317,19 @@ namespace DxMessaging.Core
1317
1317
 
1318
1318
  private sealed class HandlerActionCache<T>
1319
1319
  {
1320
- public readonly Dictionary<T, int> handlers = new();
1321
- public readonly Dictionary<T, T> originalToAugmented = new();
1320
+ internal readonly struct Entry
1321
+ {
1322
+ public Entry(T handler, int count)
1323
+ {
1324
+ this.handler = handler;
1325
+ this.count = count;
1326
+ }
1327
+
1328
+ public readonly T handler;
1329
+ public readonly int count;
1330
+ }
1331
+
1332
+ public readonly Dictionary<T, Entry> entries = new();
1322
1333
  public readonly List<T> cache = new();
1323
1334
  public long version;
1324
1335
  public long lastSeenVersion = -1;
@@ -1522,7 +1533,7 @@ namespace DxMessaging.Core
1522
1533
  public void HandleGlobalUntargeted(ref IUntargetedMessage message)
1523
1534
  {
1524
1535
  RunFastHandlers(_globalUntargetedFastHandlers, ref message);
1525
- if (_globalUntargetedHandlers?.handlers is not { Count: > 0 })
1536
+ if (_globalUntargetedHandlers?.entries is not { Count: > 0 })
1526
1537
  {
1527
1538
  return;
1528
1539
  }
@@ -1545,7 +1556,7 @@ namespace DxMessaging.Core
1545
1556
  {
1546
1557
  RunFastHandlers(ref target, _globalTargetedFastHandlers, ref message);
1547
1558
 
1548
- if (_globalTargetedHandlers?.handlers is not { Count: > 0 })
1559
+ if (_globalTargetedHandlers?.entries is not { Count: > 0 })
1549
1560
  {
1550
1561
  return;
1551
1562
  }
@@ -1568,7 +1579,7 @@ namespace DxMessaging.Core
1568
1579
  {
1569
1580
  RunFastHandlers(ref source, _globalBroadcastFastHandlers, ref message);
1570
1581
 
1571
- if (_globalBroadcastHandlers?.handlers is not { Count: > 0 })
1582
+ if (_globalBroadcastHandlers?.entries is not { Count: > 0 })
1572
1583
  {
1573
1584
  return;
1574
1585
  }
@@ -2433,7 +2444,7 @@ namespace DxMessaging.Core
2433
2444
  where TMessage : IMessage
2434
2445
  where TU : IMessage
2435
2446
  {
2436
- if (cache?.handlers is not { Count: > 0 })
2447
+ if (cache?.entries is not { Count: > 0 })
2437
2448
  {
2438
2449
  return;
2439
2450
  }
@@ -2494,7 +2505,7 @@ namespace DxMessaging.Core
2494
2505
  where TMessage : IMessage
2495
2506
  where TU : IMessage
2496
2507
  {
2497
- if (cache?.handlers is not { Count: > 0 })
2508
+ if (cache?.entries is not { Count: > 0 })
2498
2509
  {
2499
2510
  return;
2500
2511
  }
@@ -2789,10 +2800,15 @@ namespace DxMessaging.Core
2789
2800
 
2790
2801
  List<TU> cache = actionCache.cache;
2791
2802
  cache.Clear();
2792
- foreach (TU handler in actionCache.originalToAugmented.Values)
2803
+
2804
+ if (actionCache.entries.Count > 0)
2793
2805
  {
2794
- cache.Add(handler);
2806
+ foreach (HandlerActionCache<TU>.Entry entry in actionCache.entries.Values)
2807
+ {
2808
+ cache.Add(entry.handler);
2809
+ }
2795
2810
  }
2811
+
2796
2812
  actionCache.lastSeenVersion = actionCache.version;
2797
2813
  return cache;
2798
2814
  }
@@ -2829,63 +2845,78 @@ namespace DxMessaging.Core
2829
2845
  sortedHandlers[priority] = cache;
2830
2846
  }
2831
2847
 
2832
- Dictionary<TU, int> handlers = cache.handlers;
2833
- int count = handlers.GetValueOrDefault(originalHandler, 0);
2834
- if (count == 0)
2848
+ if (
2849
+ !cache.entries.TryGetValue(
2850
+ originalHandler,
2851
+ out HandlerActionCache<TU>.Entry entry
2852
+ )
2853
+ )
2835
2854
  {
2836
- cache.originalToAugmented[originalHandler] = augmentedHandler;
2855
+ entry = new HandlerActionCache<TU>.Entry(augmentedHandler, 0);
2837
2856
  }
2838
- handlers[originalHandler] = count + 1;
2857
+
2858
+ entry =
2859
+ entry.count == 0
2860
+ ? new HandlerActionCache<TU>.Entry(augmentedHandler, 1)
2861
+ : new HandlerActionCache<TU>.Entry(entry.handler, entry.count + 1);
2862
+
2863
+ cache.entries[originalHandler] = entry;
2864
+ cache.version++;
2839
2865
 
2840
2866
  Dictionary<
2841
2867
  InstanceId,
2842
2868
  Dictionary<int, HandlerActionCache<TU>>
2843
2869
  > localHandlersByContext = handlersByContext;
2844
2870
 
2845
- cache.version++;
2846
2871
  return () =>
2847
2872
  {
2848
- cache.version++;
2849
2873
  if (!localHandlersByContext.TryGetValue(context, out sortedHandlers))
2850
2874
  {
2851
2875
  return;
2852
2876
  }
2853
2877
 
2854
- if (!sortedHandlers.TryGetValue(priority, out cache))
2878
+ if (
2879
+ !sortedHandlers.TryGetValue(priority, out HandlerActionCache<TU> localCache)
2880
+ )
2855
2881
  {
2856
2882
  return;
2857
2883
  }
2858
2884
 
2859
- handlers = cache.handlers;
2860
-
2861
- if (!handlers.TryGetValue(originalHandler, out count))
2885
+ if (
2886
+ !localCache.entries.TryGetValue(
2887
+ originalHandler,
2888
+ out HandlerActionCache<TU>.Entry localEntry
2889
+ )
2890
+ )
2862
2891
  {
2863
2892
  return;
2864
2893
  }
2865
2894
 
2866
- // Always invoke deregistration action, as MessageBus dedupes this as well
2895
+ localCache.version++;
2896
+
2867
2897
  deregistration?.Invoke();
2868
2898
 
2869
- if (count <= 1)
2899
+ if (localEntry.count <= 1)
2870
2900
  {
2871
- _ = handlers.Remove(originalHandler);
2872
- _ = cache.originalToAugmented.Remove(originalHandler);
2873
- if (0 < handlers.Count)
2874
- {
2875
- return;
2876
- }
2877
-
2878
- _ = sortedHandlers.Remove(priority);
2879
- if (0 < sortedHandlers.Count)
2901
+ _ = localCache.entries.Remove(originalHandler);
2902
+ if (localCache.entries.Count == 0)
2880
2903
  {
2881
- return;
2904
+ _ = sortedHandlers.Remove(priority);
2905
+ if (sortedHandlers.Count == 0)
2906
+ {
2907
+ localHandlersByContext.Remove(context);
2908
+ }
2882
2909
  }
2883
2910
 
2884
- localHandlersByContext.Remove(context);
2885
2911
  return;
2886
2912
  }
2887
2913
 
2888
- handlers[originalHandler] = count - 1;
2914
+ localEntry = new HandlerActionCache<TU>.Entry(
2915
+ localEntry.handler,
2916
+ localEntry.count - 1
2917
+ );
2918
+
2919
+ localCache.entries[originalHandler] = localEntry;
2889
2920
  };
2890
2921
  }
2891
2922
 
@@ -2897,37 +2928,54 @@ namespace DxMessaging.Core
2897
2928
  )
2898
2929
  {
2899
2930
  cache ??= new HandlerActionCache<TU>();
2900
- Dictionary<TU, int> handlersByPriority = cache.handlers;
2901
- int count = handlersByPriority.GetValueOrDefault(originalHandler, 0);
2902
- if (count == 0)
2931
+
2932
+ if (
2933
+ !cache.entries.TryGetValue(
2934
+ originalHandler,
2935
+ out HandlerActionCache<TU>.Entry entry
2936
+ )
2937
+ )
2903
2938
  {
2904
- cache.originalToAugmented[originalHandler] = augmentedHandler;
2939
+ entry = new HandlerActionCache<TU>.Entry(augmentedHandler, 0);
2905
2940
  }
2906
2941
 
2907
- handlersByPriority[originalHandler] = count + 1;
2942
+ entry =
2943
+ entry.count == 0
2944
+ ? new HandlerActionCache<TU>.Entry(augmentedHandler, 1)
2945
+ : new HandlerActionCache<TU>.Entry(entry.handler, entry.count + 1);
2908
2946
 
2909
- Dictionary<TU, int> localHandlers = handlersByPriority;
2947
+ cache.entries[originalHandler] = entry;
2948
+ cache.version++;
2910
2949
 
2911
2950
  HandlerActionCache<TU> localCache = cache;
2912
- localCache.version++;
2951
+
2913
2952
  return () =>
2914
2953
  {
2915
- localCache.version++;
2916
- if (!localHandlers.TryGetValue(originalHandler, out count))
2954
+ if (
2955
+ !localCache.entries.TryGetValue(
2956
+ originalHandler,
2957
+ out HandlerActionCache<TU>.Entry localEntry
2958
+ )
2959
+ )
2917
2960
  {
2918
2961
  return;
2919
2962
  }
2920
2963
 
2921
- // Always invoke deregistration action, as MessageBus dedupes this as well
2964
+ localCache.version++;
2965
+
2922
2966
  deregistration?.Invoke();
2923
- if (count <= 1)
2967
+
2968
+ if (localEntry.count <= 1)
2924
2969
  {
2925
- _ = localHandlers.Remove(originalHandler);
2926
- _ = localCache.originalToAugmented.Remove(originalHandler);
2970
+ _ = localCache.entries.Remove(originalHandler);
2927
2971
  return;
2928
2972
  }
2929
2973
 
2930
- localHandlers[originalHandler] = count - 1;
2974
+ localEntry = new HandlerActionCache<TU>.Entry(
2975
+ localEntry.handler,
2976
+ localEntry.count - 1
2977
+ );
2978
+ localCache.entries[originalHandler] = localEntry;
2931
2979
  };
2932
2980
  }
2933
2981
 
@@ -2947,44 +2995,64 @@ namespace DxMessaging.Core
2947
2995
  handlers[priority] = cache;
2948
2996
  }
2949
2997
 
2950
- int count = cache.handlers.GetValueOrDefault(originalHandler, 0);
2951
- if (count == 0)
2998
+ if (
2999
+ !cache.entries.TryGetValue(
3000
+ originalHandler,
3001
+ out HandlerActionCache<TU>.Entry entry
3002
+ )
3003
+ )
2952
3004
  {
2953
- cache.originalToAugmented[originalHandler] = augmentedHandler;
3005
+ entry = new HandlerActionCache<TU>.Entry(augmentedHandler, 0);
2954
3006
  }
2955
3007
 
2956
- cache.handlers[originalHandler] = count + 1;
3008
+ entry =
3009
+ entry.count == 0
3010
+ ? new HandlerActionCache<TU>.Entry(augmentedHandler, 1)
3011
+ : new HandlerActionCache<TU>.Entry(entry.handler, entry.count + 1);
2957
3012
 
2958
- Dictionary<int, HandlerActionCache<TU>> localHandlers = handlers;
3013
+ cache.entries[originalHandler] = entry;
2959
3014
  cache.version++;
2960
3015
 
3016
+ Dictionary<int, HandlerActionCache<TU>> localHandlers = handlers;
3017
+
2961
3018
  return () =>
2962
3019
  {
2963
- cache.version++;
2964
- if (!localHandlers.TryGetValue(priority, out cache))
3020
+ if (!localHandlers.TryGetValue(priority, out HandlerActionCache<TU> localCache))
2965
3021
  {
2966
3022
  return;
2967
3023
  }
2968
3024
 
2969
- if (!cache.handlers.TryGetValue(originalHandler, out count))
3025
+ if (
3026
+ !localCache.entries.TryGetValue(
3027
+ originalHandler,
3028
+ out HandlerActionCache<TU>.Entry localEntry
3029
+ )
3030
+ )
2970
3031
  {
2971
3032
  return;
2972
3033
  }
2973
3034
 
2974
- // Always invoke deregistration action, as MessageBus dedupes this as well
3035
+ localCache.version++;
3036
+
2975
3037
  deregistration?.Invoke();
2976
- if (count <= 1)
3038
+
3039
+ if (localEntry.count <= 1)
2977
3040
  {
2978
- _ = cache.handlers.Remove(originalHandler);
2979
- _ = cache.originalToAugmented.Remove(originalHandler);
2980
- if (cache.handlers.Count == 0)
3041
+ _ = localCache.entries.Remove(originalHandler);
3042
+ if (localCache.entries.Count == 0)
2981
3043
  {
2982
3044
  _ = localHandlers.Remove(priority);
2983
3045
  }
3046
+
2984
3047
  return;
2985
3048
  }
2986
3049
 
2987
- cache.handlers[originalHandler] = count - 1;
3050
+ localEntry = new HandlerActionCache<TU>.Entry(
3051
+ localEntry.handler,
3052
+ localEntry.count - 1
3053
+ );
3054
+
3055
+ localCache.entries[originalHandler] = localEntry;
2988
3056
  };
2989
3057
  }
2990
3058
  }
@@ -1,5 +1,3 @@
1
- [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("WallstopStudios.Dxmessaging.Editor")]
2
-
3
1
  namespace DxMessaging.Core
4
2
  {
5
3
  using System;
@@ -16,6 +16,11 @@ namespace DxMessaging.Unity
16
16
  /// </summary>
17
17
  protected virtual bool MessageRegistrationTiedToEnableStatus => true;
18
18
 
19
+ /// <summary>
20
+ /// If true, will register/unregister handles for StringMessages.
21
+ /// </summary>
22
+ protected virtual bool RegisterForStringMessages => true;
23
+
19
24
  protected bool _isQuitting;
20
25
 
21
26
  protected MessagingComponent _messagingComponent;
@@ -29,17 +34,20 @@ namespace DxMessaging.Unity
29
34
 
30
35
  protected virtual void RegisterMessageHandlers()
31
36
  {
32
- _ = _messageRegistrationToken.RegisterGameObjectTargeted<StringMessage>(
33
- gameObject,
34
- HandleStringGameObjectMessage
35
- );
36
- _ = _messageRegistrationToken.RegisterComponentTargeted<StringMessage>(
37
- this,
38
- HandleStringComponentMessage
39
- );
40
- _ = _messageRegistrationToken.RegisterUntargeted<GlobalStringMessage>(
41
- HandleGlobalStringMessage
42
- );
37
+ if (RegisterForStringMessages)
38
+ {
39
+ _ = _messageRegistrationToken.RegisterGameObjectTargeted<StringMessage>(
40
+ gameObject,
41
+ HandleStringGameObjectMessage
42
+ );
43
+ _ = _messageRegistrationToken.RegisterComponentTargeted<StringMessage>(
44
+ this,
45
+ HandleStringComponentMessage
46
+ );
47
+ _ = _messageRegistrationToken.RegisterUntargeted<GlobalStringMessage>(
48
+ HandleGlobalStringMessage
49
+ );
50
+ }
43
51
  }
44
52
 
45
53
  protected virtual void OnEnable()
@@ -52,11 +60,6 @@ namespace DxMessaging.Unity
52
60
 
53
61
  protected virtual void OnDisable()
54
62
  {
55
- if (_isQuitting)
56
- {
57
- return;
58
- }
59
-
60
63
  if (MessageRegistrationTiedToEnableStatus)
61
64
  {
62
65
  _messageRegistrationToken?.Disable();
@@ -65,11 +68,6 @@ namespace DxMessaging.Unity
65
68
 
66
69
  protected virtual void OnDestroy()
67
70
  {
68
- if (_isQuitting)
69
- {
70
- return;
71
- }
72
-
73
71
  _messageRegistrationToken?.Disable();
74
72
  _messageRegistrationToken = null;
75
73
  }