diff --git a/executor-wasm/pkg/executor_wasm.js b/executor-wasm/pkg/executor_wasm.js index 509e40a..50a6aa7 100644 --- a/executor-wasm/pkg/executor_wasm.js +++ b/executor-wasm/pkg/executor_wasm.js @@ -1593,68 +1593,68 @@ function __wbg_get_imports() { const ret = wasm.memory; return addHeapObject(ret); }; + imports.wbg.__wbindgen_closure_wrapper11131 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 9430, __wbg_adapter_32); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper11132 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 9430, __wbg_adapter_32); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_closure_wrapper11133 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 9430, __wbg_adapter_32); + return addHeapObject(ret); + }; imports.wbg.__wbindgen_closure_wrapper11134 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 9432, __wbg_adapter_32); + const ret = makeMutClosure(arg0, arg1, 9430, __wbg_adapter_39); return addHeapObject(ret); }; imports.wbg.__wbindgen_closure_wrapper11135 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 9432, __wbg_adapter_32); + const ret = makeMutClosure(arg0, arg1, 9430, __wbg_adapter_32); return addHeapObject(ret); }; imports.wbg.__wbindgen_closure_wrapper11136 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 9432, __wbg_adapter_32); + const ret = makeMutClosure(arg0, arg1, 9430, __wbg_adapter_44); return addHeapObject(ret); }; - imports.wbg.__wbindgen_closure_wrapper11137 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 9432, __wbg_adapter_39); + imports.wbg.__wbindgen_closure_wrapper11140 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 9430, __wbg_adapter_32); return addHeapObject(ret); }; - imports.wbg.__wbindgen_closure_wrapper11138 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 9432, __wbg_adapter_32); + imports.wbg.__wbindgen_closure_wrapper30789 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 25999, __wbg_adapter_49); return addHeapObject(ret); }; - imports.wbg.__wbindgen_closure_wrapper11139 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 9432, __wbg_adapter_44); + imports.wbg.__wbindgen_closure_wrapper32207 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 26718, __wbg_adapter_52); return addHeapObject(ret); }; - imports.wbg.__wbindgen_closure_wrapper11143 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 9432, __wbg_adapter_32); + imports.wbg.__wbindgen_closure_wrapper32208 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 26718, __wbg_adapter_55); return addHeapObject(ret); }; - imports.wbg.__wbindgen_closure_wrapper30792 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 26001, __wbg_adapter_49); + imports.wbg.__wbindgen_closure_wrapper32209 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 26718, __wbg_adapter_55); return addHeapObject(ret); }; imports.wbg.__wbindgen_closure_wrapper32210 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 26720, __wbg_adapter_52); + const ret = makeMutClosure(arg0, arg1, 26718, __wbg_adapter_55); return addHeapObject(ret); }; imports.wbg.__wbindgen_closure_wrapper32211 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 26720, __wbg_adapter_55); + const ret = makeMutClosure(arg0, arg1, 26718, __wbg_adapter_55); return addHeapObject(ret); }; imports.wbg.__wbindgen_closure_wrapper32212 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 26720, __wbg_adapter_55); + const ret = makeMutClosure(arg0, arg1, 26718, __wbg_adapter_55); return addHeapObject(ret); }; imports.wbg.__wbindgen_closure_wrapper32213 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 26720, __wbg_adapter_55); + const ret = makeMutClosure(arg0, arg1, 26718, __wbg_adapter_55); return addHeapObject(ret); }; - imports.wbg.__wbindgen_closure_wrapper32214 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 26720, __wbg_adapter_55); - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_closure_wrapper32215 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 26720, __wbg_adapter_55); - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_closure_wrapper32216 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 26720, __wbg_adapter_55); - return addHeapObject(ret); - }; - imports.wbg.__wbindgen_closure_wrapper37762 = function(arg0, arg1, arg2) { - const ret = makeMutClosure(arg0, arg1, 30116, __wbg_adapter_68); + imports.wbg.__wbindgen_closure_wrapper37759 = function(arg0, arg1, arg2) { + const ret = makeMutClosure(arg0, arg1, 30114, __wbg_adapter_68); return addHeapObject(ret); }; diff --git a/executor-wasm/pkg/executor_wasm_bg.wasm b/executor-wasm/pkg/executor_wasm_bg.wasm index 21718f3..baec935 100644 Binary files a/executor-wasm/pkg/executor_wasm_bg.wasm and b/executor-wasm/pkg/executor_wasm_bg.wasm differ diff --git a/game/src/enemy.rs b/game/src/enemy.rs index 101240d..026fbac 100644 --- a/game/src/enemy.rs +++ b/game/src/enemy.rs @@ -1,11 +1,7 @@ use fyrox::{ core::{ - algebra::{Vector2}, - impl_component_provider, - pool::Handle, - reflect::prelude::*, - uuid_provider, - visitor::prelude::*, + algebra::Vector2, impl_component_provider, pool::Handle, reflect::prelude::*, + uuid_provider, visitor::prelude::*, }, scene::animation::spritesheet::SpriteSheetAnimation, scene::dim2::{collider::Collider, rectangle::Rectangle, rigidbody::RigidBody}, @@ -60,14 +56,46 @@ impl Enemy { } fn move_do(&mut self, context: &mut ScriptContext) { - let rigid_body = context.scene.graph[context.handle].cast_mut::(); - match rigid_body { - Some(rigid_data) => { - let x_speed = self.get_speed(); - rigid_data.set_lin_vel(Vector2::new(x_speed, rigid_data.lin_vel().y)); - } - None => {} + let mut graph_ctx = context.scene.graph.begin_multi_borrow::<2>(); + let enemy_rigid_body = graph_ctx.try_get(context.handle).unwrap().cast_mut::(); + // match rigid_body { + // Some(rigid_data) => { + // let x_speed = self.get_speed(); + // rigid_data.set_lin_vel(Vector2::new(x_speed, rigid_data.lin_vel().y)); + // } + // None => {} + // } + let enemy_rigid_data = match enemy_rigid_body { + Some(rigid_data) => rigid_data, + None => return, + }; + let player_rigid_body = graph_ctx.try_get(self.player_handle).unwrap().cast_mut::(); + let player_rigid_data = match player_rigid_body { + Some(rigid_body) => rigid_body, + None => return, + }; + + let player_position = player_rigid_data.local_transform().position(); + let enemy_position = enemy_rigid_data.local_transform().position(); + + // // Calculate the direction vector from *this* node to the player node + // let dir_x = player_position.x - self_position.x; + // let dir_y = player_position.y - self_position.y; + + // // Calculate the factor to scale the direction vector by + // // to ensure the enemy moves at the speed we want + // let factor = self.get_speed() / (dir_x.powi(2) + dir_y.powi(2)).sqrt(); + + // Set the linear velocity of *this* node to the scaled direction vector + // enemy_rigid_data.set_lin_vel(Vector2::new(dir_x * factor, dir_y * factor)); + let mut x_speed = self.get_speed(); + + if player_position.x > enemy_position.x { + x_speed *= -1.0; } + + enemy_rigid_data.set_lin_vel(Vector2::new(x_speed, enemy_rigid_data.lin_vel().y)); + } pub fn animation_do(&mut self, context: &mut ScriptContext) { diff --git a/settings.ron b/settings.ron index f353489..1a4d94f 100644 --- a/settings.ron +++ b/settings.ron @@ -322,73 +322,7 @@ ), node_infos: { ( - index: 40, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 92, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 58, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 12, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 29, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 57, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 86, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 47, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 10, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 91, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 69, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 56, + index: 23, generation: 1, ): ( is_expanded: true, @@ -399,78 +333,6 @@ ): ( is_expanded: false, ), - ( - index: 95, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 45, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 44, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 17, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 35, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 33, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 72, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 52, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 13, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 53, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 32, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 25, - generation: 1, - ): ( - is_expanded: false, - ), ( index: 22, generation: 1, @@ -478,7 +340,19 @@ is_expanded: false, ), ( - index: 94, + index: 1, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 24, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 38, generation: 1, ): ( is_expanded: true, @@ -490,13 +364,25 @@ is_expanded: true, ), ( - index: 36, + index: 4, generation: 1, ): ( - is_expanded: false, + is_expanded: true, ), ( - index: 48, + index: 3, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 47, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 77, generation: 1, ): ( is_expanded: true, @@ -507,6 +393,216 @@ ): ( is_expanded: true, ), + ( + index: 89, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 2, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 66, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 56, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 26, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 48, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 17, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 72, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 20, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 92, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 29, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 16, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 54, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 42, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 93, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 95, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 32, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 50, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 53, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 5, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 78, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 18, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 34, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 40, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 0, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 9, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 11, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 28, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 33, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 51, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 83, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 69, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 82, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 41, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 8, + generation: 1, + ): ( + is_expanded: false, + ), ( index: 60, generation: 1, @@ -520,91 +616,7 @@ is_expanded: false, ), ( - index: 42, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 4, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 87, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 18, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 0, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 19, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 50, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 5, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 54, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 37, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 28, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 65, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 20, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 3, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 89, + index: 35, generation: 1, ): ( is_expanded: true, @@ -615,216 +627,18 @@ ): ( is_expanded: false, ), - ( - index: 24, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 82, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 27, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 93, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 1, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 6, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 81, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 84, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 51, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 80, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 43, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 8, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 21, - generation: 1, - ): ( - is_expanded: false, - ), ( index: 63, generation: 1, ): ( is_expanded: false, ), - ( - index: 11, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 16, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 66, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 83, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 55, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 26, - generation: 1, - ): ( - is_expanded: true, - ), ( index: 49, generation: 1, ): ( is_expanded: false, ), - ( - index: 78, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 74, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 30, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 90, - generation: 1, - ): ( - is_expanded: false, - ), - ( - index: 71, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 77, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 2, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 31, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 23, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 38, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 59, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 15, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 34, - generation: 1, - ): ( - is_expanded: true, - ), - ( - index: 9, - generation: 1, - ): ( - is_expanded: false, - ), ( index: 62, generation: 1, @@ -832,11 +646,197 @@ is_expanded: true, ), ( - index: 41, + index: 81, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 36, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 30, generation: 1, ): ( is_expanded: true, ), + ( + index: 80, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 21, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 44, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 65, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 94, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 6, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 55, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 43, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 57, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 71, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 31, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 10, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 27, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 90, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 87, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 91, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 12, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 74, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 59, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 19, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 86, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 15, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 52, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 58, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 45, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 37, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 13, + generation: 1, + ): ( + is_expanded: true, + ), + ( + index: 25, + generation: 1, + ): ( + is_expanded: false, + ), + ( + index: 84, + generation: 1, + ): ( + is_expanded: false, + ), }, ), },