elicit_bevy 0.11.0

Elicitation-enabled Bevy ECS tools for code generation and game development
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
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
//! Glam vector newtypes re-exported from `bevy::math`.

use elicitation::{elicit_newtype, elicit_newtype_traits};
use elicitation_derive::reflect_methods;

// ── Vec2 ─────────────────────────────────────────────────────────────────────

elicit_newtype!(bevy::math::Vec2, as Vec2);
elicit_newtype_traits!(Vec2, bevy::math::Vec2, [eq]);

impl serde::Serialize for Vec2 {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        (*self.0).serialize(s)
    }
}
impl<'de> serde::Deserialize<'de> for Vec2 {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        bevy::math::Vec2::deserialize(d).map(|v| Vec2(std::sync::Arc::new(v)))
    }
}
impl From<Vec2> for bevy::math::Vec2 {
    fn from(v: Vec2) -> Self {
        *v.0
    }
}

#[reflect_methods]
impl Vec2 {
    /// X component.
    #[tracing::instrument(skip(self))]
    pub fn vec2_x(&self) -> f32 {
        self.0.x
    }
    /// Y component.
    #[tracing::instrument(skip(self))]
    pub fn vec2_y(&self) -> f32 {
        self.0.y
    }
    /// Computes the length.
    #[tracing::instrument(skip(self))]
    pub fn vec2_length(&self) -> f32 {
        self.0.length()
    }
    /// Returns the normalized vector, or zero if length is zero.
    #[tracing::instrument(skip(self))]
    pub fn vec2_normalize_or_zero(&self) -> Vec2 {
        Vec2::from(self.0.normalize_or_zero())
    }
    /// Dot product with another vector.
    #[tracing::instrument(skip(self, other))]
    pub fn vec2_dot(&self, other: Vec2) -> f32 {
        self.0.dot(*other.0)
    }
    /// Returns a new vector with each component clamped.
    #[tracing::instrument(skip(self, min, max))]
    pub fn clamp(&self, min: Vec2, max: Vec2) -> Vec2 {
        Vec2::from(self.0.clamp(*min.0, *max.0))
    }
    /// Distance to another vector.
    #[tracing::instrument(skip(self, other))]
    pub fn vec2_distance(&self, other: Vec2) -> f32 {
        self.0.distance(*other.0)
    }
    /// Constructs from x and y (ignores self).
    #[tracing::instrument(skip(self))]
    pub fn vec2_new(&self, x: f32, y: f32) -> Vec2 {
        Vec2::from(bevy::math::Vec2::new(x, y))
    }
    /// Zero vector.
    #[tracing::instrument(skip(self))]
    pub fn vec2_zero(&self) -> Vec2 {
        Vec2::from(bevy::math::Vec2::ZERO)
    }
    /// One vector.
    #[tracing::instrument(skip(self))]
    pub fn vec2_one(&self) -> Vec2 {
        Vec2::from(bevy::math::Vec2::ONE)
    }
}

mod emit_impls {
    use super::Vec2;
    use elicitation::emit_code::ToCodeLiteral;
    use proc_macro2::TokenStream;
    impl ToCodeLiteral for Vec2 {
        fn to_code_literal(&self) -> TokenStream {
            let x = self.0.x;
            let y = self.0.y;
            quote::quote! { ::bevy::math::Vec2::new(#x, #y) }
        }
    }
}
impl elicitation::ElicitComplete for Vec2 {}

// ── Vec3 ─────────────────────────────────────────────────────────────────────

elicit_newtype!(bevy::math::Vec3, as Vec3);
elicit_newtype_traits!(Vec3, bevy::math::Vec3, [eq]);

impl serde::Serialize for Vec3 {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        (*self.0).serialize(s)
    }
}
impl<'de> serde::Deserialize<'de> for Vec3 {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        bevy::math::Vec3::deserialize(d).map(|v| Vec3(std::sync::Arc::new(v)))
    }
}
impl From<Vec3> for bevy::math::Vec3 {
    fn from(v: Vec3) -> Self {
        *v.0
    }
}

#[reflect_methods]
impl Vec3 {
    /// X component.
    #[tracing::instrument(skip(self))]
    pub fn vec3_x(&self) -> f32 {
        self.0.x
    }
    /// Y component.
    #[tracing::instrument(skip(self))]
    pub fn vec3_y(&self) -> f32 {
        self.0.y
    }
    /// Z component.
    #[tracing::instrument(skip(self))]
    pub fn vec3_z(&self) -> f32 {
        self.0.z
    }
    /// Computes the length.
    #[tracing::instrument(skip(self))]
    pub fn vec3_length(&self) -> f32 {
        self.0.length()
    }
    /// Returns the normalized vector, or zero if length is zero.
    #[tracing::instrument(skip(self))]
    pub fn vec3_normalize_or_zero(&self) -> Vec3 {
        Vec3::from(self.0.normalize_or_zero())
    }
    /// Dot product with another vector.
    #[tracing::instrument(skip(self, other))]
    pub fn vec3_dot(&self, other: Vec3) -> f32 {
        self.0.dot(*other.0)
    }
    /// Cross product.
    #[tracing::instrument(skip(self, other))]
    pub fn cross(&self, other: Vec3) -> Vec3 {
        Vec3::from(self.0.cross(*other.0))
    }
    /// Distance to another vector.
    #[tracing::instrument(skip(self, other))]
    pub fn vec3_distance(&self, other: Vec3) -> f32 {
        self.0.distance(*other.0)
    }
    /// Constructs from x, y, z (ignores self).
    #[tracing::instrument(skip(self))]
    pub fn vec3_new(&self, x: f32, y: f32, z: f32) -> Vec3 {
        Vec3::from(bevy::math::Vec3::new(x, y, z))
    }
    /// Zero vector.
    #[tracing::instrument(skip(self))]
    pub fn vec3_zero(&self) -> Vec3 {
        Vec3::from(bevy::math::Vec3::ZERO)
    }
    /// One vector.
    #[tracing::instrument(skip(self))]
    pub fn vec3_one(&self) -> Vec3 {
        Vec3::from(bevy::math::Vec3::ONE)
    }
    /// Up direction (0, 1, 0).
    #[tracing::instrument(skip(self))]
    pub fn up(&self) -> Vec3 {
        Vec3::from(bevy::math::Vec3::Y)
    }
    /// Forward direction (0, 0, -1) in right-hand coordinates.
    #[tracing::instrument(skip(self))]
    pub fn forward(&self) -> Vec3 {
        Vec3::from(bevy::math::Vec3::NEG_Z)
    }
}

mod emit_impls_vec3 {
    use super::Vec3;
    use elicitation::emit_code::ToCodeLiteral;
    use proc_macro2::TokenStream;
    impl ToCodeLiteral for Vec3 {
        fn to_code_literal(&self) -> TokenStream {
            let x = self.0.x;
            let y = self.0.y;
            let z = self.0.z;
            quote::quote! { ::bevy::math::Vec3::new(#x, #y, #z) }
        }
    }
}
impl elicitation::ElicitComplete for Vec3 {}

// ── Vec3A ─────────────────────────────────────────────────────────────────────

elicit_newtype!(bevy::math::Vec3A, as Vec3A);
elicit_newtype_traits!(Vec3A, bevy::math::Vec3A, [eq]);

impl serde::Serialize for Vec3A {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        (*self.0).serialize(s)
    }
}
impl<'de> serde::Deserialize<'de> for Vec3A {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        bevy::math::Vec3A::deserialize(d).map(|v| Vec3A(std::sync::Arc::new(v)))
    }
}
impl From<Vec3A> for bevy::math::Vec3A {
    fn from(v: Vec3A) -> Self {
        *v.0
    }
}

#[reflect_methods]
impl Vec3A {
    /// X component.
    #[tracing::instrument(skip(self))]
    pub fn vec3_a_x(&self) -> f32 {
        self.0.x
    }
    /// Y component.
    #[tracing::instrument(skip(self))]
    pub fn vec3_a_y(&self) -> f32 {
        self.0.y
    }
    /// Z component.
    #[tracing::instrument(skip(self))]
    pub fn vec3_a_z(&self) -> f32 {
        self.0.z
    }
    /// Length.
    #[tracing::instrument(skip(self))]
    pub fn vec3_a_length(&self) -> f32 {
        self.0.length()
    }
    /// Constructs from x, y, z (ignores self).
    #[tracing::instrument(skip(self))]
    pub fn vec3_a_new(&self, x: f32, y: f32, z: f32) -> Vec3A {
        Vec3A::from(bevy::math::Vec3A::new(x, y, z))
    }
}

mod emit_impls_vec3a {
    use super::Vec3A;
    use elicitation::emit_code::ToCodeLiteral;
    use proc_macro2::TokenStream;
    impl ToCodeLiteral for Vec3A {
        fn to_code_literal(&self) -> TokenStream {
            let x = self.0.x;
            let y = self.0.y;
            let z = self.0.z;
            quote::quote! { ::bevy::math::Vec3A::new(#x, #y, #z) }
        }
    }
}
impl elicitation::ElicitComplete for Vec3A {}

// ── Vec4 ─────────────────────────────────────────────────────────────────────

elicit_newtype!(bevy::math::Vec4, as Vec4);
elicit_newtype_traits!(Vec4, bevy::math::Vec4, [eq]);

impl serde::Serialize for Vec4 {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        (*self.0).serialize(s)
    }
}
impl<'de> serde::Deserialize<'de> for Vec4 {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        bevy::math::Vec4::deserialize(d).map(|v| Vec4(std::sync::Arc::new(v)))
    }
}
impl From<Vec4> for bevy::math::Vec4 {
    fn from(v: Vec4) -> Self {
        *v.0
    }
}

#[reflect_methods]
impl Vec4 {
    /// X component.
    #[tracing::instrument(skip(self))]
    pub fn vec4_x(&self) -> f32 {
        self.0.x
    }
    /// Y component.
    #[tracing::instrument(skip(self))]
    pub fn vec4_y(&self) -> f32 {
        self.0.y
    }
    /// Z component.
    #[tracing::instrument(skip(self))]
    pub fn vec4_z(&self) -> f32 {
        self.0.z
    }
    /// W component.
    #[tracing::instrument(skip(self))]
    pub fn vec4_w(&self) -> f32 {
        self.0.w
    }
    /// Length.
    #[tracing::instrument(skip(self))]
    pub fn vec4_length(&self) -> f32 {
        self.0.length()
    }
    /// Constructs from x, y, z, w (ignores self).
    #[tracing::instrument(skip(self))]
    pub fn vec4_new(&self, x: f32, y: f32, z: f32, w: f32) -> Vec4 {
        Vec4::from(bevy::math::Vec4::new(x, y, z, w))
    }
}

mod emit_impls_vec4 {
    use super::Vec4;
    use elicitation::emit_code::ToCodeLiteral;
    use proc_macro2::TokenStream;
    impl ToCodeLiteral for Vec4 {
        fn to_code_literal(&self) -> TokenStream {
            let x = self.0.x;
            let y = self.0.y;
            let z = self.0.z;
            let w = self.0.w;
            quote::quote! { ::bevy::math::Vec4::new(#x, #y, #z, #w) }
        }
    }
}
impl elicitation::ElicitComplete for Vec4 {}

// ── DVec2 ─────────────────────────────────────────────────────────────────────

elicit_newtype!(bevy::math::DVec2, as DVec2);
elicit_newtype_traits!(DVec2, bevy::math::DVec2, [eq]);

impl serde::Serialize for DVec2 {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        (*self.0).serialize(s)
    }
}
impl<'de> serde::Deserialize<'de> for DVec2 {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        bevy::math::DVec2::deserialize(d).map(|v| DVec2(std::sync::Arc::new(v)))
    }
}
impl From<DVec2> for bevy::math::DVec2 {
    fn from(v: DVec2) -> Self {
        *v.0
    }
}

#[reflect_methods]
impl DVec2 {
    /// X component.
    #[tracing::instrument(skip(self))]
    pub fn d_vec2_x(&self) -> f64 {
        self.0.x
    }
    /// Y component.
    #[tracing::instrument(skip(self))]
    pub fn d_vec2_y(&self) -> f64 {
        self.0.y
    }
    /// Constructs from x, y (ignores self).
    #[tracing::instrument(skip(self))]
    pub fn d_vec2_new(&self, x: f64, y: f64) -> DVec2 {
        DVec2::from(bevy::math::DVec2::new(x, y))
    }
}

mod emit_impls_dvec2 {
    use super::DVec2;
    use elicitation::emit_code::ToCodeLiteral;
    use proc_macro2::TokenStream;
    impl ToCodeLiteral for DVec2 {
        fn to_code_literal(&self) -> TokenStream {
            let x = self.0.x;
            let y = self.0.y;
            quote::quote! { ::bevy::math::DVec2::new(#x, #y) }
        }
    }
}
impl elicitation::ElicitComplete for DVec2 {}

// ── DVec3 ─────────────────────────────────────────────────────────────────────

elicit_newtype!(bevy::math::DVec3, as DVec3);
elicit_newtype_traits!(DVec3, bevy::math::DVec3, [eq]);

impl serde::Serialize for DVec3 {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        (*self.0).serialize(s)
    }
}
impl<'de> serde::Deserialize<'de> for DVec3 {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        bevy::math::DVec3::deserialize(d).map(|v| DVec3(std::sync::Arc::new(v)))
    }
}
impl From<DVec3> for bevy::math::DVec3 {
    fn from(v: DVec3) -> Self {
        *v.0
    }
}

#[reflect_methods]
impl DVec3 {
    /// X component.
    #[tracing::instrument(skip(self))]
    pub fn d_vec3_x(&self) -> f64 {
        self.0.x
    }
    /// Y component.
    #[tracing::instrument(skip(self))]
    pub fn d_vec3_y(&self) -> f64 {
        self.0.y
    }
    /// Z component.
    #[tracing::instrument(skip(self))]
    pub fn d_vec3_z(&self) -> f64 {
        self.0.z
    }
    /// Constructs from x, y, z (ignores self).
    #[tracing::instrument(skip(self))]
    pub fn d_vec3_new(&self, x: f64, y: f64, z: f64) -> DVec3 {
        DVec3::from(bevy::math::DVec3::new(x, y, z))
    }
}

mod emit_impls_dvec3 {
    use super::DVec3;
    use elicitation::emit_code::ToCodeLiteral;
    use proc_macro2::TokenStream;
    impl ToCodeLiteral for DVec3 {
        fn to_code_literal(&self) -> TokenStream {
            let x = self.0.x;
            let y = self.0.y;
            let z = self.0.z;
            quote::quote! { ::bevy::math::DVec3::new(#x, #y, #z) }
        }
    }
}
impl elicitation::ElicitComplete for DVec3 {}

// ── DVec4 ─────────────────────────────────────────────────────────────────────

elicit_newtype!(bevy::math::DVec4, as DVec4);
elicit_newtype_traits!(DVec4, bevy::math::DVec4, [eq]);

impl serde::Serialize for DVec4 {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        (*self.0).serialize(s)
    }
}
impl<'de> serde::Deserialize<'de> for DVec4 {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        bevy::math::DVec4::deserialize(d).map(|v| DVec4(std::sync::Arc::new(v)))
    }
}
impl From<DVec4> for bevy::math::DVec4 {
    fn from(v: DVec4) -> Self {
        *v.0
    }
}

#[reflect_methods]
impl DVec4 {
    /// X component.
    #[tracing::instrument(skip(self))]
    pub fn d_vec4_x(&self) -> f64 {
        self.0.x
    }
    /// Y component.
    #[tracing::instrument(skip(self))]
    pub fn d_vec4_y(&self) -> f64 {
        self.0.y
    }
    /// Z component.
    #[tracing::instrument(skip(self))]
    pub fn d_vec4_z(&self) -> f64 {
        self.0.z
    }
    /// W component.
    #[tracing::instrument(skip(self))]
    pub fn d_vec4_w(&self) -> f64 {
        self.0.w
    }
    /// Constructs from x, y, z, w (ignores self).
    #[tracing::instrument(skip(self))]
    pub fn d_vec4_new(&self, x: f64, y: f64, z: f64, w: f64) -> DVec4 {
        DVec4::from(bevy::math::DVec4::new(x, y, z, w))
    }
}

