Only NPCs speak when hit. Farm animal alignment changed from NPC to Tame

This commit is contained in:
CapsizeGlimmer
2020-05-25 22:45:13 -04:00
committed by Pfauenauge90
parent 3cea76b82f
commit 78a06550d0
5 changed files with 57 additions and 20 deletions

View File

@ -5,9 +5,15 @@ use vek::*;
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum Alignment {
/// Wild animals and gentle giants
Wild,
/// Dungeon cultists and bandits
Enemy,
/// Friendly folk in villages
Npc,
/// Farm animals and pets of villagers
Tame,
/// Pets you've tamed with a collar
Owned(EcsEntity),
}
@ -27,6 +33,10 @@ impl Alignment {
match (self, other) {
(Alignment::Enemy, Alignment::Enemy) => true,
(Alignment::Owned(a), Alignment::Owned(b)) if a == b => true,
(Alignment::Npc, Alignment::Npc) => true,
(Alignment::Npc, Alignment::Tame) => true,
(Alignment::Tame, Alignment::Npc) => true,
(Alignment::Tame, Alignment::Tame) => true,
_ => false,
}
}
@ -40,6 +50,9 @@ impl Component for Alignment {
pub struct Agent {
pub patrol_origin: Option<Vec3<f32>>,
pub activity: Activity,
/// Does the agent talk when e.g. hit by the player
// TODO move speech patterns into a Behavior component
pub can_speak: bool,
}
impl Agent {
@ -47,6 +60,15 @@ impl Agent {
self.patrol_origin = Some(origin);
self
}
pub fn new(origin: Vec3<f32>, can_speak: bool) -> Self {
let patrol_origin = Some(origin);
Agent {
patrol_origin,
can_speak,
..Default::default()
}
}
}
impl Component for Agent {