wow_world_base 0.3.0

Base definitions and functions for World of Warcraft game servers
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
/// Auto generated from the original `wowm` in file [`wow_message_parser/wowm/world/spell/spell_common_3_3_5.wowm:54`](https://github.com/gtker/wow_messages/tree/main/wow_message_parser/wowm/world/spell/spell_common_3_3_5.wowm#L54):
/// ```text
/// flag GameobjectCastFlags : u32 {
///     LOCK_PLAYER_CAST_ANIM = 0x01;
///     UNKNOWN2 = 0x02;
///     UNKNOWN4 = 0x04;
///     UNKNOWN8 = 0x08;
///     UNKNOWN16 = 0x10;
///     AMMO = 0x20;
///     DEST_LOCATION = 0x040;
///     ITEM_CASTER = 0x100;
///     UNK200 = 0x200;
///     EXTRA_MESSAGE = 0x400;
///     POWER_UPDATE = 0x800;
///     UNK2000 = 0x2000;
///     UNK1000 = 0x1000;
///     UNK8000 = 0x8000;
///     ADJUST_MISSILE = 0x20000;
///     UNK40000 = 0x40000;
///     VISUAL_CHAIN = 0x80000;
///     RUNE_UPDATE = 0x200000;
///     UNK400000 = 0x400000;
/// }
/// ```
#[derive(Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Copy, Clone, Default)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct GameobjectCastFlags {
    inner: u32,
}

#[cfg(feature = "print-testcase")]
impl GameobjectCastFlags {
    #[allow(clippy::missing_const_for_fn)]
    pub fn as_test_case_value(&self) -> String {
        let mut s = String::new();
        let mut first = true;
        if self.is_lock_player_cast_anim() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "LOCK_PLAYER_CAST_ANIM").unwrap();
            first = false;
        }
        if self.is_unknown2() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "UNKNOWN2").unwrap();
            first = false;
        }
        if self.is_unknown4() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "UNKNOWN4").unwrap();
            first = false;
        }
        if self.is_unknown8() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "UNKNOWN8").unwrap();
            first = false;
        }
        if self.is_unknown16() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "UNKNOWN16").unwrap();
            first = false;
        }
        if self.is_ammo() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "AMMO").unwrap();
            first = false;
        }
        if self.is_dest_location() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "DEST_LOCATION").unwrap();
            first = false;
        }
        if self.is_item_caster() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "ITEM_CASTER").unwrap();
            first = false;
        }
        if self.is_unk200() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "UNK200").unwrap();
            first = false;
        }
        if self.is_extra_message() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "EXTRA_MESSAGE").unwrap();
            first = false;
        }
        if self.is_power_update() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "POWER_UPDATE").unwrap();
            first = false;
        }
        if self.is_unk2000() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "UNK2000").unwrap();
            first = false;
        }
        if self.is_unk1000() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "UNK1000").unwrap();
            first = false;
        }
        if self.is_unk8000() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "UNK8000").unwrap();
            first = false;
        }
        if self.is_adjust_missile() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "ADJUST_MISSILE").unwrap();
            first = false;
        }
        if self.is_unk40000() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "UNK40000").unwrap();
            first = false;
        }
        if self.is_visual_chain() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "VISUAL_CHAIN").unwrap();
            first = false;
        }
        if self.is_rune_update() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "RUNE_UPDATE").unwrap();
            first = false;
        }
        if self.is_unk400000() {
            use std::fmt::Write;
            if !first {
                write!(s, " | ").unwrap();
            }
            write!(s, "UNK400000").unwrap();
            first = false;
        }
        s
    }

}

impl GameobjectCastFlags {
    pub const fn new(inner: u32) -> Self {
        Self { inner }
    }

    pub const LOCK_PLAYER_CAST_ANIM: u32 = 0x01;
    pub const UNKNOWN2: u32 = 0x02;
    pub const UNKNOWN4: u32 = 0x04;
    pub const UNKNOWN8: u32 = 0x08;
    pub const UNKNOWN16: u32 = 0x10;
    pub const AMMO: u32 = 0x20;
    pub const DEST_LOCATION: u32 = 0x40;
    pub const ITEM_CASTER: u32 = 0x100;
    pub const UNK200: u32 = 0x200;
    pub const EXTRA_MESSAGE: u32 = 0x400;
    pub const POWER_UPDATE: u32 = 0x800;
    pub const UNK2000: u32 = 0x2000;
    pub const UNK1000: u32 = 0x1000;
    pub const UNK8000: u32 = 0x8000;
    pub const ADJUST_MISSILE: u32 = 0x20000;
    pub const UNK40000: u32 = 0x40000;
    pub const VISUAL_CHAIN: u32 = 0x80000;
    pub const RUNE_UPDATE: u32 = 0x200000;
    pub const UNK400000: u32 = 0x400000;

    pub const fn empty() -> Self {
        Self { inner: 0 }
    }

    pub const fn is_empty(&self) -> bool {
        self.inner == 0
    }

    pub const fn all() -> Self {
        Self {
            inner: Self::LOCK_PLAYER_CAST_ANIM
                | Self::UNKNOWN2
                | Self::UNKNOWN4
                | Self::UNKNOWN8
                | Self::UNKNOWN16
                | Self::AMMO
                | Self::DEST_LOCATION
                | Self::ITEM_CASTER
                | Self::UNK200
                | Self::EXTRA_MESSAGE
                | Self::POWER_UPDATE
                | Self::UNK2000
                | Self::UNK1000
                | Self::UNK8000
                | Self::ADJUST_MISSILE
                | Self::UNK40000
                | Self::VISUAL_CHAIN
                | Self::RUNE_UPDATE
                | Self::UNK400000
        }
    }

    pub const fn is_lock_player_cast_anim(&self) -> bool {
        (self.inner & Self::LOCK_PLAYER_CAST_ANIM) != 0
    }

    /// also do not send standstate update
    pub const fn new_lock_player_cast_anim() -> Self {
        Self { inner: Self::LOCK_PLAYER_CAST_ANIM }
    }

    pub fn set_lock_player_cast_anim(&mut self) -> Self {
        self.inner |= Self::LOCK_PLAYER_CAST_ANIM;
        *self
    }

    pub fn clear_lock_player_cast_anim(&mut self) -> Self {
        self.inner &= Self::LOCK_PLAYER_CAST_ANIM.reverse_bits();
        *self
    }

    pub const fn is_unknown2(&self) -> bool {
        (self.inner & Self::UNKNOWN2) != 0
    }

    pub const fn new_unknown2() -> Self {
        Self { inner: Self::UNKNOWN2 }
    }

    pub fn set_unknown2(&mut self) -> Self {
        self.inner |= Self::UNKNOWN2;
        *self
    }

    pub fn clear_unknown2(&mut self) -> Self {
        self.inner &= Self::UNKNOWN2.reverse_bits();
        *self
    }

    pub const fn is_unknown4(&self) -> bool {
        (self.inner & Self::UNKNOWN4) != 0
    }

    pub const fn new_unknown4() -> Self {
        Self { inner: Self::UNKNOWN4 }
    }

    pub fn set_unknown4(&mut self) -> Self {
        self.inner |= Self::UNKNOWN4;
        *self
    }

    pub fn clear_unknown4(&mut self) -> Self {
        self.inner &= Self::UNKNOWN4.reverse_bits();
        *self
    }

    pub const fn is_unknown8(&self) -> bool {
        (self.inner & Self::UNKNOWN8) != 0
    }

    pub const fn new_unknown8() -> Self {
        Self { inner: Self::UNKNOWN8 }
    }

    pub fn set_unknown8(&mut self) -> Self {
        self.inner |= Self::UNKNOWN8;
        *self
    }

    pub fn clear_unknown8(&mut self) -> Self {
        self.inner &= Self::UNKNOWN8.reverse_bits();
        *self
    }

    pub const fn is_unknown16(&self) -> bool {
        (self.inner & Self::UNKNOWN16) != 0
    }

    pub const fn new_unknown16() -> Self {
        Self { inner: Self::UNKNOWN16 }
    }

    pub fn set_unknown16(&mut self) -> Self {
        self.inner |= Self::UNKNOWN16;
        *self
    }

    pub fn clear_unknown16(&mut self) -> Self {
        self.inner &= Self::UNKNOWN16.reverse_bits();
        *self
    }

    pub const fn is_ammo(&self) -> bool {
        (self.inner & Self::AMMO) != 0
    }

    /// 2 functions are called on 2 values
    pub const fn new_ammo() -> Self {
        Self { inner: Self::AMMO }
    }

    pub fn set_ammo(&mut self) -> Self {
        self.inner |= Self::AMMO;
        *self
    }

    pub fn clear_ammo(&mut self) -> Self {
        self.inner &= Self::AMMO.reverse_bits();
        *self
    }

    pub const fn is_dest_location(&self) -> bool {
        (self.inner & Self::DEST_LOCATION) != 0
    }

    pub const fn new_dest_location() -> Self {
        Self { inner: Self::DEST_LOCATION }
    }

    pub fn set_dest_location(&mut self) -> Self {
        self.inner |= Self::DEST_LOCATION;
        *self
    }

    pub fn clear_dest_location(&mut self) -> Self {
        self.inner &= Self::DEST_LOCATION.reverse_bits();
        *self
    }

    pub const fn is_item_caster(&self) -> bool {
        (self.inner & Self::ITEM_CASTER) != 0
    }

    pub const fn new_item_caster() -> Self {
        Self { inner: Self::ITEM_CASTER }
    }

    pub fn set_item_caster(&mut self) -> Self {
        self.inner |= Self::ITEM_CASTER;
        *self
    }

    pub fn clear_item_caster(&mut self) -> Self {
        self.inner &= Self::ITEM_CASTER.reverse_bits();
        *self
    }

    pub const fn is_unk200(&self) -> bool {
        (self.inner & Self::UNK200) != 0
    }

    pub const fn new_unk200() -> Self {
        Self { inner: Self::UNK200 }
    }

    pub fn set_unk200(&mut self) -> Self {
        self.inner |= Self::UNK200;
        *self
    }

    pub fn clear_unk200(&mut self) -> Self {
        self.inner &= Self::UNK200.reverse_bits();
        *self
    }

    pub const fn is_extra_message(&self) -> bool {
        (self.inner & Self::EXTRA_MESSAGE) != 0
    }

    /// TARGET MISSES AND OTHER MESSAGES LIKE 'Resist'
    pub const fn new_extra_message() -> Self {
        Self { inner: Self::EXTRA_MESSAGE }
    }

    pub fn set_extra_message(&mut self) -> Self {
        self.inner |= Self::EXTRA_MESSAGE;
        *self
    }

    pub fn clear_extra_message(&mut self) -> Self {
        self.inner &= Self::EXTRA_MESSAGE.reverse_bits();
        *self
    }

    pub const fn is_power_update(&self) -> bool {
        (self.inner & Self::POWER_UPDATE) != 0
    }

    /// seems to work hand in hand with some visual effect of update actually
    pub const fn new_power_update() -> Self {
        Self { inner: Self::POWER_UPDATE }
    }

    pub fn set_power_update(&mut self) -> Self {
        self.inner |= Self::POWER_UPDATE;
        *self
    }

    pub fn clear_power_update(&mut self) -> Self {
        self.inner &= Self::POWER_UPDATE.reverse_bits();
        *self
    }

    pub const fn is_unk2000(&self) -> bool {
        (self.inner & Self::UNK2000) != 0
    }

    pub const fn new_unk2000() -> Self {
        Self { inner: Self::UNK2000 }
    }

    pub fn set_unk2000(&mut self) -> Self {
        self.inner |= Self::UNK2000;
        *self
    }

