com.elestrago.unity.entitas-redux 3.3.3 → 3.4.0
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
package/Core/Entity/Entity.cs
CHANGED
|
@@ -73,54 +73,6 @@ namespace JCMG.EntitasRedux
|
|
|
73
73
|
return new ContextInfo("No Context", componentNames, null);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
private void ReplaceComponentInternal(int index, IComponent replacement)
|
|
77
|
-
{
|
|
78
|
-
// TODO VD PERFORMANCE
|
|
79
|
-
// _toStringCache = null;
|
|
80
|
-
|
|
81
|
-
var previousComponent = _components[index];
|
|
82
|
-
if (replacement != previousComponent)
|
|
83
|
-
{
|
|
84
|
-
_components[index] = replacement;
|
|
85
|
-
_componentsCache = null;
|
|
86
|
-
if (replacement != null)
|
|
87
|
-
{
|
|
88
|
-
using (_onComponentReplaced.Invokable(out var listeners))
|
|
89
|
-
{
|
|
90
|
-
foreach (var handler in listeners)
|
|
91
|
-
handler(this, index, previousComponent, replacement);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
else
|
|
95
|
-
{
|
|
96
|
-
_componentIndicesCache = null;
|
|
97
|
-
|
|
98
|
-
// TODO VD PERFORMANCE
|
|
99
|
-
_toStringCache = null;
|
|
100
|
-
|
|
101
|
-
using (_onComponentRemoved.Invokable(out var listeners))
|
|
102
|
-
{
|
|
103
|
-
foreach (var handler in listeners)
|
|
104
|
-
handler(this, index, previousComponent);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// ReSharper disable once SuspiciousTypeConversion.Global
|
|
109
|
-
if (previousComponent is IDisposable disposable)
|
|
110
|
-
disposable.Dispose();
|
|
111
|
-
|
|
112
|
-
GetComponentPool(index).Push(previousComponent);
|
|
113
|
-
}
|
|
114
|
-
else
|
|
115
|
-
{
|
|
116
|
-
using (_onComponentReplaced.Invokable(out var listeners))
|
|
117
|
-
{
|
|
118
|
-
foreach (var handler in listeners)
|
|
119
|
-
handler(this, index, previousComponent, replacement);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
76
|
/// <summary>
|
|
125
77
|
/// Returns a cached string to describe the entity
|
|
126
78
|
/// with the following format:
|
|
@@ -256,6 +208,7 @@ namespace JCMG.EntitasRedux
|
|
|
256
208
|
private readonly Event<EntityEvent> _onDestroyEntity = new();
|
|
257
209
|
|
|
258
210
|
private GenId _id;
|
|
211
|
+
|
|
259
212
|
public GenId Id => _id;
|
|
260
213
|
|
|
261
214
|
/// <summary>
|
|
@@ -318,52 +271,6 @@ namespace JCMG.EntitasRedux
|
|
|
318
271
|
_isEnabled = true;
|
|
319
272
|
}
|
|
320
273
|
|
|
321
|
-
/// <summary>
|
|
322
|
-
/// Adds a component at the specified index.
|
|
323
|
-
/// You can only have one component at an index.
|
|
324
|
-
/// Each component type must have its own constant index.
|
|
325
|
-
/// The preferred way is to use the
|
|
326
|
-
/// generated methods from the code generator.
|
|
327
|
-
/// </summary>
|
|
328
|
-
/// <param name="index"></param>
|
|
329
|
-
/// <param name="component"></param>
|
|
330
|
-
public void AddComponent(int index, IComponent component)
|
|
331
|
-
{
|
|
332
|
-
if (!_isEnabled)
|
|
333
|
-
{
|
|
334
|
-
throw new EntityIsNotEnabledException(
|
|
335
|
-
"Cannot add component '" +
|
|
336
|
-
_contextInfo.componentNames[index] +
|
|
337
|
-
"' to " +
|
|
338
|
-
this +
|
|
339
|
-
"!");
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
if (HasComponent(index))
|
|
343
|
-
{
|
|
344
|
-
throw new EntityAlreadyHasComponentException(
|
|
345
|
-
index,
|
|
346
|
-
"Cannot add component '" +
|
|
347
|
-
_contextInfo.componentNames[index] +
|
|
348
|
-
"' to " +
|
|
349
|
-
this +
|
|
350
|
-
"!",
|
|
351
|
-
"You should check if an entity already has the component " +
|
|
352
|
-
"before adding it or use entity.ReplaceComponent().");
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
_components[index] = component;
|
|
356
|
-
_componentsCache = null;
|
|
357
|
-
_componentIndicesCache = null;
|
|
358
|
-
_toStringCache = null;
|
|
359
|
-
|
|
360
|
-
using (_onComponentAdded.Invokable(out var listeners))
|
|
361
|
-
{
|
|
362
|
-
foreach (var handler in listeners)
|
|
363
|
-
handler(this, index, component);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
274
|
/// <summary>
|
|
368
275
|
/// Removes a component at the specified index.
|
|
369
276
|
/// You can only remove a component at an index if it exists.
|
|
@@ -400,14 +307,14 @@ namespace JCMG.EntitasRedux
|
|
|
400
307
|
}
|
|
401
308
|
|
|
402
309
|
/// <summary>
|
|
403
|
-
///
|
|
310
|
+
/// Add or replace an existing component at the specified index
|
|
404
311
|
/// or adds it if it doesn't exist yet.
|
|
405
312
|
/// The preferred way is to use the
|
|
406
313
|
/// generated methods from the code generator.
|
|
407
314
|
/// </summary>
|
|
408
315
|
/// <param name="index"></param>
|
|
409
316
|
/// <param name="component"></param>
|
|
410
|
-
public void
|
|
317
|
+
public void AddComponent(int index, IComponent component)
|
|
411
318
|
{
|
|
412
319
|
if (!_isEnabled)
|
|
413
320
|
{
|
|
@@ -425,7 +332,69 @@ namespace JCMG.EntitasRedux
|
|
|
425
332
|
}
|
|
426
333
|
else if (component != null)
|
|
427
334
|
{
|
|
428
|
-
|
|
335
|
+
AddComponentInternal(index, component);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
private void AddComponentInternal(int index, IComponent component)
|
|
340
|
+
{
|
|
341
|
+
_components[index] = component;
|
|
342
|
+
_componentsCache = null;
|
|
343
|
+
_componentIndicesCache = null;
|
|
344
|
+
_toStringCache = null;
|
|
345
|
+
|
|
346
|
+
using (_onComponentAdded.Invokable(out var listeners))
|
|
347
|
+
{
|
|
348
|
+
foreach (var handler in listeners)
|
|
349
|
+
handler(this, index, component);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
private void ReplaceComponentInternal(int index, IComponent replacement)
|
|
354
|
+
{
|
|
355
|
+
// TODO VD PERFORMANCE
|
|
356
|
+
// _toStringCache = null;
|
|
357
|
+
|
|
358
|
+
var previousComponent = _components[index];
|
|
359
|
+
if (replacement != previousComponent)
|
|
360
|
+
{
|
|
361
|
+
_components[index] = replacement;
|
|
362
|
+
_componentsCache = null;
|
|
363
|
+
if (replacement != null)
|
|
364
|
+
{
|
|
365
|
+
using (_onComponentReplaced.Invokable(out var listeners))
|
|
366
|
+
{
|
|
367
|
+
foreach (var handler in listeners)
|
|
368
|
+
handler(this, index, previousComponent, replacement);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
else
|
|
372
|
+
{
|
|
373
|
+
_componentIndicesCache = null;
|
|
374
|
+
|
|
375
|
+
// TODO VD PERFORMANCE
|
|
376
|
+
_toStringCache = null;
|
|
377
|
+
|
|
378
|
+
using (_onComponentRemoved.Invokable(out var listeners))
|
|
379
|
+
{
|
|
380
|
+
foreach (var handler in listeners)
|
|
381
|
+
handler(this, index, previousComponent);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// ReSharper disable once SuspiciousTypeConversion.Global
|
|
386
|
+
if (previousComponent is IDisposable disposable)
|
|
387
|
+
disposable.Dispose();
|
|
388
|
+
|
|
389
|
+
GetComponentPool(index).Push(previousComponent);
|
|
390
|
+
}
|
|
391
|
+
else
|
|
392
|
+
{
|
|
393
|
+
using (_onComponentReplaced.Invokable(out var listeners))
|
|
394
|
+
{
|
|
395
|
+
foreach (var handler in listeners)
|
|
396
|
+
handler(this, index, previousComponent, replacement);
|
|
397
|
+
}
|
|
429
398
|
}
|
|
430
399
|
}
|
|
431
400
|
|
package/Core/Entity/IEntity.cs
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "com.elestrago.unity.entitas-redux",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
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",
|