DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Inventory.c
См. документацию.
1//-------------------------------------------------------
14{
16 SWAP,
17 //LOAD, ///< load mag from ground
18};
19
28
35
42
56
62
63enum FindInventoryReservationMode
64{
73};
74
79{
80 protected static int m_inventory_check_context = InventoryCheckContext.DEFAULT;
81
82//-------------------------------------------------------
85
91
92#ifdef DEVELOPER
97 proto native void DumpInventoryDebug();
98
103 static proto native void DumpStaticInventoryDebug();
104#endif
105
116 proto native bool HasEntityInInventory(notnull EntityAI item);
117
126
132 proto native int CountInventory();
133
134
136 proto native CargoBase GetCargo();
137 proto native CargoBase GetCargoFromIndex(int index);
141 proto native EntityAI CreateEntityInCargo(string typeName);
148 proto native EntityAI CreateEntityInCargoEx(string typeName, int idx, int row, int col, bool flip);
149
150 proto native bool HasEntityInCargo(notnull EntityAI e);
151 proto native bool HasEntityInCargoEx(notnull EntityAI e, int idx, int row, int col);
152 proto native bool CanAddEntityInCargo(notnull EntityAI e, bool flip);
153 proto native bool CanAddEntityInCargoEx(notnull EntityAI e, int idx, int row, int col, bool flip);
155 proto native bool TestAddEntityInCargoEx(notnull EntityAI e, int idx, int row, int col, bool flip, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check);
156 proto native bool TestAddEntityInCargoExLoc(notnull InventoryLocation loc, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check);
157 //proto native bool AddEntityInCargo (notnull EntityAI owner, EntityAI cargo);
158 //proto native bool AddEntityInCargoEx (notnull EntityAI owner, notnull EntityAI e, int idx, int row, int col);
159 proto native bool CanRemoveEntityInCargo(notnull EntityAI e);
160 proto native bool CanRemoveEntityInCargoEx(notnull EntityAI e, int idx, int row, int col);
162
163
165
169 proto native int GetSlotId(int index);
173 proto native int GetSlotIdCount();
178 proto native int GetAttachmentSlotId(int index);
182 proto native int GetAttachmentSlotsCount();
186 /*proto native*/bool HasAttachmentSlot(int slotId) //TODO - flip to code
187 {
188 int count = GetAttachmentSlotsCount();
189 for (int i = 0; i < count; i++)
190 {
191 if (GetAttachmentSlotId(i) == slotId)
192 return true;
193 }
194 return false;
195 }
196
199 proto native bool HasInventorySlot(int slotId);
203 proto native int AttachmentCount();
207 proto native EntityAI CreateAttachment(string typeName);
213 proto native EntityAI CreateAttachmentEx(string typeName, int slotId);
218 proto native EntityAI GetAttachmentFromIndex(int index);
222 proto native EntityAI FindAttachment(int slot);
230 proto native bool HasAttachment(notnull EntityAI e);
234 proto native bool HasAttachmentEx(notnull EntityAI e, int slot);
239 proto native bool CanAddAttachment(notnull EntityAI e);
244 proto native bool CanAddAttachmentEx(notnull EntityAI e, int slot);
245
246 proto native bool CanRemoveAttachment(EntityAI attachment);
247 proto native bool CanRemoveAttachmentEx(EntityAI attachment, int slot);
248
249 //proto native bool RemoveAttachment(EntityAI attachment);
250 //proto native bool RemoveAttachmentEx(EntityAI attachment, int slot);
251
255 proto native EntityAI FindPlaceholderForSlot(int slot);
256 proto native bool IsPlaceholderEntity(notnull Object e);
258
259
266 proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc);
267
274 proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc);
281 proto native bool FindFreeLocationForEx(notnull EntityAI item, FindInventoryLocationType flags, notnull InventoryLocation exclude, out notnull InventoryLocation loc);
282
289 proto native bool FindFirstFreeLocationForNewEntity(string item_type, FindInventoryLocationType flags, out notnull InventoryLocation loc);
290
323 proto native int FindFreeLocationsFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull array<ref InventoryLocation> locs);
324
331 static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation);
339 static proto native EntityAI LocationCreateLocalEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation);
345 static proto native bool LocationCanAddEntity(notnull InventoryLocation inv_loc);
346
347 //Added script check to LocationCanAddEntity
348 static bool LocationCanAddEntityEx(notnull InventoryLocation inv_loc)
349 {
350 return LocationCanAddEntity(inv_loc);
351 }
352
358 static proto native bool LocationTestAddEntity(notnull InventoryLocation inv_loc, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check);
364 static proto native bool LocationCanRemoveEntity(notnull InventoryLocation inv_loc);
371 static proto native bool LocationCanMoveEntity(notnull InventoryLocation src, notnull InventoryLocation dst);
372
374 {
376 }
377
379 {
381 bool result = LocationCanMoveEntity(src, dst);
383 return result;
384
385 }
386
391 static proto native EntityAI LocationGetEntity(notnull InventoryLocation inv_loc);
392
393
396 {
399 if (lcn.GetType() == InventoryLocationType.CARGO)
400 {
401 return true;
402 }
403
404 return false;
405 }
406
409 {
412 if (lcn.GetType() == InventoryLocationType.ATTACHMENT)
413 {
414 return true;
415 }
416
417 return false;
418 }
419
422 {
425 while (ent)
426 {
427 if (ent.GetInventory().GetCurrentInventoryLocation(lcn) && lcn.IsValid())
428 {
429 if (lcn.GetType() == InventoryLocationType.CARGO || lcn.GetType() == InventoryLocationType.PROXYCARGO)
430 return true;
431 }
432
433 ent = ent.GetHierarchyParent();
434 }
435
436 return false;
437 }
438
441 {
443 if (ent)
444 return ent.AreChildrenAccessible();
445
446 #ifdef DEVELOPER
447 ErrorEx("no inventory owner found!");
448 #endif
449
450 return true; //just in case inventoy without owner exists somewhere (shouldn't!)
451 }
452
454 bool GetCurrentAttachmentSlotInfo(out int slot_id, out string slot_name)
455 {
456 slot_id = InventorySlots.INVALID;
457 slot_name = "";
460 if (lcn.GetType() == InventoryLocationType.ATTACHMENT)
461 {
462 slot_id = lcn.GetSlot();
463 slot_name = InventorySlots.GetSlotName(slot_id);
464 return true;
465 }
466 return false;
467 }
468
470 {
471 int tmp = -1;
472 ctx.Read(tmp);
473
474 int type = -1;
475 if (!ctx.Read(type))
476 return;
477
478 switch (type)
479 {
480 case InventoryCommandType.SYNC_MOVE:
481 {
484
485 src.ReadFromContext(ctx);
486 dst.ReadFromContext(ctx);
487 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] t=" + GetGame().GetTime() + "ms ServerInventoryCommand cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
488
489 if (!src.GetItem() || !dst.GetItem())
490 {
491 Error("[syncinv] ServerInventoryCommand (cmd=SYNC_MOVE) dropped, item not in bubble");
492 break; // not in bubble
493 }
494
495 LocationSyncMoveEntity(src, dst);
496 break;
497 }
498
499 case InventoryCommandType.HAND_EVENT:
500 {
501 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
502 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] t=" + GetGame().GetTime() + "ms ServerInventoryCommand cmd=" + typename.EnumToString(InventoryCommandType, type) + " event=" + e.DumpToString());
503
504 if (!e.GetSrcEntity())
505 {
506 Error("[syncinv] ServerInventoryCommand (cmd=HAND_EVENT) dropped, item not in bubble");
507 break; // not in bubble
508 }
509 e.m_Player.GetHumanInventory().ProcessHandEvent(e);
510 break;
511 }
512
513 case InventoryCommandType.FORCESWAP:
514 case InventoryCommandType.SWAP:
515 {
520 src1.ReadFromContext(ctx);
521 src2.ReadFromContext(ctx);
522 dst1.ReadFromContext(ctx);
523 dst2.ReadFromContext(ctx);
524
525 if (src1.IsValid() && src2.IsValid() && dst1.IsValid() && dst2.IsValid())
526 {
527 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] t=" + GetGame().GetTime() + "ms ServerInventoryCommand Swap src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
528
529 LocationSwap(src1, src2, dst1, dst2);
530 }
531 else
532 Error("ServerInventoryCommand - cannot swap, invalid location input: src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
533
534 break;
535 }
536 }
537 }
538
544 static proto native bool LocationAddEntity(notnull InventoryLocation inv_loc);
550 static proto native bool LocationRemoveEntity(notnull InventoryLocation inv_loc);
551
557 static proto native bool LocationMoveEntity(notnull InventoryLocation src_loc, notnull InventoryLocation dst_loc);
558
565 static proto native bool LocationSyncMoveEntity(notnull InventoryLocation src_loc, notnull InventoryLocation dst_loc);
566
572 static proto native bool LocationSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2);
573
579 static proto native bool ServerLocationMoveEntity(notnull EntityAI item, ParamsWriteContext ctx);
580
588 static proto native bool ServerLocationSyncMoveEntity(Man player, notnull EntityAI item, ParamsWriteContext ctx);
589
595 static proto native bool ServerLocationSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, ParamsWriteContext ctx);
596
602 static proto native bool ServerHandEvent(notnull Man player, notnull EntityAI item, ParamsWriteContext ctx);
603
613 static proto native bool PrepareDropEntityPos(EntityAI owner, notnull EntityAI item, out vector mat[4], bool useValuesInMatrix = false, int conflictCheckDepth = -1);
614 static proto native bool TestDropEntityPos(EntityAI owner, notnull EntityAI item, out vector mat[4], bool useValuesInMatrix = false, int conflictCheckDepth = -1);
615
626 static proto native bool CanSwapEntities(notnull EntityAI item1, notnull EntityAI item2);
627
628 static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
629 {
630 int slot;
633
634 item2.GetInventory().GetCurrentInventoryLocation(il2);
635 slot = il2.GetSlot();
636
637 if (item1.CanBeSplit() && item1.GetQuantity() > item1.GetTargetQuantityMax(slot))
638 return false;
639
640 item1.GetInventory().GetCurrentInventoryLocation(il1);
641 slot = il1.GetSlot();
642
643 if (item2.CanBeSplit() && item2.GetQuantity() > item2.GetTargetQuantityMax(slot))
644 return false;
645
646 if (!item1.CanSwapEntities(item2, il2, il1) || !item2.CanSwapEntities(item1, il1, il2))
647 {
648 return false;
649 }
650
651 return CanSwapEntities(item1,item2);
652 }
653
663 static proto native bool CanForceSwapEntities(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst);
664 static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
665 {
666 if (!CanForceSwapEntities(item1, item1_dst, item2, item2_dst) )
667 return false;
668
669 int slot;
671
672 if (!item1.CanBeFSwaped())
673 return false;
674
675 if ( item1_dst == null)
676 {
677 item2.GetInventory().GetCurrentInventoryLocation(il);
678 slot = il.GetSlot();
679 }
680 else
681 {
682 slot = item1_dst.GetSlot();
683 }
684
685 if ( item1.GetQuantity() > item1.GetTargetQuantityMax(slot) )
686 return false;
687
688 if ( item2_dst == null)
689 {
690 item1.GetInventory().GetCurrentInventoryLocation(il);
691 slot = il.GetSlot();
692 }
693 else
694 {
695 slot = item2_dst.GetSlot();
696 }
697
698 if (!item1.CanSwapEntities(item2, item2_dst, item1_dst) || !item2.CanSwapEntities(item1, item1_dst, item2_dst))
699 {
700 return false;
701 }
702
703 if ( item2.GetQuantity() > item2.GetTargetQuantityMax(slot) )
704 return false;
705
706 return true;
707 }
708
709 proto native bool CanAddSwappedEntity(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2);
710
714
715 static proto native bool AddInventoryReservation(EntityAI item, InventoryLocation dst, int timeout_ms);
717 {
718 if (GetGame().IsMultiplayer() && GetGame().IsServer() )
719 return true;
720
721 bool ret_val = AddInventoryReservation(item, dst, timeout_ms);
722 #ifdef ENABLE_LOGGING
724 {
725 DayZPlayer player = GetGame().GetPlayer();
726 if ( player )
727 {
728 if (item)
729 Debug.InventoryMoveLog("Reservation result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / " + item.ToString() + " / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "AddInventoryReservation", player.ToString() );
730 else
731 Debug.InventoryMoveLog("Reservation result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / null / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "AddInventoryReservation", player.ToString() );
732 }
733 }
734 #endif
735 return ret_val;
736 }
737
738 static proto native bool ExtendInventoryReservation(EntityAI item, InventoryLocation dst, int timeout_ms);
740 {
741 if (GetGame().IsMultiplayer() && GetGame().IsServer() )
742 return true;
743
744 bool ret_val = ExtendInventoryReservation(item,dst,timeout_ms);
745 #ifdef ENABLE_LOGGING
747 {
748 DayZPlayer player = GetGame().GetPlayer();
749 if ( player )
750 {
751 if (item)
752 Debug.InventoryMoveLog("Reservation result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / " + item.ToString() + " / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "ExtendInventoryReservation", player.ToString() );
753 else
754 Debug.InventoryMoveLog("Reservation result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / null / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "ExtendInventoryReservation", player.ToString() );
755 }
756 }
757 #endif
758 return ret_val;
759 }
760
761 static proto native bool ClearInventoryReservation(EntityAI item, InventoryLocation dst);
763 {
764 if (GetGame().IsMultiplayer() && GetGame().IsServer() )
765 return true;
766
767 bool ret_val = ClearInventoryReservation(item,dst);
768 #ifdef ENABLE_LOGGING
770 {
771 DayZPlayer player = GetGame().GetPlayer();
772 if ( player )
773 {
774 if (item)
775 Debug.InventoryMoveLog("Reservation cleared result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / " + item.ToString() + " / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "ClearInventoryReservation", player.ToString() );
776 else
777 Debug.InventoryMoveLog("Reservation cleared result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / null / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "ClearInventoryReservation", player.ToString() );
778 }
779 }
780 #endif
781 return ret_val;
782 }
783
785 static proto native bool HasInventoryReservation(EntityAI item, InventoryLocation dst);
787 static proto native bool HasInventoryReservationCanAdd(EntityAI item, InventoryLocation dst);
788
790 static proto native bool HasInventoryReservationEx(EntityAI item, InventoryLocation dst, FindInventoryReservationMode itemMode, FindInventoryReservationMode parentMode);
791 static proto native bool GetInventoryReservationCount(EntityAI item, InventoryLocation dst);
794
796 proto native bool CanLockInventoryWithKey(notnull EntityAI key);
797 proto native bool CanUnlockInventoryWithKey(notnull EntityAI key);
798 proto native void LockInventoryWithKey(notnull EntityAI key);
799 proto native void UnlockInventoryWithKey(notnull EntityAI key);
800 proto native bool HasKeys();
801
802 proto native void LockInventory(int lockType);
803 proto native void UnlockInventory(int lockType);
804 proto native int GetScriptLockCount();
805 proto native bool IsInventoryUnlocked();
806 proto native bool IsInventoryLocked();
807 proto native bool IsInventoryLockedForLockType(int lockType);
808 proto native bool SetSlotLock(int slot, bool locked);
809 proto native bool GetSlotLock(int slot);
811
813 const float c_MaxItemDistanceRadius = 2.5;
814 static proto native bool CheckRequestSrc(notnull Man requestingPlayer, notnull InventoryLocation src, float radius);
815 static proto native bool CheckDropRequest(notnull Man requestingPlayer, notnull InventoryLocation src, float radius);
816 static proto native bool CheckTakeItemRequest(notnull Man requestingPlayer, notnull InventoryLocation src, notnull InventoryLocation dst, float radius);
817 static proto native bool CheckMoveToDstRequest(notnull Man requestingPlayer, notnull InventoryLocation src, notnull InventoryLocation dst, float radius);
818 static proto native bool CheckSwapItemsRequest(notnull Man requestingPlayer, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius);
819 static proto native bool CheckManipulatedObjectsDistances(notnull EntityAI e0, notnull EntityAI e1, float radius);
821
825
829 void Init()
830 {
831 GetInventoryOwner().OnInventoryInit();
832 }
833
835 bool OnStoreLoad(ParamsReadContext ctx, int version)
836 {
837 return true;
838 }
842
843 void EEInit()
844 {
847 {
848 if (src.GetType() == InventoryLocationType.HANDS)
849 {
850 Man man = Man.Cast(src.GetParent());
851 if (man)
852 {
853 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("Inventory::EEInit - Man=" + man + " item=" + this);
854 man.GetHumanInventory().OnEntityInHandsCreated(src);
855 }
856 }
857 }
858 }
859
860 void EEDelete(EntityAI parent)
861 {
863 Man player = item.GetHierarchyRootPlayer();
864 if (player)
865 player.GetInventory().ClearInventoryReservationEx(item, null);
866 }
867
875 {
878 {
879 switch (loc.GetType())
880 {
881 case InventoryLocationType.ATTACHMENT:
882 return loc.GetParent().GetInventory().CreateAttachmentEx(type, loc.GetSlot());
883 case InventoryLocationType.CARGO:
884 return loc.GetParent().GetInventory().CreateEntityInCargoEx(type, loc.GetIdx(), loc.GetRow(), loc.GetCol(), loc.GetFlip());
885 default:
886 Error("CreateInInventory: unknown location for item");
887 break;
888 }
889 }
890
891 return null;
892 }
893
905 {
907 bool result = FindFreeLocationFor(item, flag, il);
908 return result;
909 }
910
925 {
927 bool result = FindFreeLocationFor(item, FindInventoryLocationType.ANY, il);
928 if (result)
929 return LocationAddEntity(il);
930
931 return result;
932 }
933
938 {
941 return LocationCanRemoveEntity(il);
942
943 return false;
944 }
945
946 // Script version of CanAddEntity* methods based on InventoryLocation
960 {
962 return FindFreeLocationFor(item, flags, loc) && !item.IsHologram();
963 }
964
969 {
970 return CanAddEntityInto(item, FindInventoryLocationType.ANY_CARGO | FindInventoryLocationType.ATTACHMENT);
971 }
972
977 {
979 }
980
988
990
1012 {
1013 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Inv(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1014
1016 if (item.GetInventory().GetCurrentInventoryLocation(src))
1017 {
1019 if (FindFreeLocationFor(item, flags, dst))
1020 return TakeToDst(mode, src, dst);
1021
1022 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Inv(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " Warning - no room for item");
1023 return false;
1024 }
1025 Error("[inv] I::Take2Inv(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " Error - src has no inventory location");
1026 return false;
1027 }
1028
1031 {
1032 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Target(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1033
1035 if (item.GetInventory().GetCurrentInventoryLocation(src))
1036 {
1038
1039 if (target.GetInventory().FindFreeLocationFor(item, flags, dst))
1040 return TakeToDst(mode, src, dst);
1041
1042 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Target(" + typename.EnumToString(InventoryMode, mode) + ") target=" + target + " item=" + item + " Warning - no room for item in target");
1043 return false;
1044 }
1045 Error("[inv] I::Take2Target(" + typename.EnumToString(InventoryMode, mode) + ") target=" + target + " item=" + item + " Error - src has no inventory location");
1046 return false;
1047 }
1048
1055 bool TakeToDst (InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
1056 {
1057 bool ret;
1058 switch (mode)
1059 {
1060 case InventoryMode.SERVER:
1061 ret = LocationSyncMoveEntity(src, dst);
1062 if (ret && dst.IsValid())
1064 return ret;
1065 case InventoryMode.LOCAL:
1066 ret = LocationSyncMoveEntity(src, dst);
1067 return ret;
1068 default:
1069 return false;
1070 }
1071 return false;
1072 }
1073
1080 {
1081 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Cgo(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1082 return TakeEntityToInventory(mode, FindInventoryLocationType.CARGO, item);
1083 }
1084
1086 bool TakeEntityToTargetCargo(InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
1087 {
1088 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2TargetCgo(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + "to cargo of target=" + target);
1089 return TakeEntityToTargetInventory(mode, target, FindInventoryLocationType.CARGO, item);
1090 }
1091
1097 bool TakeEntityToCargoEx(InventoryMode mode, notnull EntityAI item, int idx, int row, int col)
1098 {
1099 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Cgo(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " row=" + row + " col=" + col);
1101 if (item.GetInventory().GetCurrentInventoryLocation(src))
1102 {
1104 dst.SetCargo(GetInventoryOwner(), item, idx, row, col, item.GetInventory().GetFlipCargo());
1105
1106 return TakeToDst(mode, src, dst);
1107 }
1108 Error("[inv] I::Take2Cgo(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " row=" + row + " col=" + col + " Error - src has no inventory location");
1109 return false;
1110 }
1111
1113 bool TakeEntityToTargetCargoEx(InventoryMode mode, notnull CargoBase cargo, notnull EntityAI item, int row, int col)
1114 {
1115 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2TargetCgoEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + "to cargo of target=" + cargo.GetCargoOwner() + " row=" + row + " col=" + col);
1117 if (item.GetInventory().GetCurrentInventoryLocation(src))
1118 {
1120 dst.SetCargoAuto(cargo, item, row, col, item.GetInventory().GetFlipCargo());
1121
1122 return TakeToDst(mode, src, dst);
1123 }
1124 Error("[inv] I::Take2TargetCgoEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + "to cargo of target=" + cargo.GetCargoOwner() + " row=" + row + " col=" + col);
1125 return false;
1126 }
1127
1128 bool TakeEntityAsAttachmentEx(InventoryMode mode, notnull EntityAI item, int slot)
1129 {
1130 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2AttEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " slot=" + slot);
1131 return TakeEntityAsTargetAttachmentEx(mode, GetInventoryOwner(), item, slot);
1132 }
1133
1135 bool TakeEntityAsTargetAttachmentEx(InventoryMode mode, notnull EntityAI target, notnull EntityAI item, int slot)
1136 {
1137 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2TargetAttEx(" + typename.EnumToString(InventoryMode, mode) + ") as ATT of target=" + target + " item=" + item + " slot=" + slot);
1139 if (item.GetInventory().GetCurrentInventoryLocation(src))
1140 {
1141 EntityAI att = target.GetInventory().FindAttachment(slot);
1142 if (att)
1143 {
1144 if (mode == InventoryMode.SERVER)
1145 {
1146 att.CombineItemsEx(item, true);
1147 }
1148 else
1149 {
1150 att.CombineItemsClient(item, true);
1151 }
1152 return true;
1153 }
1154 else if (item.CanBeSplit() && item.GetTargetQuantityMax(slot) < item.GetQuantity())
1155 {
1156 if (mode == InventoryMode.SERVER)
1157 {
1158 item.SplitIntoStackMaxEx(target, slot);
1159 }
1160 else
1161 {
1162 item.SplitIntoStackMaxClient(target,slot);
1163 }
1164 return true;
1165 }
1166 else
1167 {
1169 dst.SetAttachment(target, item, slot);
1170 return TakeToDst(mode, src, dst);
1171 }
1172 }
1173 Error("[inv] I::Take2AttEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " Error - src has no inventory location");
1174 return false;
1175 }
1176
1178 {
1179 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Att(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1180 return TakeEntityToInventory(mode, FindInventoryLocationType.ATTACHMENT, item);
1181 }
1182
1183 bool TakeEntityAsTargetAttachment(InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
1184 {
1185 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2AttEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1186 return TakeEntityToTargetInventory(mode, target, FindInventoryLocationType.ATTACHMENT, item);
1187 }
1188
1190 static bool MakeDstForSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, out InventoryLocation dst1, out InventoryLocation dst2)
1191 {
1192 if (dst1 == null)
1193 dst1 = new InventoryLocation();
1194
1195 dst1.Copy(src1);
1196 dst1.CopyLocationFrom(src2, false);
1197 dst1.SetFlip(src1.GetItem().GetInventory().GetFlipCargo()); // update flip flag from inventory item
1198
1199 if (dst2 == null)
1200 dst2 = new InventoryLocation();
1201
1202 dst2.Copy(src2);
1203 dst2.CopyLocationFrom(src1, false);
1204 dst2.SetFlip(src2.GetItem().GetInventory().GetFlipCargo()); // update flip flag from inventory item
1205 return true;
1206 }
1207
1209 static bool MakeSrcAndDstForSwap(notnull EntityAI item1, notnull EntityAI item2, out InventoryLocation src1, out InventoryLocation src2, out InventoryLocation dst1, out InventoryLocation dst2)
1210 {
1211 if (src1 == null)
1212 src1 = new InventoryLocation();
1213 if (src2 == null)
1214 src2 = new InventoryLocation();
1215 if (item1.GetInventory().GetCurrentInventoryLocation(src1) && item2.GetInventory().GetCurrentInventoryLocation(src2))
1216 return MakeDstForSwap(src1, src2, dst1, dst2);
1217 return false;
1218 }
1219
1221 static bool MakeSrcAndDstForForceSwap(notnull EntityAI item1, notnull EntityAI item2, out InventoryLocation src1, out InventoryLocation src2, out InventoryLocation dst1, notnull InventoryLocation dst2)
1222 {
1223 if (src1 == null)
1224 src1 = new InventoryLocation();
1225 if (src2 == null)
1226 src2 = new InventoryLocation();
1227
1228 if (item1.GetInventory().GetCurrentInventoryLocation(src1) && item2.GetInventory().GetCurrentInventoryLocation(src2))
1229 {
1230 // src1 -> dst_of(src2)
1231 if (dst1 == null)
1232 dst1 = new InventoryLocation();
1233
1234 dst1.Copy(src1);
1235 dst1.CopyLocationFrom(src2, false);
1236 dst1.SetFlip(dst1.GetItem().GetInventory().GetFlipCargo());
1237
1238 // src2 -> dst2 from user
1239 return true;
1240 }
1241
1242 return false;
1243 }
1244
1245 bool SwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
1246 {
1247 return false;
1248 }
1249
1250 bool ForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
1251 {
1252 return false;
1253 }
1254
1255 static bool SetGroundPosByOwner(EntityAI owner, notnull EntityAI item, out InventoryLocation ground)
1256 {
1257 vector m4[4];
1260 ground.SetGround(item, m4);
1261 return success;
1262 }
1263
1264 bool DropEntity(InventoryMode mode, EntityAI owner, notnull EntityAI item)
1265 {
1266 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Drop(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1268 if (item.GetInventory().GetCurrentInventoryLocation(src))
1269 {
1271 if (!SetGroundPosByOwner(owner, item, dst))
1272 {
1273 OnInventoryFailure(InventoryCommandType.SYNC_MOVE, InventoryValidationReason.DROP_PREVENTED, src, dst);
1274 return false;
1275 }
1276
1277 return TakeToDst(mode, src, dst);
1278 }
1279
1280 Error("DropEntity - No inventory location");
1281 return false;
1282 }
1283
1284 static bool SetGroundPosByTransform(EntityAI owner, notnull EntityAI item, out InventoryLocation ground, vector transform[4])
1285 {
1286 bool success = GameInventory.PrepareDropEntityPos(owner, item, transform, true, GameConstants.INVENTORY_ENTITY_DROP_OVERLAP_DEPTH);
1287 ground.SetGround(item, transform);
1288 return success;
1289 }
1290
1291 bool DropEntityWithTransform(InventoryMode mode, EntityAI owner, notnull EntityAI item, vector transform[4])
1292 {
1293 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Drop(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1295 if (item.GetInventory().GetCurrentInventoryLocation(src))
1296 {
1298 SetGroundPosByTransform(owner, item, dst, transform);
1299
1300 return TakeToDst(mode, src, dst);
1301 }
1302
1303 Error("DropEntityWithTransform - No inventory location");
1304 return false;
1305 }
1306
1307 static void SetGroundPosByOwnerBounds(EntityAI owner, notnull EntityAI item, out InventoryLocation ground, vector halfExtents, float angle, float cosAngle, float sinAngle)
1308 {
1309 vector m4[4];
1310 owner.GetTransform(m4);
1311
1312 vector randomPos = Vector(Math.RandomFloat(-halfExtents[0], halfExtents[0]), 0, Math.RandomFloat(-halfExtents[2], halfExtents[2]));
1313 randomPos = vector.RotateAroundZero(randomPos, vector.Up, cosAngle, sinAngle);
1314
1315 float dist = randomPos[0] * m4[1][0] + randomPos[1] * m4[1][1] + randomPos[2] * m4[1][2];
1316
1317 m4[3][0] = m4[3][0] + randomPos[0];
1318 m4[3][1] = m4[3][1] - dist + halfExtents[1];
1319 m4[3][2] = m4[3][2] + randomPos[2];
1320
1321 item.PlaceOnSurfaceRotated(m4, Vector(m4[3][0], m4[3][1], m4[3][2]));
1322
1323 ground.SetGround(item, m4);
1324 }
1325
1326 bool DropEntityInBounds(InventoryMode mode, EntityAI owner, notnull EntityAI item, vector halfExtents, float angle, float cosAngle, float sinAngle)
1327 {
1328 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Drop(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1329
1331 if (item.GetInventory().GetCurrentInventoryLocation(src))
1332 {
1334
1335 SetGroundPosByOwnerBounds(owner, item, dst, halfExtents, angle, cosAngle, sinAngle);
1336
1337 return TakeToDst(mode, src, dst);
1338 }
1339
1340 Error("DropEntityInBounds - No inventory location");
1341 return false;
1342 }
1343
1344 bool LocalDestroyEntity(notnull EntityAI item)
1345 {
1346 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::LocalDestroyEntity inv item=" + item);
1348 if (item.GetInventory().GetCurrentInventoryLocation(src))
1349 {
1350 if (src.GetType() == InventoryLocationType.HANDS)
1351 Error("[inv] Source location == HANDS, player has to handle this");
1352
1353 GetGame().ObjectDelete(src.GetItem());
1354 return true;
1355 }
1356
1357 Error("LocalDestroyEntity: No inventory location");
1358 return false;
1359 }
1360
1362 {
1364 if (lambda.m_OldItem.GetInventory().GetCurrentInventoryLocation(src))
1365 {
1366 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::ReplaceItemWithNew executing lambda=" + lambda + "on old_item=" + lambda.m_OldItem);
1367 lambda.Execute();
1368 return true;
1369 }
1370
1371 Error("[inv] I::ReplaceItemWithNew - no inventory location");
1372 return false;
1373 }
1374
1375 proto native bool GetFlipCargo();
1376 proto native void SetFlipCargo(bool flip);
1377 proto native void FlipCargo();
1378 proto native void ResetFlipCargo();
1380}
void syncDebugPrint(string s)
Определения Debug.c:1
void inventoryDebugPrint(string s)
Определения Debug.c:19
InventoryJunctureType
Определения Inventory.c:14
InventoryCommandType
Определения Inventory.c:3
@ USER_RESERVATION_CANCEL
Clear user reserved inventory space.
Определения Inventory.c:11
@ SYNC_MOVE
synchronous move. action is finished immeadiately, no animations involved
Определения Inventory.c:5
@ HAND_EVENT
event for hands
Определения Inventory.c:6
@ MOVE
generic move, may involve animations
Определения Inventory.c:4
enum InventoryCheckContext EQUAL
Find an exact reservation for item and dst, item and dst required.
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Определения Inventory.c:22
@ SERVER
'Server' mode operation is required if and only if the operation runs only on server (creates and/or ...
Определения Inventory.c:26
@ PREDICTIVE
'Predictive' means that the operation uses Client-Side Prediction, i.e. the action runs the same code...
Определения Inventory.c:23
@ LOCAL
'Local' operation executes from where it is run
Определения Inventory.c:24
enum InventoryCheckContext DST
Find a reservation for the dst EXCLUDING the item, item and dst required.
InventoryValidationResult
Определения Inventory.c:30
@ JUNCTURE
'Juncture' operation is used whenever there is possibility of race condition, i.e....
Определения Inventory.c:25
@ SUCCESS
Определения Inventory.c:33
@ FAILED
Определения Inventory.c:31
InventoryValidationReason
Определения Inventory.c:37
@ DROP_PREVENTED
Определения Inventory.c:40
enum InventoryCheckContext ITEM
Find a reservation for the item EXCLUDING the dst, item and dst required.
InventoryCheckContext
Определения Inventory.c:58
@ SYNC_CHECK
Определения Inventory.c:60
@ UNKNOWN
24 - Any other error. Can be returned from any call.
Определения BIOSErrorModule.c:56
PlayerSpawnPreset slotName
@ DEFAULT
Определения ECrewMemberState.c:3
JUNCTURE_DENIED
Определения Hand_Events.c:31
@ FORCESWAP
Определения Hand_Events.c:14
@ DESTROY
Определения Hand_Events.c:15
@ TAKE
Определения Hand_Events.c:9
@ REPLACE
Определения Hand_Events.c:18
@ SWAP
swapping from ground
Определения Hand_Events.c:13
void ClearInventoryReservation()
Определения Hand_Events.c:193
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
float GetTime()
Определения NotificationSystem.c:35
proto native DayZPlayer GetPlayer()
proto native void ObjectDelete(Object obj)
represents base for cargo storage for entities
Определения Cargo.c:7
static void InventoryMoveLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Определения Debug.c:137
Определения Debug.c:2
Определения Building.c:6
Определения constants.c:659
proto native bool GetFlipCargo()
proto native int CountInventory()
almost identical to EnumerateInventory except it does not return items
static proto native bool LocationTestAddEntity(notnull InventoryLocation inv_loc, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check)
test if the entity contained in inv_loc.m_item can be added to ground/attachment/cargo/hands/....
void OnAfterStoreLoad()
void OnServerInventoryCommand(ParamsReadContext ctx)
bool OnInputUserDataProcess(ParamsReadContext ctx)
synchronization
bool LocalDestroyEntity(notnull EntityAI item)
Определения Inventory.c:1344
static proto native bool CheckManipulatedObjectsDistances(notnull EntityAI e0, notnull EntityAI e1, float radius)
static proto native bool AddInventoryReservation(EntityAI item, InventoryLocation dst, int timeout_ms)
proto native EntityAI CreateEntityInCargoEx(string typeName, int idx, int row, int col, bool flip)
Create Entity of specified type in cargo of entity at coordinates (row, col)
proto native int GetAnyInventoryReservationCount()
proto native int GetAttachmentSlotsCount()
void Init()
script functions
Определения Inventory.c:829
void EEDelete(EntityAI parent)
Определения Inventory.c:860
proto native EntityAI CreateEntityInCargo(string typeName)
Create Entity of specified type in cargo of entity.
proto native bool CanAddEntityInCargoExLoc(InventoryLocation loc)
static proto native bool LocationSyncMoveEntity(notnull InventoryLocation src_loc, notnull InventoryLocation dst_loc)
synchronously removes item from current inventory location and adds it to destination no anims involv...
static proto native bool ServerLocationMoveEntity(notnull EntityAI item, ParamsWriteContext ctx)
removes item from current inventory location and adds it to destination + sync via inventory command
EntityAI CreateInInventory(string type)
creates entity somewhere in inventory
Определения Inventory.c:874
proto native bool FindFirstFreeLocationForNewEntity(string item_type, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFirstFreeLocationForNewEntity.
void OnInventoryFailure(InventoryCommandType type, InventoryValidationReason reason, InventoryLocation src, InventoryLocation dst)
static proto native bool CanSwapEntities(notnull EntityAI item1, notnull EntityAI item2)
test if ordinary swap can be performed.
bool SwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
Определения Inventory.c:1245
proto native EntityAI GetAttachmentFromIndex(int index)
static proto native bool PrepareDropEntityPos(EntityAI owner, notnull EntityAI item, out vector mat[4], bool useValuesInMatrix=false, int conflictCheckDepth=-1)
Finds a transformation for the item to be dropped to If the initial transforation overlaps with anoth...
static proto native bool ServerHandEvent(notnull Man player, notnull EntityAI item, ParamsWriteContext ctx)
hand event to clients
proto native EntityAI CreateAttachment(string typeName)
Create Entity of specified type as attachment of entity.
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
proto native EntityAI CreateAttachmentEx(string typeName, int slotId)
Create Entity of specified type as attachment of entity.
bool ExtendInventoryReservationEx(EntityAI item, InventoryLocation dst, int timeout_ms)
Определения Inventory.c:739
static void SetGroundPosByOwnerBounds(EntityAI owner, notnull EntityAI item, out InventoryLocation ground, vector halfExtents, float angle, float cosAngle, float sinAngle)
Определения Inventory.c:1307
bool CanRemoveEntity()
Returns if entity can be removed from its current location.
Определения Inventory.c:937
static proto native EntityAI LocationGetEntity(notnull InventoryLocation inv_loc)
proto native bool HasAttachment(notnull EntityAI e)
brief Returns True if entity is attached to this
proto native EntityAI FindPlaceholderForSlot(int slot)
Returns placeholder entity for slot (naked arms, legs etc)
bool TakeEntityToInventory(InventoryMode mode, FindInventoryLocationType flags, notnull EntityAI item)
Put item anywhere into this entity (as attachment or into cargo, recursively)
Определения Inventory.c:1011
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
bool IsAttachment()
Returns true if this Inventory owner is an attachment of something.
Определения Inventory.c:408
proto native bool CanAddEntityInCargo(notnull EntityAI e, bool flip)
proto native bool HasAttachmentEx(notnull EntityAI e, int slot)
brief Returns True if entity is attached to this in slot
bool TakeEntityToTargetCargoEx(InventoryMode mode, notnull CargoBase cargo, notnull EntityAI item, int row, int col)
Put item into into cargo on specific cargo location of another entity.
Определения Inventory.c:1113
static proto native bool CanForceSwapEntities(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
test if forced swap can be performed.
proto native CargoBase GetCargoFromIndex(int index)
bool TakeEntityToTargetInventory(InventoryMode mode, notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
helper that finds location first, then moves the entity into it
Определения Inventory.c:1030
bool DropEntityWithTransform(InventoryMode mode, EntityAI owner, notnull EntityAI item, vector transform[4])
Определения Inventory.c:1291
proto native void LockInventory(int lockType)
bool OnInventoryJunctureRepairFromServer(ParamsReadContext ctx)
bool ClearInventoryReservationEx(EntityAI item, InventoryLocation dst)
Определения Inventory.c:762
proto native bool HasInventorySlot(int slotId)
static proto native bool ServerLocationSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, ParamsWriteContext ctx)
swaps two entities
bool HasAttachmentSlot(int slotId)
Определения Inventory.c:186
static int GetInventoryCheckContext()
Определения Inventory.c:373
bool IsInCargo()
Returns true if this Inventory owner is in cargo of something.
Определения Inventory.c:395
proto native bool CanRemoveAttachmentEx(EntityAI attachment, int slot)
proto native bool HasEntityInCargo(notnull EntityAI e)
bool CanAddEntityIntoHands(notnull EntityAI item)
Test if entity can be put into hands.
Определения Inventory.c:976
const int c_InventoryReservationTimeoutShortMS
Определения Inventory.c:713
bool TakeEntityToCargoEx(InventoryMode mode, notnull EntityAI item, int idx, int row, int col)
moves item on specific cargo location
Определения Inventory.c:1097
proto native bool IsInventoryLocked()
proto native void UnlockInventory(int lockType)
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
Определения Inventory.c:1209
proto native bool IsInventoryUnlocked()
static proto native bool TestDropEntityPos(EntityAI owner, notnull EntityAI item, out vector mat[4], bool useValuesInMatrix=false, int conflictCheckDepth=-1)
static proto native bool ClearInventoryReservation(EntityAI item, InventoryLocation dst)
static proto native bool LocationMoveEntity(notnull InventoryLocation src_loc, notnull InventoryLocation dst_loc)
removes item from current inventory location and adds it to destination
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
Определения Inventory.c:628
proto native bool CanAddEntityInCargoEx(notnull EntityAI e, int idx, int row, int col, bool flip)
static bool MakeSrcAndDstForForceSwap(notnull EntityAI item1, notnull EntityAI item2, out InventoryLocation src1, out InventoryLocation src2, out InventoryLocation dst1, notnull InventoryLocation dst2)
helper function for ForceSwap
Определения Inventory.c:1221
proto native int FindFreeLocationsFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull array< ref InventoryLocation > locs)
searches inventory for suitable location for @item
static proto native EntityAI LocationCreateLocalEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new local item directly at location @NOTE: the item is created localy, i.e....
bool TakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
move src to dst
Определения Inventory.c:1055
static proto native bool CheckTakeItemRequest(notnull Man requestingPlayer, notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
proto native void LockInventoryWithKey(notnull EntityAI key)
bool TakeEntityAsTargetAttachment(InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
Определения Inventory.c:1183
proto native bool CanAddAttachment(notnull EntityAI e)
Check if attachment can be added to any slot.
static proto native bool GetInventoryReservationCount(EntityAI item, InventoryLocation dst)
static proto native bool ExtendInventoryReservation(EntityAI item, InventoryLocation dst, int timeout_ms)
proto native bool IsPlaceholderEntity(notnull Object e)
bool AddEntityToInventory(notnull EntityAI item)
add entity somewhere in inventory
Определения Inventory.c:924
bool CanAddEntityIntoInventory(notnull EntityAI item)
Test if entity can be put to the inventory (Cargo, ProxyCargo, Attachment)
Определения Inventory.c:968
bool OnInventoryJunctureFromServer(ParamsReadContext ctx)
proto native bool HasEntityInCargoEx(notnull EntityAI e, int idx, int row, int col)
proto native bool GetSlotLock(int slot)
proto native EntityAI GetInventoryOwner()
Engine native functions.
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
static proto native bool LocationCanMoveEntity(notnull InventoryLocation src, notnull InventoryLocation dst)
queries if the entity contained in inv_loc.m_item can be moved to another location This is a shorthan...
bool IsCargoInHiearchy()
Returns true if inventory owner or his hiearchy parents are in cargo.
Определения Inventory.c:421
bool ReplaceItemWithNew(InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
Определения Inventory.c:1361
static proto native bool HasInventoryReservationCanAdd(EntityAI item, InventoryLocation dst)
Internally: !HasInventoryReservationEx(item, dst, FindInventoryReservationMode.ITEM,...
static bool SetGroundPosByOwner(EntityAI owner, notnull EntityAI item, out InventoryLocation ground)
Определения Inventory.c:1255
proto native int GetSlotId(int index)
attachments
bool GetCurrentAttachmentSlotInfo(out int slot_id, out string slot_name)
Returns true if the item is currently attached and outputs attachment slot id and name.
Определения Inventory.c:454
proto native bool CanRemoveEntityInCargoEx(notnull EntityAI e, int idx, int row, int col)
const int c_InventoryReservationTimeoutMS
reservations
Определения Inventory.c:712
static int m_inventory_check_context
Определения Inventory.c:80
bool TakeEntityAsAttachment(InventoryMode mode, notnull EntityAI item)
Определения Inventory.c:1177
void EEInit()
Определения Inventory.c:843
static proto native bool LocationSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
swaps two entities
proto native bool CanRemoveEntityInCargo(notnull EntityAI e)
bool ForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
Определения Inventory.c:1250
static bool LocationCanMoveEntitySyncCheck(notnull InventoryLocation src, notnull InventoryLocation dst)
Определения Inventory.c:378
static void OnServerInventoryCommandStatic(ParamsReadContext ctx)
Определения Inventory.c:469
static proto native bool HasInventoryReservation(EntityAI item, InventoryLocation dst)
Internally: HasInventoryReservationEx(item, dst, FindInventoryReservationMode.LEGACY,...
static proto native bool LocationAddEntity(notnull InventoryLocation inv_loc)
adds item to inventory location
proto native bool HasKeys()
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
Определения Inventory.c:664
const float c_MaxItemDistanceRadius
anti-cheats
Определения Inventory.c:813
proto native int AttachmentCount()
Returns count of attachments attached to this item.
proto native bool CanLockInventoryWithKey(notnull EntityAI key)
locks
bool AddInventoryReservationEx(EntityAI item, InventoryLocation dst, int timeout_ms)
Определения Inventory.c:716
static bool SetGroundPosByTransform(EntityAI owner, notnull EntityAI item, out InventoryLocation ground, vector transform[4])
Определения Inventory.c:1284
static proto native bool LocationCanRemoveEntity(notnull InventoryLocation inv_loc)
queries if the entity contained in inv_loc.m_item can be removed from ground/attachment/cargo/hands/....
static proto native bool LocationCanAddEntity(notnull InventoryLocation inv_loc)
queries if the entity contained in inv_loc.m_item can be added to ground/attachment/cargo/hands/....
void OnInventoryJunctureFailureFromServer(ParamsReadContext ctx)
static bool MakeDstForSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, out InventoryLocation dst1, out InventoryLocation dst2)
helper function for swap
Определения Inventory.c:1190
proto native bool HasEntityInInventory(notnull EntityAI item)
query inventory if item is somewhere
proto native bool FindFreeLocationForEx(notnull EntityAI item, FindInventoryLocationType flags, notnull InventoryLocation exclude, out notnull InventoryLocation loc)
FindFreeLocationForEx.
bool TakeEntityToTargetCargo(InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
Put item into into cargo of another entity.
Определения Inventory.c:1086
bool AreChildrenAccessible()
Returns true if item is considered reachable within inventory.
Определения Inventory.c:440
static proto native bool CheckDropRequest(notnull Man requestingPlayer, notnull InventoryLocation src, float radius)
proto native void SetFlipCargo(bool flip)
proto native int GetSlotIdCount()
void OnStoreSave(ParamsWriteContext ctx)
db store hook
proto native bool TestAddEntityInCargoEx(notnull EntityAI e, int idx, int row, int col, bool flip, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check)
static proto native bool CheckSwapItemsRequest(notnull Man requestingPlayer, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
proto native int GetAttachmentSlotId(int index)
proto native void ResetFlipCargo()
proto native bool SetSlotLock(int slot, bool locked)
proto native EntityAI FindAttachmentByName(string slotName)
Returns attached entity in slot (you can use EntityAI.GetActionComponentName to get slot id)
bool CanAddEntityToInventory(notnull EntityAI item, int flag=FindInventoryLocationType.ANY)
ask inventory if item could be placed somewhere in inventory
Определения Inventory.c:904
static proto native bool HasInventoryReservationEx(EntityAI item, InventoryLocation dst, FindInventoryReservationMode itemMode, FindInventoryReservationMode parentMode)
itemMode will iterate over item reservations, parentMode will iterate over parent reservations
bool TakeEntityAsAttachmentEx(InventoryMode mode, notnull EntityAI item, int slot)
Определения Inventory.c:1128
proto native bool CanAddAttachmentEx(notnull EntityAI e, int slot)
Check if attachment can be added to slot @NOTE: Note that slot index IS NOT slot ID!...
static proto native bool CheckMoveToDstRequest(notnull Man requestingPlayer, notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
proto native bool CanAddSwappedEntity(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
proto native void UnlockInventoryWithKey(notnull EntityAI key)
proto native bool IsInventoryLockedForLockType(int lockType)
proto native bool CanRemoveAttachment(EntityAI attachment)
proto native bool TestAddEntityInCargoExLoc(notnull InventoryLocation loc, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check)
static proto native bool CheckRequestSrc(notnull Man requestingPlayer, notnull InventoryLocation src, float radius)
static proto native bool ServerLocationSyncMoveEntity(Man player, notnull EntityAI item, ParamsWriteContext ctx)
synchronously removes item from current inventory location and adds it to destination + sync via inve...
bool DropEntityInBounds(InventoryMode mode, EntityAI owner, notnull EntityAI item, vector halfExtents, float angle, float cosAngle, float sinAngle)
Определения Inventory.c:1326
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
proto native int GetScriptLockCount()
bool TakeEntityToCargo(InventoryMode mode, notnull EntityAI item)
moves item to cargo of this intentory
Определения Inventory.c:1079
proto native void FlipCargo()
proto native EntityAI FindAttachment(int slot)
Returns attached entity in slot (you can use InventorySlots.GetSlotIdFromString(name) to get slot id)
static proto native bool LocationRemoveEntity(notnull InventoryLocation inv_loc)
removes item from inventory location
bool TakeEntityAsTargetAttachmentEx(InventoryMode mode, notnull EntityAI target, notnull EntityAI item, int slot)
put item as attachment of target
Определения Inventory.c:1135
bool DropEntity(InventoryMode mode, EntityAI owner, notnull EntityAI item)
Определения Inventory.c:1264
bool CanAddEntityInto(notnull EntityAI item, FindInventoryLocationType flags=FindInventoryLocationType.ANY)
Asks inventory if item could be placed in inventory, hands, etc.
Определения Inventory.c:959
static bool LocationCanAddEntityEx(notnull InventoryLocation inv_loc)
Определения Inventory.c:348
bool OnStoreLoad(ParamsReadContext ctx, int version)
db load hooks
Определения Inventory.c:835
proto native bool CanUnlockInventoryWithKey(notnull EntityAI key)
script counterpart to engine's class Inventory
Определения Inventory.c:79
override string DumpToString()
Определения Hand_Events.c:332
Abstracted event, not to be used, only inherited.
Определения Hand_Events.c:209
static void SendServerMove(Man player, int type, notnull InventoryLocation src, notnull InventoryLocation dst)
Определения InventoryInputUserData.c:24
proto native bool IsValid()
verify current set inventory location
proto native EntityAI GetParent()
returns parent of current inventory location
static string DumpToStringNullSafe(InventoryLocation loc)
Определения InventoryLocation.c:226
proto native void SetAttachment(notnull EntityAI parent, EntityAI e, int slotId)
sets current inventory location type to Attachment with slot id set to <slotId>
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetCol()
returns column of cargo if current type is Cargo / ProxyCargo
proto native int GetRow()
returns row of cargo if current type is Cargo / ProxyCargo
proto native void SetCargoAuto(notnull CargoBase cargo, EntityAI e, int row, int col, bool flip)
based on Cargo.IsProxyCargo uses SetProxyCargo or SetCargo respectively
proto native int GetType()
returns type of InventoryLocation
proto native int GetIdx()
returns index of cargo if current type is Cargo / ProxyCargo
proto native void SetCargo(notnull EntityAI parent, EntityAI e, int idx, int row, int col, bool flip)
sets current inventory location type to Cargo with coordinates (idx, row, col)
proto native bool GetFlip()
returns flip status of cargo
bool ReadFromContext(ParamsReadContext ctx)
Определения InventoryLocation.c:296
proto native EntityAI GetItem()
returns item of current inventory location
InventoryLocation.
Определения InventoryLocation.c:29
const int INVALID
Invalid slot (-1)
Определения InventorySlots.c:17
static proto native owned string GetSlotName(int id)
converts slot_id to string
provides access to slot configuration
Определения InventorySlots.c:6
bool m_IsJuncture
Определения Inventory.c:45
bool IsAuthoritative()
Определения Inventory.c:51
InventoryValidationResult m_Result
Определения Inventory.c:48
InventoryValidationReason m_Reason
Определения Inventory.c:49
bool m_IsRemote
Определения Inventory.c:46
Определения Inventory.c:44
static bool IsInventoryReservationLogEnable()
Определения Debug.c:658
static bool IsSyncLogEnable()
Определения Debug.c:678
static bool IsInventoryMoveLogEnable()
Определения Debug.c:648
Определения Debug.c:594
Определения EnMath3D.c:28
Определения EnMath.c:7
Определения ObjectTyped.c:2
void Execute(HumanInventoryWithFSM fsm_to_notify=null)
Определения ReplaceItemWithNewLambdaBase.c:231
base class for transformation operations (creating one item from another)
Определения ReplaceItemWithNewLambdaBase.c:5
proto bool Read(void value_in)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
static vector RotateAroundZero(vector pos, vector axis, float cosAngle, float sinAngle)
Rotate a vector around 0,0,0.
Определения EnConvert.c:477
static const vector Up
Определения EnConvert.c:107
Определения EnConvert.c:106
Serializer ParamsReadContext
Определения gameplay.c:15
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Определения gameplay.c:6
proto native CGame GetGame()
Serializer ParamsWriteContext
Определения gameplay.c:16
enum ChatChannelType LEGACY
Legacy version, UNDER but without proxy support.
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
enum ShapeType ErrorEx
const int INVENTORY_ENTITY_DROP_OVERLAP_DEPTH
Определения constants.c:1052
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static void MatrixIdentity4(out vector mat[4])
Creates identity matrix.
Определения EnMath3D.c:256
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].