Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entities not refreshing in certain situations #90

Open
seoushi opened this issue Aug 28, 2015 · 2 comments
Open

Entities not refreshing in certain situations #90

seoushi opened this issue Aug 28, 2015 · 2 comments

Comments

@seoushi
Copy link

seoushi commented Aug 28, 2015

I have a case in my code where I create and entity from a template during OnAdded in an EntitySystem. If you do this the new entity that is create never gets refreshed because it is currently in the middle of refreshing entities and afterwards it will clear the refresh list.

Simple Example

[Artemis.Attributes.ArtemisEntitySystem(ExecutionType = ExecutionType.Synchronous,GameLoopType = GameLoopType.Update, Layer = 1)]
public class SomeSystem : EntitySystem
{
        public override void OnAdded(Entity entity)
        {
            base.OnAdded(entity);
            GetEntityWorld().CreateEntityFromTemplate("SomeEnt", null); // this entity never gets refreshed
        }
}
@seoushi
Copy link
Author

seoushi commented Aug 28, 2015

I've created a pull request to partially fix this issue. The foreach loop isn't fixed because when you modify a collection during iteration it will throw an exception. I'm not sure why you have a foreach loop in there anyways as it will cause garbage collection and is actually slower than a standard for loop in this use case.

thelinuxlich added a commit that referenced this issue Aug 28, 2015
@GrafSeismo
Copy link
Contributor

hmmm, i am seriously not happy with messaging in entity system, we had this discussion once a while ago and could not find an overall solution. My intention is to avoid any messaging while using Entity System (ES) if you can, it is not ideologic passable to its meaning in my opinion, because the "Message" should be a components data in ES. Event Messaging is therefore a paralell and dangerous way in combination with ES. You can do anything with ES, but mixing idiologics can do things more complicated as anyone can reproduce later. So if you can, avoid using events, use another component/system couple instead to get your messages transported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants