gdlib 0.4.0

Rust library for editing Geometry Dash savefiles
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
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
//! This file contains constructors for trigger objects.
//! # ⚠️ Warning
//! **This file is incomplete. More triggers will be added in the future.**

use crate::cclocallevels::gdobj::{
    Event, GDObjConfig, GDObject, GDValue, MoveEasing,
    ids::{objects::*, properties::*},
    structs::*,
};

/// Returns a move trigger object
///
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `move_config`: Details for the movement of the target group. See [`MoveMode`] struct
/// * `time`: Move time of group.
/// * `target_group`: Group that is moving.
/// * `silent`: Skips collision checking with the player(s) in the path of its motion. Useful for reducing lag. Collision blocks are unaffected.
/// * `dynamic`: Updates location of the target group in real time for target/directional move modes.
/// * `easing`: Optional easing and easing rate (default: 2) tuple.
pub fn move_trigger(
    config: &GDObjConfig,
    move_config: MoveMode,
    time: f64,
    target_group: i16,
    silent: bool,
    dynamic: bool,
    easing: Option<(MoveEasing, f64)>,
) -> GDObject {
    // aim: target group 2
    let mut properties = vec![
        (TARGET_ITEM, GDValue::Group(target_group)),
        (DURATION_GROUP_TRIGGER_CHANCE, GDValue::Float(time)),
        (SMALL_STEP, GDValue::Bool(true)),
        (DYNAMIC_MOVE, GDValue::Bool(dynamic)),
        (SILENT_MOVE, GDValue::Bool(silent)),
    ];

    add_easing(&mut properties, easing);

    match move_config {
        MoveMode::Default(config) => {
            if let Some(lock) = config.x_lock {
                properties.push((
                    match lock {
                        MoveLock::Player => FOLLOW_PLAYERS_X_MOVEMENT,
                        MoveLock::Camera => FOLLOW_CAMERAS_X_MOVEMENT,
                    },
                    GDValue::Int(1),
                ));
                properties.push((X_MOVEMENT_MULTIPLIER, GDValue::Float(config.dx)));
            } else {
                properties.push((MOVE_UNITS_X, GDValue::Int(config.dx as i32)));
            }

            if let Some(lock) = config.y_lock {
                properties.push((
                    match lock {
                        MoveLock::Player => FOLLOW_PLAYERS_Y_MOVEMENT,
                        MoveLock::Camera => FOLLOW_CAMERAS_Y_MOVEMENT,
                    },
                    GDValue::Int(1),
                ));
                properties.push((Y_MOVEMENT_MULTIPLIER, GDValue::Float(config.dy)));
            } else {
                properties.push((MOVE_UNITS_Y, GDValue::Int(config.dy as i32)));
            }
        }
        MoveMode::Targeting(config) => {
            properties.push((TARGET_MOVE_MODE, GDValue::Int(1)));
            if let Some(id) = config.center_group_id {
                properties.push((CENTER_GROUP_ID, GDValue::Group(id)));
            }

            if let Some(axis) = config.axis_only {
                properties.push((TARGET_MOVE_MODE_AXIS_LOCK, GDValue::Int(axis as i32)));
            }

            match config.target_group_id {
                MoveTarget::Player1 => properties.push((CONTROLLING_PLAYER_1, GDValue::Int(1))),
                MoveTarget::Player2 => properties.push((CONTROLLING_PLAYER_2, GDValue::Int(1))),
                MoveTarget::Group(id) => properties.push((TARGET_ITEM_2, GDValue::Group(id))),
            };
        }
        MoveMode::Directional(config) => {
            if let Some(id) = config.center_group_id {
                properties.push((CENTER_GROUP_ID, GDValue::Group(id)));
            }

            match config.target_group_id {
                MoveTarget::Player1 => properties.push((CONTROLLING_PLAYER_1, GDValue::Int(1))),
                MoveTarget::Player2 => properties.push((CONTROLLING_PLAYER_2, GDValue::Int(1))),
                MoveTarget::Group(id) => properties.push((TARGET_ITEM_2, GDValue::Group(id))),
            };

            properties.push((DIRECTIONAL_MOVE_MODE, GDValue::Int(1)));
            properties.push((DIRECTIONAL_MODE_DISTANCE, GDValue::Int(config.distance)));
        }
    }

    GDObject::new(TRIGGER_MOVE, config, properties)
}

/// Returns a start pos object
///
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `gameplay_settings`: Gameplay options for startpos
/// * `target_order`: Target order (of what, I don't know); Default: 0
/// * `target_channel`: Target channel (once again, I don't know); Default: 0
/// * `disabled`: Disabled startpos? Default: false
pub fn start_pos(
    config: &GDObjConfig,
    gameplay_settings: StartposConfig,
    target_order: i32,
    target_channel: i32,
    disabled: bool,
) -> GDObject {
    GDObject::new(
        START_POS,
        config,
        vec![
            (
                STARTING_SPEED,
                GDValue::Int(gameplay_settings.start_speed as i32),
            ),
            (
                STARTING_GAMEMODE,
                GDValue::Int(gameplay_settings.starting_gamemode as i32),
            ),
            (
                STARTING_IN_MINI_MODE,
                GDValue::Bool(gameplay_settings.starting_as_mini),
            ),
            (
                STARTING_IN_DUAL_MODE,
                GDValue::Bool(gameplay_settings.starting_as_dual),
            ),
            (IS_DISABLED, GDValue::Bool(disabled)),
            (
                STARTING_IN_MIRROR_MODE,
                GDValue::Bool(gameplay_settings.starting_mirrored),
            ),
            (
                ROTATE_GAMEPLAY,
                GDValue::Bool(gameplay_settings.rotate_gameplay),
            ),
            (
                REVERSE_GAMEPLAY,
                GDValue::Bool(gameplay_settings.reverse_gameplay),
            ),
            (TARGET_ORDER, GDValue::Int(target_order)),
            (TARGET_CHANNEL, GDValue::Int(target_channel)),
            (RESET_CAMERA, GDValue::Bool(gameplay_settings.reset_camera)),
            (10010, GDValue::Int(0)),
            (10011, GDValue::String(String::new())),
            (10022, GDValue::Int(0)),
            (10023, GDValue::Int(0)),
            (10024, GDValue::Int(0)),
            (10027, GDValue::Int(1)),
            (10031, GDValue::Int(1)),
            (10032, GDValue::Int(1)),
            (10033, GDValue::Int(1)),
            (10034, GDValue::Int(1)),
            (10036, GDValue::Int(0)),
            (10037, GDValue::Int(1)),
            (10038, GDValue::Int(1)),
            (10039, GDValue::Int(1)),
            (10040, GDValue::Int(1)),
            (10041, GDValue::Int(1)),
            (10042, GDValue::Int(1)),
            (10043, GDValue::Int(0)),
            (10044, GDValue::Int(0)),
            (10045, GDValue::Int(1)),
            (10046, GDValue::Int(0)),
            (10009, GDValue::Int(1)),
        ],
    )
}

/// Returns a colour trigger
///
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `fade_time`: Time to fade into the colour
/// * `copy_colour`: Optional [`CopyColourConfig`]
pub fn colour_trigger(
    config: &GDObjConfig,
    colour_cfg: ColourTriggerConfig,
    fade_time: f64,
    copy_colour: Option<CopyColourConfig>,
) -> GDObject {
    let mut properties = vec![
        (RED, GDValue::Int(colour_cfg.colour.red as i32)),
        (GREEN, GDValue::Int(colour_cfg.colour.green as i32)),
        (BLUE, GDValue::Int(colour_cfg.colour.blue as i32)),
        (DURATION_GROUP_TRIGGER_CHANCE, GDValue::Float(fade_time)),
        (
            USING_PLAYER_COLOUR_1,
            GDValue::Bool(colour_cfg.use_player_col_1),
        ),
        (
            USING_PLAYER_COLOUR_2,
            GDValue::Bool(colour_cfg.use_player_col_2),
        ),
        (COLOUR_CHANNEL, GDValue::Short(colour_cfg.channel.into())),
        (OPACITY, GDValue::Float(colour_cfg.opacity)),
        (BLENDING_ENABLED, GDValue::Bool(colour_cfg.blending)),
    ];

    if let Some(config) = copy_colour {
        let cfg_string = config.hsv_config.to_string();
        if !config.use_legacy_hsv {
            properties.push((NO_LEGACY_HSV, GDValue::Bool(true)));
        }

        properties.push((COPY_OPACITY, GDValue::Bool(config.copy_opacity)));
        properties.push((COPY_COLOUR_SPECS, GDValue::String(cfg_string)));
        properties.push((
            COPY_COLOUR_FROM_CHANNEL,
            GDValue::ColourChannel(config.original_ch),
        ));
    }

    GDObject::new(TRIGGER_COLOUR, config, properties)
}

/// Returns a pulse trigger
///
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `pulse_fade_in_time`: fade-in time of the pulse in seconds  
/// * `pulse_hold_time`: gold time of the pulse in seconds  
/// * `pulse_fade_out_time`: fade-out time of the pulse in seconds  
/// * `exclusive_pulse`: disable all other pulses of the same ID when this trigger is activated
/// * `pulse_target`: Target group/channel of pulse. See [`PulseTarget`]
/// * `pulse_mode`: Colour settings of this pulse. See [`PulseMode`]
pub fn pulse_trigger(
    config: &GDObjConfig,
    pulse_fade_in_time: f64,
    pulse_hold_time: f64,
    pulse_fade_out_time: f64,
    exclusive_pulse: bool,
    pulse_target: &PulseTarget,
    pulse_mode: PulseMode,
) -> GDObject {
    let mut properties = vec![
        (PULSE_FADE_IN_TIME, GDValue::Float(pulse_fade_in_time)),
        (PULSE_HOLD_TIME, GDValue::Float(pulse_hold_time)),
        (PULSE_FADE_OUT_TIME, GDValue::Float(pulse_fade_out_time)),
        (EXCLUSIVE_PULSE_MODE, GDValue::Bool(exclusive_pulse)),
    ];
    match pulse_target {
        PulseTarget::Channel(c) => properties.push((TARGET_ITEM, GDValue::Group(c.channel_id))),
        PulseTarget::Group(g) => {
            properties.extend_from_slice(&[
                (
                    PULSE_DETAIL_COLOUR_ONLY,
                    GDValue::Bool(g.detail_colour_only),
                ),
                (PULSE_MAIN_COLOUR_ONLY, GDValue::Bool(g.main_colour_only)),
                (PULSE_GROUP, GDValue::Group(g.group_id)),
            ]);
        }
    }

    match pulse_mode {
        PulseMode::Colour(c) => {
            properties.extend_from_slice(&[
                (RED, GDValue::Int(c.red as i32)),
                (GREEN, GDValue::Int(c.green as i32)),
                (BLUE, GDValue::Int(c.blue as i32)),
            ]);
        }
        PulseMode::HSV(h) => {
            properties.extend_from_slice(&[
                (NO_LEGACY_HSV, GDValue::Bool(h.use_static_hsv)),
                (COPY_COLOUR_SPECS, GDValue::String(h.hsv_config.to_string())),
                (
                    COPY_COLOUR_FROM_CHANNEL,
                    GDValue::ColourChannel(h.colour_id),
                ),
            ]);
        }
    }
    GDObject::new(TRIGGER_PULSE, config, properties)
}

/// Returns a stop trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `target_group`: Target group to stop/pause/resume
/// * `stop_mode`: Stop mode (see [`StopMode`] struct)
/// * `use_control_id`: Only stops certain triggers within a group if enabled.
#[inline]
pub fn stop_trigger(
    config: &GDObjConfig,
    target_group: i16,
    stop_mode: StopMode,
    use_control_id: bool,
) -> GDObject {
    GDObject::new(
        TRIGGER_STOP,
        config,
        vec![
            (TARGET_ITEM, GDValue::Group(target_group)),
            (USE_CONTROL_ID, GDValue::Bool(use_control_id)),
            (STOP_MODE, GDValue::Int(stop_mode.to_num())),
        ],
    )
}

/// Returns an alpha trigger
///
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `target_group`: Target group to stop/pause/resume
/// * `opacity`: Opacity to set group at
/// * `fade_time`: Time to fade to the opacity
#[inline]
pub fn alpha_trigger(
    config: &GDObjConfig,
    target_group: i16,
    opacity: f64,
    fade_time: f64,
) -> GDObject {
    GDObject::new(
        1007,
        config,
        vec![
            (DURATION_GROUP_TRIGGER_CHANCE, GDValue::Float(fade_time)),
            (OPACITY, GDValue::Float(opacity)),
            (TARGET_ITEM, GDValue::Group(target_group)),
        ],
    )
}

/// Returns a toggle trigger
///
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `target_group`: Target group to stop/pause/resume
/// * `activate_group`: Active group instead of deactivating?
#[inline]
pub fn toggle_trigger(config: &GDObjConfig, target_group: i16, activate_group: bool) -> GDObject {
    GDObject::new(
        TRIGGER_TOGGLE,
        config,
        vec![
            (TARGET_ITEM, GDValue::Group(target_group)),
            (ACTIVATE_GROUP, GDValue::Bool(activate_group)),
        ],
    )
}

/// Returns a transition object
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `transition`: Type of transition. See [`TransitionType`] struct
/// * `mode`: Mode for transition (enter/exit only). See [`TransitionMode`] struct
/// * `target_channel`: Optional target channel argument which specifies a channel for this transition.
pub fn transition_object(
    config: &GDObjConfig,
    transition: TransitionType,
    mode: TransitionMode,
    target_channel: Option<i32>,
) -> GDObject {
    let mut properties = vec![];

    if mode != TransitionMode::Both {
        properties.push((ENTEREXIT_TRANSITION_CONFIG, GDValue::Int(mode.to_num())));
    }
    if let Some(channel) = target_channel {
        properties.push((TARGET_TRANSITION_CHANNEL, GDValue::Int(channel)));
    }

    GDObject::new(transition as i32, config, properties)
}

// misc stuff

/// Returns a reverse gameplay trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
#[inline]
pub fn reverse_gameplay(config: &GDObjConfig) -> GDObject {
    GDObject::new(TRIGGER_REVERSE_GAMEPLAY, config, vec![])
}

/// Returns a link visible trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `target_group`: group that is linked visibly
#[inline]
pub fn link_visible(config: &GDObjConfig, target_group: i16) -> GDObject {
    GDObject::new(
        TRIGGER_LINK_VISIBLE,
        config,
        vec![(TARGET_ITEM, GDValue::Group(target_group))],
    )
}

