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

◆ InventoryReservation()

bool ActionBase::InventoryReservation ( ActionData action_data)
inlineprotected

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

980 {
981 if (g_Game.IsDedicatedServer())
982 return true;
983
984 if ((IsLocal() || !UseAcknowledgment()) && IsInstant())
985 return true;
986
987 //action_data.m_ReservedInventoryLocations = new array<ref InventoryLocation>;
988 bool success = true;
989 InventoryLocation targetInventoryLocation = NULL;
990 InventoryLocation handInventoryLocation = NULL;
991
992 // lock target if it has target
993 if (HasTarget())
994 {
995 ItemBase targetItem;
996 if ( ItemBase.CastTo(targetItem,action_data.m_Target.GetObject()) )
997 {
998 targetInventoryLocation = new InventoryLocation;
999 targetItem.GetInventory().GetCurrentInventoryLocation(targetInventoryLocation);
1000 if ( action_data.m_Player.GetInventory().HasInventoryReservation( targetItem, targetInventoryLocation) )
1001 {
1002 success = false;
1003 }
1004 else
1005 {
1006 action_data.m_Player.GetInventory().AddInventoryReservationEx( targetItem, targetInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
1007 }
1008 }
1009 }
1010
1011 handInventoryLocation = new InventoryLocation;
1012 handInventoryLocation.SetHands(action_data.m_Player,action_data.m_Player.GetItemInHands());
1013
1014 if (action_data.m_Player.GetInventory().HasInventoryReservation( action_data.m_Player.GetItemInHands(), handInventoryLocation))
1015 {
1016 if (HasTarget())
1017 {
1018 action_data.m_Player.GetInventory().ClearInventoryReservation(targetItem, targetInventoryLocation);
1019 }
1020
1021 success = false;
1022 }
1023 else
1024 {
1025 action_data.m_Player.GetInventory().AddInventoryReservationEx( action_data.m_Player.GetItemInHands(), handInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
1026 }
1027
1028 if (success)
1029 {
1030 if (targetInventoryLocation)
1031 action_data.m_ReservedInventoryLocations.Insert(targetInventoryLocation);
1032
1033 if (handInventoryLocation)
1034 action_data.m_ReservedInventoryLocations.Insert(handInventoryLocation);
1035 }
1036
1037 return success;
1038 }
DayZGame g_Game
Определения DayZGame.c:3942
class GP5GasMask extends MaskBase ItemBase
bool HasTarget()
Определения ActionBase.c:250
bool UseAcknowledgment()
Определения ActionBase.c:1146
bool IsInstant()
Определения ActionBase.c:268
bool IsLocal()
Определения ActionBase.c:262
proto native void SetHands(notnull EntityAI parent, EntityAI e)
sets current inventory location type to Hands

Перекрестные ссылки ActionData, GameInventory::c_InventoryReservationTimeoutMS, g_Game, HasTarget(), IsInstant(), IsLocal(), InventoryLocation::SetHands() и UseAcknowledgment().

Используется в ActionWorldCraft::OnFinishProgressServer(), ActionDeployBase::OnUpdate() и SetupAction().