1#[cfg(feature = "chumsky")]
4use chumsky::{Parser, prelude::just, text::whitespace};
5
6#[cfg(feature = "chumsky")]
7use crate::utils::f32_parser;
8
9#[derive(Debug, Clone, PartialEq)]
11pub struct Vector {
12 pub x: f32,
14 pub y: f32,
16 pub z: f32,
18}
19
20#[cfg(feature = "chumsky")]
28#[must_use]
29pub fn vector_parser<'src>()
30-> impl Parser<'src, &'src str, Vector, chumsky::extra::Err<chumsky::error::Rich<'src, char>>> {
31 just('<')
32 .then(whitespace().or_not())
33 .ignore_then(f32_parser())
34 .then_ignore(whitespace().or_not())
35 .then_ignore(just(','))
36 .then_ignore(whitespace().or_not())
37 .then(f32_parser())
38 .then_ignore(whitespace().or_not())
39 .then_ignore(just(','))
40 .then_ignore(whitespace().or_not())
41 .then(f32_parser())
42 .then_ignore(whitespace().or_not())
43 .then_ignore(just('>'))
44 .map(|((x, y), z)| Vector { x, y, z })
45}
46
47impl From<crate::map::RegionCoordinates> for Vector {
48 fn from(value: crate::map::RegionCoordinates) -> Self {
49 Self {
50 x: value.x(),
51 y: value.y(),
52 z: value.z(),
53 }
54 }
55}
56
57#[derive(Debug, Clone, PartialEq)]
59pub struct Rotation {
60 pub x: f32,
62 pub y: f32,
64 pub z: f32,
66 pub s: f32,
68}
69
70#[cfg(feature = "chumsky")]
78#[must_use]
79pub fn rotation_parser<'src>()
80-> impl Parser<'src, &'src str, Rotation, chumsky::extra::Err<chumsky::error::Rich<'src, char>>> {
81 just('<')
82 .then(whitespace().or_not())
83 .ignore_then(f32_parser())
84 .then_ignore(whitespace().or_not())
85 .then_ignore(just(','))
86 .then_ignore(whitespace().or_not())
87 .then(f32_parser())
88 .then_ignore(whitespace().or_not())
89 .then_ignore(just(','))
90 .then_ignore(whitespace().or_not())
91 .then(f32_parser())
92 .then_ignore(whitespace().or_not())
93 .then_ignore(just(','))
94 .then_ignore(whitespace().or_not())
95 .then(f32_parser())
96 .then_ignore(whitespace().or_not())
97 .then_ignore(just('>'))
98 .map(|(((x, y), z), s)| Rotation { x, y, z, s })
99}
100
101#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
105pub struct ScriptPermissions(pub i32);
106
107impl ScriptPermissions {
108 pub const DEBIT: i32 = 1 << 1;
110 pub const TAKE_CONTROLS: i32 = 1 << 2;
112 pub const TRIGGER_ANIMATION: i32 = 1 << 4;
114 pub const ATTACH: i32 = 1 << 5;
116 pub const CHANGE_LINKS: i32 = 1 << 7;
118 pub const TRACK_CAMERA: i32 = 1 << 10;
120 pub const CONTROL_CAMERA: i32 = 1 << 11;
122 pub const TELEPORT: i32 = 1 << 12;
124 pub const EXPERIENCE: i32 = 1 << 13;
126 pub const SILENT_ESTATE_MANAGEMENT: i32 = 1 << 14;
128 pub const OVERRIDE_ANIMATIONS: i32 = 1 << 15;
130 pub const RETURN_OBJECTS: i32 = 1 << 16;
132
133 #[must_use]
135 pub const fn contains(self, mask: i32) -> bool {
136 self.0 & mask == mask
137 }
138}