-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Entitas:] Find alternative to pool.CreateSystem() #233
Comments
What about sth like this .Add(new IncrementTickSystem().Bind(pools))
.Add(new AddViewSystem().Bind(pools.core))
.Add(new AddViewSystem().Bind(pools.bullet))
This might be less confusing and more explicit. Sounds more like we're using this system with the specified pool |
Any suggestions other than .Bind(core)? This will most likely be an extension method on |
UPDATE: new idea (forget .Bind()) Since this might be a big change I'd like to have your opinion on that. 2 thoughts: The goal is to simplify the creation of system lists. I'm thinking about removing Instead, use pools only and pass them in as a constructor argument if needed. Currently As a result we'd write sth like this: return new Feature("Systems")
.Add(new IncrementTickSystem(pools))
.Add(new CreatePlayerSystem(pools))
.Add(new CreateEnemySystem(pools))
.Add(new AddViewSystem(pools))
.Add(new AddViewFromObjectPoolSystem(pools)) compared to the current solution: return new Feature("Systems")
.Add(pools.CreateSystem(new IncrementTickSystem()))
.Add(pools.CreateSystem(new CreatePlayerSystem()))
.Add(pools.CreateSystem(new CreateEnemySystem()))
.Add(pools.core.CreateSystem(new AddViewSystem()))
.Add(pools.bullets.CreateSystem(new AddViewFromObjectPoolSystem())) I would need to add some mechanism to define the pool which a reactive sub system is working on to make this work, but this could be achieved by modifying public interface IReactiveSystem : IReactiveExecuteSystem {
TriggerOnEvent trigger { get; }
Pool Bind(Pools pools);
} You basically hardcode the reactive system to a pool. We kind of doing this anyway already by using {Pool}Matcher as a trigger. Any thoughts before I get started? |
I don't like the idea of adding in Pools like that because what if I wanted to reuse the system for a specific pool of the same type (referring to type safety branch) I would prefer the instance of the pool not a class with pools in to access. |
@T2RKUS Yes, that's the only thing I have in mind too. If we move in this direction |
Why "pools"? Doesn't a system live in one pool, and that's it? (yes, it could technically have a dependency on multiple pools, but that feels a little smelly, as CreateSystem is a member of Pool.) ISetPool is very repetitive indeed, about 30-70% of my systems implement ISetPool. Any chance this could be done through inheritance instead? (I generally find inheritance highly underrated). I often use SetPool to just create a group which I'm using throughout the life of an IExecuteSystem, etc. |
Oh, I understand and was misled all the time by the things you called out as misleading in the first post. 👍 |
It's the end of the year and a good time to clean up a little bit ;) I updated public interface IReactiveSystem : ISystem {
EntityCollector GetTrigger(Pools pools);
void Execute(List<Entity> entities);
} This change enabled me to get rid of loooots of code . It's a breaking change but I hope the result is less confusion and less code to maintain. I deleted:
... without loosing any features. The new Adding systems to the list is more streamlined and less code .Add(new IncrementTickSystem(pools)) |
# Conflicts: # Entitas/Entitas/Interfaces/IReactiveSystem.cs
PoolExtension.cs contains the convenience methods
pool(s).CreateSystem()
3 things:
Sometimes we use
pools.CreateSystem()
, sometimespools.core.CreateSystem()
. Would be great to streamline this.The text was updated successfully, but these errors were encountered: