use jmap_scene_types::{SceneAsset, SceneAvatar, SceneObject, SceneRegion};
use jmap_server::JmapObject;
pub use jmap_types::Urgency;
pub const SCENE_DATA_TYPES: &[&str] = &[
SceneRegion::TYPE_NAME,
SceneObject::TYPE_NAME,
SceneAvatar::TYPE_NAME,
SceneAsset::TYPE_NAME,
];
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum SceneEvent {
RegionDestroyedWithOwnObjects,
AvatarEnterOrLeave {
bound_chat_notified: bool,
},
RegionChangedForParticipant,
ObjectDestroyedByAdmin,
AssetChanged,
PositionReconciliation,
}
impl SceneEvent {
pub const fn urgency(self) -> Urgency {
match self {
Self::RegionDestroyedWithOwnObjects => Urgency::High,
Self::AvatarEnterOrLeave {
bound_chat_notified: true,
} => Urgency::Low,
Self::AvatarEnterOrLeave {
bound_chat_notified: false,
}
| Self::RegionChangedForParticipant => Urgency::Normal,
Self::ObjectDestroyedByAdmin => Urgency::Low,
Self::AssetChanged | Self::PositionReconciliation => Urgency::VeryLow,
}
}
}
pub fn push_urgency(events: impl IntoIterator<Item = SceneEvent>) -> Option<Urgency> {
events.into_iter().map(SceneEvent::urgency).max()
}