    pub fn clear_unk2000(&mut self) -> Self {
        self.inner &= Self::UNK2000.reverse_bits();
        *self
    }

    pub const fn is_unk1000(&self) -> bool {
        (self.inner & Self::UNK1000) != 0
    }

    /// no idea
    pub const fn new_unk1000() -> Self {
        Self { inner: Self::UNK1000 }
    }

    pub fn set_unk1000(&mut self) -> Self {
        self.inner |= Self::UNK1000;
        *self
    }

    pub fn clear_unk1000(&mut self) -> Self {
        self.inner &= Self::UNK1000.reverse_bits();
        *self
    }

    pub const fn is_unk8000(&self) -> bool {
        (self.inner & Self::UNK8000) != 0
    }

    /// seems to make server send extra 2 bytes before UNK1 and after UNK20000
    pub const fn new_unk8000() -> Self {
        Self { inner: Self::UNK8000 }
    }

    pub fn set_unk8000(&mut self) -> Self {
        self.inner |= Self::UNK8000;
        *self
    }

    pub fn clear_unk8000(&mut self) -> Self {
        self.inner &= Self::UNK8000.reverse_bits();
        *self
    }

    pub const fn is_adjust_missile(&self) -> bool {
        (self.inner & Self::ADJUST_MISSILE) != 0
    }

    /// seems to make server send an uint32 after `m_targets.write`
    pub const fn new_adjust_missile() -> Self {
        Self { inner: Self::ADJUST_MISSILE }
    }

    pub fn set_adjust_missile(&mut self) -> Self {
        self.inner |= Self::ADJUST_MISSILE;
        *self
    }

    pub fn clear_adjust_missile(&mut self) -> Self {
        self.inner &= Self::ADJUST_MISSILE.reverse_bits();
        *self
    }

    pub const fn is_unk40000(&self) -> bool {
        (self.inner & Self::UNK40000) != 0
    }

    /// 1 uint32. this is not confirmed but i have a feeling about it :D
    pub const fn new_unk40000() -> Self {
        Self { inner: Self::UNK40000 }
    }

    pub fn set_unk40000(&mut self) -> Self {
        self.inner |= Self::UNK40000;
        *self
    }

    pub fn clear_unk40000(&mut self) -> Self {
        self.inner &= Self::UNK40000.reverse_bits();
        *self
    }

    pub const fn is_visual_chain(&self) -> bool {
        (self.inner & Self::VISUAL_CHAIN) != 0
    }

    /// 2 functions called (same ones as for ranged but different)
    pub const fn new_visual_chain() -> Self {
        Self { inner: Self::VISUAL_CHAIN }
    }

    pub fn set_visual_chain(&mut self) -> Self {
        self.inner |= Self::VISUAL_CHAIN;
        *self
    }

    pub fn clear_visual_chain(&mut self) -> Self {
        self.inner &= Self::VISUAL_CHAIN.reverse_bits();
        *self
    }

    pub const fn is_rune_update(&self) -> bool {
        (self.inner & Self::RUNE_UPDATE) != 0
    }

    /// 2 bytes for the rune cur and rune next flags
    pub const fn new_rune_update() -> Self {
        Self { inner: Self::RUNE_UPDATE }
    }

    pub fn set_rune_update(&mut self) -> Self {
        self.inner |= Self::RUNE_UPDATE;
        *self
    }

    pub fn clear_rune_update(&mut self) -> Self {
        self.inner &= Self::RUNE_UPDATE.reverse_bits();
        *self
    }

    pub const fn is_unk400000(&self) -> bool {
        (self.inner & Self::UNK400000) != 0
    }

    /// seems to make server send an uint32 after `m_targets.write`
    pub const fn new_unk400000() -> Self {
        Self { inner: Self::UNK400000 }
    }

    pub fn set_unk400000(&mut self) -> Self {
        self.inner |= Self::UNK400000;
        *self
    }

    pub fn clear_unk400000(&mut self) -> Self {
        self.inner &= Self::UNK400000.reverse_bits();
        *self
    }

    pub const fn as_int(&self) -> u32 {
        self.inner
    }

}

impl std::fmt::UpperHex for GameobjectCastFlags {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::UpperHex::fmt(&self.inner, f)
    }
}

impl std::fmt::LowerHex for GameobjectCastFlags {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::LowerHex::fmt(&self.inner, f)
    }
}

impl std::fmt::Octal for GameobjectCastFlags {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Octal::fmt(&self.inner, f)
    }
}

impl std::fmt::Binary for GameobjectCastFlags {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        std::fmt::Binary::fmt(&self.inner, f)
    }
}

impl std::ops::BitAnd for GameobjectCastFlags {
    type Output = Self;
    fn bitand(self, rhs: Self) -> Self::Output {
        Self { inner: self.inner.bitand(rhs.inner), }
    }
}

impl std::ops::BitAndAssign for GameobjectCastFlags {
    fn bitand_assign(&mut self, rhs: Self) {
        self.inner.bitand_assign(rhs.inner)
    }
}

impl std::ops::BitOr for GameobjectCastFlags {
    type Output = Self;
    fn bitor(self, rhs: Self) -> Self::Output {
        Self { inner: self.inner.bitor(rhs.inner), }
    }
}

impl std::ops::BitOrAssign for GameobjectCastFlags {
    fn bitor_assign(&mut self, rhs: Self) {
        self.inner.bitor_assign(rhs.inner)
    }
}

impl std::ops::BitXor for GameobjectCastFlags {
    type Output = Self;
    fn bitxor(self, rhs: Self) -> Self::Output {
        Self { inner: self.inner.bitxor(rhs.inner), }
    }
}

impl std::ops::BitXorAssign for GameobjectCastFlags {
    fn bitxor_assign(&mut self, rhs: Self) {
        self.inner.bitxor_assign(rhs.inner)
    }
}

impl From<u32> for GameobjectCastFlags {
    fn from(value: u32) -> Self {
        Self::new(value)
    }
}

impl From<u8> for GameobjectCastFlags {
    fn from(value: u8) -> Self {
        Self::new(value.into())
    }
}

impl From<u16> for GameobjectCastFlags {
    fn from(value: u16) -> Self {
        Self::new(value.into())
    }
}

impl TryFrom<u64> for GameobjectCastFlags {
    type Error = u64;
    fn try_from(value: u64) -> Result<Self, Self::Error> {
        let a = TryInto::<u32>::try_into(value).ok().ok_or(value)?;
        Ok(Self::new(a))
    }
}

impl TryFrom<i8> for GameobjectCastFlags {
    type Error = i8;
    fn try_from(value: i8) -> Result<Self, Self::Error> {
        let v = u8::from_le_bytes(value.to_le_bytes());
        Ok(Self::new(v.into()))
    }
}

impl TryFrom<i16> for GameobjectCastFlags {
    type Error = i16;
    fn try_from(value: i16) -> Result<Self, Self::Error> {
        let v = u16::from_le_bytes(value.to_le_bytes());
        Ok(Self::new(v.into()))
    }
}

impl From<i32> for GameobjectCastFlags {
    fn from(value: i32) -> Self {
        Self::new(u32::from_le_bytes(value.to_le_bytes()))
    }
}

impl TryFrom<i64> for GameobjectCastFlags {
    type Error = i64;
    fn try_from(value: i64) -> Result<Self, Self::Error> {
        let v = u64::from_le_bytes(value.to_le_bytes());
        let a = TryInto::<u32>::try_into(v).ok().ok_or(value)?;
        Ok(Self::new(a))
    }
}

impl TryFrom<usize> for GameobjectCastFlags {
    type Error = usize;
    fn try_from(value: usize) -> Result<Self, Self::Error> {
        let a = TryInto::<u32>::try_into(value).ok().ok_or(value)?;
        Ok(Self::new(a))
    }
}