com.elestrago.unity.entitas-redux 3.7.2 → 3.7.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  ---
4
4
 
5
+ ## [3.7.3](https://gitlab.com/elestrago-pkg/entitas-redux/-/tags/3.7.3)
6
+
7
+ ### Changed
8
+
9
+ - Simplified `LinkableView` component subscription pattern by removing `IUnsubscribeEvent` dependency and replacing with
10
+ direct `OnEntityLinked`/`OnEntityUnlinked` lifecycle methods
11
+ - Updated event listener API to support `invokeOnSubscribe` parameter in add event listener method
12
+
13
+ ### Removed
14
+
15
+ - `UnsubscribeEvent` class and related utilities
16
+
17
+ ---
18
+
5
19
  ## [3.7.2](https://gitlab.com/elestrago-pkg/entitas-redux/-/tags/3.7.2)
6
20
 
7
21
  ### Fixed
@@ -1,4 +1,3 @@
1
- using JCMG.EntitasRedux.Core.Utils;
2
1
  using UnityEngine;
3
2
 
4
3
  namespace JCMG.EntitasRedux.Core.View.Impls
@@ -6,10 +5,15 @@ namespace JCMG.EntitasRedux.Core.View.Impls
6
5
  public abstract class LinkableView<TEntity> : LinkableView
7
6
  where TEntity : class, IEntity
8
7
  {
9
- protected sealed override void Subscribe(IEntity entity, IUnsubscribeEvent unsubscribe)
10
- => Subscribe(entity as TEntity, unsubscribe);
8
+ protected sealed override void OnEntityLinked(IEntity entity) => OnEntityLinked(entity as TEntity);
11
9
 
12
- protected virtual void Subscribe(TEntity entity, IUnsubscribeEvent unsubscribe)
10
+ protected virtual void OnEntityLinked(TEntity entity)
11
+ {
12
+ }
13
+
14
+ protected sealed override void OnEntityUnlinked(IEntity entity) => OnEntityUnlinked(entity as TEntity);
15
+
16
+ protected virtual void OnEntityUnlinked(TEntity entity)
13
17
  {
14
18
  }
15
19
  }
@@ -17,8 +21,6 @@ namespace JCMG.EntitasRedux.Core.View.Impls
17
21
  [RequireComponent(typeof(EntityLink))]
18
22
  public abstract partial class LinkableView : MonoBehaviour, ILinkable
19
23
  {
20
- private readonly UnsubscribeEvent _unsubscribeEvent = new();
21
-
22
24
  [SerializeField] protected EntityLink entityLink;
23
25
 
24
26
  private bool _destroyed;
@@ -40,7 +42,7 @@ namespace JCMG.EntitasRedux.Core.View.Impls
40
42
  return;
41
43
 
42
44
  entity.OnBeforeDestroyEntity += OnDestroyEntity;
43
- Subscribe(entity, _unsubscribeEvent);
45
+ OnEntityLinked(entity);
44
46
  }
45
47
 
46
48
  public void Unlink()
@@ -59,26 +61,18 @@ namespace JCMG.EntitasRedux.Core.View.Impls
59
61
  if (entity.Enabled)
60
62
  {
61
63
  entity.OnBeforeDestroyEntity -= OnDestroyEntity;
62
- Unsubscribe();
64
+ OnEntityUnlinked(entity);
63
65
  }
64
66
 
65
67
  if (!_destroyed)
66
- OnClear();
68
+ OnEntityDestroy();
67
69
  }
68
70
 
69
- protected abstract void Subscribe(IEntity entity, IUnsubscribeEvent unsubscribe);
71
+ protected abstract void OnEntityLinked(IEntity entity);
70
72
 
71
- private void Unsubscribe()
72
- {
73
- _unsubscribeEvent.Clear();
74
- OnUnsubscribe();
75
- }
76
-
77
- protected virtual void OnUnsubscribe()
78
- {
79
- }
73
+ protected abstract void OnEntityUnlinked(IEntity entity);
80
74
 
81
- protected virtual void OnClear()
75
+ protected virtual void OnEntityDestroy()
82
76
  {
83
77
  }
84
78
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.elestrago.unity.entitas-redux",
3
- "version": "3.7.2",
3
+ "version": "3.7.3",
4
4
  "displayName": "JCMG Entitas Redux",
5
5
  "description": "Entitas Redux is an fast, accessible, and feature-rich ECS framework for Unity. It leverages code generation and an extensible plugin framework to make life easier for developers.",
6
6
  "category": "Unity",
@@ -1,30 +0,0 @@
1
- using System;
2
- using EntitasRedux.Core.Libs;
3
-
4
- namespace JCMG.EntitasRedux.Core.Utils
5
- {
6
- public class UnsubscribeEvent : IUnsubscribeEvent
7
- {
8
- private readonly Event<Action> _events = new();
9
-
10
- public event Action Value
11
- {
12
- add => _events.AddListener(value);
13
- remove => _events.RemoveListener(value);
14
- }
15
-
16
- public void Clear()
17
- {
18
- using var _ = _events.Invokable(out var listeners);
19
- _events.RemoveAllListeners();
20
-
21
- foreach (var listener in listeners)
22
- listener();
23
- }
24
- }
25
-
26
- public interface IUnsubscribeEvent
27
- {
28
- event Action Value;
29
- }
30
- }
@@ -1,3 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: b07e7461736e4e0e922ac0177723ceb2
3
- timeCreated: 1678487489
@@ -1,13 +0,0 @@
1
- using System;
2
-
3
- namespace JCMG.EntitasRedux.Core.Utils
4
- {
5
- public static class UnsubscribeEventExtensions
6
- {
7
- public static IDisposable AddTo(this IDisposable disposable, IUnsubscribeEvent unsubscribe)
8
- {
9
- unsubscribe.Value += disposable.Dispose;
10
- return disposable;
11
- }
12
- }
13
- }
@@ -1,3 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: 8c9e182590544717a4755da46f9f806f
3
- timeCreated: 1678487883
@@ -1,3 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: 823e28aebd324636ab22d6c8d563ed6a
3
- timeCreated: 1678487365