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

◆ HandleSwapEntities()

void HandleSwapEntities ( DeferredEvent deferred_event)
protected

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

1910 {
1911 DeferredSwapEntities deferred_swap_entities = DeferredSwapEntities.Cast(deferred_event);
1912 if( deferred_swap_entities )
1913 {
1914 deferred_swap_entities.ClearInventoryReservation(this);
1915 InventoryLocation src1, src2, dst1, dst2;
1916 if (GameInventory.MakeSrcAndDstForSwap(deferred_swap_entities.m_item1, deferred_swap_entities.m_item2, src1, src2, dst1, dst2))
1917 {
1919 {
1920 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));
1921 }
1922
1923 switch (deferred_swap_entities.m_mode)
1924 {
1925 case InventoryMode.PREDICTIVE:
1926 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
1927 {
1928 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
1929 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
1930 }
1931 else
1932 {
1933 #ifdef ENABLE_LOGGING
1935 {
1936 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() );
1937 }
1938 #endif
1939 }
1940 break;
1941
1942 case InventoryMode.JUNCTURE:
1943 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
1944 {
1945 DayZPlayer player = GetGame().GetPlayer();
1946 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst1.GetItem(), deferred_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1947 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst2.GetItem(), deferred_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1948 EnableMovableOverride(deferred_swap_entities.m_dst1.GetItem());
1949 EnableMovableOverride(deferred_swap_entities.m_dst2.GetItem());
1950 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
1951 }
1952 else
1953 {
1954 #ifdef ENABLE_LOGGING
1956 {
1957 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() );
1958 }
1959 #endif
1960 }
1961 break;
1962
1963 case InventoryMode.LOCAL:
1964 break;
1965
1966 default:
1967 Error("SwapEntities - HandEvent - Invalid mode");
1968 }
1969 }
1970 else
1971 Error("SwapEntities - MakeSrcAndDstForSwap - no inv loc");
1972 }
1973 }
void inventoryDebugPrint(string s)
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
void EnableMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:1627
DayZPlayer GetDayZPlayerOwner()
Определения DayZPlayerInventory.c:168
proto string ToString()
proto native DayZPlayer GetPlayer()
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/tools/Debug.c:137
Определения 3_Game/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:48
static string DumpToStringNullSafe(InventoryLocation loc)
Определения InventoryLocation.c:226
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:29
static bool IsInventoryMoveLogEnable()
Определения 3_Game/tools/Debug.c:648
Определения 3_Game/tools/Debug.c:594
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90

Перекрестные ссылки GameInventory::c_InventoryReservationTimeoutShortMS, DeferredSwapEntities::ClearInventoryReservation(), InventoryLocation::DumpToStringNullSafe(), EnableMovableOverride(), Error(), GetDayZPlayerOwner(), GetGame(), InventoryLocation::GetItem(), CGame::GetPlayer(), 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().