mod emit_impls_dvec4 {
    use super::DVec4;
    use elicitation::emit_code::ToCodeLiteral;
    use proc_macro2::TokenStream;
    impl ToCodeLiteral for DVec4 {
        fn to_code_literal(&self) -> TokenStream {
            let x = self.0.x;
            let y = self.0.y;
            let z = self.0.z;
            let w = self.0.w;
            quote::quote! { ::bevy::math::DVec4::new(#x, #y, #z, #w) }
        }
    }
}
impl elicitation::ElicitComplete for DVec4 {}

// ── IVec2 ─────────────────────────────────────────────────────────────────────

elicit_newtype!(bevy::math::IVec2, as IVec2);
elicit_newtype_traits!(IVec2, bevy::math::IVec2, [eq]);

impl serde::Serialize for IVec2 {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        (*self.0).serialize(s)
    }
}
impl<'de> serde::Deserialize<'de> for IVec2 {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        bevy::math::IVec2::deserialize(d).map(|v| IVec2(std::sync::Arc::new(v)))
    }
}
impl From<IVec2> for bevy::math::IVec2 {
    fn from(v: IVec2) -> Self {
        *v.0
    }
}

#[reflect_methods]
impl IVec2 {
    /// X component.
    #[tracing::instrument(skip(self))]
    pub fn i_vec2_x(&self) -> i32 {
        self.0.x
    }
    /// Y component.
    #[tracing::instrument(skip(self))]
    pub fn i_vec2_y(&self) -> i32 {
        self.0.y
    }
    /// Constructs from x, y (ignores self).
    #[tracing::instrument(skip(self))]
    pub fn i_vec2_new(&self, x: i32, y: i32) -> IVec2 {
        IVec2::from(bevy::math::IVec2::new(x, y))
    }
}

mod emit_impls_ivec2 {
    use super::IVec2;
    use elicitation::emit_code::ToCodeLiteral;
    use proc_macro2::TokenStream;
    impl ToCodeLiteral for IVec2 {
        fn to_code_literal(&self) -> TokenStream {
            let x = self.0.x;
            let y = self.0.y;
            quote::quote! { ::bevy::math::IVec2::new(#x, #y) }
        }
    }
}
impl elicitation::ElicitComplete for IVec2 {}

// ── IVec3 ─────────────────────────────────────────────────────────────────────

elicit_newtype!(bevy::math::IVec3, as IVec3);
elicit_newtype_traits!(IVec3, bevy::math::IVec3, [eq]);

impl serde::Serialize for IVec3 {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        (*self.0).serialize(s)
    }
}
impl<'de> serde::Deserialize<'de> for IVec3 {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        bevy::math::IVec3::deserialize(d).map(|v| IVec3(std::sync::Arc::new(v)))
    }
}
impl From<IVec3> for bevy::math::IVec3 {
    fn from(v: IVec3) -> Self {
        *v.0
    }
}

#[reflect_methods]
impl IVec3 {
    /// X component.
    #[tracing::instrument(skip(self))]
    pub fn i_vec3_x(&self) -> i32 {
        self.0.x
    }
    /// Y component.
    #[tracing::instrument(skip(self))]
    pub fn i_vec3_y(&self) -> i32 {
        self.0.y
    }
    /// Z component.
    #[tracing::instrument(skip(self))]
    pub fn i_vec3_z(&self) -> i32 {
        self.0.z
    }
    /// Constructs from x, y, z (ignores self).
    #[tracing::instrument(skip(self))]
    pub fn i_vec3_new(&self, x: i32, y: i32, z: i32) -> IVec3 {
        IVec3::from(bevy::math::IVec3::new(x, y, z))
    }
}

mod emit_impls_ivec3 {
    use super::IVec3;
    use elicitation::emit_code::ToCodeLiteral;
    use proc_macro2::TokenStream;
    impl ToCodeLiteral for IVec3 {
        fn to_code_literal(&self) -> TokenStream {
            let x = self.0.x;
            let y = self.0.y;
            let z = self.0.z;
            quote::quote! { ::bevy::math::IVec3::new(#x, #y, #z) }
        }
    }
}
impl elicitation::ElicitComplete for IVec3 {}

// ── IVec4 ─────────────────────────────────────────────────────────────────────

elicit_newtype!(bevy::math::IVec4, as IVec4);
elicit_newtype_traits!(IVec4, bevy::math::IVec4, [eq]);

impl serde::Serialize for IVec4 {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        (*self.0).serialize(s)
    }
}
impl<'de> serde::Deserialize<'de> for IVec4 {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        bevy::math::IVec4::deserialize(d).map(|v| IVec4(std::sync::Arc::new(v)))
    }
}
impl From<IVec4> for bevy::math::IVec4 {
    fn from(v: IVec4) -> Self {
        *v.0
    }
}

#[reflect_methods]
impl IVec4 {
    /// X component.
    #[tracing::instrument(skip(self))]
    pub fn i_vec4_x(&self) -> i32 {
        self.0.x
    }
    /// Y component.
    #[tracing::instrument(skip(self))]
    pub fn i_vec4_y(&self) -> i32 {
        self.0.y
    }
    /// Z component.
    #[tracing::instrument(skip(self))]
    pub fn i_vec4_z(&self) -> i32 {
        self.0.z
    }
    /// W component.
    #[tracing::instrument(skip(self))]
    pub fn i_vec4_w(&self) -> i32 {
        self.0.w
    }
    /// Constructs from x, y, z, w (ignores self).
    #[tracing::instrument(skip(self))]
    pub fn i_vec4_new(&self, x: i32, y: i32, z: i32, w: i32) -> IVec4 {
        IVec4::from(bevy::math::IVec4::new(x, y, z, w))
    }
}

mod emit_impls_ivec4 {
    use super::IVec4;
    use elicitation::emit_code::ToCodeLiteral;
    use proc_macro2::TokenStream;
    impl ToCodeLiteral for IVec4 {
        fn to_code_literal(&self) -> TokenStream {
            let x = self.0.x;
            let y = self.0.y;
            let z = self.0.z;
            let w = self.0.w;
            quote::quote! { ::bevy::math::IVec4::new(#x, #y, #z, #w) }
        }
    }
}
impl elicitation::ElicitComplete for IVec4 {}

// ── UVec2 ─────────────────────────────────────────────────────────────────────

elicit_newtype!(bevy::math::UVec2, as UVec2);
elicit_newtype_traits!(UVec2, bevy::math::UVec2, [eq]);

impl serde::Serialize for UVec2 {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        (*self.0).serialize(s)
    }
}
impl<'de> serde::Deserialize<'de> for UVec2 {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        bevy::math::UVec2::deserialize(d).map(|v| UVec2(std::sync::Arc::new(v)))
    }
}
impl From<UVec2> for bevy::math::UVec2 {
    fn from(v: UVec2) -> Self {
        *v.0
    }
}

#[reflect_methods]
impl UVec2 {
    /// X component.
    #[tracing::instrument(skip(self))]
    pub fn u_vec2_x(&self) -> u32 {
        self.0.x
    }
    /// Y component.
    #[tracing::instrument(skip(self))]
    pub fn u_vec2_y(&self) -> u32 {
        self.0.y
    }
    /// Constructs from x, y (ignores self).
    #[tracing::instrument(skip(self))]
    pub fn u_vec2_new(&self, x: u32, y: u32) -> UVec2 {
        UVec2::from(bevy::math::UVec2::new(x, y))
    }
}

mod emit_impls_uvec2 {
    use super::UVec2;
    use elicitation::emit_code::ToCodeLiteral;
    use proc_macro2::TokenStream;
    impl ToCodeLiteral for UVec2 {
        fn to_code_literal(&self) -> TokenStream {
            let x = self.0.x;
            let y = self.0.y;
            quote::quote! { ::bevy::math::UVec2::new(#x, #y) }
        }
    }
}
impl elicitation::ElicitComplete for UVec2 {}

// ── UVec3 ─────────────────────────────────────────────────────────────────────

elicit_newtype!(bevy::math::UVec3, as UVec3);
elicit_newtype_traits!(UVec3, bevy::math::UVec3, [eq]);

impl serde::Serialize for UVec3 {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        (*self.0).serialize(s)
    }
}
impl<'de> serde::Deserialize<'de> for UVec3 {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        bevy::math::UVec3::deserialize(d).map(|v| UVec3(std::sync::Arc::new(v)))
    }
}
impl From<UVec3> for bevy::math::UVec3 {
    fn from(v: UVec3) -> Self {
        *v.0
    }
}

#[reflect_methods]
impl UVec3 {
    /// X component.
    #[tracing::instrument(skip(self))]
    pub fn u_vec3_x(&self) -> u32 {
        self.0.x
    }
    /// Y component.
    #[tracing::instrument(skip(self))]
    pub fn u_vec3_y(&self) -> u32 {
        self.0.y
    }
    /// Z component.
    #[tracing::instrument(skip(self))]
    pub fn u_vec3_z(&self) -> u32 {
        self.0.z
    }
    /// Constructs from x, y, z (ignores self).
    #[tracing::instrument(skip(self))]
    pub fn u_vec3_new(&self, x: u32, y: u32, z: u32) -> UVec3 {
        UVec3::from(bevy::math::UVec3::new(x, y, z))
    }
}

mod emit_impls_uvec3 {
    use super::UVec3;
    use elicitation::emit_code::ToCodeLiteral;
    use proc_macro2::TokenStream;
    impl ToCodeLiteral for UVec3 {
        fn to_code_literal(&self) -> TokenStream {
            let x = self.0.x;
            let y = self.0.y;
            let z = self.0.z;
            quote::quote! { ::bevy::math::UVec3::new(#x, #y, #z) }
        }
    }
}
impl elicitation::ElicitComplete for UVec3 {}

// ── UVec4 ─────────────────────────────────────────────────────────────────────

elicit_newtype!(bevy::math::UVec4, as UVec4);
elicit_newtype_traits!(UVec4, bevy::math::UVec4, [eq]);

impl serde::Serialize for UVec4 {
    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
        (*self.0).serialize(s)
    }
}
impl<'de> serde::Deserialize<'de> for UVec4 {
    fn deserialize<D: serde::Deserializer<'de>>(d: D) -> Result<Self, D::Error> {
        bevy::math::UVec4::deserialize(d).map(|v| UVec4(std::sync::Arc::new(v)))
    }
}
impl From<UVec4> for bevy::math::UVec4 {
    fn from(v: UVec4) -> Self {
        *v.0
    }
}

#[reflect_methods]
impl UVec4 {
    /// X component.
    #[tracing::instrument(skip(self))]
    pub fn u_vec4_x(&self) -> u32 {
        self.0.x
    }
    /// Y component.
    #[tracing::instrument(skip(self))]
    pub fn u_vec4_y(&self) -> u32 {
        self.0.y
    }
    /// Z component.
    #[tracing::instrument(skip(self))]
    pub fn u_vec4_z(&self) -> u32 {
        self.0.z
    }
    /// W component.
    #[tracing::instrument(skip(self))]
    pub fn u_vec4_w(&self) -> u32 {
        self.0.w
    }
    /// Constructs from x, y, z, w (ignores self).
    #[tracing::instrument(skip(self))]
    pub fn u_vec4_new(&self, x: u32, y: u32, z: u32, w: u32) -> UVec4 {
        UVec4::from(bevy::math::UVec4::new(x, y, z, w))
    }
}

mod emit_impls_uvec4 {
    use super::UVec4;
    use elicitation::emit_code::ToCodeLiteral;
    use proc_macro2::TokenStream;
    impl ToCodeLiteral for UVec4 {
        fn to_code_literal(&self) -> TokenStream {
            let x = self.0.x;
            let y = self.0.y;
            let z = self.0.z;
            let w = self.0.w;
            quote::quote! { ::bevy::math::UVec4::new(#x, #y, #z, #w) }
        }
    }
}
impl elicitation::ElicitComplete for UVec4 {}