use bevy::ecs::entity::Entity;
use bevy::ecs::message::Message;
use bevy::reflect::Reflect;
use crate::mind::{EmotionKind, Emotions};
pub const FEELING_THRESHOLD: f32 = 0.2;
#[derive(Message, Debug, Clone, PartialEq, Eq)]
pub struct Interact {
pub actor: Entity,
pub target: Entity,
pub interaction: String,
}
#[derive(Message, Debug, Clone, PartialEq, Eq)]
pub struct SocietyBark {
pub speaker: Entity,
pub text: String,
pub thought: bool,
pub feeling: Feeling,
}
#[derive(Reflect, Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Feeling {
#[default]
Neutral,
Joy,
Anger,
Sadness,
Fear,
Calm,
}
impl Feeling {
pub fn from_emotions(emotions: &Emotions) -> Self {
let Some(strongest) = emotions.strongest() else {
return Self::Neutral;
};
if strongest.intensity < FEELING_THRESHOLD {
return Self::Neutral;
}
match strongest.kind {
EmotionKind::Joy
| EmotionKind::Pride
| EmotionKind::Gratitude
| EmotionKind::Liking
| EmotionKind::Admiration => Self::Joy,
EmotionKind::Anger | EmotionKind::Reproach | EmotionKind::Disliking => Self::Anger,
EmotionKind::Distress | EmotionKind::Shame => Self::Sadness,
EmotionKind::Fear => Self::Fear,
EmotionKind::Hope => Self::Calm,
}
}
}