Skip to content

Conversation

@GlennMacdonald
Copy link
Contributor

Trying to address #255 and #264

  • Replaced all the old Messages with EntityEvents.
  • Renamed source to entity in those events to be more consistent with EntityEvents defaults
  • Removed Event Suffix from the events/messages
  • Updated examples/tests to use the new EntityEvents

I am not 100% confident that my changes to execution.rs are the 'correct' ones but it seems to work.
Same thing with the changes I made to the tests.

This is a quite a breaking change anyone who was reading the messages would need to change to use observers.

@janhohenheim
Copy link
Collaborator

Oh hell yeah, thanks for this!!

@GlennMacdonald
Copy link
Contributor Author

Oh hell yeah, thanks for this!!

No problem, Let me know if you see any issue. I ran cargo fmt --all to fix the CI issue

Copy link
Contributor

@Person-93 Person-93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI - I'm not an official reviewer or maintainer or anything, so you don't have to respond to my comments if you don't want to.

Comment on lines 10 to 25
fn execute_commands(
event: On<ExecuteCommand>,
dialogue_runners: Query<&DialogueRunner>,
mut commands: Commands,
) {
let dialogue_runner = dialogue_runners.get(event.entity).unwrap();
let Some(mut command) = clone_command(dialogue_runner, &event) else {
return;
};
let params = event.command.parameters.clone();
let entity = event.entity;
commands.queue(move |world: &mut World| {
let task_finished_indicator = command.call(params.clone(), world);
if !task_finished_indicator.is_finished() {
get_dialogue_runner_mut(world, event.source).add_command_task(task_finished_indicator);
get_dialogue_runner_mut(world, entity).add_command_task(task_finished_indicator);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be simpler to just clone the ExecuteCommand, move that into the closure, and de-structure it. Then the dialogue_runners: Query<&DialogueRunner> parameter isn't even needed any more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that's certainly cleaner, I for sure do not need that query.

pub struct AssertionPlugin;
impl Plugin for AssertionPlugin {
fn build(&self, app: &mut App) {
app.insert_resource(TriggeredEvents::<PresentLine>(Vec::new()))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come we accumulate these at all still? I think just reacting to them as they come should be more idiomatic :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it so the predicate gets checked as the event is caught.

There is still a resource tracking the number of calls mostly for the case when we want to verify that an event wasn't called.

Only one test really cared about the accumulation serves_assets_after_loading so that one had to do things a bit differently.

Copy link
Collaborator

@janhohenheim janhohenheim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely, thanks! Sorry for the delay haha

@janhohenheim
Copy link
Collaborator

Merging when the lints are green :)

auto-merge was automatically disabled November 16, 2025 14:28

Head branch was pushed to by a user without write access

@GlennMacdonald
Copy link
Contributor Author

Merging when the lints are green :)

Oops, forgot to run clippy

auto-merge was automatically disabled November 16, 2025 16:25

Head branch was pushed to by a user without write access

@GlennMacdonald
Copy link
Contributor Author

Ahh! Sorry about all the churn here. I think I removed the logic to actually call the predicate to verify something, then forgot I did that. So all the test were passing without ever testing :)

@janhohenheim janhohenheim merged commit de43d4c into YarnSpinnerTool:main Nov 17, 2025
7 checks passed
@janhohenheim
Copy link
Collaborator

janhohenheim commented Nov 17, 2025

happens! :) Thanks a bunch again!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants