com.elestrago.unity.entitas-redux 3.1.0 → 3.1.2
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 +16 -0
- package/Core/Attributes/EventAttribute.cs +17 -9
- package/Core/Attributes/EventTarget.cs +1 -1
- package/Core/Attributes/EventType.cs +1 -1
- package/Core/Attributes/ExecutionType.cs +8 -0
- package/Core/Attributes/ExecutionType.cs.meta +3 -0
- package/Core/Systems/CleanupReactiveSystem.cs +0 -5
- package/Core/Systems/FixedReactiveSystem.cs +0 -5
- package/Core/Systems/LateReactiveSystem.cs +124 -0
- package/Core/Systems/LateReactiveSystem.cs.meta +3 -0
- package/Core/Systems/ReactiveSystem.cs +0 -5
- package/Plugins/EntitasRedux.Core.Generator.dll +0 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,22 @@ All notable changes to this project will be documented in this file.
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
## [3.1.2](https://gitlab.com/elestrago-pkg/entitas-redux/-/tags/3.1.2)
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Execution type in `Event` attribute
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## [3.1.1](https://gitlab.com/elestrago-pkg/entitas-redux/-/tags/3.1.1)
|
|
18
|
+
|
|
19
|
+
### Fixes
|
|
20
|
+
|
|
21
|
+
- Try to make package visible in Unity package manager
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
9
25
|
## [v3.1.0](https://gitlab.com/elestrago-pkg/entitas-redux/-/tags/v3.1.0)
|
|
10
26
|
|
|
11
27
|
### Changes
|
|
@@ -32,15 +32,23 @@ namespace JCMG.EntitasRedux
|
|
|
32
32
|
AllowMultiple = true)]
|
|
33
33
|
public class EventAttribute : Attribute
|
|
34
34
|
{
|
|
35
|
-
public readonly EventTarget
|
|
36
|
-
public readonly EventType
|
|
37
|
-
public readonly
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
public readonly EventTarget EventTarget;
|
|
36
|
+
public readonly EventType EventType;
|
|
37
|
+
public readonly ExecutionType ExecutionType;
|
|
38
|
+
public readonly int Priority;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
public EventAttribute(
|
|
42
|
+
EventTarget eventTarget,
|
|
43
|
+
EventType eventType = EventType.Added,
|
|
44
|
+
ExecutionType executionType = ExecutionType.Update,
|
|
45
|
+
int priority = 0
|
|
46
|
+
)
|
|
40
47
|
{
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
EventTarget = eventTarget;
|
|
49
|
+
ExecutionType = executionType;
|
|
50
|
+
EventType = eventType;
|
|
51
|
+
Priority = priority;
|
|
44
52
|
}
|
|
45
53
|
}
|
|
46
|
-
}
|
|
54
|
+
}
|
|
@@ -73,11 +73,6 @@ namespace JCMG.EntitasRedux
|
|
|
73
73
|
|
|
74
74
|
public override string ToString() => _toStringCache ??= "ReactiveSystem(" + GetType().Name + ")";
|
|
75
75
|
|
|
76
|
-
~CleanupReactiveSystem()
|
|
77
|
-
{
|
|
78
|
-
Deactivate();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
76
|
/// <summary>
|
|
82
77
|
/// Activates the ReactiveSystem and starts observing changes
|
|
83
78
|
/// based on the specified Collector.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2020 Jeff Campbell
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
THE SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
using System;
|
|
27
|
+
|
|
28
|
+
namespace JCMG.EntitasRedux
|
|
29
|
+
{
|
|
30
|
+
/// <summary>
|
|
31
|
+
/// A ReactiveSystem calls Execute(entities) if there were changes based on
|
|
32
|
+
/// the specified Collector and will only pass in changed entities.
|
|
33
|
+
/// A common use-case is to react to changes, e.g. a change of the position
|
|
34
|
+
/// of an entity to update the gameObject.transform.position
|
|
35
|
+
/// of the related gameObject.
|
|
36
|
+
/// </summary>
|
|
37
|
+
/// <typeparam name="TEntity"></typeparam>
|
|
38
|
+
public abstract class LateReactiveSystem<TEntity> : IReactiveSystem, ILateUpdateSystem
|
|
39
|
+
where TEntity : class, IEntity
|
|
40
|
+
{
|
|
41
|
+
private readonly ICollector<TEntity> _collector;
|
|
42
|
+
private readonly Func<TEntity, bool> _filterCached;
|
|
43
|
+
|
|
44
|
+
private string _toStringCache;
|
|
45
|
+
|
|
46
|
+
protected LateReactiveSystem(IContext<TEntity> context)
|
|
47
|
+
{
|
|
48
|
+
_collector = GetTrigger(context);
|
|
49
|
+
_filterCached = Filter;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
protected LateReactiveSystem(ICollector<TEntity> collector)
|
|
53
|
+
{
|
|
54
|
+
_collector = collector;
|
|
55
|
+
_filterCached = Filter;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/// <summary>
|
|
59
|
+
/// Specify the collector that will trigger the ReactiveSystem.
|
|
60
|
+
/// </summary>
|
|
61
|
+
/// <param name="context"></param>
|
|
62
|
+
/// <returns></returns>
|
|
63
|
+
protected abstract ICollector<TEntity> GetTrigger(IContext<TEntity> context);
|
|
64
|
+
|
|
65
|
+
/// <summary>
|
|
66
|
+
/// This will exclude all entities which don't pass the filter.
|
|
67
|
+
/// </summary>
|
|
68
|
+
/// <param name="entity"></param>
|
|
69
|
+
/// <returns></returns>
|
|
70
|
+
protected abstract bool Filter(TEntity entity);
|
|
71
|
+
|
|
72
|
+
protected abstract void Execute(ReadOnlySpan<TEntity> entities);
|
|
73
|
+
|
|
74
|
+
public override string ToString() => _toStringCache ??= "ReactiveSystem(" + GetType().Name + ")";
|
|
75
|
+
|
|
76
|
+
/// <summary>
|
|
77
|
+
/// Activates the ReactiveSystem and starts observing changes
|
|
78
|
+
/// based on the specified Collector.
|
|
79
|
+
/// ReactiveSystem are activated by default.
|
|
80
|
+
/// </summary>
|
|
81
|
+
public void Activate()
|
|
82
|
+
{
|
|
83
|
+
_collector.Activate();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/// <summary>
|
|
87
|
+
/// Deactivates the ReactiveSystem.
|
|
88
|
+
/// No changes will be tracked while deactivated.
|
|
89
|
+
/// This will also clear the ReactiveSystem.
|
|
90
|
+
/// ReactiveSystem are activated by default.
|
|
91
|
+
/// </summary>
|
|
92
|
+
public void Deactivate()
|
|
93
|
+
{
|
|
94
|
+
_collector.Deactivate();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/// <summary>
|
|
98
|
+
/// Clears all accumulated changes.
|
|
99
|
+
/// </summary>
|
|
100
|
+
public void Clear()
|
|
101
|
+
{
|
|
102
|
+
_collector.ClearCollectedEntities();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/// <summary>
|
|
106
|
+
/// Will call Execute(entities) with changed entities
|
|
107
|
+
/// if there are any. Otherwise it will not call Execute(entities).
|
|
108
|
+
/// </summary>
|
|
109
|
+
public void LateUpdate()
|
|
110
|
+
{
|
|
111
|
+
var count = _collector.Count;
|
|
112
|
+
if (count == 0)
|
|
113
|
+
return;
|
|
114
|
+
|
|
115
|
+
using var _ = _collector.GetEntities(_filterCached, out var buffer);
|
|
116
|
+
_collector.ClearCollectedEntities();
|
|
117
|
+
|
|
118
|
+
if (buffer.Length == 0)
|
|
119
|
+
return;
|
|
120
|
+
|
|
121
|
+
Execute(buffer);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -73,11 +73,6 @@ namespace JCMG.EntitasRedux
|
|
|
73
73
|
|
|
74
74
|
public override string ToString() => _toStringCache ??= "ReactiveSystem(" + GetType().Name + ")";
|
|
75
75
|
|
|
76
|
-
~ReactiveSystem()
|
|
77
|
-
{
|
|
78
|
-
Deactivate();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
76
|
/// <summary>
|
|
82
77
|
/// Activates the ReactiveSystem and starts observing changes
|
|
83
78
|
/// based on the specified Collector.
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "com.elestrago.unity.entitas-redux",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
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
|
-
"category": "
|
|
6
|
+
"category": "unity",
|
|
7
7
|
"unity": "2022.3",
|
|
8
8
|
"homepage": "https://gitlab.com/elestrago-pkg/entitas-redux",
|
|
9
9
|
"documentationUrl": "https://gitlab.com/elestrago-pkg/entitas-redux/-/blob/main/README.md",
|