Merge branch 'james/behavior-tree' into 'master'

Transitions agent system from a FSM to a behavior tree

See merge request veloren/veloren!1801
This commit is contained in:
Joshua Barretto 2021-03-03 13:48:25 +00:00
commit eb4ce49937
2 changed files with 1691 additions and 1629 deletions

View File

@ -177,16 +177,25 @@ pub enum AgentEvent {
// Add others here
}
#[derive(Clone, Debug)]
pub struct Target {
pub target: EcsEntity,
pub hostile: bool,
}
#[derive(Clone, Debug, Default)]
pub struct Agent {
pub rtsim_controller: RtSimController,
pub patrol_origin: Option<Vec3<f32>>,
pub activity: Activity,
pub target: Option<Target>,
pub chaser: Chaser,
/// Does the agent talk when e.g. hit by the player
// TODO move speech patterns into a Behavior component
pub can_speak: bool,
pub psyche: Psyche,
pub inbox: VecDeque<AgentEvent>,
pub action_timer: f32,
pub bearing: Vec2<f32>,
}
impl Agent {
@ -217,48 +226,3 @@ impl Agent {
impl Component for Agent {
type Storage = IdvStorage<Self>;
}
#[derive(Clone, Debug)]
pub enum Activity {
Interact {
timer: f32,
interaction: AgentEvent,
},
Idle {
bearing: Vec2<f32>,
chaser: Chaser,
},
Follow {
target: EcsEntity,
chaser: Chaser,
},
Attack {
target: EcsEntity,
chaser: Chaser,
time: f64,
been_close: bool,
powerup: f32,
},
Flee {
target: EcsEntity,
chaser: Chaser,
timer: f32,
},
}
impl Activity {
pub fn is_follow(&self) -> bool { matches!(self, Activity::Follow { .. }) }
pub fn is_attack(&self) -> bool { matches!(self, Activity::Attack { .. }) }
pub fn is_flee(&self) -> bool { matches!(self, Activity::Flee { .. }) }
}
impl Default for Activity {
fn default() -> Self {
Activity::Idle {
bearing: Vec2::zero(),
chaser: Chaser::default(),
}
}
}

File diff suppressed because it is too large Load Diff