Skip to content

Instantly share code, notes, and snippets.

@ooflorent
Created May 10, 2016 06:17
Show Gist options
  • Save ooflorent/6926ac7345d430c8556c0576d4d29581 to your computer and use it in GitHub Desktop.
Save ooflorent/6926ac7345d430c8556c0576d4d29581 to your computer and use it in GitHub Desktop.
const eventBus = new EventEmitter()
function someSystem() {
for (const entity of em.query(Timer)) {
const {delay} = entity.get(Timer)
if (delay <= 0) {
// Remove `Timer` component…
entity.remove(Timer)
// …then dispatch an event
eventBus.emit("componentRemoved", {entity})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment