Skip to content

Commit

Permalink
more refactoring / fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Oct 4, 2024
1 parent 0ab840e commit d746e76
Show file tree
Hide file tree
Showing 44 changed files with 6,761 additions and 4,069 deletions.
32 changes: 18 additions & 14 deletions crates/unavi-scripting/examples/unavi-layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@ use avian3d::{prelude::PhysicsDebugPlugin, PhysicsPlugins};
use bevy::prelude::*;
use bevy_panorbit_camera::{PanOrbitCamera, PanOrbitCameraPlugin};
use unavi_scripting::{ScriptBundle, ScriptingPlugin};
use unavi_world::util::init_user_actor;

fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(AssetPlugin {
file_path: "../unavi-app/assets".to_string(),
..default()
}),
PanOrbitCameraPlugin,
PhysicsDebugPlugin::default(),
PhysicsPlugins::default(),
ScriptingPlugin,
))
.add_systems(Startup, (setup_scene, load_script))
.run();
#[tokio::main]
async fn main() {
let mut app = App::new();
init_user_actor(app.world_mut()).await;

app.add_plugins((
DefaultPlugins.set(AssetPlugin {
file_path: "../unavi-app/assets".to_string(),
..default()
}),
PanOrbitCameraPlugin,
PhysicsDebugPlugin::default(),
PhysicsPlugins::default(),
ScriptingPlugin,
))
.add_systems(Startup, (setup_scene, load_script))
.run();
}

fn setup_scene(mut ambient: ResMut<AmbientLight>, mut commands: Commands) {
Expand Down
32 changes: 18 additions & 14 deletions crates/unavi-scripting/examples/unavi-shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@ use avian3d::prelude::*;
use bevy::prelude::*;
use bevy_panorbit_camera::{PanOrbitCamera, PanOrbitCameraPlugin};
use unavi_scripting::{ScriptBundle, ScriptingPlugin};
use unavi_world::util::init_user_actor;

fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(AssetPlugin {
file_path: "../unavi-app/assets".to_string(),
..default()
}),
PanOrbitCameraPlugin,
PhysicsDebugPlugin::default(),
PhysicsPlugins::default(),
ScriptingPlugin,
))
.add_systems(Startup, (setup_scene, load_script))
.run();
#[tokio::main]
async fn main() {
let mut app = App::new();
init_user_actor(app.world_mut()).await;

app.add_plugins((
DefaultPlugins.set(AssetPlugin {
file_path: "../unavi-app/assets".to_string(),
..default()
}),
PanOrbitCameraPlugin,
PhysicsDebugPlugin::default(),
PhysicsPlugins::default(),
ScriptingPlugin,
))
.add_systems(Startup, (setup_scene, load_script))
.run();
}

fn setup_scene(mut ambient: ResMut<AmbientLight>, mut commands: Commands) {
Expand Down
32 changes: 18 additions & 14 deletions crates/unavi-scripting/examples/unavi-ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@ use avian3d::prelude::*;
use bevy::prelude::*;
use unavi_player::PlayerPlugin;
use unavi_scripting::{ScriptBundle, ScriptingPlugin};
use unavi_world::util::init_user_actor;

fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(AssetPlugin {
file_path: "../unavi-app/assets".to_string(),
..Default::default()
}),
PhysicsDebugPlugin::default(),
PhysicsPlugins::default(),
PlayerPlugin,
ScriptingPlugin,
))
.add_systems(Startup, (setup_scene, load_script))
.run();
#[tokio::main]
async fn main() {
let mut app = App::new();
init_user_actor(app.world_mut()).await;

app.add_plugins((
DefaultPlugins.set(AssetPlugin {
file_path: "../unavi-app/assets".to_string(),
..Default::default()
}),
PhysicsDebugPlugin::default(),
PhysicsPlugins::default(),
PlayerPlugin,
ScriptingPlugin,
))
.add_systems(Startup, (setup_scene, load_script))
.run();
}

fn setup_scene(mut ambient: ResMut<AmbientLight>, mut commands: Commands) {
Expand Down
32 changes: 18 additions & 14 deletions crates/unavi-scripting/examples/unavi-vscreen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@ use avian3d::prelude::*;
use bevy::prelude::*;
use unavi_player::PlayerPlugin;
use unavi_scripting::{ScriptBundle, ScriptingPlugin};
use unavi_world::util::init_user_actor;

fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(AssetPlugin {
file_path: "../unavi-app/assets".to_string(),
..Default::default()
}),
PhysicsDebugPlugin::default(),
PhysicsPlugins::default(),
PlayerPlugin,
ScriptingPlugin,
))
.add_systems(Startup, (setup_scene, load_script))
.run();
#[tokio::main]
async fn main() {
let mut app = App::new();
init_user_actor(app.world_mut()).await;

app.add_plugins((
DefaultPlugins.set(AssetPlugin {
file_path: "../unavi-app/assets".to_string(),
..Default::default()
}),
PhysicsDebugPlugin::default(),
PhysicsPlugins::default(),
PlayerPlugin,
ScriptingPlugin,
))
.add_systems(Startup, (setup_scene, load_script))
.run();
}

fn setup_scene(mut ambient: ResMut<AmbientLight>, mut commands: Commands) {
Expand Down
32 changes: 18 additions & 14 deletions crates/unavi-scripting/examples/wired-input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@ use avian3d::prelude::*;
use bevy::prelude::*;
use unavi_player::PlayerPlugin;
use unavi_scripting::{ScriptBundle, ScriptingPlugin};
use unavi_world::util::init_user_actor;

fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(AssetPlugin {
file_path: "../unavi-app/assets".to_string(),
..Default::default()
}),
PhysicsDebugPlugin::default(),
PhysicsPlugins::default(),
PlayerPlugin,
ScriptingPlugin,
))
.add_systems(Startup, (setup_scene, load_script))
.run();
#[tokio::main]
async fn main() {
let mut app = App::new();
init_user_actor(app.world_mut()).await;

app.add_plugins((
DefaultPlugins.set(AssetPlugin {
file_path: "../unavi-app/assets".to_string(),
..Default::default()
}),
PhysicsDebugPlugin::default(),
PhysicsPlugins::default(),
PlayerPlugin,
ScriptingPlugin,
))
.add_systems(Startup, (setup_scene, load_script))
.run();
}

fn setup_scene(mut ambient: ResMut<AmbientLight>, mut commands: Commands) {
Expand Down
32 changes: 18 additions & 14 deletions crates/unavi-scripting/examples/wired-physics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@ use avian3d::prelude::*;
use bevy::prelude::*;
use bevy_panorbit_camera::{PanOrbitCamera, PanOrbitCameraPlugin};
use unavi_scripting::{ScriptBundle, ScriptingPlugin};
use unavi_world::util::init_user_actor;

fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(AssetPlugin {
file_path: "../unavi-app/assets".to_string(),
..Default::default()
}),
PanOrbitCameraPlugin,
PhysicsDebugPlugin::default(),
PhysicsPlugins::default(),
ScriptingPlugin,
))
.add_systems(Startup, (setup_scene, load_script))
.run();
#[tokio::main]
async fn main() {
let mut app = App::new();
init_user_actor(app.world_mut()).await;

app.add_plugins((
DefaultPlugins.set(AssetPlugin {
file_path: "../unavi-app/assets".to_string(),
..Default::default()
}),
PanOrbitCameraPlugin,
PhysicsDebugPlugin::default(),
PhysicsPlugins::default(),
ScriptingPlugin,
))
.add_systems(Startup, (setup_scene, load_script))
.run();
}

fn setup_scene(mut ambient: ResMut<AmbientLight>, mut commands: Commands) {
Expand Down
32 changes: 18 additions & 14 deletions crates/unavi-scripting/examples/wired-player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@ use avian3d::prelude::*;
use bevy::prelude::*;
use unavi_player::PlayerPlugin;
use unavi_scripting::{ScriptBundle, ScriptingPlugin};
use unavi_world::util::init_user_actor;

fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(AssetPlugin {
file_path: "../unavi-app/assets".to_string(),
..Default::default()
}),
PhysicsDebugPlugin::default(),
PhysicsPlugins::default(),
PlayerPlugin,
ScriptingPlugin,
))
.add_systems(Startup, (setup_scene, load_script))
.run();
#[tokio::main]
async fn main() {
let mut app = App::new();
init_user_actor(app.world_mut()).await;

app.add_plugins((
DefaultPlugins.set(AssetPlugin {
file_path: "../unavi-app/assets".to_string(),
..Default::default()
}),
PhysicsDebugPlugin::default(),
PhysicsPlugins::default(),
PlayerPlugin,
ScriptingPlugin,
))
.add_systems(Startup, (setup_scene, load_script))
.run();
}