/// Returns a timewarp trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `time_scale`: How much to speed up/slow down time by. 1.0 is the default
#[inline]
pub fn timewarp(config: &GDObjConfig, time_scale: f64) -> GDObject {
    GDObject::new(
        TRIGGER_TIME_WARP,
        config,
        vec![(TIMEWARP_AMOUNT, GDValue::Float(time_scale))],
    )
}

/// Returns a trigger that shows the player
/// # Arguments
/// * `config`: General object options, such as position and scale
#[inline]
pub fn show_player(config: &GDObjConfig) -> GDObject {
    GDObject::new(1613, config, vec![])
}

/// Returns a trigger that hides the player
/// # Arguments
/// * `config`: General object options, such as position and scale
#[inline]
pub fn hide_player(config: &GDObjConfig) -> GDObject {
    GDObject::new(1612, config, vec![])
}

/// Returns a trigger that shows the player trail
/// # Arguments
/// * `config`: General object options, such as position and scale
#[inline]
pub fn show_player_trail(config: &GDObjConfig) -> GDObject {
    GDObject::new(ENABLE_PLAYER_TRAIL, config, vec![])
}

/// Returns a trigger that hides the player trail
/// # Arguments
/// * `config`: General object options, such as position and scale\
#[inline]
pub fn hide_player_trail(config: &GDObjConfig) -> GDObject {
    GDObject::new(DISABLE_PLAYER_TRAIL, config, vec![])
}

/// Returns a trigger that enables the background effect
/// # Arguments
/// * `config`: General object options, such as position and scale
#[inline]
pub fn bg_effect_on(config: &GDObjConfig) -> GDObject {
    GDObject::new(BG_EFFECT_ON, config, vec![])
}

/// Returns a trigger that disables the background effect
/// # Arguments
/// * `config`: General object options, such as position and scale
#[inline]
pub fn bg_effect_off(config: &GDObjConfig) -> GDObject {
    GDObject::new(BG_EFFECT_OFF, config, vec![])
}

/// Returns a group reset trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `target_group`: group that is to be reset
#[inline]
pub fn group_reset(config: &GDObjConfig, target_group: i16) -> GDObject {
    GDObject::new(
        TRIGGER_RESET_GROUP,
        config,
        vec![(TARGET_ITEM, GDValue::Group(target_group))],
    )
}

/// Returns a shake trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `strength`: Strength of shake
/// * `interval`: Interval in seconds between each shake
/// * `duration`: Total duration of shaking
#[inline]
pub fn shake_trigger(
    config: &GDObjConfig,
    strength: i32,
    interval: f64,
    duration: f64,
) -> GDObject {
    GDObject::new(
        TRIGGER_SHAKE,
        config,
        vec![
            (SHAKE_STRENGTH, GDValue::Int(strength)),
            (SHAKE_INTERVAL, GDValue::Float(interval)),
            (DURATION_GROUP_TRIGGER_CHANCE, GDValue::Float(duration)),
        ],
    )
}

/// Returns a background speed config trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `mod_x`: X-axis speed of BG in terms of player speed. Default is 0.3
/// * `mod_y`: Y-axis speed of BG in terms of player speed. Default is 0.5
#[inline]
pub fn bg_speed(config: &GDObjConfig, mod_x: f64, mod_y: f64) -> GDObject {
    GDObject::new(
        BG_SPEED_CONFIG,
        config,
        vec![
            (X_MOVEMENT_MULTIPLIER, GDValue::Float(mod_x)),
            (Y_MOVEMENT_MULTIPLIER, GDValue::Float(mod_y)),
        ],
    )
}

/// Returns a middleground speed config trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `mod_x`: X-axis speed of MG in terms of player speed. Default is 0.3
/// * `mod_y`: Y-axis speed of MG in terms of player speed. Default is 0.5
#[inline]
pub fn mg_speed(config: &GDObjConfig, mod_x: f64, mod_y: f64) -> GDObject {
    GDObject::new(
        MG_SPEED_CONFIG,
        config,
        vec![
            (X_MOVEMENT_MULTIPLIER, GDValue::Float(mod_x)),
            (Y_MOVEMENT_MULTIPLIER, GDValue::Float(mod_y)),
        ],
    )
}

/// Returns a player control trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `p1`: Enables these controls for player 1
/// * `p2`: Enables these controls for player 2
/// * `stop_jump`: Cancel's the player's current jump
/// * `stop_move`: Stops the player from moving
/// * `stop_rotation`: Stops the player's rotation
/// * `stop_slide`: Stops the player from sliding after a force
#[inline]
pub fn player_control(
    config: &GDObjConfig,
    p1: bool,
    p2: bool,
    stop_jump: bool,
    stop_move: bool,
    stop_rotation: bool,
    stop_slide: bool,
) -> GDObject {
    GDObject::new(
        TRIGGER_PLAYER_CONTROL,
        config,
        vec![
            (CONTROLLING_PLAYER_1, GDValue::Bool(p1)),
            (CONTROLLING_PLAYER_2, GDValue::Bool(p2)),
            (STOP_PLAYER_JUMP, GDValue::Bool(stop_jump)),
            (STOP_PLAYER_MOVEMENT, GDValue::Bool(stop_move)),
            (STOP_PLAYER_ROTATION, GDValue::Bool(stop_rotation)),
            (STOP_PLAYER_SLIDING, GDValue::Bool(stop_slide)),
        ],
    )
}

/// Returns a gravity trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `gravity`: how much gravity.
/// * `target_player`: (Optional) Player target for this gravity trigger
pub fn gravity_trigger(
    config: &GDObjConfig,
    gravity: f64,
    target_player: Option<TargetPlayer>,
) -> GDObject {
    let mut properties = vec![(GRAVITY, GDValue::Float(gravity))];

    if let Some(player) = target_player {
        properties.push((player as u16, GDValue::Bool(true)));
    }
    GDObject::new(TRIGGER_GRAVITY, config, properties)
}

/// Returns an end trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `spawn_id`: Optional group to spawn once this trigger is activated
/// * `target_pos`: Optional target end position group
/// * `no_effects`: Disables visual end effects
/// * `instant`: Teleoprts the player instead of doing the default end pull animation
/// * `no_sfx`: Disables end sound effects
pub fn end_trigger(
    config: &GDObjConfig,
    spawn_id: Option<i16>,
    target_pos: Option<i16>,
    no_effects: bool,
    instant: bool,
    no_sfx: bool,
) -> GDObject {
    let mut properties = vec![
        (NO_END_EFFECTS, GDValue::Bool(no_effects)),
        (INSTANT_END, GDValue::Bool(instant)),
        (NO_END_SOUND_EFFECTS, GDValue::Bool(no_sfx)),
    ];

    if let Some(id) = spawn_id {
        properties.push((TARGET_ITEM, GDValue::Group(id)));
    }

    if let Some(pos) = target_pos {
        properties.push((TARGET_ITEM_2, GDValue::Group(pos)));
    }

    GDObject::new(TRIGGER_END, config, properties)
}

// items and counters

