Coder Social home page Coder Social logo

Comments (3)

minecrawler avatar minecrawler commented on May 25, 2024 2

@iamcsharper I changed the way systems are assigned to states. It now works as per your request. The changes are only in the master branch, but will be included in the next release 😉

// State definition
class GameState extends State {
    activate() {
        console.log('Game State is active, now!');
    }
    
    deactivate() {
        console.log('Game State is inactive, now!');
    }
}

// System definition
class GameSystem extends System {
    readonly query = new Query({ /* ... */ });
    readonly states = [GameState];

    run() { /* ... */ }
}

// Dispatch a state once
world.dispatch(GameState);

// OR start running in a state
world.run({ initialState: GameState });

By the way, if you want to run all systems, you can do so by omitting the initial state, or if you want to switch from a state to running all systems, you can simply pass State as state. If you created the world using buildWorld(), the state State was automatically populated with all registered systems.

from sim-ecs.

minecrawler avatar minecrawler commented on May 25, 2024 1

As soon as you reach 50+ systems it gets really annoying to keep your eye on both GameState and createWorld() function

Yes, and it's a problem which directly conflicts with the use-case of sim-ecs. There is a work-item in the "New Features" project, which waits for the bevy_ecs centralized_run_criteria RFC. I am aware of the shortcomings of the current situation, however I want to derive some of the ideas from bevy to implement a solid solution. Once they move forward, I want to take a look at how to make run criteria (as in which systems should run when, including the state) easy to set up.

using decorators

Decorators are a boon, however they are still in draft and experimental, which is why I refrained from adding them. Once they are finalized and not behind a feature-flag anymore, I will probably add some to remove boilerplate where possible.

or simply a readonly array

Since there are fewer states than systems, this could be a short-term fix. I will look into it for 0.4!

from sim-ecs.

vmwxiong avatar vmwxiong commented on May 25, 2024

For what it's worth, decorators have been around for a fair bit now, and I have seen them used effectively already. I know it's not ideal, but I'm guessing that if changes are made they will be minor, and given the state of this project, it might be worth integrating now and just dealing with the change if and when it comes. Might help clarify some design decisions along the way, just my two cents.

from sim-ecs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.