DayZ 1.24
Loading...
Searching...
No Matches
Liquid Class Reference
Collaboration diagram for Liquid:
[legend]

Static Private Member Functions

static string GetLiquidClassname (int liquid_type)
 
static bool InitAllLiquids ()
 
static void Transfer (ItemBase source_ent, ItemBase target_ent, float quantity=-1)
 
static bool CanTransfer (ItemBase source_ent, ItemBase target_ent)
 
static void FillContainer (ItemBase container, int liquid_type, float amount)
 
static void FillContainerEnviro (ItemBase container, int liquid_type, float amount, bool inject_agents=false)
 
static bool CanFillContainer (ItemBase container, int liquid_type, bool ignore_fullness_check=false)
 
static string GetLiquidConfigProperty (int liquid_type, string property_name, bool is_nutrition_property=false)
 
static NutritionalProfile GetNutritionalProfileByType (int liquid_type)
 
static NutritionalProfile GetNutritionalProfileByName (string class_name)
 
static NutritionalProfile SetUpNutritionalProfile (int liquid_type, string liquid_class_name)
 
static int GetAgents (int liquid_type)
 
static float GetToxicity (int liquid_type)
 
static float GetWaterContent (int liquid_type)
 
static float GetEnergy (int liquid_type)
 
static float GetNutritionalIndex (int liquid_type)
 
static string GetName (int liquid_type)
 
static float GetFlammability (int liquid_type)
 
static float GetFullness (int liquid_type)
 
static float GetDigestibility (int liquid_type)
 

Static Private Attributes

static ref map< int, ref NutritionalProfilem_AllLiquidsByType = new map<int, ref NutritionalProfile>
 
static ref map< string, ref NutritionalProfilem_AllLiquidsByName = new map<string, ref NutritionalProfile>
 
static bool m_Init = InitAllLiquids()
 

Detailed Description

Definition at line 1 of file Liquid.c.

Member Function Documentation

◆ CanFillContainer()

static bool Liquid::CanFillContainer ( ItemBase container,
int liquid_type,
bool ignore_fullness_check = false )
inlinestaticprivate

Definition at line 136 of file Liquid.c.

137 {
138 if (!container)
139 return false;
140
141 bool is_container_full = container.IsFullQuantity();
142
144 {
145 //Debug.Log("container is full", "LiquidTransfer");
146 return false;
147
148 }
149 int container_mask = container.ConfigGetFloat("liquidContainerType");
150
151 if (container_mask == 0)
152 {
153 //Debug.Log("target is not a container", "LiquidTransfer");
154 return false;//if the target liquidContainerType is set to 0
155 }
156
157 if ((liquid_type & container_mask) == 0)
158 {
159 //Debug.Log("target liquidContainerType does not support this liquid type", "LiquidTransfer");
160 return false;
161 }
162
163 float container_quantity = container.GetQuantity();
164
165 int container_liquid_type = container.GetLiquidType();
166
168 {
169 //Debug.Log("target is not empty AND is of different liquid type than liquid_type added in", "LiquidTransfer");
170 return false;
171 }
172 return true;
173 }

Referenced by ActionWorldLiquidActionSwitch::ActionCondition(), CanTransfer(), FillContainer(), and ActionFillBottleBase::GetLiquidType().

◆ CanTransfer()

static bool Liquid::CanTransfer ( ItemBase source_ent,
ItemBase target_ent )
inlinestaticprivate

Definition at line 79 of file Liquid.c.

80 {
81 if (!source_ent || !target_ent)
82 return false;
83
84 if (!source_ent.IsItemBase() || !target_ent.IsItemBase())
85 {
86 //Debug.Log("One of the Items is not of ItemBase type", "LiquidTransfer");
87 return false;
88 }
89
92 if ((barrelTarget && !barrelTarget.IsOpen()) || (barrelSource && !barrelSource.IsOpen()))
93 return false;
94
95
96 float source_quantity = source_ent.GetQuantity();
97 if (source_quantity <= 0)
98 {
99 //Debug.Log("source has no quantity", "LiquidTransfer");
100 return false;//if there is nothing to transfer
101 }
102
103 int source_liquid_type = source_ent.GetLiquidType();
104 if (source_liquid_type < 1)
105 {
106 //Debug.Log("source has some quantity, but does not have a valid liquidType set, liquidType = "+ToString(source_liquid_type), "LiquidTransfer");
107 return false;//if source is not a container
108 }
109
111 return false;
112
113
114 return true;
115 }
static bool CanFillContainer(ItemBase container, int liquid_type, bool ignore_fullness_check=false)
Definition Liquid.c:136

