… | |
… | |
107 | ############################################################################# |
107 | ############################################################################# |
108 | # "new" plug-in system |
108 | # "new" plug-in system |
109 | |
109 | |
110 | =item $object->attach ($attachment, key => $value...) |
110 | =item $object->attach ($attachment, key => $value...) |
111 | |
111 | |
|
|
112 | =item $object->detach ($attachment) |
|
|
113 | |
112 | Attach a pre-registered attachment to an object. |
114 | Attach/detach a pre-registered attachment to an object. |
113 | |
115 | |
114 | =item $player->attach ($attachment, key => $value...) |
116 | =item $player->attach ($attachment, key => $value...) |
115 | |
117 | |
|
|
118 | =item $player->detach ($attachment) |
|
|
119 | |
116 | Attach a pre-registered attachment to a player. |
120 | Attach/detach a pre-registered attachment to a player. |
117 | |
121 | |
118 | =item $map->attach ($attachment, key => $value...) # not yet persistent |
122 | =item $map->attach ($attachment, key => $value...) |
119 | |
123 | |
|
|
124 | =item $map->detach ($attachment) |
|
|
125 | |
120 | Attach a pre-registered attachment to a map. |
126 | Attach/detach a pre-registered attachment to a map. |
121 | |
127 | |
122 | =item cf::attach_global ... |
128 | =item cf::attach_global ... |
123 | |
129 | |
124 | Attach handlers for global events. |
130 | Attach handlers for global events. |
125 | |
131 | |
… | |
… | |
276 | |
282 | |
277 | $res->{attachment} = $name; |
283 | $res->{attachment} = $name; |
278 | $res |
284 | $res |
279 | } |
285 | } |
280 | |
286 | |
281 | sub cf::object::attach { |
287 | *cf::object::attach = |
|
|
288 | *cf::player::attach = |
|
|
289 | *cf::map::attach = sub { |
282 | my ($obj, $name, %arg) = @_; |
290 | my ($obj, $name, %arg) = @_; |
283 | |
291 | |
284 | _attach_attachment $obj, $name, %arg; |
292 | _attach_attachment $obj, $name, %arg; |
285 | } |
293 | } |
286 | |
294 | |
|
|
295 | # all those should be optimised |
|
|
296 | *cf::object::detach = |
287 | sub cf::player::attach { |
297 | *cf::player::detach = |
|
|
298 | *cf::map::detach = sub { |
288 | my ($obj, $name, %arg) = @_; |
299 | my ($obj, $name) = @_; |
289 | |
300 | |
290 | _attach_attachment $obj, $name, %arg; |
301 | delete $obj->{_attachment}{$name}; |
291 | } |
302 | reattach $obj; |
292 | |
303 | }; |
293 | sub cf::map::attach { |
|
|
294 | my ($obj, $name, %arg) = @_; |
|
|
295 | |
|
|
296 | _attach_attachment $obj, $name, %arg; |
|
|
297 | } |
|
|
298 | |
304 | |
299 | sub attach_global { |
305 | sub attach_global { |
300 | _attach @CB_GLOBAL, KLASS_GLOBAL, @_ |
306 | _attach @CB_GLOBAL, KLASS_GLOBAL, @_ |
301 | } |
307 | } |
302 | |
308 | |