sl_types/
pathfinding.rs

1//! Pathfinding related types
2
3#[cfg(feature = "chumsky")]
4use chumsky::{prelude::Simple, Parser};
5
6/// Pathfinding types
7///
8/// see <https://wiki.secondlife.com/wiki/Category:LSL_Pathfinding_Types>
9#[derive(Debug, Clone, Hash, PartialEq, Eq, strum::FromRepr, strum::EnumIs)]
10#[repr(i8)]
11pub enum PathfindingType {
12    /// Attachments, Linden trees & grass
13    Other = -1,
14    /// Movable obstacles, movable phantoms, physical, and volumedetect objects
15    LegacyLinkset = 0,
16    /// Avatars
17    Avatar = 1,
18    /// Pathfinding characters
19    Character = 2,
20    /// Walkable objects
21    Walkable = 3,
22    /// Static obstacles
23    StaticObstacle = 4,
24    /// Material volumes
25    MaterialVolume = 5,
26    /// Exclusion volumes
27    ExclusionVolume = 6,
28}
29
30/// parse a signed integer as a pathfinding type based on the C/LSL constant
31/// values
32///
33/// # Errors
34///
35/// returns an error if the string could not be parsed
36#[cfg(feature = "chumsky")]
37#[must_use]
38pub fn int_as_pathfinding_type_parser() -> impl Parser<char, PathfindingType, Error = Simple<char>>
39{
40    crate::utils::i8_parser().try_map(|repr, span| {
41        crate::pathfinding::PathfindingType::from_repr(repr).ok_or(Simple::custom(
42            span,
43            "Could not convert parsed pathfinding type i8 into PathfindingType enum",
44        ))
45    })
46}