-
Notifications
You must be signed in to change notification settings - Fork 3
Signals & Hands #2
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is abut to add
SignalsandHandsto Polako. See hands example.Signals
Signal is a wrapper around Event associated with Entity. There are user defined signals like
TakeDamageSignalor system-provided signals likeOnDemand<EnterSignal>orOnDemand<UpdateSignal>.I can define Signal like this:
I can assign the Signal to the Element like this:
I can connect to Signal like this:
.on.take_damage:defines the signal to connect(e) => { this.health -= e.damage; }is the Hand.I can emit event by sending the Signal to EventWriter, or by calling
enemy.take_damage.emit(.damage: 23.)from the Hand.Hands
Hand is the Signal's handler. It looks like closure, but it is not. Hand is parsed manually. Hand have access to
emlcontext and its marks. With this knowledge it is possible to build System with only required params for the exact Hand. For example:Expanded
eml!will generate variablestime: ResourceMark<Time>,delta: EntityMark<Label>andelapsed: EntityMark<Label>. EntityMark is just an Entity with PhantomData.The expanded eml will also generate a system-like closure that requests only required system params for this hand. It looks something like this:
While this System is suboptimal, there is a lot of space for optimisations.
On-demand Signals
There are two on-demand signals right now:
EnterSignal&UpdateSignal. Emitting this signal on every entity is ineffective and useless. So I want to emit this signals only on entities with handles. So when I connect to.on.enteror.on.update- the signals start to emit on the connected entities.Hand syntax.
Hands are supposed to be very simple blocks of code. So the syntax right now is very limited.
Statements (
STMT):mark.prop = EXPR;mark.signal.emit(ARGS);MyEvent::send(ARGS);|send(MyEvent[, ARGS]);if EXPR { STMT+ } [ elif EXPR { STMT+ } ]* [ else { STMT+ } ]Expressions (
EXPR):LITERALmark.propEXPR.fmt(STR)(EXPR)EXPR + EXPREXPR - EXPREXPR * EXPREXPR / EXPRArguments (
ARGS):.name: EXPR.name: EXPR [, .name: EXPR]*Status
.on.signal:param extensionmark.prop = EXPR