DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ HasMaterials()

bool HasMaterials ( string part_name,
bool repairing = false )
protected

См. определение в файле Construction.c строка 617

618 {
619 string main_part_name = GetConstructionPart( part_name ).GetMainPartName();
620 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
621
622 if ( GetGame().ConfigIsExisting( cfg_path ) )
623 {
624 int child_count = GetGame().ConfigGetChildrenCount( cfg_path );
625
626 for ( int i = 0; i < child_count; i++ )
627 {
628 string child_name;
629 GetGame().ConfigGetChildName( cfg_path, i, child_name );
630
631 //get type, quantity from material
632 string material_path;
633 string slot_name;
634 float quantity;
635 material_path = cfg_path + " " + child_name + " " + "slot_name";
636 GetGame().ConfigGetText( material_path, slot_name );
637 material_path = cfg_path + " " + child_name + " " + "quantity";
638 quantity = GetGame().ConfigGetFloat( material_path );
639
640 if (repairing)
641 {
642 quantity *= REPAIR_MATERIAL_PERCENTAGE;
643 quantity = Math.Max(Math.Floor(quantity),1);
644 }
645
646 //if the selected material (or its quantity) is not available
647 if ( !HasMaterialWithQuantityAttached( slot_name, quantity ) )
648 {
649 return false;
650 }
651 }
652 }
653
654 return true; //return true even if no material required
655 }
ConstructionPart GetConstructionPart(string part_name)
Определения Construction.c:280
enum ConstructionMaterialType REPAIR_MATERIAL_PERCENTAGE
bool HasMaterialWithQuantityAttached(string slot_name, float quantity)
Определения Construction.c:658
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 ConfigGetText(string path, out string value)
Get string value from config on path.
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
string GetMainPartName()
Определения ConstructionPart.c:35
Определения EnMath.c:7
proto native CGame GetGame()
static proto float Max(float x, float y)
Returns bigger of two given values.
static proto float Floor(float f)
Returns floor of value.
BaseBuildingBase GetParent()
Get parent of the Effect.
Определения Construction.c:40

Перекрестные ссылки CGame::ConfigGetChildName(), CGame::ConfigGetChildrenCount(), CGame::ConfigGetFloat(), CGame::ConfigGetText(), Math::Floor(), GetConstructionPart(), GetGame(), ConstructionPart::GetMainPartName(), GetParent(), HasMaterialWithQuantityAttached(), Math::Max() и REPAIR_MATERIAL_PERCENTAGE.

Используется в CanBuildPart().