DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
CAContinuousFertilizeGardenSlot.c
См. документацию.
2{
3 protected float m_SlotFertilizerNeed;
4 protected float m_AlreadyFilledAmount; // amount of fertilizer present within slot during the setup of action
5 protected float m_TimeToComplete;
6 protected float m_SpentQuantityTotal;
7 protected float m_StartQuantity;
8 protected Slot m_Slot;
9 protected string m_Selection;
10
11 void CAContinuousFertilizeGardenSlot( float quantity_used_per_second )
12 {
13 m_QuantityUsedPerSecond = quantity_used_per_second;
15 }
16
17 override void Setup( ActionData action_data )
18 {
19 GardenBase target_GB;
20 if ( Class.CastTo(target_GB, action_data.m_Target.GetObject() ) )
21 {
23 m_StartQuantity = action_data.m_MainItem.GetQuantity();
24
25 if ( !m_SpentUnits )
26 {
27 m_SpentUnits = new Param1<float>(0);
28 }
29 else
30 {
31 m_SpentUnits.param1 = 0;
32 }
33
34 if ( action_data.m_MainItem )
35 m_ItemQuantity = action_data.m_MainItem.GetQuantity();
36
37 if ( target_GB )
38 {
39 /*string selection = target_GB.GetActionComponentName(action_data.m_Target.GetComponentIndex());
40
41 Slot slot = target_GB.GetSlotBySelection( selection );*/
42
43 array<string> selections = new array<string>;
44 target_GB.GetActionComponentNameList(action_data.m_Target.GetComponentIndex(), selections);
45
46 for (int s = 0; s < selections.Count(); s++)
47 {
48 //string selection = selections[s];
49 m_Selection = selections[s];
50 m_Slot = target_GB.GetSlotBySelection( m_Selection );
51 if (m_Slot)
52 break;
53 }
54
55 string item_type = action_data.m_MainItem.GetType();
56 float consumed_quantity = GetGame().ConfigGetFloat( "cfgVehicles " + item_type + " Horticulture ConsumedQuantity" );
57 float action_length = GetGame().ConfigGetFloat( "cfgVehicles " + item_type + " Horticulture FertilizeLength" );
58 if (action_length == 0)
59 action_length = 1;
60
61 m_Slot.SetFertilizerQuantityMax(consumed_quantity);
62 m_AlreadyFilledAmount = m_Slot.GetFertilizerQuantity();
63 m_SlotFertilizerNeed = consumed_quantity - m_AlreadyFilledAmount;
64 }
65
66 float defaultTimeComplete = consumed_quantity/m_QuantityUsedPerSecond;
67 float speedMultiplier = defaultTimeComplete / action_length;
68 m_QuantityUsedPerSecond *= speedMultiplier;
69 }
70 }
71
72
73 override int Execute( ActionData action_data )
74 {
75 if ( !action_data.m_Player )
76 {
77 return UA_ERROR;
78 }
79
81 {
82 return UA_FINISHED;
83 }
84 else
85 {
87 {
88 m_SpentQuantity = m_QuantityUsedPerSecond * action_data.m_Player.GetDeltaT();
89 GardenBase garden_base;
90 Class.CastTo(garden_base, action_data.m_Target.GetObject() );
91 //string selection = garden_base.GetActionComponentName(action_data.m_Target.GetComponentIndex());
92
94
95 if (GetGame().IsServer())
96 {
97 action_data.m_MainItem.AddQuantity( -m_SpentQuantity );
98 }
99
100 garden_base.Fertilize( action_data.m_Player, action_data.m_MainItem, m_SpentQuantity, m_Selection );
101
102 return UA_PROCESSING;
103 }
104 else
105 {
106 CalcAndSetQuantity( action_data );
107 OnCompletePogress(action_data);
108 return UA_FINISHED;
109 }
110 }
111 }
112
113 override float GetProgress()
114 {
115 return -((m_Slot.GetFertilizerQuantity() - m_AlreadyFilledAmount)/m_SlotFertilizerNeed);
116 }
117};
ActionBase ActionData
Определения ActionBase.c:30
void CalcAndSetQuantity()
Определения FireplaceBase.c:2640
void OnCompletePogress(ActionData action_data)
Определения CAContinuousBase.c:8
void CAContinuousFertilizeGardenSlot(float quantity_used_per_second)
override int Execute(ActionData action_data)
override void Setup(ActionData action_data)
float m_ItemQuantity
Определения CAContinuousQuantity.c:3
ref Param1< float > m_SpentUnits
Определения CAContinuousQuantity.c:8
float m_SpentQuantity
Определения CAContinuousQuantity.c:4
float m_QuantityUsedPerSecond
Определения CAContinuousQuantity.c:6
void CAContinuousQuantity(float quantity_used_per_second)
Определения CAContinuousQuantity.c:10
proto native float ConfigGetFloat(string path)
Get float value from config on path.
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения GardenPlot.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
const int UA_FINISHED
Определения constants.c:464
const int UA_ERROR
Определения constants.c:483
const int UA_PROCESSING
Определения constants.c:462