File size: 75,825 Bytes
24b81cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
enum FireplaceFireState
{
	NO_FIRE				= 1,
	START_FIRE			= 2,
	SMALL_FIRE			= 3,	
	NORMAL_FIRE			= 4,
	END_FIRE			= 5,
	EXTINGUISHING_FIRE	= 6,
	EXTINGUISHED_FIRE	= 7,
	REIGNITED_FIRE		= 8,
	
	COUNT				= 9			//for net sync purposes
}

enum FirePlaceFailure
{
	WIND			= 0,
	WET				= 1,	
}

class FireplaceBase extends ItemBase
{
	//State params
	protected bool m_IsBurning 						= false;   
	protected bool m_HasAshes						= false;
	protected bool m_IsOven							= false;
	protected bool m_HasStoneCircle 				= false;
	protected bool m_RoofAbove 						= false;
	protected bool m_NoIgnite 						= false;
	protected int m_OvenAttachmentsLockState 		= -1;
	protected FireplaceFireState m_FireState	 	= FireplaceFireState.NO_FIRE;
	protected FireplaceFireState m_LastFireState 	= FireplaceFireState.NO_FIRE;		//for synchronization purposes
	protected vector m_HalfExtents;
	
	//Fireplace params
	protected float m_TemperatureLossMP				= 1.0;		//! determines how fast will the fireplace loose its temperature when cooling (lower is better)
	protected float m_FuelBurnRateMP				= 1.0;		//! determines how fast will the fuel item burn before spending (lower is better)
	
	//cooking
	protected ref Cooking m_CookingProcess;
	
	//
	const float PARAM_SMALL_FIRE_TEMPERATURE 		= 150;		//! maximum fireplace temperature of a small fire (degree Celsius)
	const float PARAM_NORMAL_FIRE_TEMPERATURE 		= 1000;		//! maximum fireplace temperature of a normal fire (degree Celsius)
	const float PARAM_MIN_FIRE_TEMPERATURE 			= 30;		//! minimum fireplace temperature under which the fireplace is inactive (degree Celsius)
	const float	PARAM_TEMPERATURE_INCREASE 			= 3;		//! how much will temperature increase when fireplace is burning (degree Celsius per second)
	const float	PARAM_TEMPERATURE_DECREASE 			= 3;		//! how much will temperature decrease when fireplace is cooling (degree Celsius per second)
	const float	PARAM_MAX_WET_TO_IGNITE 			= 0.2;		//! maximum wetness value when the fireplace can be ignited
	const float PARAM_MIN_TEMP_TO_REIGNITE 			= 30;		//! minimum fireplace temperature under which the fireplace can be reignited using air only (degree Celsius)
	const float	PARAM_IGNITE_RAIN_THRESHOLD 		= 0.1;		//! maximum rain value when the fireplace can be ignited
	const float	PARAM_BURN_WET_THRESHOLD 			= 0.40;		//! maximum wetness value when the fireplace is able to burn
	const float	PARAM_WET_INCREASE_COEF 			= 0.02;		//! value for calculating of  wetness that fireplace gain when raining
	const float	PARAM_WET_HEATING_DECREASE_COEF 	= 0.01;		//! value for calculating wetness loss during heating process
	const float	PARAM_WET_COOLING_DECREASE_COEF 	= 0.002;	//! value for calculating wetness loss during cooling process
	const float	PARAM_FIRE_CONSUM_RATE_AMOUNT		= 0.5;		//! base value of fire consumption rate (how many base energy will be spent on each update)
	const float	PARAM_BURN_DAMAGE_COEF				= 5.0;		//! value for calculating damage on items located in fireplace cargo
	const float	PARAM_ITEM_HEAT_TEMP_INCREASE_COEF	= 10;		//! value for calculating temperature increase on each heat update interval (degree Celsius)
	const float	PARAM_ITEM_HEAT_MIN_TEMP			= 40;		//! minimum temperature for items that can be heated in fireplace cargo or as attachments (degree Celsius)
	const float PARAM_MAX_ITEM_HEAT_TEMP_INCREASE	= 200;		//! maximum value of temperature of items in fireplace when heating (degree Celsius)
	const float PARAM_FULL_HEAT_RADIUS 				= 2.0;		//! radius in which objects are fully heated by fire
	const float PARAM_HEAT_RADIUS 					= 4.0;		//! radius in which objects are heated by fire
	const float PARAM_HEAT_THROUGH_AIR_COEF			= 0.1;		//! DEPRECATED value for calculation of heat transfered from fireplace through air to player (environment)
	const float PARAM_MAX_TRANSFERED_TEMPERATURE	= 25;		//! maximum value for temperature that will be transfered to player (environment)
	//! 
	const int 	MIN_STONES_TO_BUILD_CIRCLE			= 8;		//! minimum amount of stones for circle
	const int 	MIN_STONES_TO_BUILD_OVEN			= 16;		//! minimum amount of stones for oven
	const int 	MAX_TEMPERATURE_TO_DISMANTLE_OVEN	= 40;		//! maximum temperature for dismantling oven
	const float	MIN_CEILING_HEIGHT 					= 5;		//! min height of ceiling for fire to be ignited
	//
	const float TEMPERATURE_LOSS_MP_DEFAULT			= 1.0;
	const float TEMPERATURE_LOSS_MP_STONES			= 0.90;		//10% boost
	const float TEMPERATURE_LOSS_MP_OVEN			= 0.75;		//25% boost

	const float FUEL_BURN_RATE_DEFAULT				= 1.0;
	const float FUEL_BURN_RATE_STONES				= 0.92;
	const float FUEL_BURN_RATE_OVEN					= 0.85;
	
	//! cooking
	const float PARAM_COOKING_TEMP_THRESHOLD		= 100;		//! temperature threshold for starting coooking process (degree Celsius)
	const float PARAM_COOKING_EQUIP_MAX_TEMP		= 250;		//! maximum temperature of attached cooking equipment (degree Celsius)
	const float PARAM_COOKING_EQUIP_TEMP_INCREASE	= 10;		//! how much will temperature increase when attached on burning fireplace (degree Celsius)
	//! 
	const int 	TIMER_HEATING_UPDATE_INTERVAL 		= 3;		//! update interval duration of heating process (seconds)
	const int 	TIMER_COOLING_UPDATE_INTERVAL 		= 2;		//! update interval duration of cooling process (seconds)
	//! direct cooking slots
	const int   DIRECT_COOKING_SLOT_COUNT			= 3;
	const float	DIRECT_COOKING_SPEED				= 1.5;		// per second
	const int   SMOKING_SLOT_COUNT					= 4;
	const float SMOKING_SPEED 						= 1;		// per second

	// stage lifetimes
	const int   LIFETIME_FIREPLACE_STONE_CIRCLE		= 172800;
	const int   LIFETIME_FIREPLACE_STONE_OVEN		= 604800;
	
	const float IGNITE_WIND_THRESHOLD				= 0.8; 		//fireplace can not be ignited above this multiple of max wind

	//Timers
	protected ref Timer m_HeatingTimer;
	protected ref Timer m_CoolingTimer;
	
	// Light entity
	protected FireplaceLight m_Light;
	protected float m_LightDistance 				= 2000;
	
	//Attachments
	protected ItemBase m_CookingEquipment;
	protected ItemBase m_DirectCookingSlots[DIRECT_COOKING_SLOT_COUNT];
	protected ItemBase m_SmokingSlots[SMOKING_SLOT_COUNT];
	protected ref FireConsumable m_ItemToConsume;
	
	//Particles - default for FireplaceBase
	protected int PARTICLE_FIRE_START 			= ParticleList.CAMP_FIRE_START;
	protected int PARTICLE_OVEN_FIRE_START 		= ParticleList.CAMP_STOVE_FIRE_START;
	protected int PARTICLE_SMALL_FIRE 			= ParticleList.CAMP_SMALL_FIRE;
	protected int PARTICLE_NORMAL_FIRE			= ParticleList.CAMP_NORMAL_FIRE;
	protected int PARTICLE_OVEN_FIRE 			= ParticleList.CAMP_STOVE_FIRE;
	protected int PARTICLE_SMALL_SMOKE 			= ParticleList.CAMP_SMALL_SMOKE;
	protected int PARTICLE_NORMAL_SMOKE			= ParticleList.CAMP_NORMAL_SMOKE;
	protected int PARTICLE_FIRE_END 			= ParticleList.CAMP_FIRE_END;
	protected int PARTICLE_OVEN_FIRE_END 		= ParticleList.CAMP_STOVE_FIRE_END;
	protected int PARTICLE_STEAM_END			= ParticleList.CAMP_STEAM_2END;
	protected int PARTICLE_STEAM_EXTINGUISHING	= ParticleList.CAMP_STEAM_EXTINGUISH_START;
	protected int PARTICLE_NO_IGNITE_WIND		= ParticleList.CAMP_NO_IGNITE_WIND;
	//
	protected Particle m_ParticleFireStart;
	protected Particle m_ParticleSmallFire;
	protected Particle m_ParticleNormalFire;
	protected Particle m_ParticleSmallSmoke;
	protected Particle m_ParticleNormalSmoke;
	protected Particle m_ParticleFireEnd;
	protected Particle m_ParticleSteamEnd;
	protected Particle m_ParticleSteamExtinguishing;
	
	//Sounds
	const string SOUND_FIRE_HEAVY 				= "HeavyFire_SoundSet";
	const string SOUND_FIRE_LIGHT				= "LightFire_SoundSet";
	const string SOUND_FIRE_NO_FIRE				= "NoFuelFire_SoundSet";
	const string SOUND_FIRE_EXTINGUISHING		= "ExtinguishByWater_SoundSet";
	const string SOUND_FIRE_EXTINGUISHED		= "ExtinguishByWaterEnd_SoundSet";
	
	//
	protected EffectSound m_SoundFireLoop;
	protected EffectSound m_SoundFire;
	//
	
	//Fuel
	//Kindling / Fuel item types
	protected static ref map<typename, ref FireConsumableType> 	m_FireConsumableTypes;
	protected ref map<ItemBase, ref FireConsumable> 			m_FireConsumables;
	
	//Player action / status messages
	const string MESSAGE_IGNITE_IGNIT_ITEM_DAMAGED 		= "You cannot start fire. Fireplace is ruined.";
	const string MESSAGE_IGNITE_NO_KINDLING 			= "There needs to be some kindling to start a fire.";
	const string MESSAGE_IGNITE_TOO_WET 				= "The fireplace is too wet to be ignited.";
	const string MESSAGE_IGNITE_RAIN	 				= "The fire went out because of the rain.";
	const string MESSAGE_IGNITE_WIND	 				= "The fire went out because of the wind.";
	const string MESSAGE_IGNITE_IN_WATER 				= "I cannot ignite the fireplace in the water.";
	const string MESSAGE_IGNITE_UNDER_LOW_ROOF 			= "I cannot ignite the fireplace here, the is not enough room.";
	const string MESSAGE_REIGNITE_NO_KINDLING 			= "There needs to be some kindling to start a fire.";
	const string MESSAGE_REIGNITE_RAIN	 				= "Cannot reignite fireplace in rain.";
	const string MESSAGE_REIGNITE_TOO_WET 				= "The fireplace is too wet to be reignited.";
	const string MESSAGE_BURY_ASHES_FAILED_NOT_EMPTY	= "Cannot bury ashes. There are sill items in it.";
	const string MESSAGE_BURY_ASHES_FAILED_SURFACE		= "Cannot bury ashes on hard surface.";
	const string MESSAGE_BURY_ASHES_FAILED_BURNING		= "Cannot bury ashes, the fireplace is still burning.";
	const string MESSAGE_BURY_ASHES_FAILED_TOO_HOT		= "Cannot bury ashes, the fireplace is too hot.";
	const string MESSAGE_CANNOT_BUILD_OVEN				= "Cannot build oven.";
	const string MESSAGE_CANNOT_DISMANTLE_OVEN			= "Cannot dismantle oven.";
	
	//Visual animations
	const string ANIMATION_ASHES 			= "Ashes";
	const string ANIMATION_KINDLING			= "Kindling";
	const string ANIMATION_STICKS			= "Sticks";
	const string ANIMATION_WOOD 			= "Wood";
	const string ANIMATION_BURNT_WOOD 		= "BurntWood";
	const string ANIMATION_STONE			= "Stone";
	const string ANIMATION_STONES 			= "StonesCircle";
	const string ANIMATION_TRIPOD 			= "Tripod";
	const string ANIMATION_OVEN 			= "Oven";
	const string ANIMATION_INVENTORY	 	= "Inventory";
	const string ANIMATION_COOKWARE_HANDLE 	= "handleRotate";
	const string ANIMATION_CAULDRON_HANDLE 	= "handle1Rotate";

	
	//Visual textures and materials
	const string MATERIAL_FIREPLACE_GLOW 		= "dz\\gear\\cooking\\data\\stoneground.rvmat";
	const string MATERIAL_FIREPLACE_NOGLOW 		= "dz\\gear\\cooking\\data\\stonegroundnoemit.rvmat";
	
	//Attachment types
	//Fuel
	typename ATTACHMENT_STICKS			= WoodenStick;
	typename ATTACHMENT_FIREWOOD		= Firewood;
	//Kindling
	typename ATTACHMENT_RAGS 					= Rag;
	typename ATTACHMENT_BANDAGE 				= BandageDressing;
	typename ATTACHMENT_BOOK 					= ItemBook;
	typename ATTACHMENT_BARK_OAK 				= Bark_Oak;
	typename ATTACHMENT_BARK_BIRCH 				= Bark_Birch;
	typename ATTACHMENT_PAPER 					= Paper;
	typename ATTACHMENT_GIFTWRAP				= GiftWrapPaper;
	typename ATTACHMENT_PUNCHEDCARD				= PunchedCard;
	typename ATTACHMENT_EYEMASK_COLORBASE		= EyeMask_ColorBase;
	//Other
	typename ATTACHMENT_TRIPOD 			= Tripod;
	typename ATTACHMENT_COOKINGSTAND	= CookingStand;
	typename ATTACHMENT_STONES 			= Stone;
	typename ATTACHMENT_COOKING_POT 	= Pot;
	typename ATTACHMENT_FRYING_PAN 		= FryingPan;
	typename ATTACHMENT_CAULDRON	 	= Cauldron;
	//
	const string OBJECT_CLUTTER_CUTTER 	= "ClutterCutterFireplace";
	protected Object m_ClutterCutter;
	
	//area damage
	protected ref AreaDamageManager 	m_AreaDamage;
	
	//quantity
	protected float m_TotalEnergy;
	
	// Noise
	ref NoiseParams m_NoisePar;
	private bool m_CanNoise = true; // Flip every fireplace update to limit amount of noise generation
	
	// UniversalTemperatureSource
	protected ref UniversalTemperatureSource m_UTSource;
	protected ref UniversalTemperatureSourceSettings m_UTSSettings;
	protected ref UniversalTemperatureSourceLambdaFireplace m_UTSLFireplace;
	
	//================================================================
	// INIT / STORE LOAD-SAVE
	//================================================================
	//Constructor
	protected void FireplaceBase()
	{
		//STATIC: define kindling types
		if (!m_FireConsumableTypes)
		{
			m_FireConsumableTypes = new ref map<typename, ref FireConsumableType>();
			m_FireConsumableTypes.Insert(ATTACHMENT_RAGS, 				new FireConsumableType(ATTACHMENT_RAGS, 				14, 	true,	"Rags"));
			m_FireConsumableTypes.Insert(ATTACHMENT_BANDAGE, 			new FireConsumableType(ATTACHMENT_BANDAGE, 				14, 	true,	"MedicalBandage"));
			m_FireConsumableTypes.Insert(ATTACHMENT_BOOK, 				new FireConsumableType(ATTACHMENT_BOOK, 				36, 	true,	"Book"));
			m_FireConsumableTypes.Insert(ATTACHMENT_BARK_OAK, 			new FireConsumableType(ATTACHMENT_BARK_OAK, 			20, 	true,	"OakBark"));
			m_FireConsumableTypes.Insert(ATTACHMENT_BARK_BIRCH, 		new FireConsumableType(ATTACHMENT_BARK_BIRCH, 			14, 	true,	"BirchBark"));
			m_FireConsumableTypes.Insert(ATTACHMENT_PAPER, 				new FireConsumableType(ATTACHMENT_PAPER, 				10, 	true,	"Paper"));
			m_FireConsumableTypes.Insert(ATTACHMENT_GIFTWRAP, 			new FireConsumableType(ATTACHMENT_GIFTWRAP, 			10, 	true,	"GiftWrapPaper"));
			m_FireConsumableTypes.Insert(ATTACHMENT_PUNCHEDCARD,		new FireConsumableType(ATTACHMENT_PUNCHEDCARD, 			10, 	true,	"PunchedCard"));
			m_FireConsumableTypes.Insert(ATTACHMENT_EYEMASK_COLORBASE,	new FireConsumableType(ATTACHMENT_EYEMASK_COLORBASE, 	10, 	true,	"EyeMask_ColorBase"));
			
			//define fuel types
			m_FireConsumableTypes.Insert(ATTACHMENT_STICKS, 		new FireConsumableType( ATTACHMENT_STICKS, 		40, 	false,	"WoodenStick"));
			m_FireConsumableTypes.Insert(ATTACHMENT_FIREWOOD, 		new FireConsumableType( ATTACHMENT_FIREWOOD, 	100, 	false,	"Firewood"));
		}

		//calculate total energy
		CalcAndSetTotalEnergy();
		
		//define fuel / kindling items (fire consumables)
		m_FireConsumables = new ref map<ItemBase, ref FireConsumable>;
		
		//default burning parameters
		SetTemperatureLossMP( TEMPERATURE_LOSS_MP_DEFAULT );
		SetFuelBurnRateMP( FUEL_BURN_RATE_DEFAULT );
		
		//synchronized variables
		RegisterNetSyncVariableBool( "m_IsBurning" );
		RegisterNetSyncVariableBool( "m_HasAshes" );
		RegisterNetSyncVariableBool( "m_IsOven" );
		RegisterNetSyncVariableBool( "m_HasStoneCircle" );
		RegisterNetSyncVariableBool( "m_RoofAbove" );
		RegisterNetSyncVariableInt( "m_FireState", FireplaceFireState.NO_FIRE, FireplaceFireState.COUNT );
		RegisterNetSyncVariableBool( "m_IsSoundSynchRemote" );
		RegisterNetSyncVariableBool( "m_IsPlaceSound" );
		RegisterNetSyncVariableBool( "m_NoIgnite" );
		
		m_HalfExtents = vector.Zero;
	}
	
	protected void ~FireplaceBase()
	{
		DestroyAreaDamage();

		if (GetLightEntity())
		{
			GetLightEntity().FadeOut();
		}
	}

	override void EEInit()
	{
		super.EEInit();

		//refresh visual on init
		RefreshFireplaceVisuals();
		
		if (GetGame().IsServer() || !GetGame().IsMultiplayer())
		{
 			m_UTSSettings 					= new UniversalTemperatureSourceSettings();
			m_UTSSettings.m_AffectStat		= true;
			m_UTSSettings.m_ManualUpdate	= true;
			m_UTSSettings.m_TemperatureMin	= 0;
			m_UTSSettings.m_TemperatureMax	= PARAM_NORMAL_FIRE_TEMPERATURE;
			m_UTSSettings.m_TemperatureCap	= PARAM_MAX_TRANSFERED_TEMPERATURE;
			m_UTSSettings.m_RangeFull		= PARAM_FULL_HEAT_RADIUS;
			m_UTSSettings.m_RangeMax		= PARAM_HEAT_RADIUS;
			
			m_UTSLFireplace = new UniversalTemperatureSourceLambdaFireplace();
			m_UTSLFireplace.SetSmallFireplaceTemperatureMax(PARAM_SMALL_FIRE_TEMPERATURE);
			m_UTSLFireplace.SetNormalFireplaceTemperatureMax(PARAM_NORMAL_FIRE_TEMPERATURE);

			m_UTSource = new UniversalTemperatureSource(this, m_UTSSettings, m_UTSLFireplace);
		}		
	}
	
	override void EEItemAttached(EntityAI item, string slot_name)
	{
		super.EEItemAttached(item, slot_name);
		
		//cookware
		switch (item.Type())
		{
		case ATTACHMENT_CAULDRON:
		case ATTACHMENT_COOKING_POT:
		case ATTACHMENT_FRYING_PAN:
			SetCookingEquipment(ItemBase.Cast(item));
		break;
		}
	}

	override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner) 
	{
		super.OnItemLocationChanged(old_owner, new_owner);
		
		//refresh physics after location change (with delay)
		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Call(RefreshFireplacePhysics);
	}
	
	override void OnAttachmentRuined(EntityAI attachment)
	{
		switch (attachment.Type())
		{
		case ATTACHMENT_TRIPOD:
		case ATTACHMENT_COOKINGSTAND:
			int slot = InventorySlots.GetSlotIdFromString("CookingEquipment");
			EntityAI ent = GetInventory().FindAttachment(slot);
			if (ent)
			{
				switch (ent.Type())
				{
				case ATTACHMENT_COOKING_POT:
				case ATTACHMENT_CAULDRON:
				case ATTACHMENT_FRYING_PAN:
					vector direction = ent.GetDirection();
					float dot = vector.Dot(direction, vector.Forward);
					
					float angle = Math.Acos(dot);	
					if (direction[0] < 0)
					{
						angle = -angle;
					}
			
					float cos = Math.Cos(angle);
					float sin = Math.Sin(angle);
					GetInventory().DropEntityInBounds(InventoryMode.SERVER, this, ent, "2 0 2", angle, cos, sin);
				break;
				}
			}

			attachment.Delete();
		break;
		}
	}
	
	override void EEDelete(EntityAI parent)
	{
		super.EEDelete(parent);

		SetFireState(FireplaceFireState.NO_FIRE);

		// cleanup particles (for cases of leaving burning fplace and going back outside of network bubble)
		#ifndef SERVER
		StopAllParticlesAndSounds();
		#endif
	}	
		
	//on store save/load
	override void OnStoreSave( ParamsWriteContext ctx )
	{   
		super.OnStoreSave(ctx);

		//Save ashes state
		ctx.Write( m_HasAshes );
		
		//Save temperature loss MP
		ctx.Write( m_TemperatureLossMP );

		//Save fuel burn rate MP
		ctx.Write( m_FuelBurnRateMP );
		
		//Save burning state
		ctx.Write( m_IsBurning );
	}
	
	override bool OnStoreLoad( ParamsReadContext ctx, int version )
	{
		if ( !super.OnStoreLoad(ctx, version) )
			return false;

		//--- Fireplace data ---
		//Load ashes state
		if ( !ctx.Read( m_HasAshes ) )
		{
			m_HasAshes = false;			//set default
			return false;
		}
		
		//Load temperature loss MP
		if ( !ctx.Read( m_TemperatureLossMP ) )
		{
			m_TemperatureLossMP = 1.0;	//set default
			return false;
		}
		
		//Load fuel burn rate MP
		if ( !ctx.Read( m_FuelBurnRateMP ) )
		{
			m_FuelBurnRateMP = 1.0;		//set default
			return false;
		}
		
		//Load burning state, if true start fire
		if ( !ctx.Read( m_IsBurning ) )
		{
			m_IsBurning = false;		//set default
			return false;
		}
		//---
		
		return true;
	}
	
	override void AfterStoreLoad()
	{	
		super.AfterStoreLoad();
				
		Synchronize();
		
		//start fire
		if (IsBurning() )
		{
			if (GetGame() && GetGame().IsServer()) 
			{
				StartFire(true);			//will be auto-synchronized when starting fire
			}
		}		
	}		
	
	//================================================================
	// SYNCHRONIZATION
	//================================================================	
	void Synchronize()
	{
		if ( GetGame() && GetGame().IsServer() )
		{
			SetSynchDirty();
			
			if ( GetGame().IsMultiplayer() && GetGame().IsServer() )
			{
				//Refresh visuals (on server)
				GetGame().GetCallQueue( CALL_CATEGORY_GAMEPLAY ).Call( RefreshFireplaceVisuals );
			}
		}
	}
	
	override void OnVariablesSynchronized()
	{
		super.OnVariablesSynchronized();

		RefreshFireplaceVisuals();
		RefreshFireParticlesAndSounds(false);
		
		if (IsPlaceSound())
		{
			PlayPlaceSound();
		}
		
		if (IsBaseFireplace() && !IsOven())
		{
			if (m_IsBurning && !m_AreaDamage)
			{
				CreateAreaDamage();
			}
			else if (!m_IsBurning && m_AreaDamage)
			{
				DestroyAreaDamage();
			}
		}
	}
	
	//================================================================
	// BASE
	//================================================================
	
	//States
	//check fireplace types
	override bool IsFireplace()
	{
		return true;
	}
	
	bool IsBaseFireplace()
	{
		return false;
	}
	
	bool IsBarrelWithHoles()
	{
		return false;
	}
	
	bool IsFireplaceIndoor()
	{
		return false;
	}

	bool IsIndoorOven()
	{
		return false;
	}
	
	override bool CanHaveWetness()
	{
		return true;
	}
	
	override bool CanHaveTemperature()
	{
		return true;
	}
	
	//cooking equipment
	ItemBase GetCookingEquipment()
	{
		return m_CookingEquipment;
	}
	
	void SetCookingEquipment(ItemBase equipment)
	{
		m_CookingEquipment = equipment;
	}
	
	void ClearCookingEquipment(ItemBase pItem)
	{
		if (m_CookingProcess)
		{
			m_CookingProcess.TerminateCookingSounds(pItem);
		}

		SetCookingEquipment(null);
	}
	
	//! DEPRECATED
	void ClearCookingEquipment()
	{
		SetCookingEquipment(null);
	}

	bool DirectCookingSlotsInUse()
	{
		for (int i = 0; i < DIRECT_COOKING_SLOT_COUNT; i++)
		{
			if ( m_DirectCookingSlots[i] )
			{
				return true;
			}
		}
		return false;
	}

	bool SmokingSlotsInUse()
	{
		for (int i = 0; i < SMOKING_SLOT_COUNT; i++)
		{
			if ( m_SmokingSlots[i] )
			{
				return true;
			}
		}
		return false;
	}

	//! [DEPRECATED]
	void DestroyFireplace()
	{
		DeleteSafe();
	}
	
	override bool IsPrepareToDelete()
	{
		return IsEmpty() && !IsBurning() && !HasAshes();
	}
	
	override void EECargoOut(EntityAI item)
	{
		super.EECargoOut(item);

		CheckForDestroy();
	}
	
	//================================================================
	// VISUAL
	//================================================================
	//Fireplace visual
	void RefreshFireplaceVisuals()
	{
		if (IsHologram())
		{
			return;
		}
		
		// Light
		#ifndef SERVER
		if (IsBurning() ) 
		{
			//turn light on
			if (!GetLightEntity())
			{
				SetLightEntity(FireplaceLight.Cast(ScriptedLightBase.CreateLight(FireplaceLight, GetPosition(), 20)));
				GetLightEntity().AttachOnMemoryPoint(this, "light");
			}

			if (GetLightEntity() && GetLightEntity().GetBrightness() > 0)
			{
				// change brightness based on the distance of player to the fireplace
				Object player 	= GetGame().GetPlayer();
				float lightDist = m_LightDistance;

				if (IsOven())
				{
					lightDist = 50;
				}

				if (player)
				{
					if (vector.DistanceSq(player.GetPosition(), this.GetPosition()) > lightDist * lightDist)
					{
						GetLightEntity().FadeBrightnessTo(0, 5);
					}
					else
					{
						GetLightEntity().FadeBrightnessTo(FireplaceLight.m_FireplaceBrightness, 5);
					}
				}
				
				// The following solves an issue with the light point clipping through narrow geometry
				if (IsItemTypeAttached(ATTACHMENT_STONES) || IsBarrelWithHoles() || IsFireplaceIndoor())
				{
					GetLightEntity().SetInteriorMode();
				}
				else
				{
					GetLightEntity().SetExteriorMode();
				}
			}
		}
		else
		{
			//turn light off
			if (GetLightEntity())
			{
				GetLightEntity().FadeOut();
			}
		}
		#endif
		
		//set default burn parameters based on fireplace type
		if (IsBarrelWithHoles() || IsFireplaceIndoor() || IsIndoorOven() || IsOven())
		{
			SetFuelBurnRateMP(FUEL_BURN_RATE_OVEN);
			SetTemperatureLossMP(TEMPERATURE_LOSS_MP_OVEN);
		}
		else if (HasStoneCircle())
		{
			SetFuelBurnRateMP(FUEL_BURN_RATE_STONES);
			SetTemperatureLossMP(TEMPERATURE_LOSS_MP_STONES);
		}
		else
		{
			SetFuelBurnRateMP(FUEL_BURN_RATE_DEFAULT);
			SetTemperatureLossMP(TEMPERATURE_LOSS_MP_DEFAULT);
		}
		
		// Oven attachments
		if (IsOven())
		{
			//lock attachment slots
			if (!m_OvenAttachmentsLockState)
			{
				LockOvenAttachments(true);
			}
		}
		else
		{
			//unlock attachment slots
			if (m_OvenAttachmentsLockState)
			{
				LockOvenAttachments(false);
			}
		}
		
		//VISUAL STATES
		//Fuel state
		if ( GetGame().IsServer() ) // SetAnimationPhase should ideally be called on server only..
		{
			// Sticks state
			if ( IsItemTypeAttached( ATTACHMENT_STICKS ) )
				SetAnimationPhase( ANIMATION_STICKS, 0 );
			else
				SetAnimationPhase( ANIMATION_STICKS, 1 );
			
			// Firewood state
			if ( IsItemTypeAttached( ATTACHMENT_FIREWOOD ) )
			{
				if ( IsBurning() && HasAshes() )
				{
					SetAnimationPhase( ANIMATION_BURNT_WOOD, 0 ); // Because this might not be set under certain circumstances
					SetAnimationPhase( ANIMATION_WOOD, 1 );
				}
				
				if ( IsWet() || !IsBurning() )
				{
					SetAnimationPhase( ANIMATION_BURNT_WOOD, 1 );
					SetAnimationPhase( ANIMATION_WOOD, 0 );
				}
			}
			else
			{
				SetAnimationPhase( ANIMATION_WOOD, 1 );
				SetAnimationPhase( ANIMATION_BURNT_WOOD, 1 );		
			}	
				
			// Kindling state
			if ( GetKindlingCount() != 0 )
				SetAnimationPhase( ANIMATION_KINDLING, 0 );
			else
				SetAnimationPhase( ANIMATION_KINDLING, 1 );
	
			// Ashes state
			if ( HasAshes() )
				SetAnimationPhase( ANIMATION_ASHES, 0 );
			else
				SetAnimationPhase( ANIMATION_ASHES, 1 );

			// Stone variations
			if (HasStones())
			{
				if (HasStoneCircle())
				{
					SetAnimationPhase(ANIMATION_STONES, 0);
					SetAnimationPhase(ANIMATION_STONE, 1);
				}
				else if (IsOven())
				{
					SetAnimationPhase(ANIMATION_OVEN, 0);
					SetAnimationPhase(ANIMATION_STONE, 1);
				}
				else
				{
					//! single stone; everything else hidden
					SetAnimationPhase(ANIMATION_STONES, 1);
					SetAnimationPhase(ANIMATION_OVEN, 1);
					SetAnimationPhase(ANIMATION_STONE, 0);
				}
			}
			else
			{
				SetAnimationPhase(ANIMATION_STONE, 1); //! hide stones stack completely
			}
		}
		
		//refresh physics (with delay)
		GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Call(RefreshFireplacePhysics);
	}

	protected void SetBurntFirewood()
	{
		if ( GetGame().IsServer() && IsInAnimPhase( ANIMATION_WOOD ) )
		{
			SetAnimationPhase( ANIMATION_WOOD, 1 );
			SetAnimationPhase( ANIMATION_BURNT_WOOD, 0 );				
		}	
	}
	
	//Refresh fireplace object physics
	void RefreshFireplacePhysics();
	
	protected void RefreshFireParticlesAndSounds( bool force_refresh )
	{
		FireplaceFireState fire_state = GetFireState();
		
		if ( m_LastFireState != fire_state || force_refresh )
		{
			switch ( fire_state )
			{
				case FireplaceFireState.START_FIRE:
				{
					//particles
					ParticleFireStartStart();
		
					//sounds
					SoundFireStop();
					SoundFireLightStart();	
					break;
				}
				case FireplaceFireState.SMALL_FIRE:
				{
					//particles
					ParticleFireStartStop();
					
					ParticleSmallFireStart();
					
					if ( CanShowSmoke() ) 
						ParticleSmallSmokeStart();
					else
						ParticleSmallSmokeStop();
					
					ParticleNormalFireStop();
					ParticleNormalSmokeStop();
					
					ParticleSteamExtinguishingStop();
					
					//sounds
					SoundFireStop();
					SoundFireLightStart();
					break;
				}
				case FireplaceFireState.NORMAL_FIRE:
				{
					//particles
					ParticleFireStartStop();
					
					ParticleSmallFireStop();
					ParticleSmallSmokeStop();
					
					ParticleNormalFireStart();
					
					if ( CanShowSmoke() ) 
						ParticleNormalSmokeStart();
					else
						ParticleNormalSmokeStop();
					
					ParticleSteamExtinguishingStop();
		
					//sounds
					SoundFireStop();
					SoundFireHeavyStart();
					break;
				}
				case FireplaceFireState.END_FIRE:
				{
					//particles
					ParticleFireStartStop();
					
					ParticleSmallFireStop();
					ParticleSmallSmokeStop();
		
					ParticleNormalFireStop();
					ParticleNormalSmokeStop();
		
					ParticleFireEndStart();
					
					//sounds
					SoundFireStop();
					SoundFireNoFireStart();
					break;
				}
				case FireplaceFireState.EXTINGUISHING_FIRE:		//TODO add steam particles when extinguishing
				{
					//particles
					ParticleFireStartStop();
					
					ParticleSmallFireStop();
					ParticleSmallSmokeStop();
		
					ParticleNormalFireStop();
					ParticleNormalSmokeStop();	
		
					ParticleFireEndStop();
					
					ParticleSteamExtinguishingStart();
					
					//sounds
					SoundFireStop();
					SoundFireExtinguishingStart();
					break;			
				}
				case FireplaceFireState.EXTINGUISHED_FIRE:		//TODO add steam particles when fireplace is extinguished
				{
					//particles
					ParticleFireStartStop();
					
					ParticleSmallFireStop();
					ParticleSmallSmokeStop();
		
					ParticleNormalFireStop();
					ParticleNormalSmokeStop();	
		
					ParticleFireEndStop();
					
					ParticleSteamExtinguishingStop();
					
					if ( CanShowSmoke() ) 
						ParticleSteamEndStart();
					else
						ParticleSteamEndStop();
					
					//sounds
					SoundFireStop();
					SoundFireExtinguishedStart();
					SoundFireNoFireStart();
					break;
				}
				case FireplaceFireState.REIGNITED_FIRE:
				{
					//particles
					ParticleFireStartStart();
					
					ParticleSmallFireStop();
					ParticleSmallSmokeStop();
		
					ParticleNormalFireStop();
					ParticleNormalSmokeStop();	
		
					ParticleFireEndStop();
					
					ParticleSteamEndStop();
					
					//sounds
					SoundFireStop();
					break;
				}
				case FireplaceFireState.NO_FIRE:
				{
					//particles
					ParticleFireStartStop();
					
					ParticleSmallFireStop();
					ParticleSmallSmokeStop();
		
					ParticleNormalFireStop();
					ParticleNormalSmokeStop();	
		
					ParticleFireEndStop();
					
					ParticleSteamEndStop();
					ParticleSteamExtinguishingStop();
					
					//sounds
					SoundFireStop();
					break;
				}
			}
			
			m_LastFireState = fire_state;
		}
	}
	
	protected void StopAllParticlesAndSounds()
	{
		// go through all fireplace particles
		if ( m_ParticleFireStart )
			StopParticle( m_ParticleFireStart );
		if ( m_ParticleSmallFire )
			StopParticle( m_ParticleSmallFire );
		if ( m_ParticleNormalFire )
			StopParticle( m_ParticleNormalFire );
		if ( m_ParticleSmallSmoke )
			StopParticle( m_ParticleSmallSmoke );
		if ( m_ParticleNormalSmoke )
			StopParticle( m_ParticleNormalSmoke );
		if ( m_ParticleFireEnd )
			StopParticle( m_ParticleFireEnd );
		if ( m_ParticleSteamEnd )
			StopParticle( m_ParticleSteamEnd );
		if ( m_ParticleSteamExtinguishing )
			StopParticle( m_ParticleSteamExtinguishing );

		// go through all fireplace sounds
		if ( m_SoundFireLoop )
			StopSoundSet( m_SoundFireLoop );
		if ( m_SoundFire )
			StopSoundSet( m_SoundFire );
	}

	bool CanShowSmoke()
	{
		return true;
	}
	
	//Fireplace fire intensity
	void RefreshFireState()
	{
		float temperature = GetTemperature();
		
		//if it's burning
		if (IsBurning())
		{
			//Start fire
			if (temperature <= PARAM_MIN_FIRE_TEMPERATURE)
			{
				if ( GetFireState() != FireplaceFireState.START_FIRE )
				{
					SetFireState( FireplaceFireState.START_FIRE );
				}
			}
			//Small fire
			else if (temperature <= PARAM_SMALL_FIRE_TEMPERATURE)
			{
				if ( GetFireState() != FireplaceFireState.SMALL_FIRE )
				{
					SetFireState( FireplaceFireState.SMALL_FIRE );
				}
			}
			//Normal fire
			else if (temperature > PARAM_SMALL_FIRE_TEMPERATURE)
			{
				if ( GetFireState() != FireplaceFireState.NORMAL_FIRE )
				{
					SetFireState( FireplaceFireState.NORMAL_FIRE );
				}
			}			
		}
	}

	//================================================================
	// PARTICLES & SOUNDS
	//================================================================
	//returns true if particle started, false if not
	protected bool PlayParticle( out Particle particle, int particle_type, vector pos, bool worldpos = false )
	{
		if ( !particle && GetGame() && ( !GetGame().IsDedicatedServer() ) )
		{
			if ( !worldpos )
			{
				particle = ParticleManager.GetInstance().PlayOnObject( particle_type, this, pos );
			}
			else
			{
				particle = ParticleManager.GetInstance().PlayInWorld( particle_type, pos );
			}
			
			return true;
		}
		
		return false;
	}
	
	//returns true if particle stopped, false if not
	protected bool StopParticle( out Particle particle )
	{
		if ( particle && GetGame() && ( !GetGame().IsDedicatedServer() ) )
		{
			particle.Stop();
			particle = NULL;
			
			return true;
		}
		
		return false;
	}
	
	//start fire
	protected void ParticleFireStartStart()
	{
		if ( IsOven() )
		{
			PlayParticle( m_ParticleFireStart, PARTICLE_OVEN_FIRE_START, GetFireEffectPosition() );
		}
		else
		{
			PlayParticle( m_ParticleFireStart, PARTICLE_FIRE_START, GetFireEffectPosition() );
		}
	}
	
	protected void ParticleFireStartStop()
	{
		StopParticle( m_ParticleFireStart );
	}
	
	//small fire
	protected void ParticleSmallFireStart()
	{
		if ( IsOven() )
		{
			PlayParticle( m_ParticleSmallFire, PARTICLE_OVEN_FIRE, GetFireEffectPosition() );
		}
		else
		{
			PlayParticle( m_ParticleSmallFire, PARTICLE_SMALL_FIRE, GetFireEffectPosition() );	
		}
	}
	
	protected void ParticleSmallFireStop()
	{
		StopParticle( m_ParticleSmallFire );
	}	
	
	//normal fire
	protected void ParticleNormalFireStart()
	{
		if ( IsOven() )
		{
			PlayParticle( m_ParticleNormalFire, PARTICLE_OVEN_FIRE, GetFireEffectPosition() );
		}
		else
		{
			PlayParticle( m_ParticleNormalFire, PARTICLE_NORMAL_FIRE, GetFireEffectPosition() );
		}
	}
	
	protected void ParticleNormalFireStop()
	{
		StopParticle( m_ParticleNormalFire );
	}
	
	//small smoke
	protected void ParticleSmallSmokeStart()
	{
		PlayParticle( m_ParticleSmallSmoke, PARTICLE_SMALL_SMOKE, GetSmokeEffectPosition() );
				
		//calculate air resistance
		float actual_height;
		if ( GetCeilingHeight( actual_height ) )
		{
			float air_resistance = GetAirResistanceForSmokeParticles( actual_height );
			
			//alter smoke height
			m_ParticleSmallSmoke.SetParameter( -1, EmitorParam.AIR_RESISTANCE, air_resistance );
		}
					
		if ( IsRoofAbove() )
		{
			m_ParticleSmallSmoke.SetParameter( -1, EmitorParam.WIND, false );
		}
	}
	
	protected void ParticleSmallSmokeStop()
	{
		StopParticle( m_ParticleSmallSmoke );
	}
	
	//normal smoke
	protected void ParticleNormalSmokeStart()
	{
		PlayParticle( m_ParticleNormalSmoke, PARTICLE_NORMAL_SMOKE, GetSmokeEffectPosition() );
		
		//calculate air resistance
		float actual_height;
		if ( GetCeilingHeight( actual_height ) )
		{		
			float air_resistance = GetAirResistanceForSmokeParticles( actual_height );
			
			//alter smoke height
			m_ParticleNormalSmoke.SetParameter( -1, EmitorParam.AIR_RESISTANCE, air_resistance );
		}
		
		if ( IsRoofAbove() )
		{
			m_ParticleNormalSmoke.SetParameter( -1, EmitorParam.WIND, false );
		}
	}
	
	protected void ParticleNormalSmokeStop()
	{
		StopParticle( m_ParticleNormalSmoke );
	}
	
	//fire end
	protected void ParticleFireEndStart()
	{
		if ( IsOven() )
		{
			PlayParticle( m_ParticleFireEnd, PARTICLE_OVEN_FIRE_END, GetFireEffectPosition() );
		}
		else
		{
			PlayParticle( m_ParticleFireEnd, PARTICLE_FIRE_END, GetFireEffectPosition() );
		}
	}
	
	protected void ParticleFireEndStop()
	{
		StopParticle( m_ParticleFireEnd );
	}
	
	protected void ParticleFireWindyNoIgniteStart()
	{
		if ( IsOven() )
		{
			PlayParticle( m_ParticleFireEnd, PARTICLE_OVEN_FIRE_END, GetFireEffectPosition() );
		}
		else
		{
			PlayParticle( m_ParticleFireEnd, PARTICLE_NO_IGNITE_WIND, GetFireEffectPosition() );
		}
	}
	
	//steam extinguishing
	protected void ParticleSteamExtinguishingStart()
	{
		PlayParticle( m_ParticleSteamExtinguishing, PARTICLE_STEAM_EXTINGUISHING, GetFireEffectPosition() );
	}
	
	protected void ParticleSteamExtinguishingStop()
	{
		StopParticle(m_ParticleSteamExtinguishing);
	}	

	//steam end
	protected void ParticleSteamEndStart()
	{
		PlayParticle( m_ParticleSteamEnd, PARTICLE_STEAM_END, GetFireEffectPosition() );
	}
	
	protected void ParticleSteamEndStop()
	{
		StopParticle( m_ParticleSteamEnd );
	}
	
	protected void ParticleWetNoIgniteStart()
	{
		PlayParticle( m_ParticleSteamEnd, PARTICLE_STEAM_END, GetFireEffectPosition() );
	}
	
	protected void ParticleWetNoIgniteStop()
	{
		StopParticle( m_ParticleSteamEnd );
	}

	bool GetCeilingHeight( out float actual_height )
	{
		vector from = this.GetPosition();
		vector to = this.GetPosition();
		from[1] = from[1] + 1.0;
		to[1] = to[1] + MIN_CEILING_HEIGHT;
		vector contactPos;
		vector contactDir;
		int contactComponent;
		
		bool hit = DayZPhysics.RaycastRV( from, to, contactPos, contactDir, contactComponent, NULL, NULL, this );
		actual_height = vector.Distance( from, contactPos ) + 1.0;
		
		return hit;
	}
	
	float GetAirResistanceForSmokeParticles( float actual_height )
	{
		float air_res;
		actual_height = Math.Clamp( actual_height, 0, 36 );
		
		air_res = ( 6 - actual_height ) * 0.33;
		air_res = Math.Clamp( air_res, 0, 2 );
		
		return air_res;
	}
	
	//Particle Positions
	//Get local fire and smoke effect position
	protected vector GetFireEffectPosition()
	{
		return Vector( 0, 0.05, 0 );
	}
	
	protected vector GetSmokeEffectPosition()
	{
		return Vector( 0, 0.05, 0 );
	}

	//================================================================
	// SOUNDS
	//================================================================
	//Burning
	//Start
	protected void SoundFireLightStart()
	{
		PlaySoundSetLoop( m_SoundFireLoop, SOUND_FIRE_LIGHT, 1.0, 1.0 );
	}
	
	protected void SoundFireHeavyStart()
	{
		PlaySoundSetLoop( m_SoundFireLoop, SOUND_FIRE_HEAVY, 1.0, 2.0 );
	}

	protected void SoundFireNoFireStart()
	{
		PlaySoundSetLoop( m_SoundFireLoop, SOUND_FIRE_NO_FIRE, 2.0, 2.0 );
	}
	
	protected void SoundFireExtinguishedStart()
	{
		PlaySoundSet( m_SoundFire, SOUND_FIRE_EXTINGUISHED, 0.1, 0.1 );
	}	
	
	protected void SoundFireWetNoIgniteStart()
	{
		PlaySoundSet( m_SoundFire, SOUND_FIRE_EXTINGUISHED, 0.1, 0.1 );
	}	

	protected void SoundFireExtinguishingStart()
	{
		PlaySoundSetLoop( m_SoundFireLoop, SOUND_FIRE_EXTINGUISHING, 1.0, 0.5 );
	}
	
	protected void SoundFireWindyNoIgniteStart()
	{
		PlaySoundSet( m_SoundFire, "ExtinguishByWind_SoundSet", 0, 0 );
	}	
	
	//Stop
	protected void SoundFireStop()
	{
		StopSoundSet( m_SoundFireLoop );
	}
	
	//================================================================
	// FUEL / KINDLING
	//================================================================
	//Add to fire consumables
	protected void AddToFireConsumables(ItemBase item)
	{
		m_FireConsumables.Insert(item, new FireConsumable(item, GetFireConsumableTypeEnergy(item)));		
		CalcAndSetQuantity();
	}

	protected float GetFireConsumableTypeEnergy(ItemBase item)
	{
		FireConsumableType fireConsumableType = m_FireConsumableTypes.Get(item.Type());
		if (!fireConsumableType)
		{
			//! support for inherited classes; second pass of lookup inside FireConsumableType
			int count = m_FireConsumableTypes.Count();
			for (int i = 0; i < count; ++i)
			{
				if (item.IsInherited(m_FireConsumableTypes.GetKey(i)))
					fireConsumableType = m_FireConsumableTypes.GetElement(i);
			}
		}
		
		if (fireConsumableType)
			return fireConsumableType.GetEnergy();

		return 0;
	}

	//Remove from fire consumables
	protected void RemoveFromFireConsumables(FireConsumable fire_consumable)
	{
		if (fire_consumable)
		{
			m_FireConsumables.Remove(fire_consumable.GetItem());
			delete fire_consumable;
		}
		
		CalcAndSetQuantity();
	}
	
	protected FireConsumable GetFireConsumableByItem( ItemBase item )
	{
		return m_FireConsumables.Get(item);
	}

	//Set fuel / kindling to consume
	//Sets the item with the lowest energy value as item that will be consumed next
	//Returns reference to set fire consumable
	protected FireConsumable SetItemToConsume()
	{
		if (m_FireConsumables.Count() == 0)
		{
			m_ItemToConsume = null;
		}
		else
		{
			for (int i = 0; i < m_FireConsumables.Count(); ++i)
			{
				ItemBase key = m_FireConsumables.GetKey(i);
				FireConsumable fireConsumable = m_FireConsumables.Get(key);
				
				if (i == 0)
				{
					m_ItemToConsume = fireConsumable;
				}
				else
				{
					if (fireConsumable.GetEnergy() < m_ItemToConsume.GetEnergy())
					{
						m_ItemToConsume = fireConsumable;
					}	
				}
			}
		}
		
		//refresh visual
		RefreshFireplaceVisuals();

		return m_ItemToConsume;
	}

	protected FireConsumable GetItemToConsume()
	{
		return m_ItemToConsume;
	}

	//Spend item that is used as consumable for fire (fuel, kindling)
	//if 'amount == 0', the whole quantity will be consumed (quantity -= 1 )
	//debug
	//int m_debug_fire_consume_time = 0;
	protected void SpendFireConsumable(float amount)
	{
		//spend item
		FireConsumable fireConsumable = GetItemToConsume();
		
		if (!fireConsumable)
		{
			//Set new item to consume
			fireConsumable = SetItemToConsume();
		}
		
		if (fireConsumable)
		{
			ItemBase item = fireConsumable.GetItem();
			fireConsumable.SetRemainingEnergy(fireConsumable.GetRemainingEnergy() - amount);
			
			if (fireConsumable.GetRemainingEnergy() <= 0 || amount == 0)
			{
				//set ashes
				if (!HasAshes())
				{
					SetAshesState(true);
				}	
				
				if (item.IsAnyInherited({ItemBook, Paper, GiftWrapPaper, EyeMask_ColorBase}))
				{
					RemoveFromFireConsumables(fireConsumable);
					item.Delete();
				}
				else
				{
					//if there is nothing left, delete and remove old consumable, set new fire consumable
					if (item.GetQuantity() <= 1)
					{
						//remove item from fuel items
						RemoveFromFireConsumables(fireConsumable);
					}
					else
					{
						fireConsumable.SetRemainingEnergy(fireConsumable.GetEnergy());
					}
					
					item.AddQuantity(-1);
					SetItemToConsume();
				}
			}
		}
		
		CalcAndSetQuantity();
	}

	//! Returns count of all kindling type items (define in 'm_KindlingTypes') attached to fireplace
	protected int GetKindlingCount()
	{
		int attachmentsCount = GetInventory().AttachmentCount();
		int kindlingCount = 0;
		
		for (int i = 0; i < attachmentsCount; ++i)
		{
			ItemBase item = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(i));
			
			if (IsKindling(item))
				kindlingCount++;
		}
		
		return kindlingCount;
	}

	//! Returns count of all fuel type items (define in 'm_FuelTypes') attached to fireplace
	protected int GetFuelCount()
	{
		int attachmentsCount = GetInventory().AttachmentCount();
		int fuelCount = 0;
		
		for (int i = 0; i < attachmentsCount; ++i)
		{
			ItemBase item = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(i));
			if (IsFuel(item))
				fuelCount++;
		}
		
		return fuelCount;
	}

	//! Returns if item attached to fireplace is kindling
	protected bool IsKindling(ItemBase item)
	{
		FireConsumableType fireConsumableType = m_FireConsumableTypes.Get(item.Type());
		if (!fireConsumableType)
		{
			//! support for inherited classes; second pass of lookup inside FireConsumableType
			int count = m_FireConsumableTypes.Count();
			for (int i = 0; i < count; ++i)
			{
				if (item.IsInherited(m_FireConsumableTypes.GetKey(i)))
					fireConsumableType = m_FireConsumableTypes.GetElement(i);
			}
		}

		return fireConsumableType && fireConsumableType.IsKindling();
	}

	//! Returns if item attached to fireplace is fuel
	protected bool IsFuel(ItemBase item)
	{
		FireConsumableType fireConsumableType = m_FireConsumableTypes.Get(item.Type());
		if (!fireConsumableType)
		{
			//! support for inherited classes; second pass of lookup inside FireConsumableType
			int count = m_FireConsumableTypes.Count();
			for (int i = 0; i < count; ++i)
			{
				if (item.IsInherited(m_FireConsumableTypes.GetKey(i)))
					fireConsumableType = m_FireConsumableTypes.GetElement(i);
			}
		}

		return fireConsumableType && !fireConsumableType.IsKindling();
	}

	//Has attachments of given type
	bool IsItemTypeAttached(typename item_type)
	{
		return GetAttachmentByType(item_type) != null;
	}

	//Has attachments of required quantity
	bool IsItemAttachedQuantity(typename item_type, float quantity)
	{
		ItemBase item = ItemBase.Cast(GetAttachmentByType(item_type));
		
		return item.GetQuantity() >= quantity;
	}

	//Has last attached item
	bool HasLastAttachment()
	{
		return GetInventory().AttachmentCount() == 1;
	}

	//Has last fuel/kindling attached
	bool HasLastFuelKindlingAttached()
	{
		return (GetFuelCount() + GetKindlingCount()) == 1;
	}

	
	//================================================================
	// FIRE STATE
	//================================================================
	//Is fireplace burning?
	bool IsBurning()
	{
		return m_IsBurning;
	}
	
	//Set burning state
	protected void SetBurningState(bool is_burning)
	{
		m_IsBurning = is_burning;
	}

	//Are ashes present in fireplace?
	bool HasAshes()
	{
		return m_HasAshes;
	}

	//Set ashes state
	protected void SetAshesState(bool has_ashes)
	{
		m_HasAshes = has_ashes;

		if (m_HasAshes)
		{
			SetBurntFirewood();
		}
	}

	//Is in oven state
	bool IsOven()
	{
		return m_IsOven;
	}		
	bool HasStoneCircle()
	{
		return m_HasStoneCircle;
	}
	
	bool HasStones()
	{
		EntityAI attached_item = GetAttachmentByType(ATTACHMENT_STONES);

		return attached_item && attached_item.GetQuantity() > 0;
	}
	
	int GetAttachedStonesCount()
	{
		if (HasStones())
		{
			return GetAttachmentByType(ATTACHMENT_STONES).GetQuantity();
		}
		
		return 0;
	}

	void SetOvenState( bool is_oven )
	{
		if ( m_IsOven != is_oven )
		{
			m_IsOven = is_oven;
			m_RoofAbove = is_oven;
			
			GetInventory().SetSlotLock( InventorySlots.GetSlotIdFromString("Stones") , is_oven);
			
			Synchronize();
		}
	}
	void SetStoneCircleState( bool has_stonecircle )
	{
		if ( m_HasStoneCircle != has_stonecircle )
		{
			m_HasStoneCircle = has_stonecircle;
			
			GetInventory().SetSlotLock( InventorySlots.GetSlotIdFromString("Stones") , has_stonecircle);
			
			Synchronize();
		}
	}
	
	//Temperature loss MP
	protected float GetTemperatureLossMP()
	{
		return m_TemperatureLossMP;
	}	
	
	protected void SetTemperatureLossMP( float value )
	{
		m_TemperatureLossMP = value;
	}
	
	//Fuel burn rate MP
	protected float GetFuelBurnRateMP()
	{
		return m_FuelBurnRateMP;
	}	
	
	protected void SetFuelBurnRateMP( float value )
	{
		m_FuelBurnRateMP = value;
	}
	
	//Get fire state 
	protected int GetFireState()
	{
		return m_FireState;
	}

	//Sets fire state
	protected void SetFireState( FireplaceFireState state )
	{
		if ( m_FireState != state )
		{
			m_FireState = state;
			
			Synchronize();
		}
	}
		
	void SetExtinguishingState()
	{
		SetFireState( FireplaceFireState.EXTINGUISHING_FIRE );
	}

	//================================================================
	// FIRE PROCESS
	//================================================================
	
	//Start the fire process
	// 1. start heating
	// 2. heating
	// 3. stop heating
	void StartFire(bool force_start = false)
	{
		//stop cooling process if active
		if (m_CoolingTimer)
		{
			m_CoolingTimer.Stop();
			m_CoolingTimer = null;
		}
		
		//set under roof flag (was fire ignited under roof?)
		if (MiscGameplayFunctions.IsUnderRoof(this))
			m_RoofAbove = true;
		
		//start fire
		if (!IsBurning() || force_start)
		{
			SetItemToConsume();
			SetBurningState(true);
			m_UTSource.SetActive(true);
			StartHeating();
			
			//Update navmesh
			if (!IsFireplaceIndoor())
			{
				SetAffectPathgraph(false, true);
				GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(GetGame().UpdatePathgraphRegionByObject, 100, false, this);
			}
		}
		
		Synchronize();
	}

	//Start heating
	protected void StartHeating()
	{
		//visual
		SetObjectMaterial(0, MATERIAL_FIREPLACE_GLOW);
		
		if (IsWindy() && !IsRoofAbove() && !IsOven() && !IsBarrelWithHoles())
		{
			StopFire();
			return;
		}
		
		if (GetWet() > PARAM_BURN_WET_THRESHOLD)
		{
			StopFire(FireplaceFireState.EXTINGUISHED_FIRE);
			return;
		}
		
		//create area damage
		if (IsBaseFireplace() && !IsOven())
			CreateAreaDamage();
		
		m_HeatingTimer = new Timer(CALL_CATEGORY_GAMEPLAY);
		m_HeatingTimer.Run(TIMER_HEATING_UPDATE_INTERVAL, this, "Heating", null, true);
		
		//Setup the noise parameters on fire start
		m_NoisePar = new NoiseParams();
		if (IsRoofAbove() || IsOven() || IsFireplaceIndoor()) //If we have a roof, we are probably inside
			m_NoisePar.LoadFromPath("CfgVehicles FireplaceBase NoiseFireplaceSpecial");
		else
			m_NoisePar.LoadFromPath("CfgVehicles FireplaceBase NoiseFireplaceBase");
	}

	//Do heating
	protected void Heating()
	{
		float temperature = GetTemperature();
		float temperature_modifier = 0;
		
		//check burning conditions
		if (GetWet() > PARAM_BURN_WET_THRESHOLD)
		{
			StopFire(FireplaceFireState.EXTINGUISHED_FIRE);
			return; 
		}
		else
		{
			if (m_FireConsumables.Count() == 0)
			{
				StopFire();
				return; 				
			}
		}
		
		//spend actual fire consumable
		float amount = PARAM_FIRE_CONSUM_RATE_AMOUNT * GetFuelBurnRateMP() * TIMER_HEATING_UPDATE_INTERVAL;
		SpendFireConsumable(amount);
		
		//set wetness if raining and alter temperature modifier (which will lower temperature increase because of rain)
		float rain = GetGame().GetWeather().GetRain().GetActual();
		if (rain >= PARAM_BURN_WET_THRESHOLD && !IsRoofAbove())
		{
			//set wet to fireplace
			AddWetnessToFireplace(PARAM_WET_INCREASE_COEF * rain);
			
			//set temperature modifier
			temperature_modifier = PARAM_TEMPERATURE_INCREASE * rain;
		}
		//subtract wetness when heating and not raining above
		else
		{
			AddWetnessToFireplace(-PARAM_WET_HEATING_DECREASE_COEF);
		}

		// temperature via UniversalTemperatureSource
		m_UTSLFireplace.SetFuelCount(GetFuelCount());
		temperature = GetTemperature() + (PARAM_TEMPERATURE_INCREASE * TIMER_HEATING_UPDATE_INTERVAL) - temperature_modifier;
		m_UTSLFireplace.SetCurrentTemperature(temperature);
		m_UTSource.Update(m_UTSSettings, m_UTSLFireplace);
		
		//check fire state
		if ( GetFireState() != FireplaceFireState.EXTINGUISHING_FIRE )
		{
			RefreshFireState();
		}
		
		//damage cargo items
		BurnItemsInFireplace();
		
		//manage cooking equipment (this applies only for case of cooking pot on a tripod)
		if (HasCookingStand() && m_CookingEquipment)
		{
			float cook_equip_temp = m_CookingEquipment.GetTemperature();
			
			if ( cook_equip_temp >= PARAM_COOKING_TEMP_THRESHOLD )
			{
				//start cooking
				CookWithEquipment();
			}
			
			//DEBUG
			/*
			PlayerBase player = ( PlayerBase ) GetGame().GetPlayer();
			string s_message = "cooking equipment temp = " + ftoa(cook_equip_temp) + " | PARAM_COOKING_TEMP_THRESHOLD = " + ftoa(PARAM_COOKING_TEMP_THRESHOLD);
			if (player != NULL) {player.MessageAction (s_message);}
			Print ( s_message );
			*/
			//set temperature to cooking equipment
			cook_equip_temp = cook_equip_temp + PARAM_COOKING_EQUIP_TEMP_INCREASE;
			if ( temperature <= PARAM_SMALL_FIRE_TEMPERATURE )
			{
				cook_equip_temp = Math.Clamp ( cook_equip_temp, PARAM_ITEM_HEAT_MIN_TEMP, PARAM_SMALL_FIRE_TEMPERATURE );
			}
			else
			{
				cook_equip_temp = Math.Clamp ( cook_equip_temp, PARAM_ITEM_HEAT_MIN_TEMP, PARAM_COOKING_EQUIP_MAX_TEMP );
			}

			m_CookingEquipment.SetTemperature( cook_equip_temp );
		}

		float cook_item_temp;
		int i;
		// manage cooking on direct cooking slots
		if ( DirectCookingSlotsInUse() )
		{
			for ( i = 0; i < DIRECT_COOKING_SLOT_COUNT; i++ )
			{
				if ( m_DirectCookingSlots[i] )
				{
					cook_item_temp = m_DirectCookingSlots[i].GetTemperature();
					if ( cook_item_temp >= PARAM_COOKING_TEMP_THRESHOLD )
					{
						CookOnDirectSlot( m_DirectCookingSlots[i], cook_item_temp, temperature );
					}
				}
			}
		}

		// manage smoking slots
		if ( SmokingSlotsInUse() )
		{
			for ( i = 0; i < SMOKING_SLOT_COUNT; i++ )
			{
				if ( m_SmokingSlots[i] )
				{
					SmokeOnSmokingSlot( m_SmokingSlots[i], cook_item_temp, temperature );
				}
			}
		}
		
		//Make noise for AI, only at night
		if ( GetGame().GetWorld().IsNight() && m_CanNoise )
		{
			NoiseSystem noise = GetGame().GetNoiseSystem();
			if ( noise && m_NoisePar )
			{
				noise.AddNoisePos( this, GetPosition(), m_NoisePar);
			}
			m_CanNoise = false;
		}
		else
			m_CanNoise = true;
		
		Synchronize();
	}

	//Stop the fire process
	// 1. start cooling
	// 2. cooling
	// 3. stop cooling
	void StopFire( FireplaceFireState fire_state = FireplaceFireState.END_FIRE )
	{
		StopHeating();
		SpendFireConsumable(0);
		SetBurningState(false);
		StartCooling();
		SetFireState(fire_state);
		
		//Update navmesh
		if (!IsFireplaceIndoor())
		{
			SetAffectPathgraph(false, false);
			GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(GetGame().UpdatePathgraphRegionByObject, 100, false, this);
		}
		
		Synchronize();
	}
	
	protected void StopHeating()
	{
		if (!m_HeatingTimer)
			return;
		
		m_HeatingTimer.Stop();
		m_HeatingTimer = null;
	}	

	protected void StartCooling()
	{
		if (m_HeatingTimer)
		{
			m_HeatingTimer.Stop();
			m_HeatingTimer = null;
		}
		
		//Start cooling
		m_CoolingTimer = new Timer(CALL_CATEGORY_GAMEPLAY);
		m_CoolingTimer.Run(TIMER_COOLING_UPDATE_INTERVAL, this, "Cooling", null, true);
	}

	protected void Cooling()
	{
		float wetness = GetWet();
		float temperature = GetTemperature();
		float temperature_modifier = 0;
		
		if (!IsBurning() && temperature >= 10)
		{
			//check wetness
			//set wetness if raining and alter temperature modifier (which will lower temperature increase because of rain)
			float rain = GetGame().GetWeather().GetRain().GetActual();
			if (IsRainingAbove() && !IsRoofAbove())
			{
				//set wet to fireplace
				AddWetnessToFireplace(PARAM_WET_INCREASE_COEF * rain);

				//set temperature modifier
				temperature_modifier = temperature_modifier + ( PARAM_TEMPERATURE_DECREASE * rain );
			}
			else //subtract wetness
			{
				AddWetnessToFireplace(-PARAM_WET_COOLING_DECREASE_COEF);
			}
			
			//calculate already obtained wetness (e.g. extinguished by water)
			temperature_modifier = temperature_modifier + ( PARAM_TEMPERATURE_DECREASE * wetness );

			// temperature via UniversalTemperatureSource
			m_UTSLFireplace.SetFuelCount(GetFuelCount());
			temperature = GetTemperature() - (PARAM_TEMPERATURE_DECREASE * TIMER_COOLING_UPDATE_INTERVAL) - temperature_modifier;
			m_UTSLFireplace.SetCurrentTemperature(temperature);
			m_UTSource.Update(m_UTSSettings, m_UTSLFireplace);
			
			//damage cargo items
			BurnItemsInFireplace();
			
			//cook with equipment if temperature of equipment is still high
			if ( m_CookingEquipment )
			{
				float cook_equip_temp = m_CookingEquipment.GetTemperature();
				
				if ( cook_equip_temp >= PARAM_COOKING_TEMP_THRESHOLD )
				{
					//cook
					CookWithEquipment();
				}
			}

			float cook_item_temp;
			int i;

			// manage cooking on direct cooking slots
			if ( DirectCookingSlotsInUse() )
			{
				for ( i = 0; i < DIRECT_COOKING_SLOT_COUNT; i++ )
				{
					if ( m_DirectCookingSlots[i] )
					{
						cook_item_temp = m_DirectCookingSlots[i].GetTemperature();
						if ( cook_item_temp >= PARAM_COOKING_TEMP_THRESHOLD )
						{
							CookOnDirectSlot( m_DirectCookingSlots[i], cook_item_temp, temperature );
						}
					}
				}
			}

			// manage smoking slots
			if ( SmokingSlotsInUse() )
			{
				for ( i = 0; i < SMOKING_SLOT_COUNT; i++ )
				{
					if ( m_SmokingSlots[i] )
					{
						SmokeOnSmokingSlot( m_SmokingSlots[i], cook_item_temp, temperature );
					}
				}
			}

			//Debug
			//PlayerBase player = ( PlayerBase ) GetGame().GetPlayer();
			//if (player != NULL) {player.MessageAction ( temperature.ToString() );}
		}
		else
		{
			//stop cooling
			if (Math.AbsFloat(temperature) < 10)
			{
				StopCooling();
				m_UTSource.SetActive(false);
			}
		}
	}

	protected void StopCooling()
	{
		//stop all fire visuals
		SetFireState(FireplaceFireState.NO_FIRE);
		SetObjectMaterial(0, MATERIAL_FIREPLACE_NOGLOW);
		
		//Stop cooling
		m_CoolingTimer.Stop();
		m_CoolingTimer = NULL;
		
		//destroy area damage
		DestroyAreaDamage();

		//remove cookware audio visuals
		if (GetCookingEquipment())
		{
			Bottle_Base cooking_pot = Bottle_Base.Cast(GetCookingEquipment());
			if ( cooking_pot )
				cooking_pot.RemoveAudioVisualsOnClient();
		}

		if (DirectCookingSlotsInUse())
		{
			for ( int i = 0; i < DIRECT_COOKING_SLOT_COUNT; i++ )
			{
				if ( m_DirectCookingSlots[i] )
				{
					Bottle_Base cookingpot = Bottle_Base.Cast( m_DirectCookingSlots[i] );
					if ( cookingpot )
						cookingpot.RemoveAudioVisualsOnClient();

					FryingPan fryingpan = FryingPan.Cast( m_DirectCookingSlots[i] );
					if ( fryingpan )
						fryingpan.RemoveAudioVisualsOnClient();

					Edible_Base itsfood = Edible_Base.Cast( m_DirectCookingSlots[i] );
					if ( itsfood )
						itsfood.MakeSoundsOnClient( false );
				}
			}
		}
	}
	
	//================================================================
	// COOKING
	//================================================================
	protected void CookWithEquipment()
	{
		if (m_CookingProcess == null)
		{
			m_CookingProcess = new Cooking();
		}

		m_CookingProcess.CookWithEquipment(m_CookingEquipment);
	}

	Cooking GetCookingProcess()
	{
		if (m_CookingProcess == null)
		{
			m_CookingProcess = new Cooking();
		}
		
		return m_CookingProcess;
	}
	
	protected void CookOnDirectSlot(ItemBase slot_item, float temp_equip, float temp_ext)
	{
		if (m_CookingProcess == null)
		{
			m_CookingProcess = new Cooking();
		}
		
		m_CookingProcess.CookWithEquipment(slot_item);
		
		switch (slot_item.Type())
		{
		case ATTACHMENT_CAULDRON:
		case ATTACHMENT_COOKING_POT:
		case ATTACHMENT_FRYING_PAN:
			float cookEquipTemp = temp_equip + PARAM_COOKING_EQUIP_TEMP_INCREASE;
			if ( temp_ext <= PARAM_SMALL_FIRE_TEMPERATURE )
			{
				cookEquipTemp = Math.Clamp(cookEquipTemp, PARAM_ITEM_HEAT_MIN_TEMP, PARAM_SMALL_FIRE_TEMPERATURE);
			}
			else
			{
				cookEquipTemp = Math.Clamp(cookEquipTemp, PARAM_ITEM_HEAT_MIN_TEMP, PARAM_COOKING_EQUIP_MAX_TEMP);
			}
			slot_item.SetTemperature(cookEquipTemp);
		break;
		}
	}
	
	protected void SmokeOnSmokingSlot( ItemBase slot_item, float temp_equip, float temp_ext )
	{
		if ( m_CookingProcess == NULL )
		{
			m_CookingProcess = new Cooking();
		}
		
		// smoking slots accept only individual meat/fruit/veg items
		Edible_Base ingr = Edible_Base.Cast( slot_item );
		if ( ingr )
		{
			m_CookingProcess.SmokeItem( ingr, FireplaceBase.TIMER_HEATING_UPDATE_INTERVAL * FireplaceBase.SMOKING_SPEED );
		}
	}
	
	//================================================================
	// FIRE VICINITY
	//================================================================
	//apply damage to all items, raise temperature to only specific items
	protected void BurnItemsInFireplace()
	{
		//! cargo
		CargoBase cargo = GetInventory().GetCargo();
		for (int i = 0; i < cargo.GetItemCount(); i++)
		{
			ItemBase item = ItemBase.Cast(cargo.GetItem(i));
			
			//set damage
			AddDamageToItemByFireEx(item, false, false);

			if (item.GetHealth("", "Health") <= 0 && !item.IsKindOf("Grenade_Base"))
			{
				item.Delete();
			}
			
			//add temperature
			AddTemperatureToItemByFire(item);
			
			//remove wetness
			AddWetnessToItem(item, -PARAM_WET_HEATING_DECREASE_COEF);
		}
		
		//! attachments
		for (int j = 0; j < GetInventory().AttachmentCount(); ++j)
		{
			ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(j));
			
			//set damage
			AddDamageToItemByFireEx(attachment, false, true);
			
			//add temperature
			AddTemperatureToItemByFire(attachment);
		
			//remove wetness
			AddWetnessToItem(attachment, -PARAM_WET_HEATING_DECREASE_COEF);
		}
	}

	//add temperature to item by fire
	protected void AddTemperatureToItemByFire(ItemBase item)
	{
		if (item.GetTemperatureMax() >= PARAM_ITEM_HEAT_MIN_TEMP)
		{
			float temperature = item.GetTemperature() + PARAM_ITEM_HEAT_TEMP_INCREASE_COEF;
			temperature = Math.Clamp(temperature, PARAM_ITEM_HEAT_MIN_TEMP, PARAM_MAX_ITEM_HEAT_TEMP_INCREASE);
			item.SetTemperature(temperature);
		}
	}

	//! DEPRECATED
	protected void AddTemperatureToFireplace(float amount) {};
	
	//add damage to item by fire
	protected void AddDamageToItemByFireEx(ItemBase item, bool can_be_ruined, bool pAttachment)
	{
		if (!item)
		{
			return;		
		}

		if (GetTemperature() <= PARAM_ITEM_HEAT_MIN_TEMP)
		{
			return;
		}

		//! fireplace cargo only
		if (!pAttachment)
		{
			//! cargo item attachments
			GameInventory itemInventory = item.GetInventory();
			if (itemInventory)
			{
				for (int i = 0; i < itemInventory.AttachmentCount(); ++i)
				{
					itemInventory.GetAttachmentFromIndex(i).AddHealth("", "", -PARAM_BURN_DAMAGE_COEF);
				}
			}

			item.AddHealth("", "", -PARAM_BURN_DAMAGE_COEF);
		}
		else
		{
			float timerCoef = 1.0;
			if (m_HeatingTimer && m_HeatingTimer.IsRunning())
			{
				timerCoef = TIMER_HEATING_UPDATE_INTERVAL;
			}
			else if (m_CoolingTimer && m_CoolingTimer.IsRunning())
			{
				timerCoef = TIMER_COOLING_UPDATE_INTERVAL;		
			}

			switch (item.Type())
			{
			case ATTACHMENT_TRIPOD:
			case ATTACHMENT_COOKINGSTAND:
			case ATTACHMENT_COOKING_POT:
			case ATTACHMENT_CAULDRON:
			case ATTACHMENT_FRYING_PAN:
				item.DecreaseHealth(GameConstants.FIRE_ATTACHMENT_DAMAGE_PER_SECOND * timerCoef, false);
			break;
			}
	
			//! fuel & kindling		
			if (IsFuel(item) || IsKindling(item))
			{
				if (item.GetHealthLevel() < GameConstants.STATE_BADLY_DAMAGED)
				{
					item.DecreaseHealth(PARAM_BURN_DAMAGE_COEF, false);
				}
			}
			
			//! cookable
			if (item.CanBeCooked() && item.GetHealthLevel() >= GameConstants.STATE_BADLY_DAMAGED)
			{
				Edible_Base edible_item = Edible_Base.Cast( item );
				edible_item.ChangeFoodStage(FoodStageType.BURNED);
			}
		}
	}
	
	// DEPRECATED
	protected void AddDamageToItemByFire(ItemBase item, bool can_be_ruined)
	{
		item.DecreaseHealth( PARAM_BURN_DAMAGE_COEF, false );

		if ( item.CanBeCooked() & item.GetHealthLevel() >= GameConstants.STATE_BADLY_DAMAGED )
		{
			Edible_Base edible_item = Edible_Base.Cast( item );
			edible_item.ChangeFoodStage( FoodStageType.BURNED );
		}
	}
	
	//add wetness on item
	protected void AddWetnessToItem(ItemBase item, float amount)
	{
		float wetness = item.GetWet();
		wetness = wetness + amount;
		wetness = Math.Clamp(wetness, 0, 1); //wetness <0-1>
		item.SetWet(wetness);
	}
	
	//add wetness on fireplace
	void AddWetnessToFireplace(float amount)
	{
		//add wetness
		float wetness = GetWet();
		wetness = wetness + amount;
		wetness = Math.Clamp(wetness, 0, 1); //wetness <0-1>
		SetWet(wetness);
		
		//decrease temperature
		if (amount > 0)
		{
			float temperature = GetTemperature();
			temperature = temperature * ( 1 - ( wetness * 0.5 ) );
			temperature = Math.Clamp( temperature, PARAM_MIN_FIRE_TEMPERATURE, PARAM_NORMAL_FIRE_TEMPERATURE );
			// temperature via UniversalTemperatureSource
			m_UTSLFireplace.SetFuelCount(GetFuelCount());
			m_UTSLFireplace.SetCurrentTemperature(temperature);
		}
	}	
	
	//! DEPRECATED
	protected void TransferHeatToNearPlayers() {}
	
	//Create and Destroy damage radius around the fireplace when starting/stopping burning process
	void CreateAreaDamage()
	{
		//destroy area damage if some already exists
		DestroyAreaDamage();
		
		//create new area damage
		m_AreaDamage = new AreaDamageLoopedDeferred( this );
		m_AreaDamage.SetDamageComponentType(AreaDamageComponentTypes.HITZONE);
		m_AreaDamage.SetExtents("-0.30 0 -0.30", "0.30 0.75 0.30");
		m_AreaDamage.SetLoopInterval( 0.5 );
		m_AreaDamage.SetDeferDuration( 0.5 );
		m_AreaDamage.SetHitZones( { "Head","Torso","LeftHand","LeftLeg","LeftFoot","RightHand","RightLeg","RightFoot" } );
		m_AreaDamage.SetAmmoName( "FireDamage" );
		m_AreaDamage.Spawn();
	}
	
	void DestroyAreaDamage()
	{
		if ( m_AreaDamage ) 
		{
			m_AreaDamage.Destroy();
		}
	}

	//! DEPRECATED
	bool IsFacingFireplace(PlayerBase player)
	{
		ErrorEx("Deprecated method", ErrorExSeverity.INFO);

		return false;
	}

	//================================================================
	// ACTIONS
	//================================================================
	// --- Actions / Action conditions
	//Check if there is some kindling attached
	bool HasAnyKindling()
	{
		return GetKindlingCount() > 0;
	}

	//Check if the weather is too windy
	static bool IsWindy()
	{
		//check wind
		float wind_speed = GetGame().GetWeather().GetWindSpeed();
		float wind_speed_threshold = GetGame().GetWeather().GetWindMaximumSpeed() * FireplaceBase.IGNITE_WIND_THRESHOLD;

		return ( wind_speed >= wind_speed_threshold );
	}
	
	bool GetIgniteFailure()
	{
		return m_NoIgnite;
	}
	
	void SetIgniteFailure( bool failure )
	{
		m_NoIgnite = failure;
	}

	//Check if the fireplace is too wet to be ignited
	static bool IsEntityWet( notnull EntityAI entity_ai )
	{
		return ( entity_ai.GetWet() >= FireplaceBase.PARAM_MAX_WET_TO_IGNITE );
	}
	
	bool IsWet()
	{
		return FireplaceBase.IsEntityWet( this );
	}

	//Check if there is any roof above fireplace
	bool IsRoofAbove()
	{
		return m_RoofAbove;
	}
	
	//check if fireplace is opened
	override bool IsOpen()
	{
		return true;
	}
	
	//Check if there is enough space for smoke
	bool IsCeilingHighEnoughForSmoke()
	{
		return !MiscGameplayFunctions.IsUnderRoof( this, FireplaceBase.MIN_CEILING_HEIGHT );
	}

	//Check if it's raining and there is only sky above fireplace
	static bool IsRainingAboveEntity( notnull EntityAI entity_ai )
	{
		return ( GetGame() && ( GetGame().GetWeather().GetRain().GetActual() >= FireplaceBase.PARAM_IGNITE_RAIN_THRESHOLD ) );
	}
	
	bool IsRainingAbove()
	{
		return FireplaceBase.IsRainingAboveEntity( this );
	}

	//Check there is water surface bellow fireplace
	static bool IsEntityOnWaterSurface(notnull EntityAI entity_ai)
	{
		vector fireplacePosition = entity_ai.GetPosition();
		string surfaceType;
		g_Game.SurfaceGetType3D(fireplacePosition[0], fireplacePosition[1] + g_Game.SurfaceGetSeaLevel(), fireplacePosition[2], surfaceType);
		if (!surfaceType)
		{
			float waterLevelDiff = fireplacePosition[1] - g_Game.SurfaceGetSeaLevel();
			return waterLevelDiff < 0.5;
		}
		else if (surfaceType.Contains("water"))
		{
			return true;
		}
		
		return false;
	}
	bool IsOnWaterSurface()
	{
		return FireplaceBase.IsEntityOnWaterSurface(this);
	}
	
	//check if the surface is interior
	static bool IsEntityOnInteriorSurface(notnull EntityAI entity_ai)
	{
		string surfaceType;
		vector fireplacePosition = entity_ai.GetPosition();
		GetGame().SurfaceGetType3D(fireplacePosition[0], fireplacePosition[1] + 1.0, fireplacePosition[2], surfaceType);
		return (GetGame().ConfigGetInt("CfgSurfaces " + surfaceType + " interior") == 1);
	}
	bool IsOnInteriorSurface()
	{
		return FireplaceBase.IsEntityOnInteriorSurface( this );
	}
	
	//Checks if has not additional items in it
	override bool IsEmpty()
	{
		return ( GetInventory().GetCargo().GetItemCount() == 0 && GetInventory().AttachmentCount() == 0 );
	}
	
	//Checks if it has no items in cargo
	bool IsCargoEmpty()
	{
		return ( GetInventory().GetCargo().GetItemCount() == 0 );
	}
	
	bool HasCookingStand()
	{
		return GetInventory().FindAttachment(InventorySlots.GetSlotIdFromString("CookingTripod")) != null;
	}
	
	//Check if object is in animation phase
	bool IsInAnimPhase( string anim_phase )
	{
		return GetAnimationPhase(anim_phase) == 0;
	}
	
	bool IsSpaceFor(vector size)
	{
		array<Object> objs = {};
		if (GetGame().IsBoxCollidingGeometry(GetWorldPosition() + Vector(0, size[1] * 0.5 + 0.1, 0), GetDirection().VectorToAngles(), size, ObjIntersect.View, ObjIntersect.Geom, {this}, objs))
		{
			foreach (Object obj : objs)
			{
				if (dBodyGetInteractionLayer(obj) == PhxInteractionLayers.ITEM_LARGE)
					return false;
			}
		}
		return true;
	}
	
	
	override bool CanSwapEntities(EntityAI otherItem, InventoryLocation otherDestination, InventoryLocation destination)
	{
		if (!otherDestination || otherDestination.GetParent() == this)
		{
			return false;
		}
		return true;
	}

	//Action condition for building oven
	bool CanBuildOven()
	{	
		return !IsOven() && !IsBurning() && (GetAttachedStonesCount() >= MIN_STONES_TO_BUILD_OVEN) && !FindAttachmentBySlotName("CookingTripod") && !HasStoneCircle() && IsSpaceForOven();
	}
	
	bool IsSpaceForOven()
	{
		const float size = 0.6;		
		return IsSpaceFor(Vector(size, size, size));
	}
	
	//Action condition for stone circle
	bool CanBuildStoneCircle()
	{
		return !HasStoneCircle() && !IsOven() && !IsBurning() && (GetAttachedStonesCount() >= MIN_STONES_TO_BUILD_CIRCLE) && IsSpaceForCircle();
	}
	
	bool IsSpaceForCircle()
	{
		return IsSpaceFor(Vector(0.9, 0.1, 0.9));
	}
	
	//Action condition for dismantling oven
	bool CanDismantleOven()
	{
		return ( IsOven() && !IsBurning() && !DirectCookingSlotsInUse() && !SmokingSlotsInUse() && GetTemperature() <= MAX_TEMPERATURE_TO_DISMANTLE_OVEN );
	}
	//Action condition for dismantling stone circle
	bool CanDismantleStoneCircle()
	{
		return ( HasStoneCircle() && !IsOven() && !IsBurning() );
	}
	
	bool CanCookOnStick()
	{
		return ( GetTemperature() >= PARAM_COOKING_TEMP_THRESHOLD );
	}
	
	//Can extinguish fire
	bool CanExtinguishFire()
	{
		return IsBurning();
	}
	
	FireplaceLight GetLightEntity()
	{
		return m_Light;
	}
	
	void SetLightEntity( FireplaceLight light )
	{
		m_Light = light;
	}
	
	//================================================================
	// ADVANCED PLACEMENT
	//================================================================
	
	override void OnPlacementComplete( Man player, vector position = "0 0 0", vector orientation = "0 0 0" )
	{
		super.OnPlacementComplete( player, position, orientation );
		
		if ( GetGame().IsServer() )
		{
			//remove grass
			Object cc_object = GetGame().CreateObjectEx( OBJECT_CLUTTER_CUTTER , position, ECE_PLACE_ON_SURFACE );
			cc_object.SetOrientation( orientation );
			GetGame().GetCallQueue( CALL_CATEGORY_GAMEPLAY ).CallLater( GetGame().ObjectDelete, 1000, false, cc_object );
			
			SetIsPlaceSound( true );
		}
	}
	
	override string GetPlaceSoundset()
	{
		return "placeFireplace_SoundSet";
	}
	
	//================================================================
	// QUANITTY
	//================================================================
	// calculates and sets total energy based on possible (fuel/kinidling) item attachments
	protected void CalcAndSetTotalEnergy()
	{
		if ( GetGame() && GetGame().IsServer() )
		{
			m_TotalEnergy = 0;
			
			foreach (FireConsumableType fireConsumableType : m_FireConsumableTypes)
			{
				string quantityConfigPath = string.Format("CfgVehicles %1 varQuantityMax", fireConsumableType.GetItemType().ToString());
				string stackMaxConfigPath = string.Format("CfgSlots Slot_%1 stackMax", fireConsumableType.GetAttSlot());
				if (GetGame().ConfigIsExisting(quantityConfigPath))
				{
					float quantityMax = GetGame().ConfigGetFloat(quantityConfigPath);
				}
				
				if (GetGame().ConfigIsExisting(stackMaxConfigPath))
				{
					float stackMax = GetGame().ConfigGetFloat(stackMaxConfigPath);
				}			
				
				//debug
				//Print( fireConsumableType.GetItemType().ToString() + " quantityMax = " + quantityMax.ToString() + " [" + (quantity_max*fire_consumable_type.GetEnergy()).ToString()  + "] | stack_max = " + stack_max.ToString() + " [" + (stack_max*fire_consumable_type.GetEnergy()).ToString() + "]" );
				
				if (stackMax > 0)
				{
					m_TotalEnergy += stackMax * fireConsumableType.GetEnergy();
				}
				else
				{
					m_TotalEnergy += quantityMax * fireConsumableType.GetEnergy();
				}
			}
			
			//debug
			//Print( "Total energy = " + m_TotalEnergy.ToString() );
		}
	}
	
	// calculates and sets current quantity based on actual (fuel/kinidling) item attachments
	protected void CalcAndSetQuantity()
	{
		if (GetGame() && GetGame().IsServer())
		{
			float remainingEnergy;
			
			foreach (FireConsumable fireConsumable : m_FireConsumables)
			{
				float quantity = fireConsumable.GetItem().GetQuantity();
				if (quantity > 0)
				{
					remainingEnergy += ((quantity - 1) * fireConsumable.GetEnergy()) + fireConsumable.GetRemainingEnergy();
					//Print( fireConsumable.GetItem().GetType() + " remaining energy = " + ( ( ( quantity - 1 ) * fire_consumable.GetEnergy() ) + fire_consumable.GetRemainingEnergy() ).ToString() );
				}
				else
				{
					remainingEnergy += fireConsumable.GetRemainingEnergy();
					//Print( fireConsumable.GetItem().GetType() + " remaining energy = " + ( fireConsumable.GetRemainingEnergy().ToString() ) );
				}
			}
			
			SetQuantity(remainingEnergy / m_TotalEnergy * GetQuantityMax());
		}
	}
	
	override void OnAttachmentQuantityChanged(ItemBase item)
	{
		super.OnAttachmentQuantityChanged(item);
		
		CalcAndSetQuantity();
	}
	
	override bool CanReleaseAttachment(EntityAI attachment)
	{
		if (!super.CanReleaseAttachment(attachment))
			return false;
		
		ItemBase item = ItemBase.Cast(attachment);
		if (IsKindling(item) || IsFuel(item))
		{
			return !IsBurning();
		}
		
		return true;
	}
	
	void LockOvenAttachments(bool lock)
	{
		//Print("LockOvenAttachments");
		//string path_cooking_equipment = "" + CFG_VEHICLESPATH + " " + GetType() + " GUIInventoryAttachmentsProps CookingEquipment attachmentSlots";
		string path_cooking_equipment = string.Format("%1 %2 GUIInventoryAttachmentsProps CookingEquipment attachmentSlots", CFG_VEHICLESPATH, GetType());
		//string path_direct_cooking = "" + CFG_VEHICLESPATH + " " + GetType() + " GUIInventoryAttachmentsProps DirectCooking attachmentSlots";
		string path_direct_cooking = string.Format("%1 %2 GUIInventoryAttachmentsProps DirectCooking attachmentSlots", CFG_VEHICLESPATH, GetType());
		if ( GetGame().ConfigIsExisting(path_cooking_equipment) && GetGame().ConfigIsExisting(path_direct_cooking) )
		{
			array<string> arr_cooking_equipment = new array<string>;
			array<string> arr_direct_cooking = new array<string>;
			GetGame().ConfigGetTextArray(path_cooking_equipment,arr_cooking_equipment);
			GetGame().ConfigGetTextArray(path_direct_cooking,arr_direct_cooking);
			for ( int i = 0; i < arr_cooking_equipment.Count(); i++ )
			{
				if ( lock != GetInventory().GetSlotLock(InventorySlots.GetSlotIdFromString(arr_cooking_equipment[i])) )
				{
					GetInventory().SetSlotLock(InventorySlots.GetSlotIdFromString(arr_cooking_equipment[i]),lock);
					//Print("attachment lock: " + arr_cooking_equipment[i] + " " + lock);
				}
			}
			
			for ( i = 0; i < arr_direct_cooking.Count(); i++ )
			{
				if ( lock == GetInventory().GetSlotLock(InventorySlots.GetSlotIdFromString(arr_direct_cooking[i])) )
				{
					GetInventory().SetSlotLock(InventorySlots.GetSlotIdFromString(arr_direct_cooking[i]),!lock);
					//Print("attachment lock: " + arr_direct_cooking[i] + " " + !lock);
				}
			}
		}
		m_OvenAttachmentsLockState = lock;
	}
	override bool DisassembleOnLastDetach()
	{
		return true;
	}
	
	override void OnRPC( PlayerIdentity sender, int rpc_type, ParamsReadContext ctx ) 
	{
		super.OnRPC( sender, rpc_type, ctx );
		
		ref Param1<bool> p = new Param1<bool>(false);
				
		if (ctx.Read(p))
		{
			bool failure = p.param1;
		}
		
		switch ( rpc_type )
		{
			case FirePlaceFailure.WIND:
			
				if ( failure )
				{
					ParticleFireWindyNoIgniteStart();
					SoundFireStop();
					SoundFireWindyNoIgniteStart();
				}
			
			break;
			
			case FirePlaceFailure.WET:
				
				if ( failure )
				{
					ParticleWetNoIgniteStart();
					SoundFireStop();
					SoundFireWetNoIgniteStart();
				}
			
			break;
		}
	}
	
	
	//================================================================
	// DEBUG
	//================================================================
			
	//Debug menu Spawn Ground Special
	override void OnDebugSpawn()
	{
			ItemBase firewood = ItemBase.Cast(GetInventory().CreateInInventory("Firewood"));
 			firewood.SetQuantity(firewood.GetQuantityMax());
			
			ItemBase sticks = ItemBase.Cast(GetInventory().CreateInInventory("WoodenStick"));
 			sticks.SetQuantity(sticks.GetQuantityMax());
			
			ItemBase stone = ItemBase.Cast(GetInventory().CreateInInventory("Stone"));
 			stone.SetQuantity(stone.GetQuantityMax());
			
			GetInventory().CreateInInventory("Rag");

			SpawnEntityOnGroundPos("PetrolLighter", GetPosition());
	}
	
	override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
	{
		outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ACTIVATE_ENTITY, "Ignite", FadeColors.LIGHT_GREY));
		outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEACTIVATE_ENTITY, "Extinguish", FadeColors.LIGHT_GREY));
		outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.LIGHT_GREY));
		
		super.GetDebugActions(outputList);
	}
	
	override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
	{
		if (super.OnAction(action_id, player, ctx))
			return true;
		if (GetGame().IsServer() || !GetGame().IsMultiplayer())
		{
			if (action_id == EActions.ACTIVATE_ENTITY)
			{
				OnIgnitedThis(null);
			}
			else if (action_id == EActions.DEACTIVATE_ENTITY)
			{
				StopFire();
			}
		}
		return false;
	}
	
	
}