DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
PlantBase.c
Go to the documentation of this file.
1class PlantBase extends ItemBase
2{
3 // Plant states
4 static const int STATE_DRY = 0;
5 static const int STATE_GROWING = 1;
6 static const int STATE_MATURE = 2;
7 static const int STATE_SPOILED = 3;
8
9 private float m_SprayUsage; // How much spray is needed to stop infestation of plant
10
11 private float m_InfestationChance;
12
13 private int m_GrowthStagesCount;
14 private int m_CropsCount;
15 private bool m_HasCrops;
16 private string m_CropsType;
18
19 private int m_PlantState;
20 private int m_PlantStateIndex;
22
23 private bool m_IsInfested;
24 private float m_SprayQuantity;
25 bool m_MarkForDeletion = false;
26
27 int m_DeleteDryPlantTime; // For how long in seconds can an unwatered plant exist before it disappears
28 int m_SpoiledRemoveTime; // For how long in seconds a spoiled plant will exist
29 int m_FullMaturityTime; // How much time needs plant to be full grown in seconds
30 int m_SpoilAfterFullMaturityTime; // How long in seconds it takes for plant to be spoiled after it is full grown
31 int m_StateChangeTime; // For how long in seconds will plant stay in one state before its going to next state
32
33 ref Timer m_GrowthTimer = NULL;
34 ref Timer m_InfestationTimer = NULL;
35 ref Timer m_SpoilAfterFullMaturityTimer = NULL;
36 ref Timer m_SpoiledRemoveTimer = NULL;
37 ref Timer m_DeleteDryPlantTimer = NULL;
38
39 private GardenBase m_GardenBase = NULL;
40 private ref Slot m_Slot = NULL;
41
42 private PluginHorticulture m_ModuleHorticulture;
43
44 private const float SPOIL_AFTER_MATURITY_TIME = 14400; //The time it takes for a fully grown plant to spoil, in seconds
45
46 void PlantBase()
47 {
48 m_ModuleHorticulture = PluginHorticulture.Cast( GetPlugin( PluginHorticulture ) );
49
50 m_SprayUsage = 5;
51 m_DeleteDryPlantTime = (60 * 10) + Math.RandomInt(0, 60 * 2);
52 m_SpoiledRemoveTime = (60 * 20) + Math.RandomInt(0, 60 * 5);
53
54 //Must be between 0 and 1
55 m_InfestationChance = 0.2; // Temporarily disabled until its fixed. Infestation is not visualy persistent over server restarts and m_SpoiledRemoveTimer crashes when it's meant to delete the plant.
56
57 string plant_type = this.GetType();
58 m_GrowthStagesCount = GetGame().ConfigGetInt( "cfgVehicles " + plant_type + " Horticulture GrowthStagesCount" );
59 m_CropsCount = GetGame().ConfigGetInt( "cfgVehicles " + plant_type + " Horticulture CropsCount" );
60 GetGame().ConfigGetText( "cfgVehicles " + plant_type + " Horticulture CropsType", m_CropsType );
61
62 m_PlantStateIndex = -1;
63 m_CurrentPlantMaterialQuantity = 0;
64 m_IsInfested = false;
65 m_SprayQuantity = 0.0;
66 m_HasCrops = true;
67
68 SetTakeable( false );
69
70
71 RegisterNetSyncVariableBool("m_HasCrops");
72 RegisterNetSyncVariableInt("m_PlantState");
73 RegisterNetSyncVariableInt("m_PlantStateIndex");
74 }
75
77 {
78 if (!m_MarkForDeletion)
79 {
81 }
82 }
83
84 void Init( GardenBase garden_base, float fertility, float harvesting_efficiency, float water )
85 {
86 m_GardenBase = garden_base;
87
88 m_FullMaturityTime += Math.RandomInt(-60,180);
89 float divided = /*(float) ((60 * 5) + Math.RandomInt(0, 60 * 1)) / fertility;*/ m_FullMaturityTime;
90
91 //divided = (float)((60 * 30) + Math.RandomInt(0, 60 * 30)) * fertility;
92 m_SpoilAfterFullMaturityTime = SPOIL_AFTER_MATURITY_TIME; //divided;
93
94 divided = (float)((float)m_FullMaturityTime / ((float)m_GrowthStagesCount - 2.0));
95 m_StateChangeTime = divided;
96
97 float count = m_CropsCount * fertility * harvesting_efficiency;
98 m_CropsCount = (int)Math.Ceil( count );
99
100 m_PlantMaterialMultiplier = 0.1 * harvesting_efficiency;
101
102 float rain_intensity = GetGame().GetWeather().GetRain().GetActual();
103 if ( rain_intensity > 0.0 )
104 {
105 CheckWater();
106 }
107 else
108 {
109 CheckWater();
110
111 if ( NeedsWater() )
112 {
113 SetPlantState(STATE_DRY);
114
115 if (GetGame().IsServer())
116 {
117 m_DeleteDryPlantTimer = new Timer( CALL_CATEGORY_SYSTEM );
118 m_DeleteDryPlantTimer.Run( m_DeleteDryPlantTime, this, "DeleteDryPlantTick", NULL, false );
119 }
120 }
121 }
122 }
123
124
125 override bool OnStoreLoad( ParamsReadContext ctx, int version )
126 {
127 if ( !super.OnStoreLoad( ctx, version ) )
128 return false;
129
130 //Print("Plant - OnStoreLoad - ");
131
132 GardenBase garden = GardenBase.Cast( GetHierarchyParent() );
133 //Print(garden);
134
135 int slot_index = -1;
136 ctx.Read( slot_index );
137
138 //Print(slot_index);
139
140 Slot slot = garden.GetSlotByIndex(slot_index);
141 //Print(slot);
142
143 SetSlot(slot);
144
145 if ( !OnStoreLoadCustom( ctx, version ) )
146 return false;
147
148 return true;
149 }
150
151 override void OnStoreSave( ParamsWriteContext ctx )
152 {
153 super.OnStoreSave( ctx );
154
155 Slot slot = GetSlot();
156
157 if (slot)
158 {
159 int slot_index = slot.GetSlotIndex();
160 slot.SetPlant(this); // hack
161
162 ctx.Write( slot_index );
163
164 OnStoreSaveCustom( ctx );
165 }
166 else
167 {
168 GetGame().ObjectDelete(this); // Plants that exist without a garden must be deleted. Otherwise they might cause problems.
169 Print("Warning! A plant existed without a garden. Therefore it was deleted from the world to prevent issues!");
170 }
171 }
172
174 {
175 return m_CropsType;
176 }
177
178
179 bool OnStoreLoadCustom( ParamsReadContext ctx, int version )
180 {
181 int loadInt;
182 if ( !ctx.Read( loadInt ) )
183 loadInt = 0;
184
185 m_SprayUsage = loadInt;
186
187 loadInt = 0;
188 if ( !ctx.Read( loadInt ) )
189 loadInt = 5;
190
191 m_DeleteDryPlantTime = loadInt;
192
193 loadInt = 0;
194 if ( !ctx.Read( loadInt ) )
195 loadInt = 5;
196 m_SpoiledRemoveTime = loadInt;
197
198 loadInt = 0;
199 if ( !ctx.Read( loadInt ) )
200 loadInt = 300;
201 m_FullMaturityTime = loadInt;
202
203 loadInt = 0;
204 if ( !ctx.Read( loadInt ) )
205 loadInt = 300;
206 m_SpoilAfterFullMaturityTime = loadInt;
207
208 loadInt = 0;
209 if ( !ctx.Read( loadInt ) )
210 return false;
211 m_StateChangeTime = loadInt;
212
213 float loadFloat = 0.0;
214 if ( !ctx.Read( loadFloat ) )
215 loadFloat = 0;
216 m_InfestationChance = loadFloat;
217
218 loadInt = 0;
219 if ( !ctx.Read( loadInt ) )
220 return false;
221 m_GrowthStagesCount = loadInt;
222
223 loadInt = 0;
224 if ( !ctx.Read( loadInt ) )
225 loadInt = 1;
226 m_CropsCount = loadInt;
227
228 string loadString = "";
229 if ( !ctx.Read( loadString ) )
230 return false;
231 m_CropsType = loadString;
232
233 loadFloat = 0.0;
234 if ( !ctx.Read( loadFloat ) )
235 loadFloat = 1;
236 m_PlantMaterialMultiplier = loadFloat;
237
238 loadInt = 0;
239 if ( !ctx.Read( loadInt ) )
240 loadInt = 1;
241 m_PlantState = loadInt;
242
243 loadInt = 0;
244 if ( !ctx.Read( loadInt ) )
245 loadInt = 0;
246 m_PlantStateIndex = loadInt;
247
248 loadFloat = 0.0;
249 if ( !ctx.Read( loadFloat ) )
250 loadFloat = 1;
251 m_CurrentPlantMaterialQuantity = loadFloat;
252
253 bool loadBool = false;
254 if ( !ctx.Read( loadBool ) )
255 loadBool = false;
256 m_IsInfested = loadBool;
257
258 loadFloat = 0.0;
259 if ( !ctx.Read( loadFloat ) )
260 loadFloat = 0;
261 m_SprayQuantity = loadFloat;
262
263
264
265 loadBool = false;
266 if ( ctx.Read( loadBool ) )
267 {
268 if ( loadBool )
269 {
270 if (GetGame().IsServer())
271 {
272 m_GrowthTimer = new Timer( CALL_CATEGORY_SYSTEM );
273 m_GrowthTimer.Run( m_StateChangeTime, this, "GrowthTimerTick", NULL, true );
274 }
275 }
276 }
277 else
278 {
279 return false;
280 }
281
282 loadFloat = 0.0;
283 if ( ctx.Read( loadFloat ) )
284 {
285 if ( loadFloat > 0.0 )
286 {
287 if (GetGame().IsServer())
288 {
289 m_InfestationTimer = new Timer( CALL_CATEGORY_SYSTEM );
290 m_InfestationTimer.Run( loadFloat, this, "InfestationTimerTick", NULL, false );
291 }
292 }
293 }
294 else
295 {
296 return false;
297 }
298
299 loadFloat = 0.0;
300 if ( ctx.Read( loadFloat ) )
301 {
302 if ( loadFloat > 0.0 )
303 {
304 if (GetGame().IsServer())
305 {
306 m_SpoilAfterFullMaturityTimer = new Timer( CALL_CATEGORY_SYSTEM );
307 m_SpoilAfterFullMaturityTimer.Run( loadFloat, this, "SetSpoiled", NULL, false );
308 }
309 }
310 }
311 else
312 {
313 return false;
314 }
315
316 loadFloat = 0.0;
317 if ( ctx.Read( loadFloat ) )
318 {
319 if ( loadFloat > 0.0 )
320 {
321 if (GetGame().IsServer())
322 {
323 if (!m_SpoiledRemoveTimer)
324 m_SpoiledRemoveTimer = new Timer( CALL_CATEGORY_SYSTEM );
325
326 m_SpoiledRemoveTimer.Run( loadFloat, this, "SpoiledRemoveTimerTick", NULL, false );
327 }
328 }
329 }
330 else
331 {
332 return false;
333 }
334
335 loadFloat = 0.0;
336 if ( ctx.Read( loadFloat ) )
337 {
338 if ( loadFloat > 0.0 )
339 {
340 if (GetGame().IsServer())
341 {
342 m_DeleteDryPlantTimer = new Timer( CALL_CATEGORY_SYSTEM );
343 m_DeleteDryPlantTimer.Run( loadFloat, this, "DeleteDryPlantTick", NULL, false );
344 }
345 }
346 }
347 else
348 {
349 return false;
350 }
351
352
353 UpdatePlant();
354 return true;
355 }
356
358 {
359 ctx.Write( m_SprayUsage );
360
361 ctx.Write( m_DeleteDryPlantTime );
362
363 ctx.Write( m_SpoiledRemoveTime );
364
365 ctx.Write( m_FullMaturityTime );
366
367 ctx.Write( m_SpoilAfterFullMaturityTime );
368
369 ctx.Write( m_StateChangeTime );
370
371 ctx.Write( m_InfestationChance );
372
373 ctx.Write( m_GrowthStagesCount );
374
375 ctx.Write( m_CropsCount );
376
377 ctx.Write( m_CropsType );
378
379 ctx.Write( m_PlantMaterialMultiplier );
380
381 ctx.Write( m_PlantState );
382
383 ctx.Write( m_PlantStateIndex );
384
385 ctx.Write( m_CurrentPlantMaterialQuantity );
386
387 ctx.Write( m_IsInfested );
388
389 ctx.Write( m_SprayQuantity );
390
391 bool saveBool = false;
392 if ( m_GrowthTimer != NULL )
393 {
394 saveBool = true;
395 }
396 ctx.Write( saveBool );
397
398 float saveFloat = 0.0;
399 if ( m_InfestationTimer != NULL )
400 {
401 saveFloat = m_InfestationTimer.GetRemaining();
402 }
403 ctx.Write( saveFloat );
404
405 saveFloat = 0.0;
406 if ( m_SpoilAfterFullMaturityTimer != NULL )
407 {
408 saveFloat = m_SpoilAfterFullMaturityTimer.GetRemaining();
409 }
410 ctx.Write( saveFloat );
411
412 saveFloat = 0.0;
413 if ( m_SpoiledRemoveTimer != NULL )
414 {
415 saveFloat = m_SpoiledRemoveTimer.GetRemaining();
416 }
417 ctx.Write( saveFloat );
418
419 saveFloat = 0.0;
420 if ( m_DeleteDryPlantTimer != NULL )
421 {
422 saveFloat = m_DeleteDryPlantTimer.GetRemaining();
423 }
424 ctx.Write( saveFloat );
425 }
426
428 {
429 Print("PRINT ALL VALUES OF PLANT...");
430 Print(this);
431
432 Print(m_HasCrops);
433 Print(m_PlantState);
434 Print(m_PlantStateIndex);
435 Print(m_CurrentPlantMaterialQuantity);
436 Print(m_IsInfested);
437 Print(m_SprayQuantity);
438 Print(m_Slot);
439 Print(m_GardenBase);
440 Print("----------------------------------------------------------");
441 }
442
443 override bool CanPutInCargo( EntityAI parent )
444 {
445 return super.CanPutInCargo(parent);
446 }
447
448 override bool CanPutIntoHands( EntityAI player )
449 {
450 return super.CanPutIntoHands(parent);
451 }
452
453 override bool CanRemoveFromHands( EntityAI player )
454 {
455 return false;
456 }
457
458 void ChangeInfestation( bool is_infested )
459 {
460 m_IsInfested = is_infested;
461
462 string plant_type = GetType();
463 PlantMaterialHealth material = m_ModuleHorticulture.GetPlantMaterial( plant_type );
464
465 if ( m_IsInfested )
466 {
467 if ( material.m_InfestedTex != "" )
468 {
469 SetObjectTexture( 0, material.m_InfestedTex );
470 }
471 if ( material.m_InfestedMat != "" )
472 {
473 SetObjectMaterial( 0, material.m_InfestedMat );
474 }
475 }
476 else
477 {
478 if ( material.m_HealthyTex != "" )
479 {
480 SetObjectTexture( 0, material.m_HealthyTex );
481 }
482 if ( material.m_HealthyMat != "" )
483 {
484 SetObjectMaterial( 0, material.m_HealthyMat );
485 }
486 }
487 }
488
490 {
491 if ( m_PlantStateIndex > 0 )
492 {
493 string plant_state_index = m_PlantStateIndex.ToStringLen(2);
494 string prev_plant_state_index = ( m_PlantStateIndex - 1 ).ToStringLen( 2 );
495
496 // HIDING PREVIOUS PLANT STATE AND SHOWING THE CURRENT ONE
497 ShowSelection( "plantStage_" + plant_state_index ); // SHOW!
498 HideSelection( "plantStage_" + prev_plant_state_index ); // HIDE!
499
500 // HIDING PREVIOUS CROPS STATE AND SHOWING THE CURRENT ONE
501
502 if ( HasCrops() )
503 {
504 ShowSelection( "plantStage_" + plant_state_index + "_crops" ); // SHOW!
505 HideSelection( "plantStage_" + prev_plant_state_index + "_crops" ); // HIDE!
506 }
507 else
508 {
509 HideSelection( "plantStage_" + plant_state_index + "_crops" ); // HIDE!
510 HideSelection( "plantStage_" + prev_plant_state_index + "_crops" ); // HIDE!
511 }
512
513 // HIDING PREVIOUS SHADOW STATE AND SHOWING THE CURRENT ONE
514 ShowSelection( "plantStage_" + plant_state_index + "_shadow" ); // SHOW!
515 HideSelection( "plantStage_" + prev_plant_state_index + "_shadow" ); // HIDE!
516 }
517
518 float float_plant_state_index = (float)m_PlantStateIndex;
519 m_CurrentPlantMaterialQuantity = m_PlantMaterialMultiplier * float_plant_state_index;
520 }
521
523 {
524 if ( IsGrowing() )
525 {
526 if ( m_PlantStateIndex < m_GrowthStagesCount - 2 )
527 {
528 m_PlantStateIndex++;
529 UpdatePlant();
530 SetSynchDirty();
531
532 if ( m_PlantStateIndex == 0 )
533 {
534 float infestation_time_min = (float)m_FullMaturityTime * 0.2;
535 int int_infestation_time_min = (int)infestation_time_min;
536
537 float infestation_time_max = (float)m_FullMaturityTime * 0.6;
538 int int_infestation_time_max = (int)infestation_time_max;
539
540 if (GetGame().IsServer())
541 {
542 if (!m_InfestationTimer)
543 m_InfestationTimer = new Timer( CALL_CATEGORY_SYSTEM );
544
545 m_InfestationTimer.Run( Math.RandomInt(int_infestation_time_min, int_infestation_time_max), this, "InfestationTimerTick", NULL, false );
546 }
547 }
548
549 if ( m_PlantStateIndex == m_GrowthStagesCount - 2 )
550 {
551 if ( m_IsInfested )
552 {
553 SetSpoiled();
554 }
555 else
556 {
557 SetPlantState(STATE_MATURE);
558 }
559 }
560 }
561 }
562 else if ( IsMature() )
563 {
564 if (GetGame().IsServer())
565 {
566 if (!m_SpoilAfterFullMaturityTimer)
567 m_SpoilAfterFullMaturityTimer = new Timer( CALL_CATEGORY_SYSTEM );
568
569 if ( !m_SpoilAfterFullMaturityTimer.IsRunning() )
570 m_SpoilAfterFullMaturityTimer.Run( m_SpoilAfterFullMaturityTime, this, "SetSpoiled", NULL, false );
571 }
572 }
573 }
574
576 {
577 float infestation_rnd = Math.RandomFloat01();
578
579 if ( m_InfestationChance > infestation_rnd )
580 {
581 ChangeInfestation( true );
582 }
583 }
584
586 {
587 if ( m_GrowthTimer != NULL )
588 {
589 m_GrowthTimer.Stop();
590 }
591
592 RemoveSlot();
593 }
594
596 {
597 /*if ( IsDry() )
598 {
599 RemoveSlot();
600 }*/
601 }
602
604 {
605 if ( IsSpoiled() == false )
606 {
607 m_PlantStateIndex++;
608 SetPlantState(STATE_SPOILED);
609 UpdatePlant();
610 SetSynchDirty();
611
612 if (GetGame().IsServer())
613 {
614 if (!m_SpoiledRemoveTimer)
615 m_SpoiledRemoveTimer = new Timer( CALL_CATEGORY_SYSTEM );
616
617 if (!m_SpoiledRemoveTimer.IsRunning())
618 m_SpoiledRemoveTimer.Run( m_SpoiledRemoveTime, this, "SpoiledRemoveTimerTick", NULL, false );
619 }
620 }
621 }
622
624 {
625 if ( !IsMature() && !NeedsWater() )
626 {
627 if ( m_DeleteDryPlantTimer )
628 {
629 m_DeleteDryPlantTimer.Stop();
630 }
631
632 SetPlantState(STATE_GROWING);
633
634 if (GetGame().IsServer())
635 {
636 m_GrowthTimer = new Timer( CALL_CATEGORY_SYSTEM );
637 m_GrowthTimer.Run( m_StateChangeTime, this, "GrowthTimerTick", NULL, true );
638 }
639 }
640 }
641
642 //NEW METHOD FOR PLANT SPRAYING
643 void SprayPlant( float consumed_quantity )
644 {
645 //Rework this to have something smooth
646 m_SprayQuantity += consumed_quantity;
647
648 if ( !NeedsSpraying() )
649 {
650 if ( m_InfestationTimer != NULL )
651 {
652 m_InfestationTimer.Stop();
653 }
654
655 m_IsInfested = false;
656 m_InfestationChance = 0;
657
658 ChangeInfestation( false );
659 UpdatePlant();
660 }
661 }
662
663 //DEPRECATED
664 string StopInfestation( float consumed_quantity )
665 {
666 m_SprayQuantity += consumed_quantity;
667
668 if ( !NeedsSpraying() )
669 {
670 if ( m_InfestationTimer != NULL )
671 {
672 m_InfestationTimer.Stop();
673 }
674
675 m_IsInfested = false;
676 m_InfestationChance = 0;
677
678 ChangeInfestation( false );
679 UpdatePlant();
680
681 return "I've sprayed the plant a bit. Now it is enough spayed.";
682 }
683 else
684 {
685 return "I've sprayed the plant a bit.";
686 }
687 }
688
689 //DEPRECATED
691 {
692 if ( GetGame() && GetGame().IsServer() )
693 {
695
696 if ( m_CurrentPlantMaterialQuantity > 0.0 )
697 {
698 vector pos = GetPosition();
699 ItemBase item = ItemBase.Cast( GetGame().CreateObjectEx( "PlantMaterial", pos, ECE_PLACE_ON_SURFACE ) );
700 item.SetQuantity( m_CurrentPlantMaterialQuantity * 1000.0 );
701 }
702
703 RemoveSlot();
704 }
705 }
706
708 {
709 if ( GetGame() && GetGame().IsServer() )
710 {
712
713 if ( m_CurrentPlantMaterialQuantity > 0.0 )
714 {
715 ItemBase item = ItemBase.Cast( GetGame().CreateObjectEx( "PlantMaterial", pos, ECE_PLACE_ON_SURFACE ) );
716 item.SetQuantity( m_CurrentPlantMaterialQuantity * 1000.0 );
717 }
718
719 RemoveSlot();
720 }
721 }
722
724 {
725 if ( GetGame() && GetGame().IsServer() )
726 {
728
729 RemoveSlot();
730 }
731 }
732
733 void Harvest( PlayerBase player )
734 {
735 //TODO Boris: Add soft skill 2.0
736 //PluginExperience module_exp = GetPlugin(PluginExperience);
737 //float harvesting_efficiency = module_exp.GetExpParamNumber(player, PluginExperience.EXP_FARMER_HARVESTING, "efficiency");
738
739 //m_CropsCount = m_CropsCount * harvesting_efficiency;
740
741 if ( !IsSpoiled() )
742 {
743 for ( int i = 0; i < m_CropsCount; i++ )
744 {
745 vector pos = player.GetPosition();
746 ItemBase item = ItemBase.Cast( GetGame().CreateObjectEx( m_CropsType, pos, ECE_PLACE_ON_SURFACE ) );
747 item.SetQuantity( item.GetQuantityMax() );
748 }
749 }
750
751 m_HasCrops = false;
752 SetSynchDirty();
753 UpdatePlant();
754 }
755
756 void SetPlantState(int state)
757 {
758 m_PlantState = state;
759 SetSynchDirty();
760 }
761
763 {
764 return m_PlantState;
765 }
766
768 {
769 return m_PlantStateIndex;
770 }
771
772 float GetWater()
773 {
774 if ( GetSlot() )
775 return GetSlot().GetWater();
776
777 return 0;
778 }
779
781 {
782 if ( GetSlot() )
783 return GetSlot().GetWaterUsage();
784
785 return 0;
786 }
787
789 {
790 Slot slotPlant = m_Slot;
791
792 if ( IsDry() && slotPlant && slotPlant.GetWater() < slotPlant.GetWaterUsage() )
793 {
794 return true;
795 }
796 else
797 {
798 return false;
799 }
800 }
801
803 {
804 if ( m_SprayQuantity < m_SprayUsage )
805 {
806 return true;
807 }
808 else
809 {
810 return false;
811 }
812 }
813
815 {
816 return m_SprayQuantity;
817 }
818
820 {
821 return m_SprayUsage;
822 }
823
825 {
826 GardenBase garden = GardenBase.Cast( GetHierarchyParent() );
827
828 if ( garden )
829 {
830 if (m_SpoiledRemoveTimer)
831 {
832 m_SpoiledRemoveTimer.Stop();
833 m_SpoiledRemoveTimer = NULL;
834 }
835
836 garden.RemoveSlotPlant( this );
837 }
838 }
839
840 void SetSlot(Slot slot)
841 {
842 if ( slot )
843 {
844 m_Slot = slot;
845 }
846 }
847
848 Slot GetSlot()
849 {
850 return m_Slot;
851 }
852
854 {
855 return m_GardenBase;
856 }
857
858 bool IsDry()
859 {
860 if ( GetPlantState() == STATE_DRY )
861 {
862 return true;
863 }
864 else
865 {
866 return false;
867 }
868 }
869
871 {
872 if ( GetPlantState() == STATE_GROWING )
873 {
874 return true;
875 }
876 else
877 {
878 return false;
879 }
880 }
881
882
883 bool IsMature()
884 {
885 if ( GetPlantState() == STATE_MATURE )
886 {
887 return true;
888 }
889 else
890 {
891 return false;
892 }
893 }
894
896 {
897 if ( GetPlantState() == STATE_SPOILED )
898 {
899 return true;
900 }
901 else
902 {
903 return false;
904 }
905 }
906
907 bool HasCrops()
908 {
909 return m_HasCrops;
910 }
911
912 override void SetActions()
913 {
914 super.SetActions();
915
918 }
919}
eBleedingSourceType GetType()
void AddAction(typename actionName)
class RecipeCacheData int
const int ECE_PLACE_ON_SURFACE
string ToStringLen(int len)
Integer to string with fixed length, padded with zeroes.
Definition EnConvert.c:59
override void SetTakeable(bool pState)
Definition ItemBase.c:8843
void UnlockFromParent()
Unlocks this item from its attachment slot of its parent.
Definition ItemBase.c:5432
PluginBase GetPlugin(typename plugin_type)
class JsonUndergroundAreaTriggerData GetPosition
proto native void ObjectDelete(Object obj)
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native int ConfigGetInt(string path)
Get int value from config on path.
proto native bool IsServer()
proto native Weather GetWeather()
Returns weather controller object.
private float m_PlantMaterialMultiplier
Definition PlantBase.c:17
void Init(GardenBase garden_base, float fertility, float harvesting_efficiency, float water)
Definition PlantBase.c:84
override bool CanRemoveFromHands(EntityAI player)
Definition PlantBase.c:453
bool IsGrowing()
Definition PlantBase.c:870
private const float SPOIL_AFTER_MATURITY_TIME
Definition PlantBase.c:44
bool NeedsWater()
Definition PlantBase.c:788
int m_StateChangeTime
Definition PlantBase.c:31
string GetCropsType()
Definition PlantBase.c:173
void OnStoreSaveCustom(ParamsWriteContext ctx)
Definition PlantBase.c:357
Slot GetSlot()
Definition PlantBase.c:848
bool IsMature()
Definition PlantBase.c:883
bool IsSpoiled()
Definition PlantBase.c:895
void InfestationTimerTick()
Definition PlantBase.c:575
override void OnStoreSave(ParamsWriteContext ctx)
Definition PlantBase.c:151
bool IsDry()
Definition PlantBase.c:858
int GetPlantStateIndex()
Definition PlantBase.c:767
void PrintValues()
Definition PlantBase.c:427
private int m_PlantState
Definition PlantBase.c:19
void SprayPlant(float consumed_quantity)
Definition PlantBase.c:643
void DestroyPlant()
Definition PlantBase.c:723
void ChangeInfestation(bool is_infested)
Definition PlantBase.c:458
GardenBase GetGarden()
Definition PlantBase.c:853
override bool CanPutIntoHands(EntityAI player)
Definition PlantBase.c:448
void ~PlantBase()
Definition PlantBase.c:76
override bool CanPutInCargo(EntityAI parent)
Definition PlantBase.c:443
float GetSprayUsage()
Definition PlantBase.c:819
void CheckWater()
Definition PlantBase.c:623
int m_SpoiledRemoveTime
Definition PlantBase.c:28
private int m_PlantStateIndex
Definition PlantBase.c:20
private float m_InfestationChance
Definition PlantBase.c:11
void SpoiledRemoveTimerTick()
Definition PlantBase.c:585
private float m_CurrentPlantMaterialQuantity
Definition PlantBase.c:21
private int m_CropsCount
Definition PlantBase.c:14
void RemovePlantEx(vector pos)
Definition PlantBase.c:707
void RemoveSlot()
Definition PlantBase.c:824
bool HasCrops()
Definition PlantBase.c:907
private float m_SprayQuantity
Definition PlantBase.c:24
private bool m_IsInfested
Definition PlantBase.c:23
float GetWaterMax()
Definition PlantBase.c:780
bool NeedsSpraying()
Definition PlantBase.c:802
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition PlantBase.c:125
void PlantBase()
Definition PlantBase.c:46
void GrowthTimerTick()
Definition PlantBase.c:522
float GetWater()
Definition PlantBase.c:772
int GetPlantState()
Definition PlantBase.c:762
void SetSpoiled()
Definition PlantBase.c:603
private int m_GrowthStagesCount
Definition PlantBase.c:13
void RemovePlant()
Definition PlantBase.c:690
private GardenBase m_GardenBase
Definition PlantBase.c:39
private string m_CropsType
Definition PlantBase.c:16
void SetSlot(Slot slot)
Definition PlantBase.c:840
void UpdatePlant()
Definition PlantBase.c:489
void DeleteDryPlantTick()
Definition PlantBase.c:595
int m_DeleteDryPlantTime
Definition PlantBase.c:27
bool OnStoreLoadCustom(ParamsReadContext ctx, int version)
Definition PlantBase.c:179
int m_SpoilAfterFullMaturityTime
Definition PlantBase.c:30
private ref Slot m_Slot
Definition PlantBase.c:40
void SetPlantState(int state)
Definition PlantBase.c:756
private float m_SprayUsage
Definition PlantBase.c:9
void Harvest(PlayerBase player)
Definition PlantBase.c:733
float GetSprayQuantity()
Definition PlantBase.c:814
override void SetActions()
Definition PlantBase.c:912
private PluginHorticulture m_ModuleHorticulture
Definition PlantBase.c:42
int m_FullMaturityTime
Definition PlantBase.c:29
private bool m_HasCrops
Definition PlantBase.c:15
string StopInfestation(float consumed_quantity)
Definition PlantBase.c:664
Definition EnMath.c:7
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto bool Write(void value_out)
proto bool Read(void value_in)
proto native Rain GetRain()
Returns a rain phenomenon object.
proto native float GetActual()
Returns actual value of phenomenon in range <0, 1>.
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
static float RandomFloat01()
Returns a random float number between and min [inclusive] and max [inclusive].
Definition EnMath.c:106
static proto float Ceil(float f)
Returns ceil of value.
const int CALL_CATEGORY_SYSTEM
Definition tools.c:8