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

[Chapter 70] Missing text for fire_on_target #233

Open
PierreGuyot opened this issue Jan 16, 2025 · 0 comments
Open

[Chapter 70] Missing text for fire_on_target #233

PierreGuyot opened this issue Jan 16, 2025 · 0 comments

Comments

@PierreGuyot
Copy link

PierreGuyot commented Jan 16, 2025

fn fire_on_target(ecs: &mut World) -> RunState {
let targets = ecs.write_storage::<Target>();
let entities = ecs.entities();
let mut current_target : Option<Entity> = None;
let mut log = ecs.fetch_mut::<GameLog>();
for (e,_t) in (&entities, &targets).join() {
current_target = Some(e);
}
if let Some(target) = current_target {
let player_entity = ecs.fetch::<Entity>();
let mut shoot_store = ecs.write_storage::<WantsToShoot>();
let names = ecs.read_storage::<Name>();
if let Some(name) = names.get(target) {
log.entries.push(format!("You fire at {}", name.name));
}
shoot_store.insert(*player_entity, WantsToShoot{ target }).expect("Insert Fail");
RunState::Ticking
} else {
log.entries.push("You don't have a target selected!".to_string());
RunState::AwaitingInput
}
}

https://github.com/amethyst/rustrogueliketutorial/blob/master/chapter-70-missiles/src/player.rs#L482

The chapter 70 forgets to add the fire_on_target function and to call it from player.rs (to fire with the F key). The code for it is in the repo, but not mentioned in the book.

@PierreGuyot PierreGuyot changed the title [Chapter 70] Missing text for fire_target [Chapter 70] Missing text for fire_on_target Jan 16, 2025
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

No branches or pull requests

1 participant