| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Branching sequences of events as plain data — dialog, quests, cutscenes, tutorials — for any engine. The host defines the steps; plotline runs order, branches, subroutines, jumps, and waits.
[dependencies]
plotline = "0.2"use core::task::Poll;
use plotline::{Completion, Library, Outcome, Runner, Sequence, TypeMap, steps};
let ready = Completion::new();
let waiting_on = ready.clone();
let mut library = Library::new();
let farewell = library.insert(
Sequence::new("farewell")
.with_step(steps::run("Say goodbye", |_ctx| println!("Safe roads."))),
);
let greeting = library.insert(
Sequence::new("greeting")
.with_step(steps::run("Say hello", |_ctx| println!("Hello, traveler.")))
.with_step(steps::run("Wait for the world", move |_ctx| waiting_on.clone()))
.with_step(steps::Branch {
condition: None,
if_true: Some(farewell),
if_false: None,
}),
);
let mut runner = Runner::default();
let mut services = TypeMap::new();
runner.start(greeting, None).unwrap();
assert_eq!(runner.advance(&mut library, &mut services), Poll::Pending);
ready.signal();
assert_eq!(
runner.advance(&mut library, &mut services),
Poll::Ready(Outcome::Finished),
);Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Banner artwork: “Subway” (1934) by Lily Furedi, via Wikimedia Commons. The digital image is credited to the Smithsonian American Art Museum; the file is marked public domain.
| Back | FazBrowse Home | New Git URL |