Comments (3)
@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.
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.
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)
- Sync-Point ergonomics HOT 1
- Implement async error handling (when a system throws/rejects)
- Add Madge as post-build-step HOT 1
- Investigate Deno (again) HOT 3
- I really like this git repository ! Why is insertion very slow ? HOT 1
- Rename `findWorld()` to `getWorld()`
- Create shorthand aliases for long `with...()` methods
- Add convencience methods to Query, like `filter`, `sort`,... HOT 1
- Make components Objects-of-Arrays (like BitECS) HOT 1
- Add snapshots
- Investigate preformance regression on master HOT 1
- Update Benchmarks
- Implement HMR functionality
- It feels like benchmarks are missing the point HOT 6
- Integration with ecosystem HOT 4
- Implement Component Observers
- Run pipeline from pipeline HOT 4
- deno - publish fixed imports HOT 3
- Create more examples
- The runtime world hasn't initialized a scheduler executor! HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sim-ecs.