86 {
87 if (!Liquid.CanTransfer(source_ent, target_ent))
88 return;
89
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();
94
95 float available_capacity = target_ent.GetQuantityMax() - target_quantity;
96 float quantity_to_transfer;
97
98 if (quantity == -1)
99 {
100 quantity_to_transfer =
Math.
Clamp(source_quantity,0,available_capacity);
101 }
102
103 else
104 {
105 quantity_to_transfer =
Math.
Clamp(
Math.
Min(source_quantity,quantity),0,available_capacity);
106 }
107
108 PluginTransmissionAgents m_mta = PluginTransmissionAgents.Cast(
GetPlugin(PluginTransmissionAgents));
110
111 source_ent.AddQuantity(-quantity_to_transfer);
112
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);
115
117
118 Liquid.FillContainer(target_ent,source_liquid_type,quantity_to_transfer);
119 }
static void AffectContainerOnTransfer(ItemBase container, int liquidType, float amount, float sourceLiquidTransfer)
PluginBase GetPlugin(typename plugin_type)
const int AGT_TRANSFER_COPY
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'.