… | |
… | |
174 | |
174 | |
175 | Attach handlers to all maps. |
175 | Attach handlers to all maps. |
176 | |
176 | |
177 | =item cf:register_attachment $name, ... |
177 | =item cf:register_attachment $name, ... |
178 | |
178 | |
|
|
179 | Register an attachment by name through which objects can refer to this |
|
|
180 | attachment. |
|
|
181 | |
|
|
182 | =item cf:register_map_attachment $name, ... |
|
|
183 | |
|
|
184 | Register an attachment by name through which maps can refer to this |
|
|
185 | attachment. |
|
|
186 | |
179 | =cut |
187 | =cut |
180 | |
188 | |
181 | # the following variables are defined in .xs and must not be re-created |
189 | # the following variables are defined in .xs and must not be re-created |
182 | our @CB_GLOBAL = (); # registry for all global events |
190 | our @CB_GLOBAL = (); # registry for all global events |
183 | our @CB_OBJECT = (); # all objects (should not be used except in emergency) |
191 | our @CB_OBJECT = (); # all objects (should not be used except in emergency) |
… | |
… | |
277 | } |
285 | } |
278 | |
286 | |
279 | sub cf::player::attach { |
287 | sub cf::player::attach { |
280 | my ($obj, $name, %arg) = @_; |
288 | my ($obj, $name, %arg) = @_; |
281 | |
289 | |
282 | _attach_attachment KLASS_PLAYER, $obj, $name, %arg; |
290 | _attach_attachment $obj, $name, %arg; |
283 | } |
291 | } |
284 | |
292 | |
285 | sub cf::map::attach { |
293 | sub cf::map::attach { |
286 | my ($obj, $name, %arg) = @_; |
294 | my ($obj, $name, %arg) = @_; |
287 | |
295 | |
288 | _attach_attachment KLASS_MAP, $obj, $name, %arg; |
296 | _attach_attachment $obj, $name, %arg; |
289 | } |
297 | } |
290 | |
298 | |
291 | sub attach_global { |
299 | sub attach_global { |
292 | _attach @CB_GLOBAL, KLASS_GLOBAL, @_ |
300 | _attach @CB_GLOBAL, KLASS_GLOBAL, @_ |
293 | } |
301 | } |
… | |
… | |
313 | |
321 | |
314 | sub register_attachment { |
322 | sub register_attachment { |
315 | my $name = shift; |
323 | my $name = shift; |
316 | |
324 | |
317 | $attachment{$name} = [[KLASS_OBJECT, @_]]; |
325 | $attachment{$name} = [[KLASS_OBJECT, @_]]; |
|
|
326 | } |
|
|
327 | |
|
|
328 | sub register_map_attachment { |
|
|
329 | my $name = shift; |
|
|
330 | |
|
|
331 | $attachment{$name} = [[KLASS_MAP, @_]]; |
318 | } |
332 | } |
319 | |
333 | |
320 | our $override; |
334 | our $override; |
321 | our @invoke_results = (); # referenced from .xs code. TODO: play tricks with reify and mortals? |
335 | our @invoke_results = (); # referenced from .xs code. TODO: play tricks with reify and mortals? |
322 | |
336 | |