bevy_script_api 0.8.0

Bevy API for multiple script languages, part of bevy_mod_scripting.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
// @generated by cargo bevy-api-gen generate, modify the templates not this file
#![allow(clippy::all)]
#![allow(unused, deprecated, dead_code)]
#![cfg_attr(rustfmt, rustfmt_skip)]
use super::bevy_ecs::*;
use super::bevy_reflect::*;
use super::bevy_core::*;
use super::bevy_math::*;
use super::bevy_hierarchy::*;
extern crate self as bevy_script_api;
use bevy_script_api::{
    lua::RegisterForeignLuaType, ReflectedValue, common::bevy::GetWorld,
};
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(
    derive(clone),
    remote = "bevy::transform::components::GlobalTransform",
    functions[r#"

    #[lua(
        as_trait = "std::ops::Mul",
        kind = "MetaFunction",
        output(proxy),
        composite = "mul",
        metamethod = "Mul",
    )]
    fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3;

"#,
    r#"

    #[lua(
        as_trait = "std::ops::Mul",
        kind = "MetaFunction",
        output(proxy),
        composite = "mul",
        metamethod = "Mul",
    )]
    fn mul(
        self,
        #[proxy]
        global_transform: bevy::transform::components::GlobalTransform,
    ) -> bevy::transform::components::GlobalTransform;

"#,
    r#"

    #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
    fn clone(&self) -> bevy::transform::components::GlobalTransform;

"#,
    r#"

    #[lua(
        as_trait = "std::ops::Mul",
        kind = "MetaFunction",
        output(proxy),
        composite = "mul",
        metamethod = "Mul",
    )]
    fn mul(
        self,
        #[proxy]
        transform: bevy::transform::components::Transform,
    ) -> bevy::transform::components::GlobalTransform;

