nil_core/world/cheat/
npc.rs1use crate::bail_if_cheats_are_not_allowed;
5use crate::error::Result;
6use crate::ethic::Ethics;
7use crate::infrastructure::Infrastructure;
8use crate::npc::bot::BotId;
9use crate::ruler::Ruler;
10use crate::world::World;
11use tap::Pipe;
12
13impl World {
14 pub fn cheat_get_ethics(&self, ruler: &Ruler) -> Result<Option<Ethics>> {
15 bail_if_cheats_are_not_allowed!(self);
16 self.ruler(ruler)?.ethics().cloned().pipe(Ok)
17 }
18
19 pub fn cheat_set_bot_ethics(&mut self, id: &BotId, ethics: Ethics) -> Result<()> {
20 bail_if_cheats_are_not_allowed!(self);
21 *self.bot_mut(id)?.ethics_mut() = ethics;
22 Ok(())
23 }
24
25 pub fn cheat_spawn_bot(&mut self, name: &str, infrastructure: Infrastructure) -> Result<BotId> {
26 bail_if_cheats_are_not_allowed!(self);
27 self.spawn_bot(name, infrastructure)
28 }
29}