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

Customize default systems for all scenes #3101

Open
mattjennings opened this issue Jun 18, 2024 · 4 comments
Open

Customize default systems for all scenes #3101

mattjennings opened this issue Jun 18, 2024 · 4 comments
Labels
feature Label applied to new feature requests stale This issue or PR has not had any activity recently

Comments

@mattjennings
Copy link
Contributor

Context

It would be helpful to configure the default systems to be used for all scenes. This spares having to make a base scene class with the system added if I want to make sure it's always used.

Proposal

// proposal 1
new ex.Engine({
   world: {
       systems: [...], // adds to current systems
       removeDefaultSystems: true/false // removes default if true
    }
})

// proposal 2
new ex.Engine({
   world: {
       systems: [...], // overrides systems, must add back ex.MotionSystem etc
    }
})
@eonarheim
Copy link
Member

I'm into this, I'm leaning towards #1 because re-adding systems seems really rough... but on the other hand that's only once?

@eonarheim eonarheim added the feature Label applied to new feature requests label Jun 18, 2024
@mattjennings
Copy link
Contributor Author

I agree, i feel like you'd need to expose the default systems somewhere to they can be spread in. Here's 2 more ideas:

// proposal 3
new ex.Engine({
   world: {
       systems: [...ex.DefaultSystems, MySystem],
    }
})

// proposal 4
new ex.Engine({
   world:  {
       setup(world) {
           world.systemManager.addSystem(MySystem)
       }
   }
})

@Autsider666
Copy link
Contributor

I like the removeDefaultSystems option from proposal 1 a lot, because it currently takes a bit of work to get a scene without the default systems preloaded.

Using a callback (proposal 4) feels like the "best" method to me, because it prevents the reuse of system instances between scenes (causing initialize to be called more than once).

What about adding initializeWorld: (world:World)=>void to the scene constructor that falls back to a default function that adds the systems currently added in the constructor.
This default function could be overwritten if needed using something like proposal 4

Copy link

This issue hasn't had any recent activity lately and is being marked as stale automatically.

@github-actions github-actions bot added the stale This issue or PR has not had any activity recently label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Label applied to new feature requests stale This issue or PR has not had any activity recently
Projects
None yet
Development

No branches or pull requests

3 participants