-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix MultiReactive system retaining entities multiple times. Closes #818
- Loading branch information
Showing
4 changed files
with
121 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
Tests/Tests/Fixtures/Systems/MultiTriggeredMultiReactiveSystemSpy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Entitas; | ||
|
||
public class MultiTriggeredMultiReactiveSystemSpy : MultiReactiveSystem<IMyEntity, Contexts> { | ||
|
||
public int didExecute { get { return _didExecute; } } | ||
public IEntity[] entities { get { return _entities; } } | ||
|
||
public Action<List<IMyEntity>> executeAction; | ||
|
||
protected int _didExecute; | ||
protected IEntity[] _entities; | ||
|
||
public MultiTriggeredMultiReactiveSystemSpy(Contexts contexts) : base(contexts) { | ||
} | ||
|
||
protected override ICollector[] GetTrigger(Contexts contexts) { | ||
return new ICollector[] { | ||
contexts.test.CreateCollector(TestMatcher.NameAge), | ||
contexts.test.CreateCollector(TestMatcher.NameAge.Removed()) | ||
}; | ||
} | ||
|
||
protected override bool Filter(IMyEntity entity) { | ||
return true; | ||
} | ||
|
||
protected override void Execute(List<IMyEntity> entities) { | ||
_didExecute += 1; | ||
|
||
if (entities != null) { | ||
_entities = entities.ToArray(); | ||
} else { | ||
_entities = null; | ||
} | ||
|
||
if (executeAction != null) { | ||
executeAction(entities); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters