Removed patrol origin from humanoid NPCs

This commit is contained in:
Joshua Barretto 2023-01-05 17:22:36 +00:00
parent 84eb7b0653
commit 2aa6ced357
3 changed files with 16 additions and 23 deletions

View File

@ -467,7 +467,9 @@ fn villager(visiting_site: SiteId) -> impl Action {
format!("travel to visiting site") format!("travel to visiting site")
} }
})) }))
} else if DayPeriod::from(ctx.time_of_day.0).is_dark() { } else if DayPeriod::from(ctx.time_of_day.0).is_dark()
&& !matches!(ctx.npc.profession, Some(Profession::Guard))
{
important( important(
now(move |ctx| { now(move |ctx| {
if let Some(house_wpos) = ctx if let Some(house_wpos) = ctx

View File

@ -260,19 +260,6 @@ impl<'a> System<'a> for Sys {
if let Some(agent) = agent { if let Some(agent) = agent {
agent.rtsim_controller.travel_to = npc.goto.map(|(wpos, _)| wpos); agent.rtsim_controller.travel_to = npc.goto.map(|(wpos, _)| wpos);
agent.rtsim_controller.speed_factor = npc.goto.map_or(1.0, |(_, sf)| sf); agent.rtsim_controller.speed_factor = npc.goto.map_or(1.0, |(_, sf)| sf);
// TODO:
// agent.rtsim_controller.heading_to =
// npc.pathing.intersite_path.as_ref().
// and_then(|(path, _)| {
// Some(
// index
// .sites
//
// .get(data.sites.get(path.end)?.world_site?)
// .name()
// .to_string(),
// )
// });
} }
}); });
} }

View File

@ -513,15 +513,19 @@ impl NpcData {
}; };
let agent = has_agency.then(|| { let agent = has_agency.then(|| {
comp::Agent::from_body(&body) let mut agent = comp::Agent::from_body(&body).with_behavior(
.with_behavior(
Behavior::default() Behavior::default()
.maybe_with_capabilities(can_speak.then_some(BehaviorCapability::SPEAK)) .maybe_with_capabilities(can_speak.then_some(BehaviorCapability::SPEAK))
.maybe_with_capabilities(trade_for_site.map(|_| BehaviorCapability::TRADE)) .maybe_with_capabilities(trade_for_site.map(|_| BehaviorCapability::TRADE))
.with_trade_site(trade_for_site), .with_trade_site(trade_for_site),
) );
.with_patrol_origin(pos)
.with_no_flee_if(matches!(agent_mark, Some(agent::Mark::Guard)) || no_flee) // Non-humanoids get a patrol origin to stop them moving too far
if !matches!(body, comp::Body::Humanoid(_)) {
agent = agent.with_patrol_origin(pos);
}
agent.with_no_flee_if(matches!(agent_mark, Some(agent::Mark::Guard)) || no_flee)
}); });
let agent = if matches!(alignment, comp::Alignment::Enemy) let agent = if matches!(alignment, comp::Alignment::Enemy)