fn setup_scene(mut ambient: ResMut<AmbientLight>, mut commands: Commands) {
Expand Down
32 changes: 18 additions & 14 deletions crates/unavi-scripting/examples/wired-scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@ use bevy::prelude::*;
use bevy_inspector_egui::quick::WorldInspectorPlugin;
use bevy_panorbit_camera::{PanOrbitCamera, PanOrbitCameraPlugin};
use unavi_scripting::{ScriptBundle, ScriptingPlugin};
use unavi_world::util::init_user_actor;

fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(AssetPlugin {
file_path: "../unavi-app/assets".to_string(),
..default()
}),
WorldInspectorPlugin::default(),
PanOrbitCameraPlugin,
PhysicsPlugins::default(),
ScriptingPlugin,
))
.add_systems(Startup, (setup_scene, load_script))
.run();
#[tokio::main]
async fn main() {
let mut app = App::new();
init_user_actor(app.world_mut()).await;

app.add_plugins((
DefaultPlugins.set(AssetPlugin {
file_path: "../unavi-app/assets".to_string(),
..default()
}),
WorldInspectorPlugin::default(),
PanOrbitCameraPlugin,
PhysicsPlugins::default(),
ScriptingPlugin,
))
.add_systems(Startup, (setup_scene, load_script))
.run();
}

fn setup_scene(mut ambient: ResMut<AmbientLight>, mut commands: Commands) {
Expand Down
2 changes: 1 addition & 1 deletion crates/unavi-scripting/src/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use wired::{dwn::WiredDwn, log::WiredLog, player::WiredPlayer, scene::WiredScene};

pub(crate) mod utils;
pub mod utils;
pub mod wired;

#[derive(Default)]
Expand Down
44 changes: 35 additions & 9 deletions crates/unavi-scripting/src/api/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,46 @@ pub trait RefResource: RefCount + Send + Sized + 'static {

#[cfg(test)]
pub mod tests {
use crate::{data::ScriptData, load::DefaultMaterial};
use crate::{
api::{
wired::{
log::WiredLog,
scene::{Entities, WiredScene},
},
ApiData,
},
data::ScriptData,
load::DefaultMaterial,
};

use super::*;

pub fn init_test_data() -> (World, ScriptData) {
let mut world = World::new();
world.init_resource::<Assets<Mesh>>();
pub fn init_test_data() -> (App, ScriptData) {
let mut app = App::new();

let default_material = Handle::default();
world.insert_resource(DefaultMaterial(default_material.clone()));

let data = ScriptData::default();
app.add_plugins((MinimalPlugins, AssetPlugin::default()))
.init_asset::<Mesh>()
.init_asset::<StandardMaterial>();

(world, data)
let default_material = Handle::default();
app.insert_resource(DefaultMaterial(default_material.clone()));

let data = ScriptData {
api: ApiData {
wired_log: Some(WiredLog {
name: "test".to_string(),
}),
wired_scene: Some(WiredScene {
default_material,
entities: Entities::default(),
root: Resource::new_own(0),
}),
..Default::default()
},
..Default::default()
};

(app, data)
}

pub fn test_drop<T: RefResource + Send>(data: &mut ScriptData, res_a: Resource<T>) {
Expand Down
2 changes: 1 addition & 1 deletion crates/unavi-scripting/src/api/wired/physics/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use bevy::prelude::*;
use crate::{
api::{
utils::RefResource,
wired::scene::node::{NodeId, NodeRes},
wired::scene::nodes::base::{NodeId, NodeRes},
},
execution::ScriptTickrate,
load::ScriptMap,
Expand Down
Loading

0 comments on commit d746e76

Please sign in to comment.