/// Returns a counter object
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `item_id`: ID of the counter
/// * `timer`: Is a timer?
/// * `align`: Visual alignment of counter object. See [`ItemAlign`] struct.
/// * `seconds_only`: Show only seconds if timer?
/// * `special_mode`: Other special mode of timer. See [`CounterMode`] struct.
pub fn counter_object(
    config: &GDObjConfig,
    item: Item,
    align: ItemAlign,
    seconds_only: bool,
) -> GDObject {
    let mut properties = vec![
        (SECONDS_ONLY, GDValue::Bool(seconds_only)),
        (COUNTER_ALIGNMENT, GDValue::Int(align.to_num())),
    ];

    match item {
        Item::Attempts | Item::MainTime | Item::Points => {
            properties.push((
                SPECIAL_COUNTER_MODE,
                GDValue::Int(item.as_special_mode_i32().unwrap()),
            ));
        }
        Item::Counter(c) => {
            properties.push((INPUT_ITEM_1, GDValue::Item(c)));
        }
        Item::Timer(t) => {
            properties.extend_from_slice(&[
                (INPUT_ITEM_1, GDValue::Item(t)),
                (IS_TIMER, GDValue::Bool(true)),
            ]);
        }
    }

    GDObject::new(COUNTER, config, properties)
}

/// Returns an item edit trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `operand1`: Optional first operand, tuple of (ID, item type)
/// * `operand2`: Optional second operand, tuple of (ID, item type)
/// * `target_id`: Target item id
/// * `target_type`: Target item type
/// * `modifier`: f64 modifier; default is 1.0
/// * `assign_op`: operator for modifying target; see [`Op`] enum. An `Op::Add` is equivalent to `+=`.
/// * `multiply_mod`: whether the result between operands should be multiplied or divided by the mod.
/// * `id_op`: operator between operands 1 and 2; see [`Op`] enum.
/// * `id_rounding`: rounding mode of the result after both operands are evaluated; see [`RoundMode`] enum.
/// * `result_rounding`: rounding mode of the final result; see [`RoundMode`] enum.
/// * `id_sign`: sign mode of the result after both operands are evaluated; see [`SignMode`] enum.
/// * `result_sign`: sign mode of the final result; see [`SignMode`] enum.
#[allow(clippy::too_many_arguments)]
pub fn item_edit(
    config: &GDObjConfig,
    operand1: Option<Item>,
    operand2: Option<Item>,
    target: Item,
    modifier: f64,
    assign_op: Op,
    multiply_mod: bool,
    id_op: Option<Op>,
    id_rounding: RoundMode,
    result_rounding: RoundMode,
    id_sign: SignMode,
    result_sign: SignMode,
) -> GDObject {
    // set default values
    let mod_op = match multiply_mod {
        true => Op::Mul,
        false => Op::Div,
    };
    let id_op = match id_op {
        Some(op) => op,
        None => Op::Add,
    };

    let mut properties = vec![
        (TARGET_ITEM, GDValue::Item(target.id())),
        (TARGET_ITEM_TYPE, GDValue::Int(target.get_type_as_i32())),
        (MODIFIER, GDValue::Float(modifier)),
        (LEFT_OPERATOR, GDValue::Int(assign_op.to_num())),
        (RIGHT_OPERATOR, GDValue::Int(id_op.to_num())),
        (COMPARE_OPERATOR, GDValue::Int(mod_op.to_num())),
        (LEFT_ROUND_MODE, GDValue::Int(id_rounding as i32)),
        (RIGHT_ROUND_MODE, GDValue::Int(result_rounding as i32)),
        (LEFT_SIGN_MODE, GDValue::Int(id_sign as i32)),
        (RIGHT_SIGN_MODE, GDValue::Int(result_sign as i32)),
    ];

    if let Some(item) = operand1 {
        properties.extend_from_slice(&[
            (INPUT_ITEM_1, GDValue::Item(item.id())),
            (FIRST_ITEM_TYPE, GDValue::Int(item.get_type_as_i32())),
        ]);
    }

    if let Some(item) = operand2 {
        properties.extend_from_slice(&[
            (INPUT_ITEM_2, GDValue::Item(item.id())),
            (SECOND_ITEM_TYPE, GDValue::Int(item.get_type_as_i32())),
        ]);
    }

    GDObject::new(TRIGGER_ITEM_EDIT, config, properties)
}

/// Returns an item compare trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `true_id`: Group that is activated when the comparison is true
/// * `false_id`: Group that is activated when the comparison is false
/// * \*`lhs`: [`CompareOperand`] config struct for left-hand side operand.
/// * \*`rhs`: [`CompareOperand`] config struct for right-hand side operand.
/// * `compare_op`: Operator used to compare the two sides. See [`CompareOp`] enum.
/// * `tolerance`: Tolerant range of comparsion. Comparsion will be true if the absolute resulting value is less than or equal to the tolerance.
///
/// \* The modifier operators describe how the modifier interacts with the item, except for setting the item
///
/// The modifier is applied to each respective operand according to the specified modifier operator.
/// The round and sign modes are applied at the end of evaluation to each operand.
/// The right-hand side will be just the modifier if the item id is left as 0 (not specified).
/// This is useful when it is necessary to compare an item value and an integer or float literal.
pub fn item_compare(
    config: &GDObjConfig,
    true_id: i16,
    false_id: i16,
    lhs: CompareOperand,
    rhs: CompareOperand,
    compare_op: CompareOp,
    tolerance: f64,
) -> GDObject {
    let properties = vec![
        (TARGET_ITEM, GDValue::Item(true_id)),
        (TARGET_ITEM_2, GDValue::Item(false_id)),
        // ids
        (INPUT_ITEM_1, GDValue::Item(lhs.operand_item.id())),
        (INPUT_ITEM_2, GDValue::Item(rhs.operand_item.id())),
        // types
        (
            FIRST_ITEM_TYPE,
            GDValue::Int(lhs.operand_item.get_type_as_i32()),
        ),
        (
            SECOND_ITEM_TYPE,
            GDValue::Int(rhs.operand_item.get_type_as_i32()),
        ),
        // modifiers
        (MODIFIER, GDValue::Float(lhs.modifier)),
        (SECOND_MODIFIER, GDValue::Float(rhs.modifier)),
        // modifiers ops
        (LEFT_OPERATOR, GDValue::Int(lhs.mod_op.to_num())),
        (RIGHT_OPERATOR, GDValue::Int(rhs.mod_op.to_num())),
        (COMPARE_OPERATOR, GDValue::Int(compare_op.to_num())),
        (TOLERANCE, GDValue::Float(tolerance)),
        // round modes
        (LEFT_ROUND_MODE, GDValue::Int(lhs.rounding as i32)),
        (RIGHT_ROUND_MODE, GDValue::Int(rhs.rounding as i32)),
        // sign modes
        (LEFT_SIGN_MODE, GDValue::Int(lhs.sign as i32)),
        (RIGHT_SIGN_MODE, GDValue::Int(rhs.sign as i32)),
    ];

    GDObject::new(TRIGGER_ITEM_COMPARE, config, properties)
}

/// Returns a persistent item trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `item_id`: Target item ID
/// * `timer`: Targets a timer with the corresponding ID if enabled
/// * `persistent`: make this item persistent?
/// * `target_all`: Target all persistent items?
/// * `reset`: Reset item(s) to 0?
pub fn persistent_item(
    config: &GDObjConfig,
    item_id: i16,
    timer: bool,
    persistent: bool,
    target_all: bool,
    reset: bool,
) -> GDObject {
    GDObject::new(
        TRIGGER_PERSISTENT_ITEM,
        config,
        vec![
            (TARGET_ITEM, GDValue::Item(item_id)),
            (SET_PERSISTENT_ITEM, GDValue::Bool(persistent)),
            (TARGET_ALL_PERSISTENT_ITEMS, GDValue::Bool(target_all)),
            (RESET_ITEM_TO_0, GDValue::Bool(reset)),
            (TIMER, GDValue::Bool(timer)),
        ],
    )
}

// spawners

/// Returns a random trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `chance`: chance to trigger group 1
/// * `target_group1`: target group 1
/// * `target_group1`: target group 2
pub fn random_trigger(
    config: &GDObjConfig,
    chance: f64,
    target_group1: i16,
    target_group2: i16,
) -> GDObject {
    GDObject::new(
        TRIGGER_RANDOM,
        config,
        vec![
            (TARGET_ITEM, GDValue::Group(target_group1)),
            (TARGET_ITEM_2, GDValue::Group(target_group2)),
            (DURATION_GROUP_TRIGGER_CHANCE, GDValue::Float(chance)),
        ],
    )
}

/// Returns a spawn trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `spawn_id`: Spawns this group
/// * `delay`: Delay between beign triggered and spawning the group
/// * `delay_variation`: Random variation on delay
/// * `reset_remap`: Resets the remapping of group IDs
/// * `spawn_ordered`: Spawns constituents of group in the order of x-position
/// * `preview_disable`: prevents the trigger's resulting spawns from being rendered in editor preview
pub fn spawn_trigger(
    config: &GDObjConfig,
    spawn_id: i16,
    delay: f64,
    delay_variation: f64,
    reset_remap: bool,
    spawn_ordered: bool,
    preview_disable: bool,
    spawn_remap: Vec<(i16, i16)>,
) -> GDObject {
    GDObject::new(
        TRIGGER_SPAWN,
        config,
        vec![
            (TARGET_ITEM, GDValue::Group(spawn_id)),
            (SPAWN_DELAY, GDValue::Float(delay)),
            (DISABLE_PREVIEW, GDValue::Bool(preview_disable)),
            (SPAWN_ORDERED, GDValue::Bool(spawn_ordered)),
            (SPAWN_DELAY_VARIATION, GDValue::Float(delay_variation)),
            (RESET_REMAP, GDValue::Bool(reset_remap)),
            (SPAWN_ID_REMAPS, GDValue::from_spawn_remaps(spawn_remap)),
        ],
    )
}

/// Returns an on-death trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `target_group`: Spawns this group
/// * `activate_group`: Activate this group (instead of toggling off)?
#[inline]
pub fn on_death(config: &GDObjConfig, target_group: i16, activate_group: bool) -> GDObject {
    GDObject::new(
        TRIGGER_ON_DEATH,
        config,
        vec![
            (TARGET_ITEM, GDValue::Group(target_group)),
            (ACTIVATE_GROUP, GDValue::Bool(activate_group)),
        ],
    )
}

/// Returns a particle spawner trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `particle_group`: Group that contains the particle objects
/// * `position_group`: Group at which the particles will be spawned
/// * `spawn_cfg`: Spawning configure for the particles themselves. See [`ParticleSpawnConfig`]
pub fn spawn_particle(
    config: &GDObjConfig,
    particle_group: i16,
    position_group: i16,
    spawn_cfg: ParticleSpawnConfig,
) -> GDObject {
    let mut properties = vec![
        (TARGET_ITEM, GDValue::Group(particle_group)),
        (TARGET_ITEM_2, GDValue::Group(position_group)),
        (
            MATCH_ROTATION_OF_SPAWNED_PARTICLES,
            GDValue::Bool(spawn_cfg.match_rotation),
        ),
    ];

    if let Some((x, y)) = spawn_cfg.position_offsets {
        properties.push((X_OFFSET_OF_SPAWNED_PARTICLES, GDValue::Int(x)));
        properties.push((Y_OFFSET_OF_SPAWNED_PARTICLES, GDValue::Int(y)));
    }

    if let Some((x, y)) = spawn_cfg.position_variation {
        properties.push((X_OFFSET_VARIATION_OF_SPAWNED_PARTICLES, GDValue::Int(x)));
        properties.push((Y_OFFSET_VARIATION_OF_SPAWNED_PARTICLES, GDValue::Int(y)));
    }

    if let Some((rot, var)) = spawn_cfg.rotation_config {
        properties.push((ROTATION_OF_SPAWNED_PARTICLES, GDValue::Int(rot)));
        properties.push((ROTATION_VARIATION_OF_SPAWNED_PARTICLES, GDValue::Int(var)));
    }

    if let Some((scale, var)) = spawn_cfg.scale_config {
        properties.push((SCALE_OF_SPAWNED_PARTICLES, GDValue::Float(scale)));
        properties.push((SCALE_VARIATION_OF_SPAWNED_PARTICLES, GDValue::Float(var)));
    }

    GDObject::new(TRIGGER_SPAWN_PARTICLE, config, properties)
}

// collision blocks

/// Returns a collision block object
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `id`: Collision block ID
/// * `dynamic`: Does this block register collisions with other collision blocks?
#[inline]
pub fn collision_block(config: &GDObjConfig, id: i16, dynamic: bool) -> GDObject {
    GDObject::new(
        COLLISION_BLOCK,
        config,
        vec![
            (INPUT_ITEM_1, GDValue::Item(id)),
            (DYNAMIC_BLOCK, GDValue::Bool(dynamic)),
        ],
    )
}

/// Returns a toggle block object
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `target_group`: Spawns this group
/// * `activate_group`: Activate/spawn group instead of deactivating?
/// * `claim_touch`: Disable buffer clicking?
/// * `multi_activate`: Allow multiple activations?
/// * `spawn_only`: Spawn only without toggling?
#[inline]
pub fn toggle_block(
    config: &GDObjConfig,
    target_group: i16,
    activate_group: bool,
    claim_touch: bool,
    multi_activate: bool,
    spawn_only: bool,
) -> GDObject {
    GDObject::new(
        TOGGLE_BLOCK,
        config,
        vec![
            (TARGET_ITEM, GDValue::Group(target_group)),
            (ACTIVATE_GROUP, GDValue::Bool(activate_group)),
            (MULTI_ACTIVATE, GDValue::Bool(multi_activate)),
            (CLAIM_TOUCH, GDValue::Bool(claim_touch)),
            (SPAWN_ONLY, GDValue::Bool(spawn_only)),
        ],
    )
}

/// Returns a state block object
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `state_on`: Group that is activated when the player enters this block's hitbox
/// * `state_off`: Group that is activated when the player exits this block's hitbox
#[inline]
pub fn state_block(config: &GDObjConfig, state_on: i16, state_off: i16) -> GDObject {
    GDObject::new(
        COLLISION_STATE_BLOCK,
        config,
        vec![
            (TARGET_ITEM, GDValue::Group(state_on)),
            (TARGET_ITEM_2, GDValue::Group(state_off)),
        ],
    )
}

/// Returns a collision trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `collider_cfg`: Settings for colliders for this collision detection. See [`ColliderConfig`]
/// * `target_id`: ID of group that is activated when the two colliders collide
/// * `activate_group`: whether this trigger will activate or deactivate the target group
/// * `trigger_on_exit`: activates group when the two colliders' hitboxes stop overlapping after collision
///   instead of when they start colliding.
///
/// **Note**: At least one of the collider blocks must be dynamic for this collision to register.
#[inline]
pub fn collision_trigger(
    config: &GDObjConfig,
    collider_cfg: ColliderConfig,
    target_id: i16,
    activate_group: bool,
    trigger_on_exit: bool,
) -> GDObject {
    GDObject::new(
        TRIGGER_COLLISION,
        config,
        vec![
            (INPUT_ITEM_1, GDValue::Item(collider_cfg.collider1)),
            (INPUT_ITEM_2, GDValue::Item(collider_cfg.collider2)),
            (TARGET_ITEM, GDValue::Item(target_id)),
            (
                CONTROLLING_PLAYER_1,
                GDValue::Bool(collider_cfg.collide_player1),
            ),
            (
                CONTROLLING_PLAYER_2,
                GDValue::Bool(collider_cfg.collide_player2),
            ),
            (
                CONTROLLING_TARGET_PLAYER,
                GDValue::Bool(collider_cfg.collide_both_players),
            ),
            (ACTIVATE_GROUP, GDValue::Bool(activate_group)),
            (TRIGGER_ON_EXIT, GDValue::Bool(trigger_on_exit)),
        ],
    )
}