References CanFillContainer().

Referenced by ActionDrainLiquid::ActionCondition(), ActionPourLiquid::ActionCondition(), ActionTransferLiquid::ActionCondition(), RecipeBase::CanDo(), and Transfer().

◆ FillContainer()

static void Liquid::FillContainer ( ItemBase container,
int liquid_type,
float amount )
inlinestaticprivate

Definition at line 116 of file Liquid.c.

117 {
119 return;
120 //filling
121 container.SetLiquidType(liquid_type);
122 container.AddQuantity(amount);
123
124 }

References CanFillContainer().

Referenced by FillContainerEnviro(), and Transfer().

◆ FillContainerEnviro()

static void Liquid::FillContainerEnviro ( ItemBase container,
int liquid_type,
float amount,
bool inject_agents = false )
inlinestaticprivate

Definition at line 126 of file Liquid.c.

127 {
129 if (inject_agents)
130 {
131 PluginTransmissionAgents plugin = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
132 plugin.TransmitAgents(NULL, container, AGT_WATER_POND, amount);
133 }
134 }
PluginBase GetPlugin(typename plugin_type)
static void FillContainer(ItemBase container, int liquid_type, float amount)
Definition Liquid.c:116
const int AGT_WATER_POND
Definition constants.c:471

References AGT_WATER_POND, FillContainer(), and GetPlugin().

Referenced by CAContinuousFill::CalcAndSetQuantity(), RainProcurementComponentBase::ProcureLiquid(), and RainProcurementManager::RainProcurementCheck().

◆ GetAgents()

static int Liquid::GetAgents ( int liquid_type)
inlinestaticprivate

Definition at line 229 of file Liquid.c.

230 {
231 return Liquid.GetLiquidConfigProperty(liquid_type, "agents", true).ToInt();
232 }
Definition Liquid.c:2
static string GetLiquidConfigProperty(int liquid_type, string property_name, bool is_nutrition_property=false)
Definition Liquid.c:175

References GetLiquidConfigProperty().

◆ GetDigestibility()

static float Liquid::GetDigestibility ( int liquid_type)
inlinestaticprivate

Definition at line 269 of file Liquid.c.

270 {
271 return Liquid.GetLiquidConfigProperty(liquid_type, "digestibility", true).ToFloat();
272 }

References GetLiquidConfigProperty().

Referenced by SetUpNutritionalProfile().

◆ GetEnergy()

static float Liquid::GetEnergy ( int liquid_type)
inlinestaticprivate

Definition at line 244 of file Liquid.c.

245 {
246 return Liquid.GetLiquidConfigProperty(liquid_type, "energy", true).ToFloat();
247 }

References GetLiquidConfigProperty().

◆ GetFlammability()

static float Liquid::GetFlammability ( int liquid_type)
inlinestaticprivate

Definition at line 259 of file Liquid.c.

260 {
261 return Liquid.GetLiquidConfigProperty(liquid_type, "flammability").ToFloat();
262 }

References GetLiquidConfigProperty().

◆ GetFullness()

static float Liquid::GetFullness ( int liquid_type)
inlinestaticprivate

Definition at line 264 of file Liquid.c.

265 {
266 return Liquid.GetLiquidConfigProperty(liquid_type, "fullnessIndex", true).ToFloat();
267 }

References GetLiquidConfigProperty().

Referenced by SetUpNutritionalProfile().

◆ GetLiquidClassname()

static string Liquid::GetLiquidClassname ( int liquid_type)
inlinestaticprivate

Definition at line 8 of file Liquid.c.

9 {
11 if (liquid)
12 return liquid.GetLiquidClassname();
13
14 return "";
15 }
static ref map< int, ref NutritionalProfile > m_AllLiquidsByType
Definition Liquid.c:3

References m_AllLiquidsByType.

Referenced by ManBase::Consume().

◆ GetLiquidConfigProperty()

static string Liquid::GetLiquidConfigProperty ( int liquid_type,
string property_name,
bool is_nutrition_property = false )
inlinestaticprivate

Definition at line 175 of file Liquid.c.

176 {
177 string cfg_classname = "cfgLiquidDefinitions";
178 string property_value = "NULL_PROPERTY";
179 int cfg_item_count = g_Game.ConfigGetChildrenCount(cfg_classname);
180
181 for (int i = 0; i < cfg_item_count; i++)
182 {
183 string liquid_class_name;
184 GetGame().ConfigGetChildName(cfg_classname, i, liquid_class_name);
185 string liquid_full_path = string.Format("%1 %2", cfg_classname, liquid_class_name);
186 int config_liquid_type = GetGame().ConfigGetInt(string.Format("%1 type", liquid_full_path));
187
188 if (config_liquid_type == liquid_type)// found the specific class, now lets extract the values
189 {
191 {
192 GetGame().ConfigGetText(string.Format("%1 %2", liquid_full_path, property_name), property_value);
193 return property_value;
194 }
195 else
196 {
197 GetGame().ConfigGetText(string.Format("%1 Nutrition %2", liquid_full_path, property_name), property_value);
198 return property_value;
199 }
200 }
201 }
202 return property_value;
203 }
DayZGame g_Game
Definition DayZGame.c:3528
proto native CGame GetGame()

References g_Game, and GetGame().

Referenced by GetAgents(), GetDigestibility(), GetEnergy(), GetFlammability(), GetFullness(), GetName(), GetNutritionalIndex(), GetToxicity(), and GetWaterContent().

◆ GetName()

static string Liquid::GetName ( int liquid_type)
inlinestaticprivate

Definition at line 254 of file Liquid.c.

255 {
257 }

References GetLiquidConfigProperty().

◆ GetNutritionalIndex()

static float Liquid::GetNutritionalIndex ( int liquid_type)
inlinestaticprivate

Definition at line 249 of file Liquid.c.

250 {
251 return Liquid.GetLiquidConfigProperty(liquid_type, "nutritionalIndex", true).ToFloat();
252 }

References GetLiquidConfigProperty().

Referenced by SetUpNutritionalProfile().

◆ GetNutritionalProfileByName()

static NutritionalProfile Liquid::GetNutritionalProfileByName ( string class_name)
inlinestaticprivate

Definition at line 210 of file Liquid.c.

211 {
212 return m_AllLiquidsByName.Get(class_name);
213 }
class OptionSelectorMultistate extends OptionSelector class_name
static ref map< string, ref NutritionalProfile > m_AllLiquidsByName
Definition Liquid.c:4

References class_name, and m_AllLiquidsByName.

Referenced by AddToStomach().

◆ GetNutritionalProfileByType()

static NutritionalProfile Liquid::GetNutritionalProfileByType ( int liquid_type)
inlinestaticprivate

Definition at line 205 of file Liquid.c.

206 {
208 }

References m_AllLiquidsByType.

◆ GetToxicity()

static float Liquid::GetToxicity ( int liquid_type)
inlinestaticprivate

Definition at line 234 of file Liquid.c.

235 {
236 return Liquid.GetLiquidConfigProperty(liquid_type, "toxicity", true).ToFloat();
237 }

References GetLiquidConfigProperty().

Referenced by SetUpNutritionalProfile().

◆ GetWaterContent()

static float Liquid::GetWaterContent ( int liquid_type)
inlinestaticprivate

Definition at line 239 of file Liquid.c.

240 {
241 return Liquid.GetLiquidConfigProperty(liquid_type, "water", true).ToFloat();
242 }

References GetLiquidConfigProperty().

Referenced by SetUpNutritionalProfile().

◆ InitAllLiquids()

static bool Liquid::InitAllLiquids ( )
inlinestaticprivate

Definition at line 17 of file Liquid.c.

18 {
19 string cfg_classname = "cfgLiquidDefinitions";
20 string property_value = "NULL_PROPERTY";
21 int cfg_item_count = g_Game.ConfigGetChildrenCount(cfg_classname);
22
23 for (int i = 0; i < cfg_item_count; i++)
24 {
25 string liquid_class_name;
26 GetGame().ConfigGetChildName(cfg_classname, i, liquid_class_name);
27 string liquid_full_path = string.Format("%1 %2", cfg_classname, liquid_class_name);
28 int config_liquid_type = GetGame().ConfigGetInt(string.Format("%1 type", liquid_full_path));
31
32 }
33 return true;
34 }
static NutritionalProfile SetUpNutritionalProfile(int liquid_type, string liquid_class_name)
Definition Liquid.c:215

