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

◆ HandleSwapEntities()

void HandleSwapEntities ( DeferredEvent deferred_event)
protected

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

2165 {
2166 DeferredSwapEntities deferred_swap_entities = DeferredSwapEntities.Cast(deferred_event);
2167 if( deferred_swap_entities )
2168 {
2169 deferred_swap_entities.ClearInventoryReservation(this);
2170 InventoryLocation src1, src2, dst1, dst2;
2171 if (GameInventory.MakeSrcAndDstForSwap(deferred_swap_entities.m_item1, deferred_swap_entities.m_item2, src1, src2, dst1, dst2))
2172 {
2174 {
2175 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));
2176 }
2177
2178 switch (deferred_swap_entities.m_mode)
2179 {
2180 case InventoryMode.PREDICTIVE:
2181 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
2182 {
2183 #ifdef DIAG_DEVELOPER
2184 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
2185 {
2186 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
2187 }
2188 else
2189 {
2190 #endif
2191
2192 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
2193 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
2194
2195 #ifdef DIAG_DEVELOPER
2196 }
2197 #endif
2198 }
2199 else
2200 {
2201 #ifdef ENABLE_LOGGING
2203 {
2204 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() );
2205 }
2206 #endif
2207 }
2208 break;
2209
2210 case InventoryMode.JUNCTURE:
2211 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(),deferred_swap_entities.m_dst2.GetItem()) )
2212 {
2213 #ifdef DIAG_DEVELOPER
2214 if (PluginInventoryDebug.Cast(GetPlugin(PluginInventoryDebug)).IsLocalOnlyMoveEnable())
2215 {
2216 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
2217 }
2218 else
2219 {
2220 #endif
2221
2222 DayZPlayer player = g_Game.GetPlayer();
2223 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst1.GetItem(), deferred_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
2224 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst2.GetItem(), deferred_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
2225 EnableMovableOverride(deferred_swap_entities.m_dst1.GetItem());
2226 EnableMovableOverride(deferred_swap_entities.m_dst2.GetItem());
2227 InventoryInputUserData.SendInputUserDataSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
2228
2229 #ifdef DIAG_DEVELOPER
2230 }
2231 #endif
2232 }
2233 else
2234 {
2235 #ifdef ENABLE_LOGGING
2237 {
2238 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() );
2239 }
2240 #endif
2241 }
2242 break;
2243
2244 case InventoryMode.LOCAL:
2245 break;
2246
2247 default:
2248 Error("SwapEntities - HandEvent - Invalid mode");
2249 }
2250 }
2251 else
2252 Error("SwapEntities - MakeSrcAndDstForSwap - no inv loc");
2253 }
2254 }
void inventoryDebugPrint(string s)
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
DayZGame g_Game
Определения DayZGame.c:3942
void EnableMovableOverride(EntityAI item)
Определения DayZPlayerInventory.c:1860
DayZPlayer GetDayZPlayerOwner()
Определения DayZPlayerInventory.c:167
proto string ToString()
PluginBase GetPlugin(typename plugin_type)
Определения PluginManager.c:325
Определения 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:197
Определения 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:746
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().