20 protected void Init(
string className)
22 string path =
"cfgLiquidDefinitions " + className;
27 if (
GetGame().ConfigIsExisting(
string.Format(
"%1 liquidFreezeThreshold",
path)))
29 if (
GetGame().ConfigIsExisting(
string.Format(
"%1 liquidThawThreshold",
path)))
31 if (
GetGame().ConfigIsExisting(
string.Format(
"%1 liquidBoilingThreshold",
path)))
61 string cfg_classname =
"cfgLiquidDefinitions";
62 string property_value =
"NULL_PROPERTY";
63 int cfg_item_count =
g_Game.ConfigGetChildrenCount(cfg_classname);
65 for (
int i = 0; i < cfg_item_count; i++)
67 string liquid_class_name;
69 string liquid_full_path =
string.Format(
"%1 %2",cfg_classname, liquid_class_name);
70 int config_liquid_type =
GetGame().
ConfigGetInt(
string.Format(
"%1 type", liquid_full_path));
87 if (!Liquid.CanTransfer(source_ent, target_ent))
90 float source_quantity = source_ent.GetQuantity();
91 float target_quantity = target_ent.GetQuantity();
92 float targetCfgWeight = target_ent.m_ConfigWeight;
93 int source_liquid_type = source_ent.GetLiquidType();
95 float available_capacity = target_ent.GetQuantityMax() - target_quantity;
96 float quantity_to_transfer;
100 quantity_to_transfer =
Math.
Clamp(source_quantity,0,available_capacity);
105 quantity_to_transfer =
Math.
Clamp(
Math.
Min(source_quantity,quantity),0,available_capacity);
108 PluginTransmissionAgents m_mta = PluginTransmissionAgents.Cast(
GetPlugin(PluginTransmissionAgents));
111 source_ent.AddQuantity(-quantity_to_transfer);
113 float retultTemp = (source_ent.GetTemperature() * quantity_to_transfer + target_ent.GetTemperature() * (targetCfgWeight + target_quantity)) / (targetCfgWeight + target_quantity + quantity_to_transfer);
114 target_ent.SetTemperature(retultTemp);
118 Liquid.FillContainer(target_ent,source_liquid_type,quantity_to_transfer);
123 if (!source_ent || !target_ent)
128 if ((barrelTarget && !barrelTarget.
IsOpen()) || (barrelSource && !barrelSource.
IsOpen()))
133 if (source_ent.GetIsFrozen())
138 float source_quantity = source_ent.GetQuantity();
139 if (source_quantity <= 0)
145 int source_liquid_type = source_ent.GetLiquidType();
146 if (source_liquid_type < 1)
167 container.SetLiquidType(liquid_type);
168 container.AddQuantity(amount);
174 float containerCfgWeight = container.m_ConfigWeight;
175 float retultTemp = (
GetLiquidTypeEnviroTemperature(liquid_type) * amount + container.GetTemperature() * (containerCfgWeight + container.GetQuantity())) / (container.GetQuantity() + containerCfgWeight + amount);
176 container.SetTemperature(retultTemp);
183 PluginTransmissionAgents plugin = PluginTransmissionAgents.Cast(
GetPlugin(PluginTransmissionAgents));
203 plugin.TransmitAgents(NULL, container, agtSource, amount);
210 container.AffectLiquidContainerOnFill(liquid_type,amount);
215 container.AffectLiquidContainerOnTransfer(liquidType,amount,sourceLiquidTransfer);
239 bool is_container_full = container.IsFullQuantity();
241 if (is_container_full && !ignore_fullness_check)
247 int container_mask = container.GetLiquidContainerMask();
249 if (container_mask == 0)
255 if ((liquid_type & container_mask) == 0)
261 float container_quantity = container.GetQuantity();
263 int container_liquid_type = container.GetLiquidType();
265 if (container_quantity > 0 && container_liquid_type != liquid_type)
287 string cfg_classname =
"cfgLiquidDefinitions";
288 string property_value =
"NULL_PROPERTY";
290 return property_value;
292 int cfg_item_count =
g_Game.ConfigGetChildrenCount(cfg_classname);
294 for (
int i = 0; i < cfg_item_count; i++)
296 string liquid_class_name;
298 string liquid_full_path =
string.Format(
"%1 %2", cfg_classname, liquid_class_name);
299 int config_liquid_type =
GetGame().
ConfigGetInt(
string.Format(
"%1 type", liquid_full_path));
301 if (config_liquid_type == liquid_type)
303 if (!is_nutrition_property)
305 GetGame().
ConfigGetText(
string.Format(
"%1 %2", liquid_full_path, property_name), property_value);
306 return property_value;
310 GetGame().
ConfigGetText(
string.Format(
"%1 Nutrition %2", liquid_full_path, property_name), property_value);
311 return property_value;
315 return property_value;
339 profile.
m_Energy = Liquid.GetLiquidConfigProperty(liquid_type,
"energy",
true).ToFloat();
340 profile.
m_NutritionalIndex = Liquid.GetLiquidConfigProperty(liquid_type,
"nutritionalIndex",
true).ToFloat();
341 profile.
m_FullnessIndex = Liquid.GetLiquidConfigProperty(liquid_type,
"fullnessIndex",
true).ToFloat();
342 profile.
m_WaterContent = Liquid.GetLiquidConfigProperty(liquid_type,
"water",
true).ToFloat();
343 profile.
m_Toxicity = Liquid.GetLiquidConfigProperty(liquid_type,
"toxicity",
true).ToFloat();
344 profile.
m_Agents = Liquid.GetLiquidConfigProperty(liquid_type,
"agents",
true).ToInt();
345 profile.
m_Digestibility = Liquid.GetLiquidConfigProperty(liquid_type,
"digestibility",
true).ToFloat();
346 profile.
m_AgentsPerDigest = Liquid.GetLiquidConfigProperty(liquid_type,
"agentsPerDigest",
true).ToFloat();
422 return Liquid.GetLiquidConfigProperty(liquid_type,
"name");
static float GetAgentsPerDigest(ItemBase item, string className="", int foodStage=0)
static bool InitAllLiquids()
static ref map< string, ref LiquidInfo > m_LiquidInfosByName
class LiquidInfo m_AllLiquidsByType
static float GetToxicity(int liquid_type)
static float GetDigestibility(int liquid_type)
static ref map< int, ref LiquidInfo > m_LiquidInfosByType
static NutritionalProfile GetNutritionalProfileByType(int liquid_type)
static void FillContainerEnviro(ItemBase container, int liquid_type, float amount, bool inject_agents=true)
Filled from any enviro source (fuel feed, pond, snow...)
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 void AffectContainerOnTransfer(ItemBase container, int liquidType, float amount, float sourceLiquidTransfer)
static NutritionalProfile SetUpNutritionalProfile(int liquid_type, string liquid_class_name)
static string GetLiquidConfigProperty(int liquid_type, string property_name, bool is_nutrition_property=false)
static float GetFreezeThreshold(int liquid_type)
static float GetFlammability(int liquid_type)
static bool CanTransfer(ItemBase source_ent, ItemBase target_ent)
static float GetBoilThreshold(int liquid_type)
static float GetThawThreshold(int liquid_type)
static void Transfer(ItemBase source_ent, ItemBase target_ent, float quantity=-1)
static bool IsLiquidDrinkWater(int liquidType)
static int TranslateLiquidType(int liquidType)
Translates 'administrative' liquid types into liquid types with valid config class.
static NutritionalProfile GetNutritionalProfileByName(string class_name)
static void FillContainer(ItemBase container, int liquid_type, float amount)
static float GetLiquidTypeEnviroTemperature(int liquidType)
Gets liquid temperature from the enviroment.
static ref map< string, ref NutritionalProfile > m_AllLiquidsByName
static string GetDisplayName(int liquid_type)
static void AffectContainerOnFill(ItemBase container, int liquid_type, float amount)
from enviro source
static float GetWaterContent(int liquid_type)
class OptionSelectorMultistate extends OptionSelector class_name
PluginBase GetPlugin(typename plugin_type)
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
proto native float ConfigGetFloat(string path)
Get float value from config on path.
proto bool ConfigGetTextRaw(string path, out string value)
Get raw string value from config on path.
bool FormatRawConfigStringKeys(inout string value)
Changes localization key format to script-friendly format.
proto native int ConfigGetInt(string path)
Get int value from config on path.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native Mission GetMission()
ref NutritionalProfile m_NutriProfile
float m_TemperatureLiquidFreezeThreshold
float m_TemperatureLiquidBoilThreshold
float m_TemperatureLiquidThawThreshold
string m_LiquidDisplayName
void Init(string className)
void LiquidInfo(string className, NutritionalProfile profile)
void MarkAsLiquid(int liquid_type, string classname)
float GetLiquidTypeEnviroTemperature(int liquidType)
proto native CGame GetGame()
const int AGT_TRANSFER_COPY
const int AGT_WATER_HOT_SPRING
const int LIQUID_STILLWATER
const int LIQUID_HOTWATER
const int LIQUID_GROUP_DRINKWATER
const int LIQUID_FRESHWATER
const int LIQUID_RIVERWATER
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'.