@@ -66,30 +66,34 @@ impl Plugin for CoreFunctionsPlugin {
6666
6767fn register_world_functions ( reg : & mut FunctionRegistry ) -> Result < ( ) , FunctionRegistrationError > {
6868 NamespaceBuilder :: < WorldCallbackAccess > :: new ( reg)
69- . overwrite_script_function ( "hello" , |b : Ref < Entity > , c : Mut < Entity > | None :: < usize > )
70- . overwrite (
71- "test_vec" ,
72- |s : WorldCallbackAccess , entities : Vec < Entity > | entities,
73- )
74- . overwrite ( "spawn" , |s : WorldCallbackAccess | s. spawn ( ) )
75- . overwrite (
69+ // .overwrite_script_function("hello", |b: Ref<Entity>, c: Mut<Entity>| None::<usize>)
70+ // .overwrite(
71+ // "test_vec",
72+ // |s: WorldCallbackAccess, entities: Vec<Entity>| entities,
73+ // )
74+ . overwrite_script_function ( "spawn" , |s : WorldCallbackAccess | Val ( s. spawn ( ) ) )
75+ . overwrite_script_function (
7676 "get_type_by_name" ,
77- |world : WorldCallbackAccess , type_name : String | world. get_type_by_name ( type_name) ,
77+ |world : WorldCallbackAccess , type_name : String | {
78+ world. get_type_by_name ( type_name) . map ( Val )
79+ } ,
7880 )
79- . overwrite (
81+ . overwrite_script_function (
8082 "get_component" ,
81- |world : WorldCallbackAccess , entity : Entity , registration : ScriptTypeRegistration | {
83+ |world : WorldCallbackAccess ,
84+ entity : Val < Entity > ,
85+ registration : Val < ScriptTypeRegistration > | {
8286 let s: ScriptValue = registration
8387 . component_id ( )
84- . and_then ( |id| world. get_component ( entity, id) . transpose ( ) )
88+ . and_then ( |id| world. get_component ( * entity, id) . transpose ( ) )
8589 . into ( ) ;
8690 s
8791 } ,
8892 )
89- . overwrite ( "exit" , |s : WorldCallbackAccess | s. exit ( ) ) ;
93+ . overwrite_script_function ( "exit" , |s : WorldCallbackAccess | s. exit ( ) ) ;
9094
9195 NamespaceBuilder :: < ReflectReference > :: new ( reg)
92- . overwrite (
96+ . overwrite_script_function (
9397 "get" ,
9498 |world : WorldCallbackAccess , self_ : ScriptValue , key : ScriptValue | {
9599 if let ScriptValue :: Reference ( mut r) = self_ {
@@ -103,7 +107,7 @@ fn register_world_functions(reg: &mut FunctionRegistry) -> Result<(), FunctionRe
103107 }
104108 } ,
105109 )
106- . overwrite (
110+ . overwrite_script_function (
107111 "get_1_indexed" ,
108112 |world : WorldCallbackAccess , self_ : ScriptValue , key : ScriptValue | {
109113 if let ScriptValue :: Reference ( mut r) = self_ {
@@ -118,7 +122,7 @@ fn register_world_functions(reg: &mut FunctionRegistry) -> Result<(), FunctionRe
118122 }
119123 } ,
120124 )
121- . overwrite (
125+ . overwrite_script_function (
122126 "set" ,
123127 |world : WorldCallbackAccess ,
124128 self_ : ScriptValue ,
@@ -151,7 +155,7 @@ fn register_world_functions(reg: &mut FunctionRegistry) -> Result<(), FunctionRe
151155 ScriptValue :: Unit
152156 } ,
153157 )
154- . overwrite (
158+ . overwrite_script_function (
155159 "set_1_indexed" ,
156160 |world : WorldCallbackAccess ,
157161 self_ : ScriptValue ,
0 commit comments