com.wallstop-studios.dxmessaging 2.0.0-rc26 → 2.0.0-rc26.1

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.
@@ -3,8 +3,8 @@
3
3
  "isRoot": true,
4
4
  "tools": {
5
5
  "CSharpier": {
6
- "version": "0.30.6",
7
- "commands": ["dotnet-csharpier"]
6
+ "version": "1.0.1",
7
+ "commands": ["csharpier"]
8
8
  }
9
9
  }
10
10
  }
@@ -15,7 +15,7 @@ repos:
15
15
  description: Install the .NET tools listed at .config/dotnet-tools.json.
16
16
  - id: csharpier
17
17
  name: Run CSharpier on C# files
18
- entry: dotnet tool run dotnet-csharpier
18
+ entry: dotnet tool run Csharpier format
19
19
  language: system
20
20
  types:
21
21
  - c#
@@ -62,12 +62,7 @@ namespace DxMessaging.Editor
62
62
  continue;
63
63
  }
64
64
 
65
- if (
66
- !dllPath.Contains(
67
- "Assets/Plugins/WallstopStudios.DxMessaging",
68
- StringComparison.OrdinalIgnoreCase
69
- )
70
- )
65
+ if (!dllPath.Contains("Assets/Plugins", StringComparison.OrdinalIgnoreCase))
71
66
  {
72
67
  string dllName = Path.GetFileName(dllPath);
73
68
  DllNames.Add(dllName);
@@ -95,10 +90,14 @@ namespace DxMessaging.Editor
95
90
  }
96
91
 
97
92
  const string pluginsDirectory =
98
- "Assets/Plugins/WallstopStudios.DxMessaging/";
93
+ "Assets/Plugins/Editor/WallstopStudios.DxMessaging/";
99
94
  string outputAsset = $"{pluginsDirectory}{requiredDllName}";
100
95
  string sourceAsset = $"{relativeDirectory}{requiredDllName}";
101
- Directory.CreateDirectory(pluginsDirectory);
96
+ if (!Directory.Exists(pluginsDirectory))
97
+ {
98
+ Directory.CreateDirectory(pluginsDirectory);
99
+ AssetDatabase.Refresh();
100
+ }
102
101
  if (!File.Exists(outputAsset))
103
102
  {
104
103
  File.Copy(sourceAsset, outputAsset);
@@ -174,6 +174,24 @@
174
174
  messageBus.UntargetedBroadcast(ref message);
175
175
  }
176
176
 
177
+ /// <summary>
178
+ /// Emits an UntargetedMessage of the given type.
179
+ /// </summary>
180
+ /// <param name="message">UntargetedMessage to emit.</param>
181
+ /// <param name="messageBus">MessageBus to emit to. If null, uses the GlobalMessageBus.</param>
182
+ public static void Emit<TMessage>(this TMessage message, IMessageBus messageBus = null)
183
+ where TMessage : class, IUntargetedMessage
184
+ {
185
+ messageBus ??= MessageHandler.MessageBus;
186
+ if (typeof(TMessage) == typeof(IUntargetedMessage))
187
+ {
188
+ messageBus.UntypedUntargetedBroadcast(message);
189
+ return;
190
+ }
191
+
192
+ messageBus.UntargetedBroadcast(ref message);
193
+ }
194
+
177
195
  /// <summary>
178
196
  /// Emits an UntargetedMessage of the given type.
179
197
  /// </summary>
@@ -195,6 +213,24 @@
195
213
  messageBus.UntargetedBroadcast(ref message);
196
214
  }
197
215
 
216
+ /// <summary>
217
+ /// Emits an UntargetedMessage of the given type.
218
+ /// </summary>
219
+ /// <param name="message">UntargetedMessage to emit.</param>
220
+ /// <param name="messageBus">MessageBus to emit to. If null, uses the GlobalMessageBus.</param>
221
+ public static void Emit<TMessage>(this ref TMessage message, IMessageBus messageBus = null)
222
+ where TMessage : struct, IUntargetedMessage
223
+ {
224
+ messageBus ??= MessageHandler.MessageBus;
225
+ if (typeof(TMessage) == typeof(IUntargetedMessage))
226
+ {
227
+ messageBus.UntypedUntargetedBroadcast(message);
228
+ return;
229
+ }
230
+
231
+ messageBus.UntargetedBroadcast(ref message);
232
+ }
233
+
198
234
  #if UNITY_2017_1_OR_NEWER
199
235
  /// <summary>
200
236
  /// Emits a BroadcastMessage of the given type.
@@ -338,5 +374,35 @@
338
374
 
339
375
  messageBus.SourcedBroadcast(ref source, ref message);
340
376
  }
377
+
378
+ /// <summary>
379
+ /// Emits a StringMessage at the target containing the provided string.
380
+ /// </summary>
381
+ /// <param name="message">Message to send to the target.</param>
382
+ /// <param name="target">Target to send the message to.</param>
383
+ /// <param name="messageBus">MessageBus to emit to. If null, uses the GlobalMessageBus.</param>
384
+ public static void Emit(
385
+ this string message,
386
+ InstanceId target,
387
+ IMessageBus messageBus = null
388
+ )
389
+ {
390
+ StringMessage stringMessage = new(message);
391
+ (messageBus ?? MessageHandler.MessageBus).TargetedBroadcast(
392
+ ref target,
393
+ ref stringMessage
394
+ );
395
+ }
396
+
397
+ /// <summary>
398
+ /// Emits a GlobalStringMessage containing the provided string.
399
+ /// </summary>
400
+ /// <param name="message">Message to send globally.</param>
401
+ /// <param name="messageBus">MessageBus to emit to. If null, uses the GlobalMessageBus.</param>
402
+ public static void Emit(this string message, IMessageBus messageBus = null)
403
+ {
404
+ GlobalStringMessage stringMessage = new(message);
405
+ (messageBus ?? MessageHandler.MessageBus).UntargetedBroadcast(ref stringMessage);
406
+ }
341
407
  }
