-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSirens.cs
More file actions
1283 lines (1193 loc) · 55.7 KB
/
Sirens.cs
File metadata and controls
1283 lines (1193 loc) · 55.7 KB
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
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Oxide.Core;
using Oxide.Core.Libraries.Covalence;
using Rust.Instruments;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using static InstrumentKeyController;
namespace Oxide.Plugins
{
[Info("Sirens", "ZockiRR", "2.2.0")]
[Description("Gives players the ability to attach sirens to vehicles")]
class Sirens : CovalencePlugin
{
#region variables
private const string PERMISSION_ATTACHSIRENS = "sirens.attachsirens";
private const string PERMISSION_DETACHSIRENS = "sirens.detachsirens";
private const string PERMISSION_ATTACHSIRENS_GLOBAL = "sirens.attachallsirens";
private const string PERMISSION_DETACHSIRENS_GLOBAL = "sirens.detachallsirens";
private const string I18N_MISSING_SIREN = "NoSirenForName";
private const string I18N_COULD_NOT_ATTACH = "CouldNotAttach";
private const string I18N_NOT_SUPPORTED = "NotSupported";
private const string I18N_ATTACHED = "Attached";
private const string I18N_ATTACHED_GLOBAL = "AttachedGlobal";
private const string I18N_DETACHED = "Detached";
private const string I18N_DETACHED_GLOBAL = "DetachedGlobal";
private const string I18N_NOT_A_VEHICLE = "NotAVehicle";
private const string I18N_SIRENS = "Sirens";
private const string I18N_PLAYERS_ONLY = "PlayersOnly";
// Initial prefabs
private const string PREFAB_COCKPIT = "assets/content/vehicles/modularcar/module_entities/1module_cockpit.prefab";
private const string PREFAB_COCKPIT_ARMORED = "assets/content/vehicles/modularcar/module_entities/1module_cockpit_armored.prefab";
private const string PREFAB_COCKPIT_WITH_ENGINE = "assets/content/vehicles/modularcar/module_entities/1module_cockpit_with_engine.prefab";
private const string PREFAB_BUTTON = "assets/prefabs/deployable/playerioents/button/button.prefab";
private const string PREFAB_FLASHERLIGHT = "assets/prefabs/deployable/playerioents/lights/flasherlight/electric.flasherlight.deployed.prefab";
private const string PREFAB_SIRENLIGHT = "assets/prefabs/deployable/playerioents/lights/sirenlight/electric.sirenlight.deployed.prefab";
private const string PREFAB_SIRENLIGHT_ORANGE = "assets/prefabs/io/electric/lights/sirenlightorange.prefab";
private const string PREFAB_SIRENLIGHT_GREEN = "assets/prefabs/io/electric/lights/sirenlightgreen.prefab";
private const string PREFAB_SIRENLIGHT_BLUE = "assets/prefabs/io/electric/lights/sirenlightblue.prefab";
private const string PREFAB_TRUMPET = "assets/prefabs/instruments/trumpet/trumpet.weapon.prefab";
private const string PREFAB_SEDAN = "assets/content/vehicles/sedan_a/sedantest.entity.prefab";
private const string PREFAB_SEDAN_RAIL = "assets/content/vehicles/sedan_a/sedanrail.entity.prefab";
private const string PREFAB_MINICOPTER = "assets/content/vehicles/minicopter/minicopter.entity.prefab";
private const string PREFAB_TRANSPORTHELI = "assets/content/vehicles/scrap heli carrier/scraptransporthelicopter.prefab";
private const string PREFAB_RHIB = "assets/content/vehicles/boats/rhib/rhib.prefab";
private const string PREFAB_ROWBOAT = "assets/content/vehicles/boats/rowboat/rowboat.prefab";
private const string PREFAB_WORKCART = "assets/content/vehicles/trains/workcart/workcart.entity.prefab";
private const string PREFAB_WORKCART_ABOVE_GROUND = "assets/content/vehicles/trains/workcart/workcart_aboveground.entity.prefab";
private const string PREFAB_WORKCART_COVERED = "assets/content/vehicles/trains/workcart/workcart_aboveground2.entity.prefab";
private const string PREFAB_MAGNETCRANE = "assets/content/vehicles/crane_magnet/magnetcrane.entity.prefab";
private const string PREFAB_HORSE = "assets/rust.ai/nextai/testridablehorse.prefab";
private const string PREFAB_ATTACKHELI = "assets/content/vehicles/attackhelicopter/attackhelicopter.entity.prefab";
private const string PREFAB_TUGBOAT = "assets/content/vehicles/boats/tugboat/tugboat.prefab";
private const string KEY_MODULAR_CAR = "MODULAR_CAR";
private const string DATAPATH_SIRENS = "sirens/";
// Preconfigured sirens
private static readonly Siren SIREN_DEFAULT = new Siren("police-germany",
new Dictionary<string, Attachment[]>
{
[PREFAB_COCKPIT] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.05f, 0.68f, 0.2f), new Vector3(200f, 0f, 0f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(-0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_TRUMPET, new Vector3(-0.08f, 1.4f, -0.9f), new Vector3(148f, 150f, 30f))
},
[PREFAB_COCKPIT_ARMORED] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.05f, 0.68f, 0.2f), new Vector3(200f, 0f, 0f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(-0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_TRUMPET, new Vector3(-0.08f, 1.4f, -0.9f), new Vector3(148f, 150f, 30f))
},
[PREFAB_COCKPIT_WITH_ENGINE] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.05f, 0.68f, 0.2f), new Vector3(200f, 0f, 0f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(-0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_TRUMPET, new Vector3(-0.08f, 1.4f, -0.9f), new Vector3(148f, 150f, 30f))
}
},
new Dictionary<string, Attachment[]>
{
[PREFAB_SEDAN] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.0f, 1.0f, 1.32f), new Vector3(210f, 0f, 0f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(-0.4f, 1.65f, 0.2f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.4f, 1.65f, 0.2f)),
new Attachment(PREFAB_TRUMPET, new Vector3(-0.08f, 1.68f, 0.2f), new Vector3(148f, 150f, 30f))
},
[PREFAB_SEDAN_RAIL] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.0f, 1.23f, 0.56f), new Vector3(210f, 0f, 0f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(-0.4f, 1.9f, -0.555f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.4f, 1.9f, -0.555f)),
new Attachment(PREFAB_TRUMPET, new Vector3(-0.08f, 1.92f, -0.555f), new Vector3(148f, 150f, 30f))
},
[PREFAB_MINICOPTER] = new Attachment[] {
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.0f, 2.235f, -0.025f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.0f, 0.832f, -2.7f), new Vector3(272f, 0f, 0f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.09f, 0.78f, -0.9f), new Vector3(148f, 330f, 30f))
},
[PREFAB_TRANSPORTHELI] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.012f, 1.215f, 2.86f), new Vector3(242f, 0f, 0f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(-0.3f, 3.15f, -7.65f), new Vector3(0f, 0f, 90f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.1f, 3.15f, -7.65f), new Vector3(0f, 0f, 270f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.0f, 0.55f, 3.6f), new Vector3(180f, 0f, 0f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.0f, 0.58f, 2.5f), new Vector3(328f, 30f, 30f))
},
[PREFAB_RHIB] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(-0.43f, 2.23f, 0.62f), new Vector3(210f, 0f, 0f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(-0.55f, 2.83f, 0.62f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.55f, 2.83f, 0.62f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.8f, 1.16f, 0.5f), new Vector3(148f, 150f, 30f))
},
[PREFAB_ROWBOAT] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(-0.5f, 0.495f, -1.8f), new Vector3(270f, 270f, 0f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.0f, 0.8f, 2.18f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.5f, 0.1f, -0.4f), new Vector3(148f, 150f, 30f))
},
[PREFAB_WORKCART] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.185f, 2.405f, 3.95f), new Vector3(235f, 0f, 0f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.1f, 3.93f, 4.13f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(1.25f, 3.93f, 4.13f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(-1.49f, 2.5f, -4.58f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(1.51f, 2.5f, -4.58f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.59f, 3.82f, 4.13f), new Vector3(148f, 150f, 30f))
},
[PREFAB_WORKCART_ABOVE_GROUND] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.185f, 2.405f, 3.95f), new Vector3(235f, 0f, 0f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.1f, 3.93f, 4.13f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(1.25f, 3.93f, 4.13f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(-1.49f, 2.5f, -4.58f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(1.51f, 2.5f, -4.58f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.59f, 3.82f, 4.13f), new Vector3(148f, 150f, 30f))
},
[PREFAB_WORKCART_COVERED] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.185f, 2.405f, 3.95f), new Vector3(235f, 0f, 0f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.1f, 3.93f, 4.13f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(1.25f, 3.93f, 4.13f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.59f, 3.82f, 4.13f), new Vector3(148f, 150f, 30f))
},
[PREFAB_MAGNETCRANE] = new Attachment[] {
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(-0.95f, 4.25f, 0.5f)),
new Attachment(PREFAB_TRUMPET, new Vector3(-0.08f, 1.4f, 0.0f), new Vector3(148f, 150f, 30f))
},
[PREFAB_HORSE] = new Attachment[] {
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.0f, 1.7f, 1.2f), new Vector3(25f, 0f, 0f), "head"),
new Attachment(PREFAB_TRUMPET, new Vector3(-0.06f, 1.15f, 1.3f), new Vector3(90f, 150f, 90f), "lip_lower")
},
[PREFAB_ATTACKHELI] = new Attachment[] {
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.0f, 2.48f, -0.3f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.1f, 2.3f, -6.5f), new Vector3(0f, 0f, 90f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.09f, 0.78f, -0.9f), new Vector3(148f, 330f, 30f))
},
[PREFAB_TUGBOAT] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(1.15f, 6.76f, 3.8f), new Vector3(-52f, 222f, 0f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(0.0f, 8.3f, 4.98f), new Vector3(45f, 0f, 0f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(2.88f, 3.08f, -8.08f)),
new Attachment(PREFAB_FLASHERLIGHT, new Vector3(-2.88f, 3.08f, -8.08f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.7f, 4.4f, 5.75f), new Vector3(148f, 150f, 30f))
}
}, new Tone(Notes.A, NoteType.Regular, 4, 1f), new Tone(Notes.D, NoteType.Regular, 5, 1f));
private static readonly Siren SIREN_SILENT = new Siren("warning-lights",
new Dictionary<string, Attachment[]>
{
[PREFAB_COCKPIT] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.05f, 0.68f, 0.2f), new Vector3(200f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(-0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(0.4f, 1.4f, -0.9f))
},
[PREFAB_COCKPIT_ARMORED] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.05f, 0.68f, 0.2f), new Vector3(200f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(-0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(0.4f, 1.4f, -0.9f))
},
[PREFAB_COCKPIT_WITH_ENGINE] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.05f, 0.68f, 0.2f), new Vector3(200f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(-0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(0.4f, 1.4f, -0.9f))
}
},
new Dictionary<string, Attachment[]>
{
[PREFAB_SEDAN] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.0f, 1.0f, 1.32f), new Vector3(210f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(-0.4f, 1.64f, 0.2f), new Vector3(0f, 0f, 3f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(0.4f, 1.64f, 0.2f), new Vector3(0f, 0f, 357f))
},
[PREFAB_SEDAN_RAIL] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.0f, 1.23f, 0.56f), new Vector3(210f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(-0.4f, 1.885f, -0.555f), new Vector3(0f, 0f, 3f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(0.4f, 1.885f, -0.555f), new Vector3(0f, 0f, 357f))
},
[PREFAB_MINICOPTER] = new Attachment[] {
new Attachment(PREFAB_SIRENLIGHT, new Vector3(0.0f, 2.235f, -0.025f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(0.0f, 0.832f, -2.7f), new Vector3(272f, 0f, 0f))
},
[PREFAB_TRANSPORTHELI] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.012f, 1.215f, 2.86f), new Vector3(242f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(-0.3f, 3.15f, -7.65f), new Vector3(0f, 0f, 90f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(0.1f, 3.15f, -7.65f), new Vector3(0f, 0f, 270f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(0.0f, 0.55f, 3.6f), new Vector3(180f, 0f, 0f))
},
[PREFAB_RHIB] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(-0.43f, 2.23f, 0.62f), new Vector3(210f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(0.0f, 1.55f, 4.15f))
},
[PREFAB_ROWBOAT] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(-0.5f, 0.495f, -1.8f), new Vector3(270f, 270f, 0f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(0.0f, 0.8f, 2.18f))
},
[PREFAB_WORKCART] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.185f, 2.405f, 3.95f), new Vector3(235f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(1.24f, 3.78f, 4.13f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(-1.49f, 2.5f, -4.58f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(1.51f, 2.5f, -4.58f))
},
[PREFAB_WORKCART_ABOVE_GROUND] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.185f, 2.405f, 3.95f), new Vector3(235f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(1.24f, 3.78f, 4.13f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(-1.49f, 2.5f, -4.58f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(1.51f, 2.5f, -4.58f))
},
[PREFAB_WORKCART_COVERED] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.185f, 2.405f, 3.95f), new Vector3(235f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(1.24f, 3.78f, 4.13f))
},
[PREFAB_MAGNETCRANE] = new Attachment[] {
new Attachment(PREFAB_SIRENLIGHT, new Vector3(-0.95f, 4.25f, 0.5f))
},
[PREFAB_HORSE] = new Attachment[] {
new Attachment(PREFAB_SIRENLIGHT, new Vector3(0.0f, 1.7f, 1.2f), new Vector3(25f, 0f, 0f), "head"),
new Attachment(PREFAB_TRUMPET, new Vector3(-0.06f, 1.15f, 1.3f), new Vector3(90f, 150f, 90f), "lip_lower")
},
[PREFAB_ATTACKHELI] = new Attachment[] {
new Attachment(PREFAB_SIRENLIGHT, new Vector3(0.0f, 2.48f, -0.37f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(0.11f, 2.2f, -6.45f), new Vector3(0f, 0f, -90f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.09f, 0.78f, -0.9f), new Vector3(148f, 330f, 30f))
},
[PREFAB_TUGBOAT] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(1.15f, 6.76f, 3.8f), new Vector3(-52f, 222f, 0f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(0.0f, 8.3f, 4.98f), new Vector3(45f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(2.88f, 3.08f, -8.08f)),
new Attachment(PREFAB_SIRENLIGHT, new Vector3(-2.88f, 3.08f, -8.08f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.7f, 4.4f, 5.75f), new Vector3(148f, 150f, 30f))
}
});
private static readonly Siren SIREN_ORANGE = new Siren("orange-lights",
new Dictionary<string, Attachment[]>
{
[PREFAB_COCKPIT] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.05f, 0.68f, 0.2f), new Vector3(200f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(-0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(0.4f, 1.4f, -0.9f))
},
[PREFAB_COCKPIT_ARMORED] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.05f, 0.68f, 0.2f), new Vector3(200f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(-0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(0.4f, 1.4f, -0.9f))
},
[PREFAB_COCKPIT_WITH_ENGINE] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.05f, 0.68f, 0.2f), new Vector3(200f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(-0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(0.4f, 1.4f, -0.9f))
}
},
new Dictionary<string, Attachment[]>
{
[PREFAB_SEDAN] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.0f, 1.0f, 1.32f), new Vector3(210f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(-0.4f, 1.64f, 0.2f), new Vector3(0f, 0f, 3f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(0.4f, 1.64f, 0.2f), new Vector3(0f, 0f, 357f))
},
[PREFAB_SEDAN_RAIL] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.0f, 1.23f, 0.56f), new Vector3(210f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(-0.4f, 1.885f, -0.555f), new Vector3(0f, 0f, 3f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(0.4f, 1.885f, -0.555f), new Vector3(0f, 0f, 357f))
},
[PREFAB_MINICOPTER] = new Attachment[] {
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(0.0f, 2.235f, -0.025f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(0.0f, 0.832f, -2.7f), new Vector3(272f, 0f, 0f))
},
[PREFAB_TRANSPORTHELI] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.012f, 1.215f, 2.86f), new Vector3(242f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(-0.3f, 3.15f, -7.65f), new Vector3(0f, 0f, 90f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(0.1f, 3.15f, -7.65f), new Vector3(0f, 0f, 270f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(0.0f, 0.55f, 3.6f), new Vector3(180f, 0f, 0f))
},
[PREFAB_RHIB] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(-0.43f, 2.23f, 0.62f), new Vector3(210f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(0.0f, 1.55f, 4.15f))
},
[PREFAB_ROWBOAT] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(-0.5f, 0.495f, -1.8f), new Vector3(270f, 270f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(0.0f, 0.8f, 2.18f))
},
[PREFAB_WORKCART] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.185f, 2.405f, 3.95f), new Vector3(235f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(1.24f, 3.78f, 4.13f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(-1.49f, 2.5f, -4.58f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(1.51f, 2.5f, -4.58f))
},
[PREFAB_WORKCART_ABOVE_GROUND] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.185f, 2.405f, 3.95f), new Vector3(235f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(1.24f, 3.78f, 4.13f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(-1.49f, 2.5f, -4.58f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(1.51f, 2.5f, -4.58f))
},
[PREFAB_WORKCART_COVERED] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.185f, 2.405f, 3.95f), new Vector3(235f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(1.24f, 3.78f, 4.13f))
},
[PREFAB_MAGNETCRANE] = new Attachment[] {
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(-0.95f, 4.25f, 0.5f))
},
[PREFAB_HORSE] = new Attachment[] {
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(0.0f, 1.7f, 1.2f), new Vector3(25f, 0f, 0f), "head"),
new Attachment(PREFAB_TRUMPET, new Vector3(-0.06f, 1.15f, 1.3f), new Vector3(90f, 150f, 90f), "lip_lower")
},
[PREFAB_ATTACKHELI] = new Attachment[] {
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(0.0f, 2.48f, -0.37f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(0.11f, 2.2f, -6.45f), new Vector3(0f, 0f, -90f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.09f, 0.78f, -0.9f), new Vector3(148f, 330f, 30f))
},
[PREFAB_TUGBOAT] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(1.15f, 6.76f, 3.8f), new Vector3(-52f, 222f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(0.0f, 8.3f, 4.98f), new Vector3(45f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(2.88f, 3.08f, -8.08f)),
new Attachment(PREFAB_SIRENLIGHT_ORANGE, new Vector3(-2.88f, 3.08f, -8.08f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.7f, 4.4f, 5.75f), new Vector3(148f, 150f, 30f))
}
});
private static readonly Siren SIREN_GREEN = new Siren("green-lights",
new Dictionary<string, Attachment[]>
{
[PREFAB_COCKPIT] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.05f, 0.68f, 0.2f), new Vector3(200f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(-0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(0.4f, 1.4f, -0.9f))
},
[PREFAB_COCKPIT_ARMORED] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.05f, 0.68f, 0.2f), new Vector3(200f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(-0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(0.4f, 1.4f, -0.9f))
},
[PREFAB_COCKPIT_WITH_ENGINE] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.05f, 0.68f, 0.2f), new Vector3(200f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(-0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(0.4f, 1.4f, -0.9f))
}
},
new Dictionary<string, Attachment[]>
{
[PREFAB_SEDAN] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.0f, 1.0f, 1.32f), new Vector3(210f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(-0.4f, 1.64f, 0.2f), new Vector3(0f, 0f, 3f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(0.4f, 1.64f, 0.2f), new Vector3(0f, 0f, 357f))
},
[PREFAB_SEDAN_RAIL] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.0f, 1.23f, 0.56f), new Vector3(210f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(-0.4f, 1.885f, -0.555f), new Vector3(0f, 0f, 3f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(0.4f, 1.885f, -0.555f), new Vector3(0f, 0f, 357f))
},
[PREFAB_MINICOPTER] = new Attachment[] {
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(0.0f, 2.235f, -0.025f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(0.0f, 0.832f, -2.7f), new Vector3(272f, 0f, 0f))
},
[PREFAB_TRANSPORTHELI] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.012f, 1.215f, 2.86f), new Vector3(242f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(-0.3f, 3.15f, -7.65f), new Vector3(0f, 0f, 90f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(0.1f, 3.15f, -7.65f), new Vector3(0f, 0f, 270f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(0.0f, 0.55f, 3.6f), new Vector3(180f, 0f, 0f))
},
[PREFAB_RHIB] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(-0.43f, 2.23f, 0.62f), new Vector3(210f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(0.0f, 1.55f, 4.15f))
},
[PREFAB_ROWBOAT] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(-0.5f, 0.495f, -1.8f), new Vector3(270f, 270f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(0.0f, 0.8f, 2.18f))
},
[PREFAB_WORKCART] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.185f, 2.405f, 3.95f), new Vector3(235f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(1.24f, 3.78f, 4.13f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(-1.49f, 2.5f, -4.58f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(1.51f, 2.5f, -4.58f))
},
[PREFAB_WORKCART_ABOVE_GROUND] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.185f, 2.405f, 3.95f), new Vector3(235f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(1.24f, 3.78f, 4.13f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(-1.49f, 2.5f, -4.58f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(1.51f, 2.5f, -4.58f))
},
[PREFAB_WORKCART_COVERED] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.185f, 2.405f, 3.95f), new Vector3(235f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(1.24f, 3.78f, 4.13f))
},
[PREFAB_MAGNETCRANE] = new Attachment[] {
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(-0.95f, 4.25f, 0.5f))
},
[PREFAB_HORSE] = new Attachment[] {
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(0.0f, 1.7f, 1.2f), new Vector3(25f, 0f, 0f), "head"),
new Attachment(PREFAB_TRUMPET, new Vector3(-0.06f, 1.15f, 1.3f), new Vector3(90f, 150f, 90f), "lip_lower")
},
[PREFAB_ATTACKHELI] = new Attachment[] {
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(0.0f, 2.48f, -0.37f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(0.11f, 2.2f, -6.45f), new Vector3(0f, 0f, -90f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.09f, 0.78f, -0.9f), new Vector3(148f, 330f, 30f))
},
[PREFAB_TUGBOAT] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(1.15f, 6.76f, 3.8f), new Vector3(-52f, 222f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(0.0f, 8.3f, 4.98f), new Vector3(45f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(2.88f, 3.08f, -8.08f)),
new Attachment(PREFAB_SIRENLIGHT_GREEN, new Vector3(-2.88f, 3.08f, -8.08f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.7f, 4.4f, 5.75f), new Vector3(148f, 150f, 30f))
}
});
private static readonly Siren SIREN_BLUE = new Siren("blue-sirens",
new Dictionary<string, Attachment[]>
{
[PREFAB_COCKPIT] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.05f, 0.68f, 0.2f), new Vector3(200f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(-0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_TRUMPET, new Vector3(-0.08f, 1.4f, -0.9f), new Vector3(148f, 150f, 30f))
},
[PREFAB_COCKPIT_ARMORED] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.05f, 0.68f, 0.2f), new Vector3(200f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(-0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_TRUMPET, new Vector3(-0.08f, 1.4f, -0.9f), new Vector3(148f, 150f, 30f))
},
[PREFAB_COCKPIT_WITH_ENGINE] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.05f, 0.68f, 0.2f), new Vector3(200f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(-0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(0.4f, 1.4f, -0.9f)),
new Attachment(PREFAB_TRUMPET, new Vector3(-0.08f, 1.4f, -0.9f), new Vector3(148f, 150f, 30f))
}
},
new Dictionary<string, Attachment[]>
{
[PREFAB_SEDAN] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.0f, 1.0f, 1.32f), new Vector3(210f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(-0.4f, 1.64f, 0.2f), new Vector3(0f, 0f, 3f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(0.4f, 1.64f, 0.2f), new Vector3(0f, 0f, 357f)),
new Attachment(PREFAB_TRUMPET, new Vector3(-0.08f, 1.68f, 0.2f), new Vector3(148f, 150f, 30f))
},
[PREFAB_SEDAN_RAIL] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.0f, 1.23f, 0.56f), new Vector3(210f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(-0.4f, 1.885f, -0.555f), new Vector3(0f, 0f, 3f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(0.4f, 1.885f, -0.555f), new Vector3(0f, 0f, 357f)),
new Attachment(PREFAB_TRUMPET, new Vector3(-0.08f, 1.92f, -0.555f), new Vector3(148f, 150f, 30f))
},
[PREFAB_MINICOPTER] = new Attachment[] {
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(0.0f, 2.235f, -0.025f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(0.0f, 0.832f, -2.7f), new Vector3(272f, 0f, 0f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.09f, 0.78f, -0.9f), new Vector3(148f, 330f, 30f))
},
[PREFAB_TRANSPORTHELI] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.012f, 1.215f, 2.86f), new Vector3(242f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(-0.3f, 3.15f, -7.65f), new Vector3(0f, 0f, 90f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(0.1f, 3.15f, -7.65f), new Vector3(0f, 0f, 270f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(0.0f, 0.55f, 3.6f), new Vector3(180f, 0f, 0f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.0f, 0.58f, 2.5f), new Vector3(328f, 30f, 30f))
},
[PREFAB_RHIB] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(-0.43f, 2.23f, 0.62f), new Vector3(210f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(0.0f, 1.55f, 4.15f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.8f, 1.16f, 0.5f), new Vector3(148f, 150f, 30f))
},
[PREFAB_ROWBOAT] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(-0.5f, 0.495f, -1.8f), new Vector3(270f, 270f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(0.0f, 0.8f, 2.18f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.5f, 0.1f, -0.4f), new Vector3(148f, 150f, 30f))
},
[PREFAB_WORKCART] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.185f, 2.405f, 3.95f), new Vector3(235f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(1.24f, 3.78f, 4.13f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(-1.49f, 2.5f, -4.58f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(1.51f, 2.5f, -4.58f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.59f, 3.82f, 4.13f), new Vector3(148f, 150f, 30f))
},
[PREFAB_WORKCART_ABOVE_GROUND] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.185f, 2.405f, 3.95f), new Vector3(235f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(1.24f, 3.78f, 4.13f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(-1.49f, 2.5f, -4.58f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(1.51f, 2.5f, -4.58f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.59f, 3.82f, 4.13f), new Vector3(148f, 150f, 30f))
},
[PREFAB_WORKCART_COVERED] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(0.185f, 2.405f, 3.95f), new Vector3(235f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(1.24f, 3.78f, 4.13f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.59f, 3.82f, 4.13f), new Vector3(148f, 150f, 30f))
},
[PREFAB_MAGNETCRANE] = new Attachment[] {
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(-0.95f, 4.25f, 0.5f)),
new Attachment(PREFAB_TRUMPET, new Vector3(-0.08f, 1.4f, 0.0f), new Vector3(148f, 150f, 30f))
},
[PREFAB_HORSE] = new Attachment[] {
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(0.0f, 1.7f, 1.2f), new Vector3(25f, 0f, 0f), "head"),
new Attachment(PREFAB_TRUMPET, new Vector3(-0.06f, 1.15f, 1.3f), new Vector3(90f, 150f, 90f), "lip_lower")
},
[PREFAB_ATTACKHELI] = new Attachment[] {
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(0.0f, 2.48f, -0.37f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(0.11f, 2.2f, -6.45f), new Vector3(0f, 0f, -90f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.09f, 0.78f, -0.9f), new Vector3(148f, 330f, 30f))
},
[PREFAB_TUGBOAT] = new Attachment[] {
new Attachment(PREFAB_BUTTON, new Vector3(1.15f, 6.76f, 3.8f), new Vector3(-52f, 222f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(0.0f, 8.3f, 4.98f), new Vector3(45f, 0f, 0f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(2.88f, 3.08f, -8.08f)),
new Attachment(PREFAB_SIRENLIGHT_BLUE, new Vector3(-2.88f, 3.08f, -8.08f)),
new Attachment(PREFAB_TRUMPET, new Vector3(0.7f, 4.4f, 5.75f), new Vector3(148f, 150f, 30f))
}
}, new Tone(Notes.A, NoteType.Regular, 4, 1f), new Tone(Notes.D, NoteType.Regular, 5, 1f));
#endregion variables
#region data
private class DataContainer
{
// Map BaseVehicle.net.ID -> SirenInfos
public Dictionary<ulong, VehicleContainer> VehicleSirenMap = new Dictionary<ulong, VehicleContainer>();
}
private class VehicleContainer
{
public string SirenName = SIREN_DEFAULT.Name;
public SirenController.States State = SirenController.States.OFF;
public HashSet<ulong> NetIDs = new HashSet<ulong>();
public VehicleContainer()
{
}
public VehicleContainer(string aSirenName, SirenController.States aState, IEnumerable<NetworkableId> someNetIDs)
{
SirenName = aSirenName;
State = aState;
NetIDs.UnionWith(someNetIDs.Select(eachNetID => eachNetID.Value));
}
}
#endregion data
#region configuration
private Configuration config;
private IDictionary<string, Siren> SirenDictionary { get; } = new Dictionary<string, Siren>();
private class Configuration
{
[JsonProperty("MountNeeded")]
public bool MountNeeded = true;
[JsonProperty("SoundEnabled")]
public bool SoundEnabled = true;
[JsonProperty("SirenSpawnProbability")]
public Dictionary<string, float> SirenSpawnProbability = new Dictionary<string, float>
{
[KEY_MODULAR_CAR] = 0f,
[PREFAB_HORSE] = 0f,
[PREFAB_MAGNETCRANE] = 0f,
[PREFAB_MINICOPTER] = 0f,
[PREFAB_RHIB] = 0f,
[PREFAB_ROWBOAT] = 0f,
[PREFAB_SEDAN] = 0f,
[PREFAB_SEDAN_RAIL] = 0f,
[PREFAB_TRANSPORTHELI] = 0f,
[PREFAB_WORKCART] = 0f,
[PREFAB_WORKCART_ABOVE_GROUND] = 0f,
[PREFAB_WORKCART_COVERED] = 0f
};
[JsonConverter(typeof(StringEnumConverter))]
[JsonProperty("DefaultState")]
public SirenController.States DefaultState = SirenController.States.OFF;
public string ToJson() => JsonConvert.SerializeObject(this);
public Dictionary<string, object> ToDictionary() => JsonConvert.DeserializeObject<Dictionary<string, object>>(ToJson());
}
private class Tone
{
public Tone(Notes aNote = Notes.A, NoteType aNoteType = NoteType.Regular, int anOctave = 4, float aDuration = 1f)
{
Note = aNote;
NoteType = aNoteType;
Octave = anOctave;
Duration = aDuration;
}
[JsonConverter(typeof(StringEnumConverter))]
[JsonProperty("Note")]
public Notes Note;
[JsonConverter(typeof(StringEnumConverter))]
[JsonProperty("NoteType")]
public NoteType NoteType;
[JsonProperty("Octave")]
public int Octave;
[JsonProperty("Duration")]
public float Duration;
public string ToJson() => JsonConvert.SerializeObject(this);
public Dictionary<string, object> ToDictionary() => JsonConvert.DeserializeObject<Dictionary<string, object>>(ToJson());
}
private class Siren
{
public Siren(string aName, Dictionary<string, Attachment[]> someModules, Dictionary<string, Attachment[]> someVehicles, params Tone[] someTones)
{
Name = aName;
Modules = someModules;
Vehicles = someVehicles;
Tones = someTones;
}
[JsonProperty("Name")]
public string Name;
[JsonProperty("Tones")]
public Tone[] Tones;
[JsonProperty("Modules")]
public Dictionary<string, Attachment[]> Modules;
[JsonProperty("Vehicles")]
public Dictionary<string, Attachment[]> Vehicles;
public string ToJson() => JsonConvert.SerializeObject(this);
public Dictionary<string, object> ToDictionary() => JsonConvert.DeserializeObject<Dictionary<string, object>>(ToJson());
}
private class Attachment
{
public Attachment(string aPrefab, Vector3 aPosition, Vector3 anAngle = new Vector3(), string aBone = null)
{
Prefab = aPrefab;
Position = aPosition;
Angle = anAngle;
Bone = aBone;
}
[JsonProperty("Prefab")]
public string Prefab;
[JsonProperty("Position")]
public Vector3 Position;
[JsonProperty("Angle")]
public Vector3 Angle;
[JsonProperty("Bone")]
public string Bone;
public string ToJson() => JsonConvert.SerializeObject(this);
public Dictionary<string, object> ToDictionary() => JsonConvert.DeserializeObject<Dictionary<string, object>>(ToJson());
}
protected override void LoadDefaultConfig()
{
config = new Configuration();
SirenDictionary.Clear();
SirenDictionary.Add(SIREN_DEFAULT.Name, SIREN_DEFAULT);
SirenDictionary.Add(SIREN_SILENT.Name, SIREN_SILENT);
SirenDictionary.Add(SIREN_ORANGE.Name, SIREN_ORANGE);
SirenDictionary.Add(SIREN_GREEN.Name, SIREN_GREEN);
SirenDictionary.Add(SIREN_BLUE.Name, SIREN_BLUE);
}
protected override void LoadConfig()
{
base.LoadConfig();
try
{
config = Config.ReadObject<Configuration>();
if (config == null)
{
throw new JsonException();
}
SaveDefaultSirens();
try
{
foreach (string eachSirenFile in Interface.Oxide.DataFileSystem.GetFiles(DATAPATH_SIRENS, "*.json"))
{
string theFilename = eachSirenFile.Basename(".json");
try
{
Siren theSiren = Interface.Oxide.DataFileSystem.ReadObject<Siren>(DATAPATH_SIRENS + theFilename);
SirenDictionary.Add(theSiren.Name, theSiren);
}
catch
{
PrintWarning($"Siren file {theFilename}.json is invalid; ignoring");
}
}
}
catch
{
}
Puts("Loaded sirens: " + string.Join(", ", SirenDictionary.Keys));
if (!config.ToDictionary().Keys.SequenceEqual(Config.ToDictionary(x => x.Key, x => x.Value).Keys))
{
PrintWarning("Configuration appears to be outdated; updating and saving");
SaveConfig();
}
}
catch
{
PrintWarning($"Configuration file {Name}.json is invalid; using defaults");
LoadDefaultConfig();
}
}
protected override void SaveConfig()
{
PrintWarning($"Configuration changes saved to {Name}.json");
Config.WriteObject(config, true);
}
protected void SaveDefaultSirens()
{
PrintWarning($"Saved default sirens");
Interface.Oxide.DataFileSystem.WriteObject(DATAPATH_SIRENS + SIREN_DEFAULT.Name, SIREN_DEFAULT);
Interface.Oxide.DataFileSystem.WriteObject(DATAPATH_SIRENS + SIREN_SILENT.Name, SIREN_SILENT);
Interface.Oxide.DataFileSystem.WriteObject(DATAPATH_SIRENS + SIREN_ORANGE.Name, SIREN_ORANGE);
Interface.Oxide.DataFileSystem.WriteObject(DATAPATH_SIRENS + SIREN_GREEN.Name, SIREN_GREEN);
Interface.Oxide.DataFileSystem.WriteObject(DATAPATH_SIRENS + SIREN_BLUE.Name, SIREN_BLUE);
}
#endregion configuration
#region localization
protected override void LoadDefaultMessages()
{
lang.RegisterMessages(new Dictionary<string, string>
{
[I18N_MISSING_SIREN] = "No siren was found for the given name (using {0} instead)",
[I18N_COULD_NOT_ATTACH] = "Could not attach '{0}'",
[I18N_ATTACHED] = "Attached siren '{0}'",
[I18N_ATTACHED_GLOBAL] = "Attached siren '{0}' to all existing cars",
[I18N_DETACHED] = "Detached siren",
[I18N_DETACHED_GLOBAL] = "Detached all existing sirens",
[I18N_NOT_A_VEHICLE] = "This entity is not a (supported) vehicle",
[I18N_SIRENS] = "Available sirens: {0}",
[I18N_PLAYERS_ONLY] = "Command '{0}' can only be used by a player",
[I18N_NOT_SUPPORTED] = "The siren '{0}' has no configuration for '{1}'"
}, this);
}
#endregion localization
#region commands
[Command("attachsirens"), Permission(PERMISSION_ATTACHSIRENS)]
private void AttachCarSirens(IPlayer aPlayer, string aCommand, string[] someArgs)
{
if (aPlayer.IsServer)
{
Message(aPlayer, I18N_PLAYERS_ONLY, aCommand);
return;
}
BaseVehicle theVehicle = RaycastVehicle(aPlayer);
if (theVehicle)
{
Siren theSiren = someArgs.Length > 0 ? FindSirenForName(someArgs[0], aPlayer) : SirenDictionary.Values.First();
if (AttachSirens(theVehicle, theSiren, config.DefaultState, aPlayer))
{
Message(aPlayer, I18N_ATTACHED, theSiren.Name);
}
}
}
[Command("detachsirens"), Permission(PERMISSION_DETACHSIRENS)]
private void DetachCarSirens(IPlayer aPlayer, string aCommand, string[] _)
{
if (aPlayer.IsServer)
{
Message(aPlayer, I18N_PLAYERS_ONLY, aCommand);
return;
}
BaseVehicle theVehicle = RaycastVehicle(aPlayer);
if (theVehicle && DetachSirens(theVehicle))
{
Message(aPlayer, I18N_DETACHED);
}
}
[Command("attachallsirens"), Permission(PERMISSION_ATTACHSIRENS_GLOBAL)]
private void AttachAllCarSirens(IPlayer aPlayer, string _, string[] someArgs)
{
Siren theSiren = someArgs.Length > 0 ? FindSirenForName(someArgs[0], aPlayer) : SirenDictionary.Values.First();
bool theAtLeastOneSuccessful = false;
foreach (BaseVehicle eachVehicle in BaseNetworkable.serverEntities.OfType<BaseVehicle>())
{
theAtLeastOneSuccessful |= AttachSirens(eachVehicle, theSiren, config.DefaultState, aPlayer);
}
if (theAtLeastOneSuccessful)
{
Message(aPlayer, I18N_ATTACHED_GLOBAL, theSiren.Name);
}
}
[Command("detachallsirens"), Permission(PERMISSION_DETACHSIRENS_GLOBAL)]
private void DetachAllCarSirens(IPlayer aPlayer, string _, string[] _1)
{
foreach (BaseVehicle eachVehicle in BaseNetworkable.serverEntities.OfType<BaseVehicle>())
{
DetachSirens(eachVehicle);
}
Message(aPlayer, I18N_DETACHED_GLOBAL);
}
[Command("listsirens")]
private void ListSirens(IPlayer aPlayer, string _, string[] _1)
{
Message(aPlayer, I18N_SIRENS, string.Join(", ", SirenDictionary.Keys));
}
[Command("togglesirens")]
private void ToggleSirens(IPlayer aPlayer, string aCommand, string[] _)
{
if (aPlayer.IsServer)
{
Message(aPlayer, I18N_PLAYERS_ONLY, aCommand);
return;
}
BasePlayer thePlayer = aPlayer.Object as BasePlayer;
BaseVehicle theVehicle = thePlayer?.GetMountedVehicle();
if (theVehicle)
{
theVehicle.GetComponent<SirenController>()?.ChangeState();
}
else if (!config.MountNeeded)
{
RaycastVehicle(aPlayer)?.GetComponent<SirenController>()?.ChangeState(); ;
}
}
#endregion commands
#region hooks
private void Unload()
{
OnServerSave();
foreach (BaseVehicle eachVehicle in BaseNetworkable.serverEntities.OfType<BaseVehicle>())
{
DetachSirens(eachVehicle);
}
}
private void OnServerSave()
{
DataContainer thePersistentData = new DataContainer();
foreach (BaseVehicle eachCar in BaseNetworkable.serverEntities.OfType<BaseVehicle>())
{
SirenController theController = eachCar.GetComponent<SirenController>();
thePersistentData.VehicleSirenMap.Add(eachCar.net.ID.Value, theController ? new VehicleContainer(theController.Siren.Name, theController.State, theController.NetIDs) : null);
}
Interface.Oxide.DataFileSystem.WriteObject(Name, thePersistentData);
}
private void OnServerInitialized(bool _)
{
bool theSpawnRandomlyFlag = config.SirenSpawnProbability.Any(entry => entry.Value > 0f);
if (!theSpawnRandomlyFlag)
{
Unsubscribe("OnEntitySpawned");
}
// Reattach on server restart
DataContainer thePersistentData = Interface.Oxide.DataFileSystem.ReadObject<DataContainer>(Name);
foreach (BaseVehicle eachVehicle in BaseNetworkable.serverEntities.OfType<BaseVehicle>())
{
if (thePersistentData.VehicleSirenMap.TryGetValue(eachVehicle.net.ID.Value, out VehicleContainer theContainer))
{
if (theContainer != null)
{
if (SirenDictionary.TryGetValue(theContainer.SirenName, out Siren theSiren))
{
CreateSirenController(eachVehicle, theSiren, theContainer.NetIDs);
AttachSirens(eachVehicle, theSiren, theContainer.State);
}
else
{
CreateSirenController(eachVehicle, null, theContainer.NetIDs);
DetachSirens(eachVehicle);
PrintWarning($"Missing siren for name \"{theContainer.SirenName}\". Ignoring...");
}
}
}
else if (theSpawnRandomlyFlag)
{
SirenController theController = eachVehicle.GetComponent<SirenController>();
if (!theController)
{
if (config.SirenSpawnProbability.TryGetValue(eachVehicle is ModularCar ? KEY_MODULAR_CAR : eachVehicle.PrefabName, out float theProbability) && Core.Random.Range(0f, 1f) < theProbability)
{
AttachSirens(eachVehicle, SirenDictionary.Values.First(), config.DefaultState);
}
}
}
}
}
private object OnButtonPress(PressButton aButton, BasePlayer aPlayer)
{
BaseVehicle theVehicle = aButton.GetComponentInParent<BaseVehicleModule>()?.Vehicle;
theVehicle = theVehicle ? theVehicle : aButton.GetComponentInParent<BaseVehicle>();
if (theVehicle)
{
SirenController theController = theVehicle.GetComponent<SirenController>();
if (theController)
{
if ((config.MountNeeded && aPlayer.GetMountedVehicle() != theVehicle) || !theController.NetIDs.Contains(aButton.net.ID))
{
return false;
}
theController.ChangeState();
}
}
return null;
}
private void OnEntitySpawned(BaseVehicle aVehicle)
{
SirenController theController = aVehicle.GetComponent<SirenController>();
if (!theController)
{
if (config.SirenSpawnProbability.TryGetValue(aVehicle is ModularCar ? KEY_MODULAR_CAR : aVehicle.PrefabName, out float theProbability) && Core.Random.Range(0f, 1f) < theProbability)
{
AttachSirens(aVehicle, SirenDictionary.Values.First(), config.DefaultState);
}
}
}
#endregion hooks
#region methods
/// <summary>
/// Tries to attach the given siren to the vehicle, replacing any existing siren.
/// </summary>
/// <param name="aVehicle">The vehicle.</param>
/// <param name="aSiren">The siren.</param>
/// <param name="anInitialState">The initial siren state.</param>
/// <param name="aPlayer">The calling player.</param>
/// <returns>True, if successful.</returns>
private bool AttachSirens(BaseVehicle aVehicle, Siren aSiren, SirenController.States anInitialState, IPlayer aPlayer = null)
{
DetachSirens(aVehicle);
SirenController theController = CreateSirenController(aVehicle, aSiren);
if (aVehicle as ModularCar)
{
if (aSiren.Modules == null)
{
Message(aPlayer, I18N_NOT_SUPPORTED, aSiren.Name, KEY_MODULAR_CAR);
DetachSirens(aVehicle);
return false;
}
foreach (BaseVehicleModule eachModule in aVehicle.GetComponentsInChildren<BaseVehicleModule>())
{
SpawnAttachments(aSiren.Modules, aPlayer, theController, eachModule);
}
}
else if (!SpawnAttachments(aSiren.Vehicles, aPlayer, theController, aVehicle))
{
Message(aPlayer, I18N_NOT_SUPPORTED, aSiren.Name, aVehicle.PrefabName);
DetachSirens(aVehicle);
return false;
}
theController.SetState(anInitialState);
return true;
}
/// <summary>
/// Spawns the attachments for the given dictionary for the given parent entity.
/// </summary>
/// <param name="someAttachments">The dictionary.</param>
/// <param name="aPlayer">The calling player.</param>
/// <param name="theController">The SirenController of the Parent.</param>
/// <param name="aParent">The Parent.</param>
/// <returns>True, if the parent has an entry in the dictionary with at least one Attachment.</returns>
private bool SpawnAttachments(IDictionary<string, Attachment[]> someAttachments, IPlayer aPlayer, SirenController theController, BaseEntity aParent)
{
if (someAttachments == null)
{
return false;