MCPcopy Create free account
hub / github.com/TheSeekerGame/TheSeeker / script_driver_system

Function script_driver_system

engine/src/script.rs:438–561  ·  view source on GitHub ↗
(
    mut q_script: Query<(Entity, &mut ScriptPlayer<T>)>,
    mut params: ParamSet<(
        StaticSystemParam<<T::Tracker as ScriptTracker>::UpdateParam>,
        StaticSystemParam<<T::Action as Scr

Source from the content-addressed store, hash-verified

436}
437
438fn script_driver_system<T: ScriptAsset>(
439 mut q_script: Query<(Entity, &mut ScriptPlayer<T>)>,
440 mut params: ParamSet<(
441 StaticSystemParam<<T::Tracker as ScriptTracker>::UpdateParam>,
442 StaticSystemParam<<T::Action as ScriptAction>::Param>,
443 StaticSystemParam<
444 <T::ActionParams as ScriptActionParams>::ShouldRunParam,
445 >,
446 )>,
447 mut action_queue: ResMut<ScriptActionQueue<T>>,
448) {
449 'outer: for (e, player) in &mut q_script {
450 let player = player.into_inner();
451
452 let mut is_loop = true;
453 let mut is_end = false;
454 while is_loop {
455 is_loop = false;
456 // do the borrow checker dance ;)
457 let mut old_state = std::mem::replace(
458 &mut player.state,
459 ScriptPlayerState::Stopped,
460 );
461 // enqueue actions
462 let script_rt = match &mut old_state {
463 ScriptPlayerState::Starting { ref mut runtime } => {
464 {
465 let mut tracker_param = params.p0().into_inner();
466 runtime.tracker.do_start(
467 e,
468 &runtime.settings,
469 &mut tracker_param,
470 &mut action_queue.0,
471 );
472 }
473 runtime
474 },
475 ScriptPlayerState::Playing { ref mut runtime } => {
476 {
477 let mut tracker_param = params.p0().into_inner();
478 let r = runtime.tracker.update(
479 e,
480 &runtime.settings,
481 &mut tracker_param,
482 &mut action_queue.0,
483 );
484 is_loop |= r.is_loop();
485 is_end |= r.is_end();
486 }
487 runtime
488 },
489 ScriptPlayerState::Stopping { ref mut runtime } => {
490 {
491 let mut tracker_param = params.p0().into_inner();
492 runtime.tracker.do_stop(
493 e,
494 &runtime.settings,
495 &mut tracker_param,

Callers

nothing calls this directly

Calls 9

is_loopMethod · 0.80
is_endMethod · 0.80
stopMethod · 0.80
do_startMethod · 0.45
updateMethod · 0.45
do_stopMethod · 0.45
queue_extra_actionsMethod · 0.45
should_runMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected