430 {
432
433 if ( slot != NULL )
434 {
435 string item_type = item.GetType();
436
437 if ( slot.GetFertilityType() == "" || slot.GetFertilityType() == item_type )
438 {
439 slot.SetFertilityType(item_type);
440
441 float add_energy_to_slot =
GetGame().
ConfigGetFloat(
string.Format(
"cfgVehicles %1 Horticulture AddEnergyToSlot", item_type) );
442 slot.m_FertilizerUsage =
GetGame().
ConfigGetFloat(
string.Format(
"cfgVehicles %1 Horticulture ConsumedQuantity", item_type) );
443
444 float coef = Math.Clamp( consumed_quantity / slot.m_FertilizerUsage, 0.0, 1.0 );
445 add_energy_to_slot = coef * add_energy_to_slot;
446
447 slot.m_FertilizerQuantity += consumed_quantity;
448 slot.m_Fertility += add_energy_to_slot;
449
450 if ( slot.GetFertilizerQuantity() >= slot.GetFertilizerQuantityMax() )
451 {
452 int slot_index = slot.GetSlotIndex();
453
454 if (slot_index > -1)
455 {
458
460 }
461 }
462 }
463 else
464 {
465 slot.SetFertilizerQuantity(0);
466 slot.SetFertilityType("");
468 }
469 SetSynchDirty();
470 }
471 }
proto native float ConfigGetFloat(string path)
Get float value from config on path.
Slot GetSlotBySelection(string selection_component)
void UpdateSlotTexture(int slot_index)
proto native CGame GetGame()