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

◆ InventoryReservation()

bool InventoryReservation ( ActionData action_data)
protected

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

1054 {
1055#ifdef ENABLE_LOGGING
1057 {
1058 Debug.ActionLog("STS = " + action_data.m_Player.GetSimulationTimeStamp(), this.ToString() , "n/a", "InventoryReservation", action_data.m_Player.ToString() );
1059 }
1060#endif
1061 if (g_Game.IsDedicatedServer())
1062 return true;
1063
1064 if ((IsLocal() || !UseAcknowledgment()) && IsInstant())
1065 return true;
1066
1067 //action_data.m_ReservedInventoryLocations = new array<ref InventoryLocation>;
1068 bool success = true;
1069 InventoryLocation targetInventoryLocation = NULL;
1070 InventoryLocation handInventoryLocation = NULL;
1071
1072 // lock target if it has target
1073 if (HasTarget())
1074 {
1075 ItemBase targetItem;
1076 if ( ItemBase.CastTo(targetItem,action_data.m_Target.GetObject()) )
1077 {
1078 targetInventoryLocation = new InventoryLocation;
1079 targetItem.GetInventory().GetCurrentInventoryLocation(targetInventoryLocation);
1080 if ( action_data.m_Player.GetInventory().HasInventoryReservation( targetItem, targetInventoryLocation) )
1081 {
1082 success = false;
1083 }
1084 else
1085 {
1086 action_data.m_Player.GetInventory().AddInventoryReservationEx( targetItem, targetInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
1087 }
1088 }
1089 }
1090
1091 handInventoryLocation = new InventoryLocation;
1092 handInventoryLocation.SetHands(action_data.m_Player,action_data.m_Player.GetItemInHands());
1093
1094 if (action_data.m_Player.GetInventory().HasInventoryReservation( action_data.m_Player.GetItemInHands(), handInventoryLocation))
1095 {
1096 if (HasTarget())
1097 {
1098 action_data.m_Player.GetInventory().ClearInventoryReservation(targetItem, targetInventoryLocation);
1099 }
1100
1101 success = false;
1102 }
1103 else
1104 {
1105 action_data.m_Player.GetInventory().AddInventoryReservationEx( action_data.m_Player.GetItemInHands(), handInventoryLocation, GameInventory.c_InventoryReservationTimeoutMS);
1106 }
1107
1108 if (success)
1109 {
1110 if (targetInventoryLocation)
1111 action_data.m_ReservedInventoryLocations.Insert(targetInventoryLocation);
1112
1113 if (handInventoryLocation)
1114 action_data.m_ReservedInventoryLocations.Insert(handInventoryLocation);
1115 }
1116
1117 return success;
1118 }
bool HasTarget()
Определения ActionBase.c:259
bool UseAcknowledgment()
Определения ActionBase.c:1255
bool IsLocal()
Определения ActionBase.c:271
bool IsInstant()
Определения ActionBase.c:294
DayZGame g_Game
Определения DayZGame.c:4074
PlayerBase m_Player
Определения ActionBase.c:40
ref ActionTarget m_Target
Определения ActionBase.c:39
ref array< ref InventoryLocation > m_ReservedInventoryLocations
Определения ActionBase.c:42
static void ActionLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Определения 3_Game/DayZ/tools/Debug.c:188
Определения 3_Game/DayZ/tools/Debug.c:2
const int c_InventoryReservationTimeoutMS
reservations
script counterpart to engine's class Inventory
proto native void SetHands(notnull EntityAI parent, EntityAI e)
sets current inventory location type to Hands
InventoryLocation.
Определения InventoryLocation.c:30
static bool IsActionLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:749

Перекрестные ссылки Debug::ActionLog(), GameInventory::c_InventoryReservationTimeoutMS, g_Game, HasTarget(), LogManager::IsActionLogEnable(), IsInstant(), IsLocal(), ActionData::m_Player, ActionData::m_ReservedInventoryLocations, ActionData::m_Target, InventoryLocation::SetHands() и UseAcknowledgment().

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