Post by Admin on Jul 16, 2016 3:43:34 GMT
JuDelCo @judelco Aug 14 2015 02:37
Hi, great work with Entitas ! :smile:
I just wanted to ask some questions:
1- What about multiple components of the same type for an entity ? For example, I want to add multiple colliders (or meshes, or audio sources, or ... ) to the same entity.
... maybe that was about "unity" components they belongs to the "view" part, but.... what about a component which link a Entitas entity with other ? And two ? (like a team of warriors or multiple targets). Should be done with a component storing a c# collection ? (List, vector...)
2- Parenting entities should be done with a "ParentComponent"-like component ? (like simulating the transform component of Unity) or there are another better approach ?
3- In ReactiveSystem class there are two IMatcher I don't know what they are for: _ensureComponents and _excludeComponents. How to use them ?
4- (The curious one, not really needed to answer) Best approach to implement multithreading to the systems ? (If it's possible...)
JuDelCo @judelco Aug 14 2015 03:12
Btw, I think issue #25 is a critical one !
Kamil Chmurzynski @cloudjubei Aug 14 2015 05:03
from what I understand issue #25 is actually a misunderstanding. The removed entities will NEVER have some of the components they trigger on as that's why they've been put into that given reactive system. The system gets them, because certain components got removed. If you want to get the Entity with all the components before they actually get removed you should subscribe to the Group's OnEntityWillBeRemoved or if you have the newest version then OnEntityReplaced.
Brandon Catcho @bcatcho Aug 14 2015 05:04
Aye, it's just a way to know that the group was changed and why (something was removed). If you want to know what was removed you will need to find that a different way.
JuDelCo @judelco Aug 14 2015 05:04
But the problem is the entity may be used to instantiate another (and his components) so it may have those components
Kamil Chmurzynski @cloudjubei Aug 14 2015 05:05
JuDelCo can you clarify what you want to do exactly? I don't quite understand...
JuDelCo @judelco Aug 14 2015 05:11
(still #25 related) If a reactive system wants to be notified of 'OnEntityRemoved' (when a component gets removed OR entity gets destroyed) in the NEXT frameloop after "destroySystem" but another system in the next frame instantiate more entities (reusing the destroyed one) then the entity notified in that reactive system will be an actual living entity with different data and/or components.
For example, in the case of Match-One example, see this line -> github.com/sschmid/Match-One/blob/master/Assets/Sources/Features/RenderResource/RemoveViewSystem.cs#L32
JuDelCo @judelco Aug 14 2015 05:16
If entity was removed after Execution of that System in frame X, but in the next frame X+1 other system instantiate new entities (reusing that destroyed one) then that line can fail
Kamil Chmurzynski @cloudjubei Aug 14 2015 06:28
I think I understand what you mean now. The problem is destroying entities. I've discussed this with @sschmid and we haven't reached a consensus, but it's true that currently entities that get destroyed could get reused in the next frame by reactiveSystems even though they shouldn't. We will discuss it more and try to come up with a good solution
JuDelCo @judelco Aug 14 2015 06:30
I'm programming a sort of fix
I will pull request it later to review
Kamil Chmurzynski @cloudjubei Aug 14 2015 06:32
to answer your other questions:
1) multiple same components to same entity don't make sense - either you have to make a list or some container inside 1 component (for instance a ColliderComponent that has a List<Collider>) or make multiple components that have slightly different names (I wouldn't advise this though).
Linking to other entities - just be careful - you can do it, but what happens when the other entity you link to gets destroyed or reused or totally modified? Are you handling that case well? Just make sure you know about the caveats when you do this. To support a team of warriors etc. just assign a component that puts them in the team (i.e. TeamComponent that has int order and by this order you can filter who is with whom in what team in a system).
2) same as above - you can do it but be wary
3) you just implement the interfaces IEnsureComponents or IExcludeComponents on a IReactiveSystem and the Matcher that you provide will filter the entites that get passed to Execute based on these Matchers
so if you pass in a Matcher.A to ensureComponents it will make sure that an Entity has ComponentA - otherwise you won't get it in the Execute
analogously with exclude
Kamil Chmurzynski @cloudjubei Aug 14 2015 06:38
4) I don't think any one of us has tried Entitas multithreaded on a serious example so we don't really know, but I guess many things can work. The problem is that if your application has to provide deterministic outputs (for instance some sort of battle simulation that HAS to be right) then multithreading is a bad idea. @mzaks has a link to a nice talk about multithreading that he can provide - and the take away from it is - don't do multithreading unless you REALLY REALLY know that it will make things better.
JuDelCo @judelco Aug 14 2015 06:40
Not to mention that if I run a system with multithreading and somewhat it changes the components o entities bad things will happen
I think multithreading is good only for cases when you want to MOVE unity gameObjects linked in a "PositionComponent" from a "MoveViewSystem"-like
Anyway I had only curious about that topic, I dont have planned anything multithreaded
Thanks for your answers @cloudjubei :clap:
Kamil Chmurzynski @cloudjubei Aug 14 2015 06:45
you can always do what @sschmid does - he uses a tweening library (DOTween if i'm not mistaken) that does the moving (which works as a coroutine I think)
np
JuDelCo @judelco Aug 14 2015 06:46
Yes, but DOTween don't know where will be the entity in the next frame. That only works for fixed animations
Not simulation
JuDelCo @judelco Aug 14 2015 07:06
Okay, i just pull requested my fix proposal ( #26 ). Tomorrow after work i will read the "judgement" of it xD
There is only one disadvantage to it. You must "Add" the pools to the System class like Systems, example:
Before:
#if (UNITY_EDITOR)
return new DebugSystems()
#else
return new Systems()
#endif
.Add(pool.CreateScoreSystem())
// ... etc (rest of systems)
After:
// ...
#endif
.Add(Pools.pool) // HERE
.Add(pool.CreateScoreSystem())
// ... etc (rest of systems)
I hope it's helpful, at least to give more ideas to fix the problem
Good night
Hi, great work with Entitas ! :smile:
I just wanted to ask some questions:
1- What about multiple components of the same type for an entity ? For example, I want to add multiple colliders (or meshes, or audio sources, or ... ) to the same entity.
... maybe that was about "unity" components they belongs to the "view" part, but.... what about a component which link a Entitas entity with other ? And two ? (like a team of warriors or multiple targets). Should be done with a component storing a c# collection ? (List, vector...)
2- Parenting entities should be done with a "ParentComponent"-like component ? (like simulating the transform component of Unity) or there are another better approach ?
3- In ReactiveSystem class there are two IMatcher I don't know what they are for: _ensureComponents and _excludeComponents. How to use them ?
4- (The curious one, not really needed to answer) Best approach to implement multithreading to the systems ? (If it's possible...)
JuDelCo @judelco Aug 14 2015 03:12
Btw, I think issue #25 is a critical one !
Kamil Chmurzynski @cloudjubei Aug 14 2015 05:03
from what I understand issue #25 is actually a misunderstanding. The removed entities will NEVER have some of the components they trigger on as that's why they've been put into that given reactive system. The system gets them, because certain components got removed. If you want to get the Entity with all the components before they actually get removed you should subscribe to the Group's OnEntityWillBeRemoved or if you have the newest version then OnEntityReplaced.
Brandon Catcho @bcatcho Aug 14 2015 05:04
Aye, it's just a way to know that the group was changed and why (something was removed). If you want to know what was removed you will need to find that a different way.
JuDelCo @judelco Aug 14 2015 05:04
But the problem is the entity may be used to instantiate another (and his components) so it may have those components
Kamil Chmurzynski @cloudjubei Aug 14 2015 05:05
JuDelCo can you clarify what you want to do exactly? I don't quite understand...
JuDelCo @judelco Aug 14 2015 05:11
(still #25 related) If a reactive system wants to be notified of 'OnEntityRemoved' (when a component gets removed OR entity gets destroyed) in the NEXT frameloop after "destroySystem" but another system in the next frame instantiate more entities (reusing the destroyed one) then the entity notified in that reactive system will be an actual living entity with different data and/or components.
For example, in the case of Match-One example, see this line -> github.com/sschmid/Match-One/blob/master/Assets/Sources/Features/RenderResource/RemoveViewSystem.cs#L32
JuDelCo @judelco Aug 14 2015 05:16
If entity was removed after Execution of that System in frame X, but in the next frame X+1 other system instantiate new entities (reusing that destroyed one) then that line can fail
Kamil Chmurzynski @cloudjubei Aug 14 2015 06:28
I think I understand what you mean now. The problem is destroying entities. I've discussed this with @sschmid and we haven't reached a consensus, but it's true that currently entities that get destroyed could get reused in the next frame by reactiveSystems even though they shouldn't. We will discuss it more and try to come up with a good solution
JuDelCo @judelco Aug 14 2015 06:30
I'm programming a sort of fix
I will pull request it later to review
Kamil Chmurzynski @cloudjubei Aug 14 2015 06:32
to answer your other questions:
1) multiple same components to same entity don't make sense - either you have to make a list or some container inside 1 component (for instance a ColliderComponent that has a List<Collider>) or make multiple components that have slightly different names (I wouldn't advise this though).
Linking to other entities - just be careful - you can do it, but what happens when the other entity you link to gets destroyed or reused or totally modified? Are you handling that case well? Just make sure you know about the caveats when you do this. To support a team of warriors etc. just assign a component that puts them in the team (i.e. TeamComponent that has int order and by this order you can filter who is with whom in what team in a system).
2) same as above - you can do it but be wary
3) you just implement the interfaces IEnsureComponents or IExcludeComponents on a IReactiveSystem and the Matcher that you provide will filter the entites that get passed to Execute based on these Matchers
so if you pass in a Matcher.A to ensureComponents it will make sure that an Entity has ComponentA - otherwise you won't get it in the Execute
analogously with exclude
Kamil Chmurzynski @cloudjubei Aug 14 2015 06:38
4) I don't think any one of us has tried Entitas multithreaded on a serious example so we don't really know, but I guess many things can work. The problem is that if your application has to provide deterministic outputs (for instance some sort of battle simulation that HAS to be right) then multithreading is a bad idea. @mzaks has a link to a nice talk about multithreading that he can provide - and the take away from it is - don't do multithreading unless you REALLY REALLY know that it will make things better.
JuDelCo @judelco Aug 14 2015 06:40
Not to mention that if I run a system with multithreading and somewhat it changes the components o entities bad things will happen
I think multithreading is good only for cases when you want to MOVE unity gameObjects linked in a "PositionComponent" from a "MoveViewSystem"-like
Anyway I had only curious about that topic, I dont have planned anything multithreaded
Thanks for your answers @cloudjubei :clap:
Kamil Chmurzynski @cloudjubei Aug 14 2015 06:45
you can always do what @sschmid does - he uses a tweening library (DOTween if i'm not mistaken) that does the moving (which works as a coroutine I think)
np
JuDelCo @judelco Aug 14 2015 06:46
Yes, but DOTween don't know where will be the entity in the next frame. That only works for fixed animations
Not simulation
JuDelCo @judelco Aug 14 2015 07:06
Okay, i just pull requested my fix proposal ( #26 ). Tomorrow after work i will read the "judgement" of it xD
There is only one disadvantage to it. You must "Add" the pools to the System class like Systems, example:
Before:
#if (UNITY_EDITOR)
return new DebugSystems()
#else
return new Systems()
#endif
.Add(pool.CreateScoreSystem())
// ... etc (rest of systems)
After:
// ...
#endif
.Add(Pools.pool) // HERE
.Add(pool.CreateScoreSystem())
// ... etc (rest of systems)
I hope it's helpful, at least to give more ideas to fix the problem
Good night