/// Returns a collision trigger
///
/// Activates a group when the two colliders collide or do not collide.
/// This condition is only checked once and never again
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `collider_cfg`: Settings for colliders for this collision detection. See [`ColliderConfig`]
/// * `true_id`: ID of group that is activated if the two colliders collide
/// * `false_id`: ID of group that is activated if the two colliders do not collide
#[inline]
pub fn instant_coll_trigger(
    config: &GDObjConfig,
    collider_cfg: ColliderConfig,
    true_id: i16,
    false_id: i16,
) -> GDObject {
    GDObject::new(
        TRIGGER_COLLISION,
        config,
        vec![
            (INPUT_ITEM_1, GDValue::Item(collider_cfg.collider1)),
            (INPUT_ITEM_2, GDValue::Item(collider_cfg.collider2)),
            (TARGET_ITEM, GDValue::Item(true_id)),
            (TARGET_ITEM_2, GDValue::Item(false_id)),
            (
                CONTROLLING_PLAYER_1,
                GDValue::Bool(collider_cfg.collide_player1),
            ),
            (
                CONTROLLING_PLAYER_2,
                GDValue::Bool(collider_cfg.collide_player2),
            ),
            (
                CONTROLLING_TARGET_PLAYER,
                GDValue::Bool(collider_cfg.collide_both_players),
            ),
        ],
    )
}

// time triggers

/// Returns a time trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `time_cfg`: Main trigger configuration. See [`TimeTriggerConfig`].
/// * `target_group`: Group that is activated when the timer reaches the target value
pub fn time_trigger(
    config: &GDObjConfig,
    time_cfg: TimeTriggerConfig,
    target_group: i16,
) -> GDObject {
    GDObject::new(
        TRIGGER_TIME,
        config,
        vec![
            (START_TIME, GDValue::Float(time_cfg.start_time)),
            (TARGET_TIME, GDValue::Float(time_cfg.stop_time)),
            (
                PAUSE_AT_TARGET_TIME,
                GDValue::Bool(time_cfg.pause_when_reached),
            ),
            (TIME_VALUE_MULTIPLER, GDValue::Float(time_cfg.time_mod)),
            (INPUT_ITEM_1, GDValue::Item(time_cfg.timer_id)),
            (TARGET_ITEM, GDValue::Group(target_group)),
            (IGNORE_TIMEWARP, GDValue::Bool(time_cfg.ignore_timewarp)),
            (START_PAUSED_TIMER, GDValue::Bool(time_cfg.start_paused)),
            (DONT_OVERRIDE, GDValue::Bool(time_cfg.dont_override)),
        ],
    )
}

/// Returns a time control trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `id`: Timer ID
/// * `stop`: If enabled, stops the timer; otherwise, starts the timer.
#[inline]
pub fn time_control(config: &GDObjConfig, id: i16, stop: bool) -> GDObject {
    GDObject::new(
        TRIGGER_TIME_CONTROL,
        config,
        vec![
            (INPUT_ITEM_1, GDValue::Item(id)),
            (STOP_TIME_COUNTER, GDValue::Bool(stop)),
        ],
    )
}

/// Returns a time event trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `id`: Timer ID
/// * `target_group`: If enabled, stops the timer; otherwise, starts the timer.
/// * `target_time`: At what time the timer should be to activate objects in `target_group`.
/// * `multi_activate`: Should this event be triggerable multiple times?
#[inline]
pub fn time_event(
    config: &GDObjConfig,
    id: i16,
    target_group: i16,
    target_time: f64,
    multi_activate: bool,
) -> GDObject {
    GDObject::new(
        TRIGGER_TIME_EVENT,
        config,
        vec![
            (INPUT_ITEM_1, GDValue::Group(id)),
            (TARGET_ITEM, GDValue::Group(target_group)),
            (TARGET_TIME, GDValue::Float(target_time)),
            (MULTIACTIVATABLE_TIME_EVENT, GDValue::Bool(multi_activate)),
        ],
    )
}

// camera triggers

/// Returns a camera zoom trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `zoom`: Resulting camera zoom. Default is 1.0
/// * `time`: Time to zoom
/// * `easing`: Zoom easing config. See [`MoveEasing`] struct.
pub fn camera_zoom(
    config: &GDObjConfig,
    zoom: f64,
    time: f64,
    easing: Option<(MoveEasing, f64)>,
) -> GDObject {
    let mut properties = vec![
        (DURATION_GROUP_TRIGGER_CHANCE, GDValue::Float(time)),
        (CAMERA_ZOOM, GDValue::Float(zoom)),
    ];

    if let Some((easing, rate)) = easing {
        properties.push((MOVE_EASING, GDValue::Int(easing as i32)));
        properties.push((EASING_RATE, GDValue::Float(rate)));
    }
    GDObject::new(TRIGGER_CAMERA_ZOOM, config, properties)
}

/// Returns a camera guide object
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `zoom`: Zoom of camera guide
/// * `offset_x`: Center offset from this object in x axis
/// * `offset_y`: Center offset from this object in y axis
/// * `opacity`: Opacity of guidelines
#[inline]
pub fn camera_guide(
    config: &GDObjConfig,
    zoom: f64,
    offset_x: i32,
    offset_y: i32,
    opacity: f64,
) -> GDObject {
    GDObject::new(
        CAMERA_GUIDE,
        config,
        vec![
            (MOVE_UNITS_X, GDValue::Int(offset_x)),
            (MOVE_UNITS_Y, GDValue::Int(offset_y)),
            (CAMERA_ZOOM, GDValue::Float(zoom)),
            (CAMERA_GUIDE_PREVIEW_OPACITY, GDValue::Float(opacity)),
        ],
    )
}

// im too lazy to organise ts

/// Returns a follow trigger object
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `x_mod`: Multiplier for x-axis movement of follow group
/// * `y_mod`: Multiplier for y-axis movement of follow group
/// * `follow_time`: Time that the follow group is followed for. -1.0 = infinite.
/// * `target_group`: Group that is following
/// * `follow_group`: Group that is being followed
#[inline]
pub fn follow_trigger(
    config: &GDObjConfig,
    x_mod: f64,
    y_mod: f64,
    follow_time: f64,
    target_group: i16,
    follow_group: i16,
) -> GDObject {
    GDObject::new(
        TRIGGER_FOLLOW,
        config,
        vec![
            (DURATION_GROUP_TRIGGER_CHANCE, GDValue::Float(follow_time)),
            (XAXIS_FOLLOW_MOD, GDValue::Float(x_mod)),
            (YAXIS_FOLLOW_MOD, GDValue::Float(y_mod)),
            (TARGET_ITEM, GDValue::Group(target_group)),
            (TARGET_ITEM_2, GDValue::Group(follow_group)),
        ],
    )
}

