ecs: fix Changed query; lua: lock and hide mouse in window
CI / build (push) Failing after 3m10s
Details
CI / build (push) Failing after 3m10s
Details
This commit is contained in:
parent
76b7cac699
commit
a2c52a0bb8
|
@ -1,3 +1,5 @@
|
||||||
|
HAS_SETUP_WINDOW = false
|
||||||
|
|
||||||
---Return the userdata's name from its metatable.
|
---Return the userdata's name from its metatable.
|
||||||
---
|
---
|
||||||
---Returns nil if the userdata doesn't have a metatable.
|
---Returns nil if the userdata doesn't have a metatable.
|
||||||
|
@ -28,11 +30,22 @@ function on_init()
|
||||||
print("spawned entity " .. tostring(e))
|
print("spawned entity " .. tostring(e))
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[ function on_first()
|
function on_first()
|
||||||
print("Lua's first function was called")
|
if not HAS_SETUP_WINDOW then
|
||||||
|
world:view(function (w)
|
||||||
|
if w.cursor_grab == CursorGrabMode.NONE then
|
||||||
|
w.cursor_grab = CursorGrabMode.LOCKED
|
||||||
|
w.cursor_visible = false
|
||||||
|
return w
|
||||||
|
else
|
||||||
|
HAS_SETUP_WINDOW = true
|
||||||
|
print("Window setup")
|
||||||
|
end
|
||||||
|
end, Window)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function on_pre_update()
|
--[[ function on_pre_update()
|
||||||
print("Lua's pre-update function was called")
|
print("Lua's pre-update function was called")
|
||||||
end ]]
|
end ]]
|
||||||
|
|
||||||
|
@ -57,13 +70,6 @@ function on_update()
|
||||||
t:translate(0, 0.15 * dt, 0)
|
t:translate(0, 0.15 * dt, 0)
|
||||||
return t
|
return t
|
||||||
end, Transform)
|
end, Transform)
|
||||||
|
|
||||||
world:view(function (w)
|
|
||||||
print("cursor pos: " .. tostring(w.cursor_position))
|
|
||||||
print("mode: " .. w.window_mode)
|
|
||||||
print("pos: " .. tostring(w.position))
|
|
||||||
print("theme: " .. tostring(w.theme))
|
|
||||||
end, Window)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[ function on_post_update()
|
--[[ function on_post_update()
|
||||||
|
|
|
@ -20,7 +20,7 @@ where
|
||||||
|
|
||||||
unsafe fn get_item(&mut self, entity: crate::world::ArchetypeEntityId) -> Self::Item {
|
unsafe fn get_item(&mut self, entity: crate::world::ArchetypeEntityId) -> Self::Item {
|
||||||
let tick = self.col.entity_ticks[entity.0 as usize];
|
let tick = self.col.entity_ticks[entity.0 as usize];
|
||||||
tick >= self.tick
|
*tick >= (*self.tick) - 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ impl<'a, T: ResourceObject> Res<'a, T> {
|
||||||
|
|
||||||
/// Returns a boolean indicating if the resource changed.
|
/// Returns a boolean indicating if the resource changed.
|
||||||
pub fn changed(&self) -> bool {
|
pub fn changed(&self) -> bool {
|
||||||
self.inner.tick >= self.world_tick
|
*self.inner.tick - 1 >= *self.world_tick - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The tick that this resource was last modified at
|
/// The tick that this resource was last modified at
|
||||||
|
@ -236,7 +236,7 @@ impl<'a, T: ResourceObject> ResMut<'a, T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn changed(&self) -> bool {
|
pub fn changed(&self) -> bool {
|
||||||
self.inner.tick > self.world_tick
|
*self.inner.tick - 1 >= *self.world_tick - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The tick that this resource was last modified at
|
/// The tick that this resource was last modified at
|
||||||
|
|
|
@ -89,6 +89,6 @@ impl ResourceData {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn changed(&self, tick: Tick) -> bool {
|
pub fn changed(&self, tick: Tick) -> bool {
|
||||||
self.data.borrow().tick >= tick
|
*self.data.borrow().tick >= *tick - 1
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
use lyra_ecs::World;
|
use lyra_ecs::World;
|
||||||
use crate::lua::wrappers::{LuaQuat, LuaTransform, LuaVec3};
|
use crate::lua::wrappers::{LuaQuat, LuaTransform, LuaVec3, LuaVec2};
|
||||||
use crate::ScriptData;
|
use crate::ScriptData;
|
||||||
use crate::lua::RegisterLuaType;
|
use crate::lua::RegisterLuaType;
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ impl ScriptApiProvider for LyraMathApiProvider {
|
||||||
type ScriptContext = LuaContext;
|
type ScriptContext = LuaContext;
|
||||||
|
|
||||||
fn prepare_world(&mut self, world: &mut World) {
|
fn prepare_world(&mut self, world: &mut World) {
|
||||||
|
world.register_lua_wrapper::<LuaVec2>();
|
||||||
world.register_lua_wrapper::<LuaVec3>();
|
world.register_lua_wrapper::<LuaVec3>();
|
||||||
world.register_lua_wrapper::<LuaQuat>();
|
world.register_lua_wrapper::<LuaQuat>();
|
||||||
world.register_lua_wrapper::<LuaTransform>();
|
world.register_lua_wrapper::<LuaTransform>();
|
||||||
|
@ -24,6 +25,7 @@ impl ScriptApiProvider for LyraMathApiProvider {
|
||||||
ctx.load("lyra/math/transform.lua", bytes.as_slice())?.execute(())?; */
|
ctx.load("lyra/math/transform.lua", bytes.as_slice())?.execute(())?; */
|
||||||
|
|
||||||
let globals = ctx.globals();
|
let globals = ctx.globals();
|
||||||
|
globals.set("Vec2", ctx.create_proxy::<LuaVec2>()?)?;
|
||||||
globals.set("Vec3", ctx.create_proxy::<LuaVec3>()?)?;
|
globals.set("Vec3", ctx.create_proxy::<LuaVec3>()?)?;
|
||||||
globals.set("Quat", ctx.create_proxy::<LuaQuat>()?)?;
|
globals.set("Quat", ctx.create_proxy::<LuaQuat>()?)?;
|
||||||
globals.set("Transform", ctx.create_proxy::<LuaTransform>()?)?;
|
globals.set("Transform", ctx.create_proxy::<LuaTransform>()?)?;
|
||||||
|
|
|
@ -154,7 +154,7 @@ wrap_lua_struct!(
|
||||||
Err(mlua::Error::external(Error::unimplemented("field 'cursor_appearance' is unimplemented")))
|
Err(mlua::Error::external(Error::unimplemented("field 'cursor_appearance' is unimplemented")))
|
||||||
});
|
});
|
||||||
|
|
||||||
fields.add_field_method_get("cursor_grab_mode", |lua, this| {
|
fields.add_field_method_get("cursor_grab", |lua, this| {
|
||||||
let v = match &this.cursor.grab {
|
let v = match &this.cursor.grab {
|
||||||
CursorGrabMode::None => "none",
|
CursorGrabMode::None => "none",
|
||||||
CursorGrabMode::Confined => "confined",
|
CursorGrabMode::Confined => "confined",
|
||||||
|
@ -163,7 +163,7 @@ wrap_lua_struct!(
|
||||||
|
|
||||||
v.into_lua(lua)
|
v.into_lua(lua)
|
||||||
});
|
});
|
||||||
fields.add_field_method_set("cursor_grab_mode", |_, this, val: String| {
|
fields.add_field_method_set("cursor_grab", |_, this, val: String| {
|
||||||
let val = val.as_str();
|
let val = val.as_str();
|
||||||
|
|
||||||
let v = match val {
|
let v = match val {
|
||||||
|
|
Loading…
Reference in New Issue