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

◆ HandleSwapEntities()

void HandleSwapEntities ( DeferredEvent deferred_event)
protected

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

3995 {
3996 DeferredSwapEntities deferred_swap_entities = DeferredSwapEntities.Cast(deferred_event);
3997 if( deferred_swap_entities )
3998 {
3999 deferred_swap_entities.ClearInventoryReservation(this);
4000 InventoryLocation src1, src2, dst1, dst2;
4001 if (GameInventory.MakeSrcAndDstForSwap(deferred_swap_entities.m_item1, deferred_swap_entities.m_item2, src1, src2, dst1, dst2))
4002 {
4004 {
4005 inventoryDebugPrint("[inv] I::Swap(" + typename.EnumToString(InventoryMode, deferred_swap_entities.m_mode) + ") src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(deferred_swap_entities.m_dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(deferred_swap_entities.m_dst2));
4006 }
4007
4008 switch (deferred_swap_entities.m_mode)
4009 {
4010 case InventoryMode.PREDICTIVE:
4011 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
4012 {
4013 #ifdef DIAG_DEVELOPER
4014 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
4015 {
4016 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
4017 }
4018 else
4019 {
4020 #endif
4021
4022 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
4023 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
4024
4025 #ifdef DIAG_DEVELOPER
4026 }
4027 #endif
4028 }
4029 else
4030 {
4031 #ifdef ENABLE_LOGGING
4033 {
4034 Debug.InventoryMoveLog("Can not swap (PREDICTIVE) STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + deferred_swap_entities.m_dst1.GetItem() + " item2 = " + deferred_swap_entities.m_dst2.GetItem() + " dst=" + InventoryLocation.DumpToStringNullSafe(deferred_swap_entities.m_dst2), "n/a" , "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString() );
4035 }
4036 #endif
4037 }
4038 break;
4039
4040 case InventoryMode.JUNCTURE:
4041 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
4042 {
4043 #ifdef DIAG_DEVELOPER
4044 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
4045 {
4046 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
4047 }
4048 else
4049 {
4050 #endif
4051
4052 DayZPlayer player = g_Game.GetPlayer();
4053 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst1.GetItem(), deferred_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
4054 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst2.GetItem(), deferred_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
4055 EnableMovableOverride(deferred_swap_entities.m_dst1.GetItem());
4056 EnableMovableOverride(deferred_swap_entities.m_dst2.GetItem());
4057 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
4058
4059 #ifdef DIAG_DEVELOPER
4060 }
4061 #endif
4062 }
4063 else
4064 {
4065 #ifdef ENABLE_LOGGING
4067 {
4068 Debug.InventoryMoveLog("Can not swap (JUNCTURE) STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + deferred_swap_entities.m_dst1.GetItem() + " item2 = " + deferred_swap_entities.m_dst2.GetItem() + " dst=" + InventoryLocation.DumpToStringNullSafe(deferred_swap_entities.m_dst2), "n/a" , "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString() );
4069 }
4070 #endif
4071 }
4072 break;
4073
4074 case InventoryMode.LOCAL:
4075 break;
4076
4077 default:
4078 Error("SwapEntities - HandEvent - Invalid mode");
4079 }
4080 }
4081 else
4082 Error("SwapEntities - MakeSrcAndDstForSwap - no inv loc");
4083 }
4084 }
void inventoryDebugPrint(string s)
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
DayZGame g_Game
Определения DayZGame.c:4074
void EnableMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:3690
DayZPlayer GetDayZPlayerOwner()
Определения DayZPlayerInventory.c:170
proto string ToString()
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:326
Определения DayZPlayerImplement.c:87
static void InventoryMoveLog(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:198
Определения 3_Game/DayZ/tools/Debug.c:2
InventoryMode m_mode
Определения DayZPlayerInventory.c:4
EntityAI m_item1
Определения DayZPlayerInventory.c:42
ref InventoryLocation m_dst1
Определения DayZPlayerInventory.c:44
EntityAI m_item2
Определения DayZPlayerInventory.c:43
override void ClearInventoryReservation(HumanInventory inventory)
Определения DayZPlayerInventory.c:75
ref InventoryLocation m_dst2
Определения DayZPlayerInventory.c:45
const int c_InventoryReservationTimeoutShortMS
static bool MakeSrcAndDstForSwap(notnull EntityAI item1, notnull EntityAI item2, out InventoryLocation src1, out InventoryLocation src2, out InventoryLocation dst1, out InventoryLocation dst2)
helper function for swap
script counterpart to engine's class Inventory
static void SendInputUserDataSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap=false)
Определения InventoryInputUserData.c:81
static string DumpToStringNullSafe(InventoryLocation loc)
Определения InventoryLocation.c:233
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:30
static bool IsInventoryMoveLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:759
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90

Перекрестные ссылки GameInventory::c_InventoryReservationTimeoutShortMS, DeferredSwapEntities::ClearInventoryReservation(), InventoryLocation::DumpToStringNullSafe(), EnableMovableOverride(), Error(), g_Game, GetDayZPlayerOwner(), InventoryLocation::GetItem(), GetPlugin(), inventoryDebugPrint(), Debug::InventoryMoveLog(), LogManager::IsInventoryMoveLogEnable(), DeferredSwapEntities::m_dst1, DeferredSwapEntities::m_dst2, DeferredSwapEntities::m_item1, DeferredSwapEntities::m_item2, DeferredEvent::m_mode, GameInventory::MakeSrcAndDstForSwap(), InventoryInputUserData::SendInputUserDataSwap() и ToString().

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