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

Triggers: attaching actions to a state which is the current #112

Open
tomtzook opened this issue Feb 23, 2024 · 1 comment
Open

Triggers: attaching actions to a state which is the current #112

tomtzook opened this issue Feb 23, 2024 · 1 comment

Comments

@tomtzook
Copy link
Member

When attaching actions to triggers for a state which is current, the actions won't be used as expected until the next cycling of the action state.

For example, say the current state is TriggerState.ACTIVE, and someone invokes Trigger.whenActive with some action, this action won't be started.

The root for this is that the updates to attached actions are only done in GenericTrigger.update (called by the scheduler), which only updates the actions if the state has changed.

Problem is, we can't simply act on the actions via the attach methods (like Trigger.whenActive) because it is only allowed (and possible) via GenericTrigger.update. So either we change this, or create some list which registers newly attached actions, and in update perform special handling for them.

@tomtzook
Copy link
Member Author

For now, if encountered and this is a problem, cycle the trigger state. For a manual trigger, this simply involves calling activate and then deactivate (or the other way around, depending on the wanted state).

For a condition-based trigger, this is more problematic, as it requires cycling the condition. On option for this, is to cycle the source of the condition, or modify the condition with some variable to allow manually cycling it.

However, the actual cycling can only occur (and be detected) if the scheduler has noticed the change. So this is actually a bit difficult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant