Comments (4)
The thing about groups (at least as far as I know) they do not really respond to the entity being added/removed but to each individual component.
So in your PlayerSelectActionAttackSytem you replace the position of the entity, therefore triggering all the groups again. In effect the replace triggers the remove event first (since the old position is removed) and then the add event (since the new position is added).
I hope that makes things a little bit clearer and helps you solve the problem.
from entitas.
An entity is part of a group, when it fulfills the requirements of the matcher. In your case
Group group = pool.GetGroup(Matcher.AllOf(Matcher.PlayerSelectActionAttack, Matcher.Position));
onAdded = group.CreateObserver (GroupEventType.OnEntityAdded);
onRemoved = group.CreateObserver (GroupEventType.OnEntityRemoved);
an entity belongs to a group when it has a PlayerSelectActionAttackComponent
and a PositionComponent
.
Whenever you replace either of those it will be removed from the group (intentionally), because the idea is to remove the old component (=> entity doesn't match anymore) and the replace it with the new component (=> entity matches again). As a result e.ReplaceXyz will always trigger OnEntityAdded AND OnEntityRemoved
from entitas.
Btw, AttackPointerController
looks like it should be a ReactiveSystem rather than a MonoBehaviour. A ReactiveSystem is using a GroupObserver under the hood, so you don't have to mess with it. If you still want to use GroupObservers don't forget to call observer.ClearCollectedEntities()
You can get the most out of Entitas if you try putting all your logic into dedicated systems doing only one thing.
from entitas.
Thanks for yours responses
Now, I understand the concept of ReplaceComponent
You can get the most out of Entitas if you try putting all your logic into dedicated systems doing only one thing.
Ok, I will remove all UI Logic and create dedicated systems
Regards
from entitas.
Related Issues (20)
- Wiki closed for editing
- Unity crashes when clicking on a GameObject with Component of Entitas HOT 8
- Remove DesperateDevs dependencies
- [SOLVED] Unity 2022.3.4f1: Exceptions + broken inspector when looking at any entity HOT 16
- Add/Replace/Remove vs Set/Unset HOT 5
- Boolean in setttings for unique components to actually be unique
- A component with multiple contexts +events, only make event listeners for 1 context
- Could not resolve type with token ... expected class System.Threading.CancellationToken HOT 10
- How to generate codes in a project which has several csproj files? HOT 1
- Update on Entitas 2.0-beta and my situation HOT 3
- [1.14.1]code gen twice and compile error HOT 1
- there is a Error, on click Tools/Jenny/Gennerate, how can I do? HOT 4
- _group.GetEntities().AsParallel().ForAll(Execute);这段语句有GC HOT 2
- Is it feasible to use Entitas in the backend? HOT 7
- Entity Behaviour in Unity inspector not visible HOT 2
- Removal of crucial SearchPaths when executing the wiz command
- How to get all group in some context, without reflection。
- GUI Null ref when trying to view entity in inspector HOT 1
- generator issues HOT 1
- Error running dotnet Jenny/Jenny.Generator.Cli.dll gen -v command - System.IO.FileNotFoundException HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from entitas.