From f3d258cbc913bbfdaa2f0c7d9dd6ef1c06fd3f90 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 25 Jan 2026 13:46:50 +0000 Subject: [PATCH] Trying to figure out Instances. --- src/duck.rs | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 47 ++------------------------------- 2 files changed, 78 insertions(+), 45 deletions(-) create mode 100644 src/duck.rs diff --git a/src/duck.rs b/src/duck.rs new file mode 100644 index 0000000..d5618ed --- /dev/null +++ b/src/duck.rs @@ -0,0 +1,76 @@ +use mlua::UserData; +use mlua::Lua; +use bevy::prelude::*; + +use include_dir::{include_dir, Dir}; + +static DATA_DIR: Dir<'_> = include_dir!("data"); + +/* +In lieu of the old Roblox instances. +Instances, at least for the sake of bevy's design, +are helper components that also implement a lua userdata wrapper. + +I'm sure storing the Entity in the component is bad practice, +but I can't find a cleaner way of integrating with Bevy's ECS like this. +*/ + +trait Instance: UserData { + +} + +struct Script { + name: String +} + +impl Instance for Script { + +} + +struct Context { + name: String, + lua: Lua +} + +impl Instance for Context { + +} + +struct Part { + name: String +} + +impl Instance for Part { + +} + +struct Folder { + name: String +} + +impl Instance for Folder { + +} + +#[derive(Component)] +enum AnyInstance { + Context(Context), + Script(Script), + Part(Part) +} + +fn script_executor() { + +} + +fn collision_detector() { + +} + +pub struct DuckPlugin; + +impl Plugin for DuckPlugin { + fn build(&self, app: &mut App) { + app.add_systems(Update,(script_executor,collision_detector)); + } +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 36ccc34..e6bf67d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,10 +1,7 @@ -use std::sync::Mutex; - use bevy::prelude::*; -use include_dir::{include_dir, Dir}; -use mlua::Lua; -static DATA_DIR: Dir<'_> = include_dir!("data"); +mod duck; +use duck::DuckPlugin; fn main() { App::new() @@ -14,46 +11,6 @@ fn main() { .run(); } -trait Instance { - fn new() -> Self { - Self {} - } - fn destroy() { - - } - fn clone() { - - } -} - -struct Part { - -} - -impl Instance for Part { - -} - -struct DuckPlugin; - -impl Plugin for DuckPlugin { - fn build(&self, app: &mut App) { - commands.spawn() - } -} - -// A scripting context, for threading and sandboxing scripts -#[derive(Component)] -struct DuckScriptContext { - lua: Lua -} - -// -#[derive(Component)] -struct DuckScript { - context: Entity -} - fn setup( mut commands: Commands, mut meshes: ResMut>,