2020-01-23 14:10:49 +00:00
|
|
|
use crate::path::Chaser;
|
2019-07-29 19:54:48 +00:00
|
|
|
use specs::{Component, Entity as EcsEntity};
|
|
|
|
use specs_idvs::IDVStorage;
|
2019-07-29 19:54:58 +00:00
|
|
|
use vek::*;
|
2019-04-16 21:06:33 +00:00
|
|
|
|
2020-01-24 21:24:57 +00:00
|
|
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
|
|
|
pub enum Alignment {
|
|
|
|
Wild,
|
|
|
|
Enemy,
|
|
|
|
Npc,
|
2019-04-16 21:06:33 +00:00
|
|
|
}
|
|
|
|
|
2020-01-24 21:24:57 +00:00
|
|
|
impl Alignment {
|
|
|
|
pub fn hostile_towards(self, other: Alignment) -> bool {
|
|
|
|
match (self, other) {
|
|
|
|
(Alignment::Wild, Alignment::Npc) => true,
|
|
|
|
_ => self != other,
|
2019-08-02 18:56:37 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-24 21:24:57 +00:00
|
|
|
}
|
2020-01-22 03:12:17 +00:00
|
|
|
|
2020-01-24 21:24:57 +00:00
|
|
|
impl Component for Alignment {
|
|
|
|
type Storage = IDVStorage<Self>;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Default)]
|
|
|
|
pub struct Agent {
|
|
|
|
pub chaser: Chaser,
|
2020-01-25 02:15:15 +00:00
|
|
|
pub target: Option<(EcsEntity, f64)>,
|
2020-01-24 21:24:57 +00:00
|
|
|
pub owner: Option<EcsEntity>,
|
|
|
|
pub patrol_origin: Option<Vec3<f32>>,
|
2020-01-25 02:15:15 +00:00
|
|
|
pub wander_pos: Option<Vec3<f32>>,
|
2020-01-24 21:24:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Agent {
|
|
|
|
pub fn with_pet(mut self, owner: EcsEntity) -> Self {
|
|
|
|
self.owner = Some(owner);
|
|
|
|
self
|
2020-01-22 03:12:17 +00:00
|
|
|
}
|
2020-01-25 02:15:15 +00:00
|
|
|
|
|
|
|
pub fn with_patrol_origin(mut self, origin: Vec3<f32>) -> Self {
|
|
|
|
self.patrol_origin = Some(origin);
|
|
|
|
self
|
|
|
|
}
|
2019-08-02 18:56:37 +00:00
|
|
|
}
|
|
|
|
|
2019-04-16 21:06:33 +00:00
|
|
|
impl Component for Agent {
|
2019-07-29 19:54:48 +00:00
|
|
|
type Storage = IDVStorage<Self>;
|
2019-04-16 21:06:33 +00:00
|
|
|
}
|