portals 1
This commit is contained in:
@@ -223,6 +223,26 @@ impl GameState {
|
||||
Action::Scroll(lines) => {
|
||||
new_scroll = Some(Scroll { source: ba.source, lines });
|
||||
}
|
||||
Action::Teleport { x, y } => {
|
||||
if !board.in_bounds((x, y)) {
|
||||
logs.push(LogLine::error(format!(
|
||||
"teleport({x},{y}): out of bounds"
|
||||
)));
|
||||
} else {
|
||||
let (ux, uy) = (x as usize, y as usize);
|
||||
let source_solid = board.objects.get(&ba.source)
|
||||
.map(|o| o.solid)
|
||||
.unwrap_or(false);
|
||||
if source_solid && board.solid_at(ux, uy).is_some() {
|
||||
logs.push(LogLine::error(format!(
|
||||
"teleport({x},{y}): destination is solid"
|
||||
)));
|
||||
} else if let Some(obj) = board.objects.get_mut(&ba.source) {
|
||||
obj.x = ux;
|
||||
obj.y = uy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user