Trying to figure out Instances.

This commit is contained in:
2026-01-25 13:46:50 +00:00
parent 4f2b63aa47
commit f3d258cbc9
2 changed files with 78 additions and 45 deletions

76
src/duck.rs Normal file
View File

@@ -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));
}
}