342
408
  }
@@ -1,7 +1,6 @@
1
- namespace DxMessaging.Unity.Messages
1
+ namespace DxMessaging.Core.Messages
2
2
  {
3
3
  using System;
4
- using Core.Messages;
5
4
 
6
5
  public readonly struct GlobalStringMessage : IUntargetedMessage<GlobalStringMessage>
7
6
  {
@@ -1,7 +1,6 @@
1
- namespace DxMessaging.Unity.Messages
1
+ namespace DxMessaging.Core.Messages
2
2
  {
3
3
  using System;
4
- using Core.Messages;
5
4
 
6
5
  public readonly struct StringMessage : ITargetedMessage<StringMessage>
7
6
  {
@@ -1,7 +1,7 @@
1
1
  namespace DxMessaging.Unity
2
2
  {
3
3
  using Core;
4
- using Messages;
4
+ using Core.Messages;
5
5
  using UnityEngine;
6
6
 
7
7
  [RequireComponent(typeof(MessagingComponent))]
@@ -6,7 +6,6 @@
6
6
  using DxMessaging.Core;
7
7
  using DxMessaging.Core.Extensions;
8
8
  using DxMessaging.Core.Messages;
9
- using global::Unity.PerformanceTesting;
10
9
  using NUnit.Framework;
11
10
  using Scripts.Components;
12
11
  using Scripts.Messages;
@@ -55,96 +54,6 @@
55
54
  RunTest(component => ReflexiveThreeArguments(timer, timeout, component.gameObject));
56
55
  }
57
56
 
58
- [Test]
59
- [Performance]
60
- public void BenchmarkBroadcast()
61
- {
62
- GameObject go = CreateGameObject();
63
- MessageRegistrationToken token = GetToken(
64
- go.GetComponent<EmptyMessageAwareComponent>()
65
- );
66
- // ReSharper disable once NotAccessedVariable
67
- int count = 0;
68
- token.RegisterGameObjectBroadcast<SimpleBroadcastMessage>(go, Handle);
69
-
70
- SimpleBroadcastMessage message = new();
71
- SampleGroup time = new("Time", SampleUnit.Nanosecond);
72
-
73
- Measure
74
- .Method(() => message.EmitGameObjectBroadcast(go))
75
- .SampleGroup(time)
76
- .WarmupCount(10)
77
- .IterationsPerMeasurement(1)
78
- .MeasurementCount(10_000)
79
- .Run();
80
- return;
81
-
82
- void Handle(SimpleBroadcastMessage _)
83
- {
84
- ++count;
85
- }
86
- }
87
-
88
- [Test]
89
- [Performance]
90
- public void BenchmarkTargeted()
91
- {
92
- GameObject go = CreateGameObject();
93
- MessageRegistrationToken token = GetToken(
94
- go.GetComponent<EmptyMessageAwareComponent>()
95
- );
96
- // ReSharper disable once NotAccessedVariable
97
- int count = 0;
98
- token.RegisterGameObjectTargeted<SimpleTargetedMessage>(go, Handle);
99
-
100
- SimpleTargetedMessage message = new();
101
- SampleGroup time = new("Time", SampleUnit.Nanosecond);
102
-
103
- Measure
104
- .Method(() => message.EmitGameObjectTargeted(go))
105
- .SampleGroup(time)
106
- .WarmupCount(10)
107
- .IterationsPerMeasurement(1)
108
- .MeasurementCount(10_000)
109
- .Run();
110
- return;
111
-
112
- void Handle(SimpleTargetedMessage _)
113
- {
114
- ++count;
115
- }
116
- }
117
-
118
- [Test]
119
- [Performance]
120
- public void BenchmarkUntargeted()
121
- {
122
- GameObject go = CreateGameObject();
123
- MessageRegistrationToken token = GetToken(
124
- go.GetComponent<EmptyMessageAwareComponent>()
125
- );
126
- // ReSharper disable once NotAccessedVariable
127
- int count = 0;
128
- token.RegisterUntargeted<SimpleUntargetedMessage>(Handle);
129
-
130
- SimpleUntargetedMessage message = new();
131
- SampleGroup time = new("Time", SampleUnit.Nanosecond);
132
-
133
- Measure
134
- .Method(() => message.EmitUntargeted())
135
- .SampleGroup(time)
136
- .WarmupCount(10)
137
- .IterationsPerMeasurement(1)
138
- .MeasurementCount(10_000)
139
- .Run();
140
- return;
141
-
142
- void Handle(SimpleUntargetedMessage _)
143
- {
144
- ++count;
145
- }
146
- }
147
-
148
57
  private GameObject CreateGameObject()
149
58
  {
150
59
  GameObject target = new(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.dxmessaging",
3
- "version": "2.0.0-rc26",
3
+ "version": "2.0.0-rc26.1",
4
4
  "displayName": "DxMessaging",
5
5
  "description": "Synchronous Event Bus for Unity",
6
6
  "unity": "2021.3",
@@ -32,3 +32,4 @@
32
32
  "test": "echo \"Error: no test specified\" && exit 1"
33
33
  }
34
34
  }
35
+
@@ -1,3 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: f1a132a737bb42a79205b2269554e818
3
- timeCreated: 1745160607