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

◆ TakeMaterialsServer()

void TakeMaterialsServer ( string part_name,
bool repairing = false )
protected

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

672 {
673 string main_part_name = GetConstructionPart( part_name ).GetMainPartName();
674 string cfg_path = "cfgVehicles" + " " + GetParent().GetType() + " "+ "Construction" + " " + main_part_name + " " + part_name + " " + "Materials";
675
676 if ( GetGame().ConfigIsExisting( cfg_path ) )
677 {
678 int child_count = GetGame().ConfigGetChildrenCount( cfg_path );
679
680 for ( int i = 0; i < child_count; i++ )
681 {
682 string child_name;
683 GetGame().ConfigGetChildName( cfg_path, i, child_name );
684
685 //get type, quantity from material
686 string config_path;
687 string slot_name;
688 config_path = cfg_path + " " + child_name + " " + "slot_name";
689 GetGame().ConfigGetText( config_path, slot_name );
690 config_path = cfg_path + " " + child_name + " " + "quantity";
691 float quantity = GetGame().ConfigGetFloat( config_path );
692 config_path = cfg_path + " " + child_name + " " + "lockable";
693 bool lockable = GetGame().ConfigGetInt( config_path );
694
695 ItemBase attachment = ItemBase.Cast( GetParent().FindAttachmentBySlotName( slot_name ) );
696 if ( lockable )
697 {
698 //lock attachment
699 InventoryLocation inventory_location = new InventoryLocation;
700 attachment.GetInventory().GetCurrentInventoryLocation( inventory_location );
701
702 GetParent().GetInventory().SetSlotLock( inventory_location.GetSlot(), true );
703 }
704 else
705 {
706 if ( quantity > -1 ) //0 - ignores quantity
707 {
708 if (repairing)
709 {
710 quantity *= REPAIR_MATERIAL_PERCENTAGE;
711 quantity = Math.Max(Math.Floor(quantity),1);
712 }
713 //subtract quantity
714 attachment.AddQuantity( -quantity );
715 }
716 else //-1 - deletes the object
717 {
718 GetGame().ObjectDelete( attachment );
719 }
720 }
721 }
722 }
723 }
ConstructionPart GetConstructionPart(string part_name)
Определения Construction.c:280
enum ConstructionMaterialType REPAIR_MATERIAL_PERCENTAGE
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 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 int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native void ObjectDelete(Object obj)
string GetMainPartName()
Определения ConstructionPart.c:35
proto native int GetSlot()
returns slot id if current type is Attachment
InventoryLocation.
Определения InventoryLocation.c:29
Определения InventoryItem.c:731
Определения 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::ConfigGetInt(), CGame::ConfigGetText(), Math::Floor(), GetConstructionPart(), GetGame(), ConstructionPart::GetMainPartName(), GetParent(), InventoryLocation::GetSlot(), Math::Max(), CGame::ObjectDelete() и REPAIR_MATERIAL_PERCENTAGE.

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