3
3
//! These are designed to be used to pipe inputs into other systems which require them, while handling any configuration erorrs nicely.
4
4
#![ allow( deprecated) ]
5
5
use crate :: bindings:: pretty_print:: DisplayWithWorld ;
6
+ use crate :: handler:: ScriptingHandler ;
6
7
use crate :: {
7
8
bindings:: {
8
9
access_map:: ReflectAccessId , script_value:: ScriptValue , WorldAccessGuard , WorldGuard ,
9
10
} ,
10
11
context:: ContextLoadingSettings ,
11
12
error:: { InteropError , ScriptError } ,
12
13
event:: { CallbackLabel , IntoCallbackLabel } ,
13
- handler:: CallbackSettings ,
14
14
runtime:: RuntimeContainer ,
15
15
script:: { ScriptAttachment , ScriptContext , StaticScripts } ,
16
16
IntoScriptPluginParams ,
@@ -122,8 +122,6 @@ unsafe impl<T: Resource + Default> SystemParam for ResScope<'_, T> {
122
122
123
123
/// Context for systems which handle events for scripts
124
124
pub struct HandlerContext < P : IntoScriptPluginParams > {
125
- /// Settings for callbacks
126
- pub ( crate ) callback_settings : CallbackSettings < P > ,
127
125
/// Settings for loading contexts
128
126
pub ( crate ) context_loading_settings : ContextLoadingSettings < P > ,
129
127
/// The runtime container
@@ -139,7 +137,6 @@ impl<P: IntoScriptPluginParams> HandlerContext<P> {
139
137
/// Every call to this function must be paired with a call to [`Self::release`].
140
138
pub fn yoink ( world : & mut World ) -> Self {
141
139
Self {
142
- callback_settings : world. remove_resource ( ) . unwrap_or_default ( ) ,
143
140
context_loading_settings : world. remove_resource ( ) . unwrap_or_default ( ) ,
144
141
runtime_container : world. remove_resource ( ) . unwrap_or_default ( ) ,
145
142
static_scripts : world. remove_resource ( ) . unwrap_or_default ( ) ,
@@ -151,7 +148,6 @@ impl<P: IntoScriptPluginParams> HandlerContext<P> {
151
148
/// Only call this if you have previously yoinked the handler context from the world.
152
149
pub fn release ( self , world : & mut World ) {
153
150
// insert the handler context back into the world
154
- world. insert_resource ( self . callback_settings ) ;
155
151
world. insert_resource ( self . context_loading_settings ) ;
156
152
world. insert_resource ( self . runtime_container ) ;
157
153
world. insert_resource ( self . static_scripts ) ;
@@ -165,24 +161,17 @@ impl<P: IntoScriptPluginParams> HandlerContext<P> {
165
161
pub fn destructure (
166
162
& mut self ,
167
163
) -> (
168
- & mut CallbackSettings < P > ,
169
164
& mut ContextLoadingSettings < P > ,
170
165
& mut RuntimeContainer < P > ,
171
166
& mut StaticScripts ,
172
167
) {
173
168
(
174
- & mut self . callback_settings ,
175
169
& mut self . context_loading_settings ,
176
170
& mut self . runtime_container ,
177
171
& mut self . static_scripts ,
178
172
)
179
173
}
180
174
181
- /// Get the callback settings
182
- pub fn callback_settings ( & mut self ) -> & mut CallbackSettings < P > {
183
- & mut self . callback_settings
184
- }
185
-
186
175
/// Get the context loading settings
187
176
pub fn context_loading_settings ( & mut self ) -> & mut ContextLoadingSettings < P > {
188
177
& mut self . context_loading_settings
@@ -226,16 +215,14 @@ impl<P: IntoScriptPluginParams> HandlerContext<P> {
226
215
} ;
227
216
228
217
// call the script
229
- let handler = self . callback_settings . callback_handler ;
230
218
let pre_handling_initializers = & self
231
219
. context_loading_settings
232
220
. context_pre_handling_initializers ;
233
221
let runtime = & self . runtime_container . runtime ;
234
222
235
223
let mut context = context. lock ( ) ;
236
224
237
- CallbackSettings :: < P > :: call (
238
- handler,
225
+ P :: handle (
239
226
payload,
240
227
context_key,
241
228
label,
0 commit comments