Expose structs to Lua and write Lua type annotations #28

Merged
SeanOMik merged 15 commits from feat/lua-type-defs into main 2024-10-19 15:17:00 +00:00
3 changed files with 5 additions and 21 deletions
Showing only changes of commit 77ec620adb - Show all commits

View File

@ -16,33 +16,26 @@ pub const ACTLBL_LOOK_ROLL: &str = "LookRoll";
#[derive(Clone, Component, Reflect)] #[derive(Clone, Component, Reflect)]
pub struct FreeFlyCamera { pub struct FreeFlyCamera {
pub speed: f32, pub speed: f32,
pub modifier_speed_factor: f32,
pub look_speed: f32, pub look_speed: f32,
pub mouse_sensitivity: f32, pub mouse_sensitivity: f32,
pub look_with_keys: bool,
} }
impl Default for FreeFlyCamera { impl Default for FreeFlyCamera {
fn default() -> Self { fn default() -> Self {
Self { Self {
speed: 4.0, speed: 4.0,
modifier_speed_factor: 0.25,
look_speed: 0.5, look_speed: 0.5,
mouse_sensitivity: 0.9, mouse_sensitivity: 0.9,
look_with_keys: false,
} }
} }
} }
impl FreeFlyCamera { impl FreeFlyCamera {
#[allow(dead_code)] pub fn new(speed: f32, look_speed: f32, mouse_sensitivity: f32) -> Self {
pub fn new(speed: f32, modifier_speed_factor: f32, look_speed: f32, mouse_sensitivity: f32, look_with_keys: bool) -> Self {
Self { Self {
speed, speed,
modifier_speed_factor,
look_speed, look_speed,
mouse_sensitivity, mouse_sensitivity,
look_with_keys,
} }
} }
} }

View File

@ -5,20 +5,13 @@ FreeFlyCamera = {
---Movement speed of the camera. ---Movement speed of the camera.
---@type number ---@type number
speed = nil, speed = nil,
---The modifier speed factor. ---The speed of the camera rotation.
---
---This isn't currently used, but it would be a factor applied to `speed`
---when the modifer key is pressed. For example: a slow or sprint mode.
---
---@type number
modifier_speed_factor = nil,
---The speed that the camera rotates, i.e., looks.
---@type number ---@type number
look_speed = nil, look_speed = nil,
---The sensitivity of the mouse when looking. ---The sensitivity of the mouse when looking.
---
---This is additional to `look_speed`, but onyl applied to mouse movement.
---
---@type number ---@type number
mouse_sensitivity = nil, mouse_sensitivity = nil,
---Enable looking with arrow keys
---@type boolean
look_with_keys = nil,
} }

View File

@ -9,9 +9,7 @@ to_lua_convert!(
reflect=component, reflect=component,
fields={ fields={
speed: f32, speed: f32,
modifier_speed_factor: f32,
look_speed: f32, look_speed: f32,
mouse_sensitivity: f32, mouse_sensitivity: f32,
look_with_keys: bool,
} }
); );