DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
QuantityConversions.c
См. документацию.
2{
3 static string GetItemQuantityText( EntityAI item, bool showMax = false )
4 {
5 string quantity_text = "";
6 if ( item.IsInherited( InventoryItem) )
7 {
8 ItemBase item_base;
9 Class.CastTo(item_base, item);
10 float quantity = item_base.GetQuantity();
11 int ammo;
12 if ( item.IsMagazine() )
13 {
14 Magazine magazine_item;
15 Class.CastTo(magazine_item, item);
16 ammo = magazine_item.GetAmmoCount();
17
18 return ammo.ToString();
19 }
20 else if ( item.IsInherited( ItemBook) )
21 {
22 return "";
23 }
24 int stack_max = item.GetQuantityMax();
25
26 //int max = item.ConfigGetInt("varQuantityMax");
27 //string unit = item.ConfigGetString("stackedUnit");
28
29 if (stack_max > 0)
30 {
31 if (stack_max == 1)
32 {
33 if (quantity > 1)
34 {
35 if (showMax)
36 quantity_text = string.Format("%1/%2", quantity.ToString(), stack_max.ToString() );
37 //quantity_text = string.Format("%i/%i", quantity, stack_max );
38 else
39 quantity_text = quantity.ToString();
40 }
41 else
42 {
43 quantity_text = "";
44 }
45 }
46 else
47 {
48 if (showMax)
49 quantity_text = string.Format("%1/%2", quantity.ToString(), stack_max.ToString() );
50 //quantity_text = string.Format("%i/%i", quantity, stack_max );
51 else
52 quantity_text = quantity.ToString();
53 // if (unit == "ml")
54 // {
55 // float liters = round(quantity / 1000.0);
56 // if ( quantity < 2000 )
57 // {
58 // liters = ( round( (quantity / 100.0) ) ) / 10;
59 // }
60 // quantity_text = ftoa(liters) + "l";
61 // }
62 // else
63 // {
64 // quantity_text = itoa(quantity) + unit;
65 // }
66 }
67 }
68 }
69 return quantity_text;
70 }
71
72 static float GetItemQuantity(InventoryItem item)
73 {
74 float quantity = 0;
75 if ( item.IsInherited(InventoryItem))
76 {
77 ItemBase item_base;
78 Class.CastTo(item_base, item);
79 if (item_base)
80 {
81 if (item.IsMagazine())
82 {
83 Magazine magazine_item;
84 Class.CastTo(magazine_item, item);
85 quantity = magazine_item.GetAmmoCount();
86 }
87 else
88 {
89 quantity = item_base.GetQuantity();
90 }
91 }
92 }
93 return quantity;
94 }
95
97 {
98 float quantity = 0;
99 if (item.IsInherited(InventoryItem))
100 {
101 ItemBase item_base;
102 Class.CastTo(item_base, item);
103 if (item_base)
104 {
105 if (item.IsMagazine())
106 {
107 Magazine magazine_item;
108 Class.CastTo(magazine_item, item);
109 quantity = magazine_item.GetAmmoMax();
110 }
111 else
112 {
113 quantity = item_base.GetQuantityMax();
114 }
115 }
116 }
117 return quantity;
118 }
119
120 static void GetItemQuantity( InventoryItem item, out float q_cur, out float q_min, out float q_max )
121 {
122 if ( item.IsInherited( InventoryItem ) )
123 {
124 ItemBase item_base;
125 Class.CastTo(item_base, item);
126 if ( item.IsMagazine() )
127 {
128 Magazine magazine_item;
129 Class.CastTo(magazine_item, item);
130 q_cur = magazine_item.GetAmmoCount();
131 q_min = 0;
132 q_max = magazine_item.GetAmmoMax();
133 }
134 else
135 {
136 q_cur = item_base.GetQuantity();
137 q_min = item_base.GetQuantityMin();
138 q_max = item_base.GetQuantityMax();
139 }
140 }
141 }
142
143 static int HasItemQuantity( notnull EntityAI item )
144 {
145 ItemBase ib;
146 if ( Class.CastTo(ib, item) )
147 {
148 if ( item.IsMagazine() )
149 return QUANTITY_COUNT;
150
151 ItemBaseType itemBaseType = ItemBaseType.Cast(ib.GetEntityType());
152
153 if (!itemBaseType.m_CanShowQuantity)
154 return QUANTITY_HIDDEN;
155
156 int max = item.GetQuantityMax();
157 if (max > 0)
158 {
159 if (itemBaseType.m_HasQuantityBar)
160 {
161 return QUANTITY_PROGRESS;
162 }
163 else
164 {
165 if (max == 1)
166 {
167 return QUANTITY_HIDDEN;
168 }
169 else
170 {
171 return QUANTITY_COUNT;
172 }
173 }
174 }
175 }
176
177 return QUANTITY_HIDDEN;
178 }
179}
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения Feet.c:1
bool m_CanShowQuantity
Определения ItemBaseType.c:6
bool m_HasQuantityBar
Определения ItemBaseType.c:7
Определения ItemBaseType.c:5
static void GetItemQuantity(InventoryItem item, out float q_cur, out float q_min, out float q_max)
Определения QuantityConversions.c:120
static float GetItemQuantity(InventoryItem item)
Определения QuantityConversions.c:72
static int HasItemQuantity(notnull EntityAI item)
Определения QuantityConversions.c:143
static float GetItemQuantityMax(InventoryItem item)
Определения QuantityConversions.c:96
static string GetItemQuantityText(EntityAI item, bool showMax=false)
Определения QuantityConversions.c:3
string ToString()
Определения EnConvert.c:3
proto string ToString(bool simple=true)
const int QUANTITY_PROGRESS
Определения 3_Game/DayZ/constants.c:555
const int QUANTITY_COUNT
Определения 3_Game/DayZ/constants.c:554
const int QUANTITY_HIDDEN
Определения 3_Game/DayZ/constants.c:553
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
static proto string ToString(void var, bool type=false, bool name=false, bool quotes=true)
Return string representation of variable.
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.