/// Returns an animate trigger object
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `target_group`: Objects to animate
/// * `animation`: Animation ID, provided in [`Anim`] enum
#[inline]
pub fn animate_trigger(config: &GDObjConfig, target_group: i16, animation: Anim) -> GDObject {
    GDObject::new(
        TRIGGER_ANIMATE,
        config,
        vec![
            (TARGET_ITEM, GDValue::Group(target_group)),
            (ANIMATION_ID, GDValue::Int(animation.into())),
        ],
    )
}

/// Returns a count trigger object
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `item_id`: Checks this item
/// * `target_id`: Target group to activate
/// * `target_count`: Target count of item at `item_id`
/// * `activate_group`: Whether or not to activate the target group
/// * `multi_activate`: Whether or not this trigger is multi-activatable
#[inline]
pub fn count_trigger(
    config: &GDObjConfig,
    item_id: i16,
    target_id: i16,
    target_count: i32,
    activate_group: bool,
    multi_activate: bool,
) -> GDObject {
    GDObject::new(
        TRIGGER_COUNT,
        config,
        vec![
            (INPUT_ITEM_1, GDValue::Item(item_id)),
            (TARGET_ITEM, GDValue::Group(target_id)),
            (TARGET_COUNT, GDValue::Int(target_count)),
            (ACTIVATE_GROUP, GDValue::Bool(activate_group)),
            (MULTI_ACTIVATE, GDValue::Bool(multi_activate)),
        ],
    )
}

/// Returns an advanced random trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `probabilities`: List of tuples: (target group, chance to trigger this group).
///
/// Chances are considered relative to each other, meaning that they are not
/// precentage-based. Two groups with the same relative chance will have the same
/// (50-50) chance to be triggered
#[inline]
pub fn advanced_random_trigger(config: &GDObjConfig, probabilities: Vec<(i16, i32)>) -> GDObject {
    GDObject::new(
        TRIGGER_ADVANCED_RANDOM,
        config,
        vec![(
            RANDOM_PROBABILITIES_LIST,
            GDValue::from_prob_list(probabilities),
        )],
    )
}

/// Returns a UI config trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `target_group`: the UI objects
/// * `ui_reference_obj`: Group with a single object that is a reference for the center of the camera.
/// * `x_reference`: Reference position for the element on the X-axis
/// * `y_reference`: Reference position for the element on the Y-axis
/// * `x_ref_relative`: Whether or not the x-axis position scales with aspect ratio
/// * `y_ref_relative`: Whether or not the y-axis position scales with aspect ratio
#[inline]
pub fn ui_config_trigger(
    config: &GDObjConfig,
    target_group: i16,
    ui_reference_obj: i16,
    x_reference: UIReferencePos,
    y_reference: UIReferencePos,
    x_ref_relative: bool,
    y_ref_relative: bool,
) -> GDObject {
    GDObject::new(
        UI_CONFIG,
        config,
        vec![
            (TARGET_ITEM, GDValue::Group(target_group)),
            (TARGET_ITEM_2, GDValue::Group(ui_reference_obj)),
            (X_REFERENCE_POSITION, GDValue::Int(x_reference as i32)),
            (Y_REFERENCE_POSITION, GDValue::Int(y_reference as i32 + 4)),
            (X_REFERENCE_IS_RELATIVE, GDValue::Bool(x_ref_relative)),
            (Y_REFERENCE_IS_RELATIVE, GDValue::Bool(y_ref_relative)),
        ],
    )
}

/// Returns a rotate trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `move_time`: Time to rotate the target
/// * `rotation_cfg`: Rotation specifics. See [`RotationConfig`]
/// * `easing`: optional move easing and rate. See [`MoveEasing`]
/// * `target_group`: Group that will rotate
/// * `center_group_id`: Group that is being rotated around
/// * `bounding_box`: Optional vertices of a bounding box that limit the position of the rotation group.
///
/// The tuple corresponds to the `MinX`, `MinY`, `MaxX`, `MaxY` group ids respectively in the rotate trigger.
pub fn rotate_trigger(
    config: &GDObjConfig,
    move_time: f64,
    rotation_cfg: RotationConfig,
    easing: Option<(MoveEasing, f64)>,
    target_group: i16,
    center_group_id: i16,
    bounding_box: Option<(i16, i16, i16, i16)>,
) -> GDObject {
    let mut properties = vec![
        (DURATION_GROUP_TRIGGER_CHANCE, GDValue::Float(move_time)),
        (DYNAMIC_MOVE, GDValue::Bool(rotation_cfg.dynamic_mode)),
        (
            LOCK_OBJECT_ROTATION,
            GDValue::Bool(rotation_cfg.lock_object_rotation),
        ),
        (TARGET_ITEM, GDValue::Group(target_group)),
        (TARGET_ITEM_2, GDValue::Group(center_group_id)),
    ];

    match rotation_cfg.mode {
        RotationMode::Aim(cfg) => {
            properties.extend_from_slice(&[
                (TARGET_MOVE_MODE, GDValue::Bool(true)),
                (ROTATION_TARGET_ID, GDValue::Group(cfg.aim_target)),
                (ROTATION_OFFSET, GDValue::Float(cfg.rot_offset)),
            ]);

            if let Some(player) = cfg.player_target {
                properties.push(match player {
                    RotationPlayerTarget::Player1 => (CONTROLLING_PLAYER_1, GDValue::Bool(true)),
                    RotationPlayerTarget::Player2 => (CONTROLLING_PLAYER_2, GDValue::Bool(true)),
                });
            }
        }
        RotationMode::Follow(cfg) => {
            properties.extend_from_slice(&[
                (DIRECTIONAL_MOVE_MODE, GDValue::Bool(true)),
                (ROTATION_TARGET_ID, GDValue::Group(cfg.aim_target)),
                (ROTATION_OFFSET, GDValue::Float(cfg.rot_offset)),
            ]);

            if let Some(player) = cfg.player_target {
                properties.push(match player {
                    RotationPlayerTarget::Player1 => (CONTROLLING_PLAYER_1, GDValue::Bool(true)),
                    RotationPlayerTarget::Player2 => (CONTROLLING_PLAYER_2, GDValue::Bool(true)),
                });
            }
        }
        RotationMode::Default(cfg) => {
            properties.extend_from_slice(&[
                (ROTATE_DEGREES, GDValue::Float(cfg.degrees)),
                (ROTATE_X360, GDValue::Int(cfg.x360)),
            ]);
        }
    }

    add_easing(&mut properties, easing);
    if let Some((min_x, min_y, max_x, max_y)) = bounding_box {
        properties.extend_from_slice(&[
            (MINX_ID, GDValue::Group(min_x)),
            (MINY_ID, GDValue::Group(min_y)),
            (MAXX_ID, GDValue::Group(max_x)),
            (MAXY_ID, GDValue::Group(max_y)),
        ]);
    }

    GDObject::new(TRIGGER_ROTATION, config, properties)
}

/// Returns a scale trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `scale_config`: Scaling config. See [`ScaleConfig`]
/// * `easing`: Optional move easing and rate. See [`MoveEasing`]
/// * `center_group_id`: Center of group that is being scaled. Leave as 0 to use the default center
/// * `target_group`: Group that is being scaled.
/// * `duration`: How long the scaling will be
pub fn scale_trigger(
    config: &GDObjConfig,
    scale_config: ScaleConfig,
    easing: Option<(MoveEasing, f64)>,
    center_group_id: i16,
    target_group: i16,
    duration: f64,
) -> GDObject {
    let mut properties = vec![
        (NEW_X_SCALE, GDValue::Float(scale_config.x_scale)),
        (NEW_Y_SCALE, GDValue::Float(scale_config.y_scale)),
        (DIV_BY_VALUE_X, GDValue::Bool(scale_config.div_by_value_x)),
        (DIV_BY_VALUE_Y, GDValue::Bool(scale_config.div_by_value_y)),
        (TARGET_ITEM, GDValue::Group(target_group)),
        (TARGET_ITEM_2, GDValue::Group(center_group_id)),
        (DURATION_GROUP_TRIGGER_CHANCE, GDValue::Float(duration)),
        (ONLY_MOVE, GDValue::Bool(scale_config.only_move)),
        (RELATIVE_SCALE, GDValue::Bool(scale_config.relative_scale)),
        (
            RELATIVE_ROTATION,
            GDValue::Bool(scale_config.relative_rotation),
        ),
    ];

    add_easing(&mut properties, easing);
    GDObject::new(TRIGGER_SCALE, config, properties)
}

/// Returns a scale trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `speed`: Follow speed in the range \[0.0, 1.0]; 1.0 = instantaneously snaps to player y-pos
/// * `delay`: Delay of the following group
/// * `offset`: Y offset of the following group
/// * `max_speed`: Speed limit of the following group
/// * `move_time`: How long the group will follow the player
/// * `target_group`: The group that is following the player's y-pos
#[inline]
pub fn follow_player_y(
    config: &GDObjConfig,
    speed: f64,
    delay: f64,
    offset: i32,
    max_speed: f64,
    move_time: f64,
    target_group: i16,
) -> GDObject {
    GDObject::new(
        TRIGGER_FOLLOW_PLAYER_Y,
        config,
        vec![
            (FOLLOW_SPEED, GDValue::Float(speed)),
            (FOLLOW_DELAY, GDValue::Float(delay)),
            (FOLLOW_OFFSET, GDValue::Int(offset)),
            (MAX_FOLLOW_SPEED, GDValue::Float(max_speed)),
            (DURATION_GROUP_TRIGGER_CHANCE, GDValue::Float(move_time)),
            (TARGET_ITEM, GDValue::Group(target_group)),
        ],
    )
}

/// Returns a middleground config trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
#[inline]
pub fn mg_config(
    config: &GDObjConfig,
    offset_y: i32,
    easing: Option<(MoveEasing, f64)>,
) -> GDObject {
    let mut properties = vec![(MOVE_UNITS_Y, GDValue::Int(offset_y))];
    add_easing(&mut properties, easing);
    GDObject::new(TRIGGER_MIDDLEGROUND_CONFIG, config, properties)
}

// util fn to add easing to properties if it is specified
fn add_easing(properties: &mut Vec<(u16, GDValue)>, easing: Option<(MoveEasing, f64)>) {
    if let Some((easing, rate)) = easing {
        properties.extend_from_slice(&[
            (MOVE_EASING, GDValue::Easing(easing)),
            (EASING_RATE, GDValue::Float(rate)),
        ]);
    }
}

/// Returns an event config trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
pub fn event_trigger(
    config: &GDObjConfig,
    target_group: i16,
    events: Vec<Event>,
    extra_id: i16,
    extra_id2: ExtraID2,
) -> GDObject {
    GDObject::new(
        TRIGGER_EVENT,
        config,
        vec![
            (IS_INTERACTABLE, GDValue::Bool(true)),
            (TARGET_ITEM, GDValue::Group(target_group)),
            (EVENT_LISTENERS, GDValue::Events(events)),
            (EVENT_EXTRA_ID, GDValue::Group(extra_id)),
            (EVENT_EXTRA_ID_2, GDValue::Int(extra_id2 as i32)),
        ],
    )
}

/// Returns a middle ground change trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `middleground`: Middleground to change to
pub fn middle_ground_trigger(config: &GDObjConfig, middleground: MiddleGround) -> GDObject {
    GDObject::new(
        TRIGGER_MIDDLEGROUND_CHANGE,
        config,
        vec![(MIDDLEGROUND, GDValue::Int(middleground as i32))],
    )
}

/// Returns a middle ground change trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `target_group`: Group that is activated when the trigger registers a click
/// * `hold_mode`: Toggles target group on holding and releasing instead of clicking
/// * `dual_mode`: Blocks 2nd player's clicks. Deprecated in favour of [`OptionalPlayerTarget::Player1`]
/// * `toggle`: Toggles a specific activation mode. See [`TouchToggle`]
/// * `target_player`: Only registers clicks from one player. See [`OptionalPlayerTarget`]
pub fn touch_trigger(
    config: &GDObjConfig,
    target_group: i16,
    hold_mode: bool,
    dual_mode: bool,
    toggle: TouchToggle,
    target_player: OptionalPlayerTarget,
) -> GDObject {
    GDObject::new(
        TRIGGER_TOUCH,
        config,
        vec![
            (TARGET_ITEM, GDValue::Group(target_group)),
            (TOUCH_HOLD_MODE, GDValue::Bool(hold_mode)),
            (TOUCH_DUAL_MODE, GDValue::Bool(dual_mode)),
            (TOUCH_TOGGLE_ONOFF, GDValue::Int(toggle as i32)),
            (TOUCH_PLAYER_ONLY, GDValue::Int(target_player as i32)),
        ],
    )
}

/// Returns an area stop trigger
/// # Arguments
/// * `config`: General object options, such as position and scale
/// * `effect_id`: Area effect that is stopped
pub fn area_stop(config: &GDObjConfig, effect_id: i16) -> GDObject {
    GDObject::new(
        TRIGGER_AREA_STOP,
        config,
        vec![(TARGET_ITEM, GDValue::Short(effect_id))],
    )
}

/* TODO: trigger constructors
 * Animation triggers
 * advanced follow
 * edit advanced follow
 * re-target advanced follow
 * keyframe setup trigger
 * keyframe setup object
 *
 * Area triggers
 * area move
 * area rotate
 * area scale
 * area fade
 * area tint
 * edit area move
 * edit area rotate
 * edit area scale
 * edit area fade
 * edit area tint
 * enter area move
 * enter area rotate
 * enter area scale
 * enter area fade
 * enter area tint
 * enter area stop
 * area stop
 *
 * Background triggers
 * switch bg
 * sdwitch ground
 *
 * Item triggers
 * instant count trigger
 * pickup trigger
 *
 * Spawner triggers
 * sequence
 *
 * Camera
 * static camera
 * offset camera
 * gameplay offset camera
 * rotate camera
 * edge camera
 * camera mode
 *
 * Gameplay triggers
 * rotate gameplay
 *
 * Sound triggers
 * song trigger
 * edit song trigger
 * sfx trigger
 * edit sfx trigger
 *
 * Misc.
 * bpm marker
 * gradient
 *
 * Player triggers
 * options
 * teleport trigger
 *
 * Shaders
 * shader setup
 * shock wave shader
 * shock line shader
 * glitch shader
 * chromatic shader
 * chromatic glitch shader
 * pixelate shader
 * lens circle shader
 * radial bulb shader
 * motion blur shader
 * bulge shader
 * pinch shader
 * gray scale shader
 * sepia shader
 * invert colour shader
 * hue shader
 * edit colour shader
 * split screen shader
 */