References g_Game, GetGame(), m_AllLiquidsByName, m_AllLiquidsByType, and SetUpNutritionalProfile().

◆ SetUpNutritionalProfile()

static NutritionalProfile Liquid::SetUpNutritionalProfile ( int liquid_type,
string liquid_class_name )
inlinestaticprivate

Definition at line 215 of file Liquid.c.

216 {
226 return profile;
227 }
float GetEnergy()
Definition ItemBase.c:8140
override int GetAgents()
Definition ItemBase.c:8554
static float GetNutritionalIndex(int liquid_type)
Definition Liquid.c:249
static float GetToxicity(int liquid_type)
Definition Liquid.c:234
static float GetFullness(int liquid_type)
Definition Liquid.c:264
static float GetWaterContent(int liquid_type)
Definition Liquid.c:239
static float GetDigestibility(int liquid_type)
Definition Liquid.c:269

References GetAgents(), GetDigestibility(), GetEnergy(), GetFullness(), GetNutritionalIndex(), GetToxicity(), and GetWaterContent().

Referenced by InitAllLiquids().

◆ Transfer()

static void Liquid::Transfer ( ItemBase source_ent,
ItemBase target_ent,
float quantity = -1 )
inlinestaticprivate

Definition at line 37 of file Liquid.c.

38 {
40 return;
41
44
45 // Debug.Log("Transfer, source:"+source.ToString()+" target: "+target.ToString(), "LiquidTransfer");
46
47 float source_quantity = source.GetQuantity();
48 float target_quantity = target.GetQuantity();
49 int source_liquid_type = source.GetLiquidType();
50 int target_liquid_type = target.GetLiquidType();
51 int target_mask = target_ent.ConfigGetFloat("liquidContainerType");
52 int source_mask = source_ent.ConfigGetFloat("liquidContainerType");
53
54 float available_capacity = target.GetQuantityMax() - target_quantity;
55
56 // Debug.Log("target_mask ="+target_mask.ToString(), "LiquidTransfer");
57 // Debug.Log("source_mask ="+source_mask.ToString(), "LiquidTransfer");
58 // Debug.Log("source_liquid_type ="+source_liquid_type.ToString(), "LiquidTransfer");
59 // Debug.Log("target_liquid_type ="+target_liquid_type.ToString(), "LiquidTransfer");
60
61 //target.GetBloodType(source_liquid_type);//override target liquidType
63 //transfers all
64 if (quantity == -1)
66 //transfers exact ammount
67 else
69
70 //target.AddQuantity(quantity_to_transfer);
71 PluginTransmissionAgents m_mta = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
73
74 source.AddQuantity(-quantity_to_transfer);
75
77 }
static bool CanTransfer(ItemBase source_ent, ItemBase target_ent)
Definition Liquid.c:79
Definition EnMath.c:7
const int AGT_TRANSFER_COPY
Definition constants.c:469
static proto float Min(float x, float y)
Returns smaller of two given values.
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.

References AGT_TRANSFER_COPY, CanTransfer(), Math::Clamp(), FillContainer(), GetPlugin(), and Math::Min().

Referenced by CAContinuousQuantityLiquidTransfer::CalcAndSetQuantity(), and RecipeBase::Do().

Member Data Documentation

◆ m_AllLiquidsByName

ref map<string, ref NutritionalProfile> Liquid::m_AllLiquidsByName = new map<string, ref NutritionalProfile>
staticprivate

Definition at line 4 of file Liquid.c.

Referenced by GetNutritionalProfileByName(), and InitAllLiquids().

◆ m_AllLiquidsByType

ref map<int, ref NutritionalProfile> Liquid::m_AllLiquidsByType = new map<int, ref NutritionalProfile>
staticprivate

Definition at line 3 of file Liquid.c.

Referenced by GetLiquidClassname(), GetNutritionalProfileByType(), and InitAllLiquids().

◆ m_Init

bool Liquid::m_Init = InitAllLiquids()
staticprivate

Definition at line 6 of file Liquid.c.


The documentation for this class was generated from the following file: