DayZ 1.29
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 ( g_Game.ConfigIsExisting( cfg_path ) )
677 {
678 int child_count = g_Game.ConfigGetChildrenCount( cfg_path );
679
680 for ( int i = 0; i < child_count; i++ )
681 {
682 string child_name;
683 g_Game.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 g_Game.ConfigGetText( config_path, slot_name );
690 config_path = cfg_path + " " + child_name + " " + "quantity";
691 float quantity = g_Game.ConfigGetFloat( config_path );
692 config_path = cfg_path + " " + child_name + " " + "lockable";
693 bool lockable = g_Game.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 g_Game.ObjectDelete( attachment );
719 }
720 }
721 }
722 }
723 }
ConstructionPart GetConstructionPart(string part_name)
Определения Construction.c:280
enum ConstructionMaterialType REPAIR_MATERIAL_PERCENTAGE
DayZGame g_Game
Определения DayZGame.c:3942
string GetMainPartName()
Определения ConstructionPart.c:35
proto native int GetSlot()
returns slot id if current type is Attachment
InventoryLocation.
Определения InventoryLocation.c:30
Определения EnMath.c:7
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

Перекрестные ссылки Math::Floor(), g_Game, GetConstructionPart(), ConstructionPart::GetMainPartName(), GetParent(), InventoryLocation::GetSlot(), Math::Max() и REPAIR_MATERIAL_PERCENTAGE.

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