mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
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:
commit
eb4ce49937
@ -177,16 +177,25 @@ pub enum AgentEvent {
|
|||||||
// Add others here
|
// Add others here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug)]
|
||||||
|
pub struct Target {
|
||||||
|
pub target: EcsEntity,
|
||||||
|
pub hostile: bool,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
pub struct Agent {
|
pub struct Agent {
|
||||||
pub rtsim_controller: RtSimController,
|
pub rtsim_controller: RtSimController,
|
||||||
pub patrol_origin: Option<Vec3<f32>>,
|
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
|
/// Does the agent talk when e.g. hit by the player
|
||||||
// TODO move speech patterns into a Behavior component
|
// TODO move speech patterns into a Behavior component
|
||||||
pub can_speak: bool,
|
pub can_speak: bool,
|
||||||
pub psyche: Psyche,
|
pub psyche: Psyche,
|
||||||
pub inbox: VecDeque<AgentEvent>,
|
pub inbox: VecDeque<AgentEvent>,
|
||||||
|
pub action_timer: f32,
|
||||||
|
pub bearing: Vec2<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Agent {
|
impl Agent {
|
||||||
@ -217,48 +226,3 @@ impl Agent {
|
|||||||
impl Component for Agent {
|
impl Component for Agent {
|
||||||
type Storage = IdvStorage<Self>;
|
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
Loading…
Reference in New Issue
Block a user