@@ -66,30 +66,34 @@ impl Plugin for CoreFunctionsPlugin {
66
66
67
67
fn register_world_functions ( reg : & mut FunctionRegistry ) -> Result < ( ) , FunctionRegistrationError > {
68
68
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 (
76
76
"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
+ } ,
78
80
)
79
- . overwrite (
81
+ . overwrite_script_function (
80
82
"get_component" ,
81
- |world : WorldCallbackAccess , entity : Entity , registration : ScriptTypeRegistration | {
83
+ |world : WorldCallbackAccess ,
84
+ entity : Val < Entity > ,
85
+ registration : Val < ScriptTypeRegistration > | {
82
86
let s: ScriptValue = registration
83
87
. component_id ( )
84
- . and_then ( |id| world. get_component ( entity, id) . transpose ( ) )
88
+ . and_then ( |id| world. get_component ( * entity, id) . transpose ( ) )
85
89
. into ( ) ;
86
90
s
87
91
} ,
88
92
)
89
- . overwrite ( "exit" , |s : WorldCallbackAccess | s. exit ( ) ) ;
93
+ . overwrite_script_function ( "exit" , |s : WorldCallbackAccess | s. exit ( ) ) ;
90
94
91
95
NamespaceBuilder :: < ReflectReference > :: new ( reg)
92
- . overwrite (
96
+ . overwrite_script_function (
93
97
"get" ,
94
98
|world : WorldCallbackAccess , self_ : ScriptValue , key : ScriptValue | {
95
99
if let ScriptValue :: Reference ( mut r) = self_ {
@@ -103,7 +107,7 @@ fn register_world_functions(reg: &mut FunctionRegistry) -> Result<(), FunctionRe
103
107
}
104
108
} ,
105
109
)
106
- . overwrite (
110
+ . overwrite_script_function (
107
111
"get_1_indexed" ,
108
112
|world : WorldCallbackAccess , self_ : ScriptValue , key : ScriptValue | {
109
113
if let ScriptValue :: Reference ( mut r) = self_ {
@@ -118,7 +122,7 @@ fn register_world_functions(reg: &mut FunctionRegistry) -> Result<(), FunctionRe
118
122
}
119
123
} ,
120
124
)
121
- . overwrite (
125
+ . overwrite_script_function (
122
126
"set" ,
123
127
|world : WorldCallbackAccess ,
124
128
self_ : ScriptValue ,
@@ -151,7 +155,7 @@ fn register_world_functions(reg: &mut FunctionRegistry) -> Result<(), FunctionRe
151
155
ScriptValue :: Unit
152
156
} ,
153
157
)
154
- . overwrite (
158
+ . overwrite_script_function (
155
159
"set_1_indexed" ,
156
160
|world : WorldCallbackAccess ,
157
161
self_ : ScriptValue ,
0 commit comments