"#,
    r#"

    #[lua(
        as_trait = "std::cmp::PartialEq",
        kind = "MetaFunction",
        composite = "eq",
        metamethod = "Eq",
    )]
    fn eq(&self, #[proxy] other: &components::global_transform::GlobalTransform) -> bool;

"#,
    r#"

    #[lua(kind = "Function", output(proxy))]
    fn from_xyz(x: f32, y: f32, z: f32) -> bevy::transform::components::GlobalTransform;

"#,
    r#"

    #[lua(kind = "Function", output(proxy))]
    fn from_translation(
        #[proxy]
        translation: bevy::math::Vec3,
    ) -> bevy::transform::components::GlobalTransform;

"#,
    r#"

    #[lua(kind = "Function", output(proxy))]
    fn from_rotation(
        #[proxy]
        rotation: bevy::math::Quat,
    ) -> bevy::transform::components::GlobalTransform;

"#,
    r#"

    #[lua(kind = "Function", output(proxy))]
    fn from_scale(
        #[proxy]
        scale: bevy::math::Vec3,
    ) -> bevy::transform::components::GlobalTransform;

"#,
    r#"

    #[lua(kind = "Function", output(proxy))]
    fn from_isometry(
        #[proxy]
        iso: bevy::math::Isometry3d,
    ) -> bevy::transform::components::GlobalTransform;

"#,
    r#"
/// Returns the 3d affine transformation matrix as a [`Mat4`].

    #[lua(kind = "Method", output(proxy))]
    fn compute_matrix(&self) -> bevy::math::Mat4;

"#,
    r#"
/// Returns the 3d affine transformation matrix as an [`Affine3A`].

    #[lua(kind = "Method", output(proxy))]
    fn affine(&self) -> bevy::math::Affine3A;

"#,
    r#"
/// Returns the transformation as a [`Transform`].
/// The transform is expected to be non-degenerate and without shearing, or the output
/// will be invalid.

    #[lua(kind = "Method", output(proxy))]
    fn compute_transform(&self) -> bevy::transform::components::Transform;

"#,
    r#"
/// Returns the isometric part of the transformation as an [isometry]. Any scaling done by the
/// transformation will be ignored.
/// The transform is expected to be non-degenerate and without shearing, or the output
/// will be invalid.
/// [isometry]: Isometry3d

    #[lua(kind = "Method", output(proxy))]
    fn to_isometry(&self) -> bevy::math::Isometry3d;

"#,
    r#"
/// Returns the [`Transform`] `self` would have if it was a child of an entity
/// with the `parent` [`GlobalTransform`].
/// This is useful if you want to "reparent" an [`Entity`](bevy_ecs::entity::Entity).
/// Say you have an entity `e1` that you want to turn into a child of `e2`,
/// but you want `e1` to keep the same global transform, even after re-parenting. You would use:
/// ```
/// # use bevy_transform::prelude::{GlobalTransform, Transform};
/// # use bevy_ecs::prelude::{Entity, Query, Component, Commands};
/// # use bevy_hierarchy::{prelude::Parent, BuildChildren};
/// #[derive(Component)]
/// struct ToReparent {
///     new_parent: Entity,
/// }
/// fn reparent_system(
///     mut commands: Commands,
///     mut targets: Query<(&mut Transform, Entity, &GlobalTransform, &ToReparent)>,
///     transforms: Query<&GlobalTransform>,
/// ) {
///     for (mut transform, entity, initial, to_reparent) in targets.iter_mut() {
///         if let Ok(parent_transform) = transforms.get(to_reparent.new_parent) {
///             *transform = initial.reparented_to(parent_transform);
///             commands.entity(entity)
///                 .remove::<ToReparent>()
///                 .set_parent(to_reparent.new_parent);
///         }
///     }
/// }
/// ```
/// The transform is expected to be non-degenerate and without shearing, or the output
/// will be invalid.

    #[lua(kind = "Method", output(proxy))]
    fn reparented_to(
        &self,
        #[proxy]
        parent: &components::global_transform::GlobalTransform,
    ) -> bevy::transform::components::Transform;

"#,
    r#"
///Return the local right vector (X).

    #[lua(kind = "Method", output(proxy))]
    fn right(&self) -> bevy::math::Dir3;

"#,
    r#"
///Return the local left vector (-X).

    #[lua(kind = "Method", output(proxy))]
    fn left(&self) -> bevy::math::Dir3;

"#,
    r#"
///Return the local up vector (Y).

    #[lua(kind = "Method", output(proxy))]
    fn up(&self) -> bevy::math::Dir3;

"#,
    r#"
///Return the local down vector (-Y).

    #[lua(kind = "Method", output(proxy))]
    fn down(&self) -> bevy::math::Dir3;

"#,
    r#"
///Return the local back vector (Z).

    #[lua(kind = "Method", output(proxy))]
    fn back(&self) -> bevy::math::Dir3;

"#,
    r#"
///Return the local forward vector (-Z).

    #[lua(kind = "Method", output(proxy))]
    fn forward(&self) -> bevy::math::Dir3;

"#,
    r#"
/// Get the translation as a [`Vec3`].

    #[lua(kind = "Method", output(proxy))]
    fn translation(&self) -> bevy::math::Vec3;

"#,
    r#"
/// Get the translation as a [`Vec3A`].

    #[lua(kind = "Method", output(proxy))]
    fn translation_vec3a(&self) -> bevy::math::Vec3A;

"#,
    r#"
/// Get the rotation as a [`Quat`].
/// The transform is expected to be non-degenerate and without shearing, or the output will be invalid.
/// # Warning
/// This is calculated using `to_scale_rotation_translation`, meaning that you
/// should probably use it directly if you also need translation or scale.

    #[lua(kind = "Method", output(proxy))]
    fn rotation(&self) -> bevy::math::Quat;

"#,
    r#"
/// Get the scale as a [`Vec3`].
/// The transform is expected to be non-degenerate and without shearing, or the output will be invalid.
/// Some of the computations overlap with `to_scale_rotation_translation`, which means you should use
/// it instead if you also need rotation.

    #[lua(kind = "Method", output(proxy))]
    fn scale(&self) -> bevy::math::Vec3;

"#,
    r#"
/// Get an upper bound of the radius from the given `extents`.

    #[lua(kind = "Method")]
    fn radius_vec3a(&self, #[proxy] extents: bevy::math::Vec3A) -> f32;

"#,
    r#"
/// Transforms the given point from local space to global space, applying shear, scale, rotation and translation.
/// It can be used like this:
/// ```
/// # use bevy_transform::prelude::{GlobalTransform};
/// # use bevy_math::prelude::Vec3;
/// let global_transform = GlobalTransform::from_xyz(1., 2., 3.);
/// let local_point = Vec3::new(1., 2., 3.);
/// let global_point = global_transform.transform_point(local_point);
/// assert_eq!(global_point, Vec3::new(2., 4., 6.));
/// ```
/// ```
/// # use bevy_transform::prelude::{GlobalTransform};
/// # use bevy_math::Vec3;
/// let global_point = Vec3::new(2., 4., 6.);
/// let global_transform = GlobalTransform::from_xyz(1., 2., 3.);
/// let local_point = global_transform.affine().inverse().transform_point3(global_point);
/// assert_eq!(local_point, Vec3::new(1., 2., 3.))
/// ```
/// To apply shear, scale, and rotation *without* applying translation, different functions are available:
/// ```
/// # use bevy_transform::prelude::{GlobalTransform};
/// # use bevy_math::prelude::Vec3;
/// let global_transform = GlobalTransform::from_xyz(1., 2., 3.);
/// let local_direction = Vec3::new(1., 2., 3.);
/// let global_direction = global_transform.affine().transform_vector3(local_direction);
/// assert_eq!(global_direction, Vec3::new(1., 2., 3.));
/// let roundtripped_local_direction = global_transform.affine().inverse().transform_vector3(global_direction);
/// assert_eq!(roundtripped_local_direction, local_direction);
/// ```

    #[lua(kind = "Method", output(proxy))]
    fn transform_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3;

"#,
    r#"
/// Multiplies `self` with `transform` component by component, returning the
/// resulting [`GlobalTransform`]

    #[lua(kind = "Method", output(proxy))]
    fn mul_transform(
        &self,
        #[proxy]
        transform: bevy::transform::components::Transform,
    ) -> bevy::transform::components::GlobalTransform;

"#,
    r#"
#[lua(kind="MetaMethod", metamethod="ToString")]
fn index(&self) -> String {
    format!("{:?}", _self)
}
"#]
)]
struct GlobalTransform();
#[derive(bevy_mod_scripting_lua_derive::LuaProxy)]
#[proxy(
    derive(clone),
    remote = "bevy::transform::components::Transform",
    functions[r#"
/// Creates a new [`Transform`] at the position `(x, y, z)`. In 2d, the `z` component
/// is used for z-ordering elements: higher `z`-value will be in front of lower
/// `z`-value.

    #[lua(kind = "Function", output(proxy))]
    fn from_xyz(x: f32, y: f32, z: f32) -> bevy::transform::components::Transform;

"#,
    r#"
/// Extracts the translation, rotation, and scale from `matrix`. It must be a 3d affine
/// transformation matrix.

    #[lua(kind = "Function", output(proxy))]
    fn from_matrix(
        #[proxy]
        world_from_local: bevy::math::Mat4,
    ) -> bevy::transform::components::Transform;

"#,
    r#"
/// Creates a new [`Transform`], with `translation`. Rotation will be 0 and scale 1 on
/// all axes.

    #[lua(kind = "Function", output(proxy))]
    fn from_translation(
        #[proxy]
        translation: bevy::math::Vec3,
    ) -> bevy::transform::components::Transform;

"#,
    r#"
/// Creates a new [`Transform`], with `rotation`. Translation will be 0 and scale 1 on
/// all axes.

    #[lua(kind = "Function", output(proxy))]
    fn from_rotation(
        #[proxy]
        rotation: bevy::math::Quat,
    ) -> bevy::transform::components::Transform;

"#,
    r#"
/// Creates a new [`Transform`], with `scale`. Translation will be 0 and rotation 0 on
/// all axes.

    #[lua(kind = "Function", output(proxy))]
    fn from_scale(
        #[proxy]
        scale: bevy::math::Vec3,
    ) -> bevy::transform::components::Transform;

"#,
    r#"
/// Creates a new [`Transform`] that is equivalent to the given [isometry].
/// [isometry]: Isometry3d

    #[lua(kind = "Function", output(proxy))]
    fn from_isometry(
        #[proxy]
        iso: bevy::math::Isometry3d,
    ) -> bevy::transform::components::Transform;

"#,
    r#"
/// Returns this [`Transform`] with a new translation.

    #[lua(kind = "Method", output(proxy))]
    fn with_translation(
        self,
        #[proxy]
        translation: bevy::math::Vec3,
    ) -> bevy::transform::components::Transform;

"#,
    r#"
/// Returns this [`Transform`] with a new rotation.

    #[lua(kind = "Method", output(proxy))]
    fn with_rotation(
        self,
        #[proxy]
        rotation: bevy::math::Quat,
    ) -> bevy::transform::components::Transform;

"#,
    r#"
/// Returns this [`Transform`] with a new scale.

    #[lua(kind = "Method", output(proxy))]
    fn with_scale(
        self,
        #[proxy]
        scale: bevy::math::Vec3,
    ) -> bevy::transform::components::Transform;

"#,
    r#"
/// Returns the 3d affine transformation matrix from this transforms translation,
/// rotation, and scale.

    #[lua(kind = "Method", output(proxy))]
    fn compute_matrix(&self) -> bevy::math::Mat4;

"#,
    r#"
/// Returns the 3d affine transformation matrix from this transforms translation,
/// rotation, and scale.

    #[lua(kind = "Method", output(proxy))]
    fn compute_affine(&self) -> bevy::math::Affine3A;

"#,
    r#"
/// Get the unit vector in the local `X` direction.

    #[lua(kind = "Method", output(proxy))]
    fn local_x(&self) -> bevy::math::Dir3;

"#,
    r#"
/// Equivalent to [`-local_x()`][Transform::local_x()]

    #[lua(kind = "Method", output(proxy))]
    fn left(&self) -> bevy::math::Dir3;

"#,
    r#"
/// Equivalent to [`local_x()`][Transform::local_x()]

    #[lua(kind = "Method", output(proxy))]
    fn right(&self) -> bevy::math::Dir3;

"#,
    r#"
/// Get the unit vector in the local `Y` direction.

    #[lua(kind = "Method", output(proxy))]
    fn local_y(&self) -> bevy::math::Dir3;

"#,
    r#"
/// Equivalent to [`local_y()`][Transform::local_y]

    #[lua(kind = "Method", output(proxy))]
    fn up(&self) -> bevy::math::Dir3;

"#,
    r#"
/// Equivalent to [`-local_y()`][Transform::local_y]

    #[lua(kind = "Method", output(proxy))]
    fn down(&self) -> bevy::math::Dir3;

"#,
    r#"
/// Get the unit vector in the local `Z` direction.

    #[lua(kind = "Method", output(proxy))]
    fn local_z(&self) -> bevy::math::Dir3;

"#,
    r#"
/// Equivalent to [`-local_z()`][Transform::local_z]

    #[lua(kind = "Method", output(proxy))]
    fn forward(&self) -> bevy::math::Dir3;

"#,
    r#"
/// Equivalent to [`local_z()`][Transform::local_z]

    #[lua(kind = "Method", output(proxy))]
    fn back(&self) -> bevy::math::Dir3;

"#,
    r#"
/// Rotates this [`Transform`] by the given rotation.
/// If this [`Transform`] has a parent, the `rotation` is relative to the rotation of the parent.
/// # Examples
/// - [`3d_rotation`]
/// [`3d_rotation`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/3d_rotation.rs

    #[lua(kind = "MutatingMethod")]
    fn rotate(&mut self, #[proxy] rotation: bevy::math::Quat) -> ();

"#,
    r#"
/// Rotates this [`Transform`] around the given `axis` by `angle` (in radians).
/// If this [`Transform`] has a parent, the `axis` is relative to the rotation of the parent.

    #[lua(kind = "MutatingMethod")]
    fn rotate_axis(&mut self, #[proxy] axis: bevy::math::Dir3, angle: f32) -> ();

"#,
    r#"
/// Rotates this [`Transform`] around the `X` axis by `angle` (in radians).
/// If this [`Transform`] has a parent, the axis is relative to the rotation of the parent.

    #[lua(kind = "MutatingMethod")]
    fn rotate_x(&mut self, angle: f32) -> ();

"#,
    r#"
/// Rotates this [`Transform`] around the `Y` axis by `angle` (in radians).
/// If this [`Transform`] has a parent, the axis is relative to the rotation of the parent.

    #[lua(kind = "MutatingMethod")]
    fn rotate_y(&mut self, angle: f32) -> ();

"#,
    r#"
/// Rotates this [`Transform`] around the `Z` axis by `angle` (in radians).
/// If this [`Transform`] has a parent, the axis is relative to the rotation of the parent.

    #[lua(kind = "MutatingMethod")]
    fn rotate_z(&mut self, angle: f32) -> ();

"#,
    r#"
/// Rotates this [`Transform`] by the given `rotation`.
/// The `rotation` is relative to this [`Transform`]'s current rotation.

    #[lua(kind = "MutatingMethod")]
    fn rotate_local(&mut self, #[proxy] rotation: bevy::math::Quat) -> ();

"#,
    r#"
/// Rotates this [`Transform`] around its local `axis` by `angle` (in radians).

    #[lua(kind = "MutatingMethod")]
    fn rotate_local_axis(&mut self, #[proxy] axis: bevy::math::Dir3, angle: f32) -> ();

"#,
    r#"
/// Rotates this [`Transform`] around its local `X` axis by `angle` (in radians).

    #[lua(kind = "MutatingMethod")]
    fn rotate_local_x(&mut self, angle: f32) -> ();

"#,
    r#"
/// Rotates this [`Transform`] around its local `Y` axis by `angle` (in radians).

    #[lua(kind = "MutatingMethod")]
    fn rotate_local_y(&mut self, angle: f32) -> ();

"#,
    r#"
/// Rotates this [`Transform`] around its local `Z` axis by `angle` (in radians).

    #[lua(kind = "MutatingMethod")]
    fn rotate_local_z(&mut self, angle: f32) -> ();

"#,
    r#"
/// Translates this [`Transform`] around a `point` in space.
/// If this [`Transform`] has a parent, the `point` is relative to the [`Transform`] of the parent.

    #[lua(kind = "MutatingMethod")]
    fn translate_around(
        &mut self,
        #[proxy]
        point: bevy::math::Vec3,
        #[proxy]
        rotation: bevy::math::Quat,
    ) -> ();

"#,
    r#"
/// Rotates this [`Transform`] around a `point` in space.
/// If this [`Transform`] has a parent, the `point` is relative to the [`Transform`] of the parent.

    #[lua(kind = "MutatingMethod")]
    fn rotate_around(
        &mut self,
        #[proxy]
        point: bevy::math::Vec3,
        #[proxy]
        rotation: bevy::math::Quat,
    ) -> ();

"#,
    r#"
/// Multiplies `self` with `transform` component by component, returning the
/// resulting [`Transform`]

    #[lua(kind = "Method", output(proxy))]
    fn mul_transform(
        &self,
        #[proxy]
        transform: bevy::transform::components::Transform,
    ) -> bevy::transform::components::Transform;

"#,
    r#"
/// Transforms the given `point`, applying scale, rotation and translation.
/// If this [`Transform`] has an ancestor entity with a [`Transform`] component,
/// [`Transform::transform_point`] will transform a point in local space into its
/// parent transform's space.
/// If this [`Transform`] does not have a parent, [`Transform::transform_point`] will
/// transform a point in local space into worldspace coordinates.
/// If you always want to transform a point in local space to worldspace, or if you need
/// the inverse transformations, see [`GlobalTransform::transform_point()`].

    #[lua(kind = "Method", output(proxy))]
    fn transform_point(&self, #[proxy] point: bevy::math::Vec3) -> bevy::math::Vec3;

"#,
    r#"
/// Returns `true` if, and only if, translation, rotation and scale all are
/// finite. If any of them contains a `NaN`, positive or negative infinity,
/// this will return `false`.

    #[lua(kind = "Method")]
    fn is_finite(&self) -> bool;

"#,
    r#"
/// Get the [isometry] defined by this transform's rotation and translation, ignoring scale.
/// [isometry]: Isometry3d

    #[lua(kind = "Method", output(proxy))]
    fn to_isometry(&self) -> bevy::math::Isometry3d;

"#,
    r#"

    #[lua(
        as_trait = "std::ops::Mul",
        kind = "MetaFunction",
        output(proxy),
        composite = "mul",
        metamethod = "Mul",
    )]
    fn mul(
        self,
        #[proxy]
        global_transform: bevy::transform::components::GlobalTransform,
    ) -> bevy::transform::components::GlobalTransform;

"#,
    r#"

    #[lua(
        as_trait = "std::cmp::PartialEq",
        kind = "MetaFunction",
        composite = "eq",
        metamethod = "Eq",
    )]
    fn eq(&self, #[proxy] other: &components::transform::Transform) -> bool;

"#,
    r#"

    #[lua(
        as_trait = "std::ops::Mul",
        kind = "MetaFunction",
        output(proxy),
        composite = "mul",
        metamethod = "Mul",
    )]
    fn mul(
        self,
        #[proxy]
        transform: bevy::transform::components::Transform,
    ) -> bevy::transform::components::Transform;

"#,
    r#"

    #[lua(as_trait = "std::clone::Clone", kind = "Method", output(proxy))]
    fn clone(&self) -> bevy::transform::components::Transform;

"#,
    r#"

    #[lua(
        as_trait = "std::ops::Mul",
        kind = "MetaFunction",
        output(proxy),
        composite = "mul",
        metamethod = "Mul",
    )]
    fn mul(self, #[proxy] value: bevy::math::Vec3) -> bevy::math::Vec3;

"#,
    r#"
#[lua(kind="MetaMethod", metamethod="ToString")]
fn index(&self) -> String {
    format!("{:?}", _self)
}
"#]
)]
struct Transform {
    #[lua(output(proxy))]
    translation: bevy::math::Vec3,
    #[lua(output(proxy))]
    rotation: bevy::math::Quat,
    #[lua(output(proxy))]
    scale: bevy::math::Vec3,
}
#[derive(Default)]
pub(crate) struct Globals;
impl bevy_mod_scripting_lua::tealr::mlu::ExportInstances for Globals {
    fn add_instances<
        'lua,
        T: bevy_mod_scripting_lua::tealr::mlu::InstanceCollector<'lua>,
    >(self, instances: &mut T) -> bevy_mod_scripting_lua::tealr::mlu::mlua::Result<()> {
        instances
            .add_instance(
                "GlobalTransform",
                bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::<
                    LuaGlobalTransform,
                >::new,
            )?;
        instances
            .add_instance(
                "Transform",
                bevy_mod_scripting_lua::tealr::mlu::UserDataProxy::<LuaTransform>::new,
            )?;
        Ok(())
    }
}
pub struct BevyTransformAPIProvider;
impl bevy_mod_scripting_core::hosts::APIProvider for BevyTransformAPIProvider {
    type APITarget = std::sync::Mutex<bevy_mod_scripting_lua::tealr::mlu::mlua::Lua>;
    type ScriptContext = std::sync::Mutex<bevy_mod_scripting_lua::tealr::mlu::mlua::Lua>;
    type DocTarget = bevy_mod_scripting_lua::docs::LuaDocFragment;
    fn attach_api(
        &mut self,
        ctx: &mut Self::APITarget,
    ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> {
        let ctx = ctx.get_mut().expect("Unable to acquire lock on Lua context");
        bevy_mod_scripting_lua::tealr::mlu::set_global_env(Globals, ctx)
            .map_err(|e| bevy_mod_scripting_core::error::ScriptError::Other(
                e.to_string(),
            ))
    }
    fn get_doc_fragment(&self) -> Option<Self::DocTarget> {
        Some(
            bevy_mod_scripting_lua::docs::LuaDocFragment::new(
                "BevyTransformAPI",
                |tw| {
                    tw.document_global_instance::<Globals>()
                        .expect("Something went wrong documenting globals")
                        .process_type::<LuaGlobalTransform>()
                        .process_type::<
                            bevy_mod_scripting_lua::tealr::mlu::UserDataProxy<
                                LuaGlobalTransform,
                            >,
                        >()
                        .process_type::<LuaTransform>()
                        .process_type::<
                            bevy_mod_scripting_lua::tealr::mlu::UserDataProxy<
                                LuaTransform,
                            >,
                        >()
                },
            ),
        )
    }
    fn setup_script(
        &mut self,
        script_data: &bevy_mod_scripting_core::hosts::ScriptData,
        ctx: &mut Self::ScriptContext,
    ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> {
        Ok(())
    }
    fn setup_script_runtime(
        &mut self,
        world_ptr: bevy_mod_scripting_core::world::WorldPointer,
        _script_data: &bevy_mod_scripting_core::hosts::ScriptData,
        ctx: &mut Self::ScriptContext,
    ) -> Result<(), bevy_mod_scripting_core::error::ScriptError> {
        Ok(())
    }
    fn register_with_app(&self, app: &mut bevy::app::App) {
        app.register_foreign_lua_type::<bevy::transform::components::GlobalTransform>();
        app.register_foreign_lua_type::<bevy::transform::components::Transform>();
    }
}