21 string cfg_classname =
"cfgLiquidDefinitions";
22 string property_value =
"NULL_PROPERTY";
23 int cfg_item_count =
g_Game.ConfigGetChildrenCount(cfg_classname);
25 for (
int i = 0; i < cfg_item_count; i++ )
27 string liquid_class_name;
29 string liquid_full_path =
string.Format(
"%1 %2",cfg_classname, liquid_class_name);
30 int config_liquid_type =
GetGame().
ConfigGetInt(
string.Format(
"%1 type", liquid_full_path) );
48 float source_quantity = source.GetQuantity();
49 float target_quantity = target.GetQuantity();
50 int source_liquid_type = source.GetLiquidType();
51 int target_liquid_type = target.GetLiquidType();
52 int target_mask = target_ent.ConfigGetFloat(
"liquidContainerType");
53 int source_mask = source_ent.ConfigGetFloat(
"liquidContainerType");
55 float available_capacity = target.GetQuantityMax() - target_quantity;
63 float quantity_to_transfer;
67 quantity_to_transfer =
Math.
Clamp(source_quantity,0,available_capacity);
72 quantity_to_transfer =
Math.
Clamp(quantity,0,available_capacity);
76 PluginTransmissionAgents m_mta = PluginTransmissionAgents.Cast(
GetPlugin(PluginTransmissionAgents));
79 source.AddQuantity(-quantity_to_transfer);
86 if (!source_ent || !target_ent)
89 if ( !source_ent.IsItemBase() || !target_ent.IsItemBase() )
97 if ((barrelTarget && !barrelTarget.
IsOpen()) || (barrelSource && !barrelSource.
IsOpen()))
104 float source_quantity = source_ent.GetQuantity();
105 if ( source_quantity <= 0 )
111 int source_liquid_type = source_ent.GetLiquidType();
112 if ( source_liquid_type < 1 )
133 container.SetLiquidType(liquid_type);
134 container.AddQuantity(amount);
143 PluginTransmissionAgents plugin = PluginTransmissionAgents.Cast(
GetPlugin(PluginTransmissionAgents));
153 bool is_container_full = container.IsFullQuantity();
155 if ( is_container_full && !ignore_fullness_check)
161 int container_mask = container.ConfigGetFloat(
"liquidContainerType");
163 if ( container_mask == 0 )
169 if ( (liquid_type & container_mask) == 0 )
175 float container_quantity = container.GetQuantity();
177 int container_liquid_type = container.GetLiquidType();
179 if ( container_quantity > 0 && container_liquid_type != liquid_type)
189 string cfg_classname =
"cfgLiquidDefinitions";
190 string property_value =
"NULL_PROPERTY";
191 int cfg_item_count =
g_Game.ConfigGetChildrenCount(cfg_classname);
193 for (
int i = 0; i < cfg_item_count; i++ )
195 string liquid_class_name;
197 string liquid_full_path =
string.Format(
"%1 %2", cfg_classname, liquid_class_name);
198 int config_liquid_type =
GetGame().
ConfigGetInt(
string.Format(
"%1 type", liquid_full_path) );
200 if ( config_liquid_type == liquid_type )
202 if (!is_nutrition_property)
204 GetGame().
ConfigGetText(
string.Format(
"%1 %2", liquid_full_path, property_name), property_value);
205 return property_value;
209 GetGame().
ConfigGetText(
string.Format(
"%1 Nutrition %2", liquid_full_path, property_name), property_value);
210 return property_value;
214 return property_value;
class OptionSelectorMultistate extends OptionSelector class_name
PluginBase GetPlugin(typename plugin_type)
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 bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
static bool InitAllLiquids()
static private string GetLiquidConfigProperty(int liquid_type, string property_name, bool is_nutrition_property=false)
static float GetToxicity(int liquid_type)
static void FillContainerEnviro(ItemBase container, int liquid_type, float amount, bool inject_agents=false)
static float GetDigestibility(int liquid_type)
static NutritionalProfile GetNutritionalProfileByType(int liquid_type)
static int GetAgents(int liquid_type)
static float GetNutritionalIndex(int liquid_type)
static float GetFullness(int liquid_type)
static bool CanFillContainer(ItemBase container, int liquid_type, bool ignore_fullness_check=false)
static string GetLiquidClassname(int liquid_type)
static string GetName(int liquid_type)
static NutritionalProfile SetUpNutritionalProfile(int liquid_type, string liquid_class_name)
static ref map< int, ref NutritionalProfile > m_AllLiquidsByType
static float GetFlammability(int liquid_type)
static bool CanTransfer(ItemBase source_ent, ItemBase target_ent)
static void Transfer(ItemBase source_ent, ItemBase target_ent, float quantity=-1)
static NutritionalProfile GetNutritionalProfileByName(string class_name)
static void FillContainer(ItemBase container, int liquid_type, float amount)
static ref map< string, ref NutritionalProfile > m_AllLiquidsByName
static float GetEnergy(int liquid_type)
static float GetWaterContent(int liquid_type)
void MarkAsLiquid(int liquid_type, string classname)
string GetLiquidClassname()
proto native CGame GetGame()
const int AGT_TRANSFER_COPY
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'.
proto native int ToInt()
Converts string to integer.
proto native float ToFloat()
Converts string to float.